<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Yes, MATNEST seems do to just what I wanted, and extremely fast too. Thanks!</p>
<p><br>
</p>
<p>For context, I am doing a snapshot POD (like SVD, but less memory intensive) in which I'm building a dense matrix S_pq = u_p^T B u_q for the EVP Sa=λa, where {u_p} and {u_q} are vectors in a particular dataset. The kernel B is the sparse matrix I was asking
 about.</p>
<p><br>
</p>
<p>Thanks again,</p>
<p>Peder</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Fra:</b> Matthew Knepley <knepley@gmail.com><br>
<b>Sendt:</b> 12. december 2022 23:58:02<br>
<b>Til:</b> Jed Brown<br>
<b>Cc:</b> Mark Adams; Peder Jørgensgaard Olesen; petsc-users@mcs.anl.gov<br>
<b>Emne:</b> Re: [petsc-users] Insert one sparse matrix as a block in another</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Mon, Dec 12, 2022 at 5:24 PM Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The description matches MATNEST (MATCOMPOSITE is for a sum or product of matrices) or parallel decompositions. Also consider the assembly style of src/snes/tutorials/ex28.c, which can create either a monolithic or block (MATNEST) matrix without extra storage
 or conversion costs.<br>
</blockquote>
<div><br>
</div>
<div>I will just say a few words about ex28. The idea is that if you are already calling MatSetValues() to assemble your submatrices, then</div>
<div>you can use MatSetValuesLocal() to remap those locations into locations in the large matrix, using a LocalToGlobalMap. This allows</div>
<div>you to choose either a standard AIJ matrix (which supports factorizations for example), or a MatNest object that supports fast extraction</div>
<div>of the blocks.</div>
<div><br>
</div>
<div>  Thanks,</div>
<div><br>
</div>
<div>    Matt</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> writes:<br>
<br>
> Do you know what kind of solver works well for this problem?<br>
><br>
> You probably want to figure that out first and not worry about efficiency.<br>
><br>
> MATCOMPOSITE does what you want but not all solvers will work with it.<br>
><br>
> Where does this problem come from? We have a lot of experience and might<br>
> know something.<br>
><br>
> Mark<br>
><br>
> On Mon, Dec 12, 2022 at 1:33 PM Peder Jørgensgaard Olesen via petsc-users <<br>
> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
><br>
>> Hello<br>
>><br>
>><br>
>> I have a set of sparse matrices (A1, A2, ...) , and need to generate a<br>
>> larger matrix B with these as submatrices. I do not know the precise sparse<br>
>> layouts of the A's (only that each row has one or two non-zero values),<br>
>> and extracting *all* values to copy into B seems incredibly wasteful. How<br>
>> can I make use of the sparsity to solve this efficiently?<br>
>><br>
>><br>
>> Thanks,<br>
>><br>
>> Peder<br>
>><br>
>><br>
>><br>
>> Peder Jørgensgaard Olesen<br>
>> PhD student<br>
>> Department of Civil and Mechanical Engineering<br>
>><br>
>> <a href="mailto:pjool@mek.dtu.dk" target="_blank">pjool@mek.dtu.dk</a><br>
>> Koppels Allé<br>
>> Building 403, room 105<br>
>> 2800 Kgs. Lyngby<br>
>> <a href="http://www.dtu.dk/english" rel="noreferrer" target="_blank">www.dtu.dk/english</a><br>
>><br>
>><br>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener</div>
<div><br>
</div>
<div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>