[petsc-users] How to obtain the local matrix from a global matrix in DMDA?
Matthew Knepley
knepley at gmail.com
Mon Mar 14 10:44:06 CDT 2022
On Mon, Mar 14, 2022 at 11:05 AM liluo <liluo at um.edu.mo> wrote:
> Dear developers,
>
>
> I defined subdomain problems that have some layers of ghost points, which
> are exactly of the "local" size of a DA.
>
> And I want to generate the corresponding submatrix in each subdomain which
> contains those layers of ghost points.
>
>
> I know that MatGetSubMatrices can return a submatrix when determining the
> index set like PCASM, but how can I get the index set including those
> layers of ghost points? When a DA is setup, such IS for creating ltog
> mapping was already destroyed.
>
> Or you may have some simpler way to get this?
>
You can use
https://petsc.org/main/docs/manualpages/IS/ISLocalToGlobalMappingGetIndices.html
to get the indices out of the L2G map, and then call MatGetSubmatrix().
Thanks,
Matt
> Bests,
>
> Li Luo
> ------------------------------
> *From:* Mark Adams <mfadams at lbl.gov>
> *Sent:* Monday, 14 March, 2022 22:49:47
> *To:* liluo
> *Cc:* petsc-users at mcs.anl.gov
> *Subject:* Re: [petsc-users] How to obtain the local matrix from a global
> matrix in DMDA?
>
> You might want to explain what you want to do.
> A local vector has ghost values that you can use to compute local
> residuals. You don't usually want a matrix that conforms with this local
> vector.
> You could get the global equations of the local vector and use
> MatCreateSubMatrix, but I think there is a better way to do what you want.
>
> OK, Matt and Jed beat me
>
> On Mon, Mar 14, 2022 at 10:35 AM liluo <liluo at um.edu.mo> wrote:
>
>> Dear developers,
>>
>>
>> I created a DMDA object and obtain the local vector from a global
>> vector by using DMGlobalToLocalBegin/End.
>>
>> How can I obtain the corresponding local matrix from the global matrix?
>>
>> In my case, the global matrix is of MPIBAIJ type created by
>> DMCreateMatrix(da,MATBAIJ,&A);
>>
>>
>> Bests,
>>
>> LI
>>
>>
>>
>>
--
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/20220314/d3fb88d5/attachment.html>
More information about the petsc-users
mailing list