[petsc-users] Multi-DOF DMDA Vec
Anush Krishnan
anush at bu.edu
Fri Jun 13 13:56:47 CDT 2014
Thanks, Jed!
On 13 June 2014 14:43, Jed Brown <jed at jedbrown.org> wrote:
> 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140613/77158774/attachment.html>
More information about the petsc-users
mailing list