[petsc-users] Indexing/using a 3D DMDA as a 1D vector

Matthew Knepley knepley at gmail.com
Wed Sep 12 09:57:28 CDT 2018


On Wed, Sep 12, 2018 at 10:43 AM Phil Tooley <phil.tooley at sheffield.ac.uk>
wrote:

> Ok, So I have figured this out a bit better now, facepalm moment as I
> finally realised that this is exactly what the DMDA exists to do...  I
> need to create a vector using the DMCreate*Vector functions and can then
> insert values using the assembly functions.
>
> Then, if I understand correctly, in order to have the state I need to
> multiply with my operator I should make use of the
> DMDAGlobalToNaturalBegin() and End() functions to ensure the correct
> ordering.  Do I then need to ensure I have reverted it to global
> ordering before I try to apply finite difference methods again?
>

Yep. Depending on what your operator is, you could also try to implement it
in the
FD way as well.

  Thanks,

    Matt


> Thanks
>
> P
>
>
> On 12/09/18 14:27, Phil Tooley wrote:
> > I will preface this by saying I am new to PETSc and am still trying to
> > get my head around all of the layout mapping that is done.  That means I
> > may well have fundamentally misunderstood something, but hopefully
> > someone will be able to to put me right.
> >
> > In my application I have some 3D pixel data which I want to manipulate
> > using finite difference methods and then transform by viewing as a 1-D
> > vector and multiplying by a large sparse matrix operator.
> >
> > I would assume that the correct way to do this is by creating a DMDA to
> > hold the image data and ghosting appropriately to apply my finite
> > difference operations.  Then I had hoped that I could use some form of
> > application ordering to allow viewing the data as a vector that can be
> > multiplied with my operator matrix.  This is where I have come unstuck,
> > I may just be missing something obivous but I can't figure out how to do
> > this.  Can anyone point me in the correct direction please?
> >
> > Many Thanks
> >
>
> --
> Phil Tooley
> Research Software Engineering
> University of Sheffield
>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180912/198f4c1f/attachment.html>


More information about the petsc-users mailing list