Re: [petsc-users] Using DMDA with regular matrices

2020-03-16 Thread Yuyun Yang
Great, thanks so much for the explanations!

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


From: Jed Brown 
Sent: Monday, March 16, 2020 9:22:16 PM
To: Yuyun Yang ; petsc-users@mcs.anl.gov 

Subject: Re: [petsc-users] Using DMDA with regular matrices

Yuyun Yang  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.


Re: [petsc-users] Using DMDA with regular matrices

2020-03-16 Thread Jed Brown
Yuyun Yang  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.


[petsc-users] Using DMDA with regular matrices

2020-03-16 Thread Yuyun Yang
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.)? Asking this because I'm using a 
mix of matrix-free and matrix-based operations, and MatShell seems to require 
the use of DMDA.

Thanks for your help.

Best,
Yuyun