[petsc-users] DMDA questions

Xiangdong epscodes at gmail.com
Tue Feb 25 11:40:03 CST 2014

On Tue, Feb 25, 2014 at 11:22 AM, Jed Brown <jed at jedbrown.org> wrote:

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

For example, if the values on the 4-by-4 grid are [1,2,3,4;  5,6,7,8;
 9,10,11,12; 13,14,15,16]. If I use 4 processors and set m=2, n=2 (or use
petsc_decide), then on processor zero, the local portion of the global
vector is 1,2,3,4 while the local vector has value 1,2,5,6. On processor
one, the local portion of the global vector is 5,6,7,8; and the local
vector is 3,4,7,8. It looks like the global is natural order, while local
vector is petsc order.

> > 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).

Any examples in petsc tutorials demonstrating the case dof>1? I found most
of them are dof=1. For dof>1, are the values stored in a interleaved

> > 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140225/3befb461/attachment.html>

More information about the petsc-users mailing list