[petsc-users] Using DMDA with regular matrices
Jed Brown
jed at jedbrown.org
Mon Mar 16 08:22:16 CDT 2020
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.
More information about the petsc-users
mailing list