[petsc-users] Using DMDA with regular matrices

Yuyun Yang yyang85 at stanford.edu
Mon Mar 16 09:08:22 CDT 2020


Great, thanks so much for the explanations!

获取 Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Jed Brown <jed at jedbrown.org>
Sent: Monday, March 16, 2020 9:22:16 PM
To: Yuyun Yang <yyang85 at stanford.edu>; petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] Using DMDA with regular matrices

Yuyun Yang <yyang85 at stanford.edu> writes:

> Hello team,
>
> Hope you're staying healthy amid the coronavirus craziness.
>
> Just want to ask a basic question: if my grid is managed by DMDA, then
> do matrices in all my intermediate steps have to be compatible with
> DMDA and formed in a special way, or can I just form them as usual
> (i.e. do MatCreate, MatMPIAIJSetPreallocation, MatSetValue etc.)?

DMCreateMatrix does the creation and preallocation for you, and enables
you to use MatSetValuesStencil.  It's otherwise the same.

Sometimes people use auxiliary DMs to describe distribution of values
that aren't the same size/shape as solution variables (e.g.,
cell-centered tensor-valued coefficients), though usually those are
accessed in your residual and Jacobian assembly functions, not via
matrices.

> Asking this because I'm using a mix of matrix-free and matrix-based
> operations, and MatShell seems to require the use of DMDA.

MatShell has no dependence on DMDA.  It's entirely in your hands, via
the callback(s) that you implement.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200316/64a50669/attachment.html>


More information about the petsc-users mailing list