[petsc-users] DMDA questions

Jed Brown jed at jedbrown.org
Tue Feb 25 10:22:26 CST 2014


Xiangdong <epscodes at gmail.com> writes:

> Hello PETSc team,
>
> I have a few quick questions about the DMDA:
>
> 1) The ordering. The global vector is using natural ordering and the local
> vector is using petsc ordering. 

No.  The natural ordering is not used explicitly because it implies an
inefficient decomposition, though you can index by (i,j) if you use
DMDAVecGetArray().

> In other words, if I create a DM with width 0 (no ghost layers), the
> local portion of global vector and the local vector are still
> different. I tested and it seems ture, just want to confirm.

The local sizes are the same, but the global Vec has collective
semantics (e.g., norms and dot products) while the local Vec is truly
local.

> 2) DOF. In each cell, I have two unknowns, say ux and uy. One way is to
> store them using one global vector with dof=2. The other way is to create
> two global vectors for each ux and uy with dof=1. Is one approach better
> than the other?

The former is better for memory streaming unless your operations
traverse the grid using only one at a time (and then, it would be better
to rephrase to traverse fewer times, using both values each time).

> 3) Matrix compatibility. When I specify the entries of my sparse matrix by
> looping each row from ns to ne (obtained from MatGetOwnershipRange), the
> local portion of global vector also has the range from ns to ne. However,
> the local vector on that processor may have different ranges (or different
> portion) due to ordering. If the entries depends on the portion from ns to
> ne + its ghost  points, what is the best way to do it?

I recommend using MatSetValuesStencil.  See
src/snes/examples/tutorials/ex15.c for example.  That way you only have
to think about (i,j) coordinates on the grid rather than local or global
indices.

> 4) Name convention. Some function are names as DMXX, while others have
> DMDAXX. Why do they have different prefix?

DM is the base class, DMDA is a specialization.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140225/06819060/attachment.pgp>


More information about the petsc-users mailing list