[petsc-users] Insert one sparse matrix as a block in another

Peder Jørgensgaard Olesen pjool at dtu.dk
Tue Dec 13 05:40:03 CST 2022


Yes, MATNEST seems do to just what I wanted, and extremely fast too. Thanks!


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.


Thanks again,

Peder

________________________________
Fra: Matthew Knepley <knepley at gmail.com>
Sendt: 12. december 2022 23:58:02
Til: Jed Brown
Cc: Mark Adams; Peder Jørgensgaard Olesen; petsc-users at mcs.anl.gov
Emne: Re: [petsc-users] Insert one sparse matrix as a block in another

On Mon, Dec 12, 2022 at 5:24 PM Jed Brown <jed at jedbrown.org<mailto:jed at jedbrown.org>> wrote:
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.

I will just say a few words about ex28. The idea is that if you are already calling MatSetValues() to assemble your submatrices, then
you can use MatSetValuesLocal() to remap those locations into locations in the large matrix, using a LocalToGlobalMap. This allows
you to choose either a standard AIJ matrix (which supports factorizations for example), or a MatNest object that supports fast extraction
of the blocks.

  Thanks,

    Matt

Mark Adams <mfadams at lbl.gov<mailto:mfadams at lbl.gov>> writes:

> Do you know what kind of solver works well for this problem?
>
> You probably want to figure that out first and not worry about efficiency.
>
> MATCOMPOSITE does what you want but not all solvers will work with it.
>
> Where does this problem come from? We have a lot of experience and might
> know something.
>
> Mark
>
> On Mon, Dec 12, 2022 at 1:33 PM Peder Jørgensgaard Olesen via petsc-users <
> petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>> wrote:
>
>> Hello
>>
>>
>> I have a set of sparse matrices (A1, A2, ...) , and need to generate a
>> larger matrix B with these as submatrices. I do not know the precise sparse
>> layouts of the A's (only that each row has one or two non-zero values),
>> and extracting *all* values to copy into B seems incredibly wasteful. How
>> can I make use of the sparsity to solve this efficiently?
>>
>>
>> Thanks,
>>
>> Peder
>>
>>
>>
>> Peder Jørgensgaard Olesen
>> PhD student
>> Department of Civil and Mechanical Engineering
>>
>> pjool at mek.dtu.dk<mailto:pjool at mek.dtu.dk>
>> Koppels Allé
>> Building 403, room 105
>> 2800 Kgs. Lyngby
>> www.dtu.dk/english<http://www.dtu.dk/english>
>>
>>


--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20221213/c23e13b5/attachment.html>


More information about the petsc-users mailing list