[petsc-users] Use of DM to update ghost values
Anton Popov
popov at uni-mainz.de
Sat Apr 5 08:19:35 CDT 2014
On 4/5/14 1:41 AM, TAY wee-beng wrote:
> Hi,
>
> Supposed, I use DM to construct my grid. I would like to know if DM
> can be used to update the ghost values easily?
>
> If I can use staggered grid, does it mean I have to create 3 DM grids
> (x,y,z)?
Yes this is how I do it currently. But this is not optimal, because you
have to scatter to ghost points four times (vx, vy, vz, p separately).
Just do it this way to start with, because by far it's the simplest
implementation.
Alternatively you can create 2 distributed vectors, the one that
contains non-overlapping partitioning of the grid points (to setup SNES,
KSP, PC), and another overlapping one that contains all ghost points you
need to compute your residual/Jacobian. Depending on the problem you
solve this can be either star or box stencil (for each solution component).
Then setup scatter context.
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecScatterCreate.html
You can reuse the same context for both accessing off-processor values
and residual assembly, just need to change scatter mode SCATTER_FORWARD
/ SCATTER_REVERSE and insert mode ADD_VALUES / INSERT_VALUES
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecScatterBegin.html
Anton
>
> Also, how can I solve the momentum eqn involving u,v,w using KSP?
>
> What examples can I follow for the above requirements?
>
> Thank you.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140405/4ba8f83d/attachment.html>
More information about the petsc-users
mailing list