[petsc-users] Multi-DOF DMDA Vec

Anush Krishnan anush at bu.edu
Fri Jun 13 21:04:03 CDT 2014


On 13 June 2014 14:59, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
> On Jun 13, 2014, at 1:43 PM, 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.
>
>      You can pull out a single set of DOF with VecStrideGather() and put
> it back with VecStrideScatter() see also VecStrideGatherAll(),
> VecStrideScatterAll() also see VecStrideNorm() etc.
>
>
With regard to the interlaced memory performing better: If I used three
vectors created from the same DMDA for each degree of freedom, how
different would that be in performance compared to a fully interlaced
vector? Wouldn't cache reuse be about the same for both cases?


> >
> >> 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/218af4b1/attachment-0001.html>


More information about the petsc-users mailing list