[petsc-users] Multi-DOF DMDA Vec
Jed Brown
jed at jedbrown.org
Fri Jun 13 13:43:13 CDT 2014
Anush Krishnan <anush at bu.edu> writes:
> Hello petsc-users,
>
> I created a vector using DMDACreate with 3 degrees of freedom. Is it
> possible for me to access each vector corresponding to a degree of freedom?
> Seeing that I need to access the array as [k][j][i][dof], does it mean that
> the values of each component are not contiguous?
The values are interlaced. This is generally better for memory
performance (cache reuse). See, for example, the PETSc-FUN3D papers or
the various discretization frameworks that rediscover this every once in
a while.
> Also, what is the difference between DMDAVecGetArray and DMDAVecGetArrayDOF?
With DMDAVecGetArray for multi-component problems, you usually write
typedef struct {PetscScalar u,v,w;} Field;
Field ***x;
DMDAVecGetArray(dm,X,&x);
...
x[k][j][i].u = 1;
With DMDAVecGetArrayDOF, you use an extra set of indices instead of the
struct.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140613/bf06ea9e/attachment.pgp>
More information about the petsc-users
mailing list