[petsc-users] Creating rectangular submatrix
Mark Adams
mfadams at lbl.gov
Sun Nov 14 13:26:49 CST 2021
On Sun, Nov 14, 2021 at 2:16 PM Peder Jørgensgaard Olesen <pjool at mek.dtu.dk>
wrote:
> I see, thanks.
>
>
> Is there some clever way to have PETSc decide for me which column goes
> where?
>
You need to know what you want before you can find a clever way to get it.
It is not clear what the issues are with your application, but the simplest
thing is to just chop the result up evenly.
You could make a vector of the number of columns and use PETSC_DECIDE for
the number of local entries (n) in this new vector and give it the number
of columns as the global size (N) and PETSc will just chop it.
Then you could get the local range of the vector as your columns. But
you could do that manually pretty easily.
> ------------------------------
> *Fra:* Mark Adams <mfadams at lbl.gov>
> *Sendt:* 14. november 2021 19:17:07
> *Til:* Peder Jørgensgaard Olesen
> *Cc:* petsc-users at mcs.anl.gov
> *Emne:* Re: [petsc-users] Creating rectangular submatrix
>
>
>
> On Sun, Nov 14, 2021 at 12:39 PM Peder Jørgensgaard Olesen via petsc-users
> <petsc-users at mcs.anl.gov> wrote:
>
>> Hello
>>
>>
>> I need to extract a submatrix consisting of a number columns from a
>> rectangular matrix. The documentation
>> <https://petsc.org/release/docs/manualpages/Mat/MatCreateSubMatrix.html>for
>> MatCreateSubMatrix states that "each process should list the columns that
>> will be in its "diagonal part" in the new matrix".
>>
>>
>> However, is it not the case that not all columns are necessarily in some
>> process's diagonal part? Consider the example of a 2x5 matrix stored on
>> two processes. Each process then stores one row. Suppose we wish to create
>> a submatrix with rows 0 and 1, and columns 2, 3, and 4 from the original
>> matrix. The diagonal parts of the matrix created then each hold one
>> element, namely (0,2) and (1,3), respectively (using source matrix
>> indices). But how would the ISs for creating this submatrix look?
>> Taking the syntax described in the documentation at face value tthe ISs
>> would be row_is = [0 | 1] and col_is = [2 | 3]. Thus, there doesn't seem
>> to be a way to tell MatCreateSubMatrix that we also want column 4
>> (unless we may simply let col_is = [2 | 3 4], and the new matrix'
>> "diagonal part" becomes non-square - which might also explain the
>> scare quotes around the term in the documentation?)
>>
>>
>> I'd be surprised if the syntax does not allow certain submatrices to be
>> formed; more likely I'm misunderstanding the documentation. Could someone
>> shed some light on this?
>>
>
> You are on the right track. You have to decide what processor is going to
> have each column. This is the partitioning of the left hand side vector
> will need when applying this new matrix.
> So [2 | 3 4] is valid. This would give you
> [01]* [03 04]
> [11] [13 14]*
> * diagonal part
>
>
>>
>> Thanks in advance.
>>
>>
>> Best regards
>>
>> Peder
>>
>>
>>
>> Peder Jørgensgaard Olesen
>> PhD student
>> Department of Mechanical Engineering
>>
>> pjool at mek.dtu.dk
>> Koppels Allé
>> Building 403, room 105
>> 2800 Kgs. Lyngby
>> www.dtu.dk/english
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20211114/4594b1ed/attachment.html>
More information about the petsc-users
mailing list