VecGetValues?

Matthew Knepley knepley at mcs.anl.gov
Mon Feb 27 13:05:23 CST 2006


billy at dem.uminho.pt writes:

> Once I update the ghosts cells values, how do I access them using the global index?
>
> I have used VecGetValues but it says: "Can only get local values, trying 100!"

  We do not have access to local values through global indices expect through the DA.
This is something we might provide with the unstructured update in the next release, but it is really
more common to refer to them through local indices, as in FEM methods.

     Matt

> Billy.
>
> Quoting billy at dem.uminho.pt:
>
>> 
>> Thank you very much for your help. :)
>> 
>> I think I will use VecCreateGhost() then.
>> 
>> Billy.
>> 
>> 
>> Quoting Barry Smith <bsmith at mcs.anl.gov>:
>> 
>> > 
>> >    If you are using a structured grid you should use DA's to
>> > manage all this. You won't need to monkey with IS or VectorScatter
>> > or VecCreateGhost. Otherwise, ... see below....
>> > 
>> > On Sun, 26 Feb 2006, billy at dem.uminho.pt wrote:
>> > 
>> > > Hi,
>> > >
>> > > I want to parallelize an unstructured finite volume CFD code. The code
>> is
>> > > second-order in space, so I only need one layer of overlap between
>> domains.
>> > The
>> > > time advancement is implicit.
>> > >
>> > > I renumbered the cells in my application to respect PETSc ordering.
>> > > Do I need to use AO: Application Orderings? Or is this optional?
>> > 
>> > You do not have to use AO to manage getting the "PETSc style" ordering,
>> > you can do it anyway you like, so long as you have a "PETSc style"
>> > ordering.
>> > 
>> > >
>> > > P0             P1
>> > > ----------     ----------
>> > > | 0| 1| 2| <-> | 9|10|11|
>> > > | 3| 4| 5| <-> |12|13|14|
>> > > | 6| 7| 8| <-> |15|16|17|
>> > > ----------     ----------
>> > >
>> > > Should I use VecCreateGhost to include the ghost cells or another type
>> of
>> > vector
>> > > like VecCreateSeq?
>> > 
>> >     Likely you will wish to use VecCreateGhost()
>> > 
>> > >
>> > > P0                P1
>> > > -------------     -------------
>> > > | 0| 1| 2| 9| <-> |18| 9|10|11|
>> > > | 3| 4| 5|10| <-> |19|12|13|14|
>> > > | 6| 7| 8|11| <-> |21|15|16|17|
>> > > -------------     -------------
>> > >
>> > > Do I need to create IS: Index Sets?
>> > 
>> > If you use VecCreateGhost() and friends (VecGhostUpdateBegin/End(), 
>> > VecGhostGetLocalForm() etc) you will not need to deal with index sets.
>> > >
>> > > P0                P1
>> > > -------------     -------------
>> > > | 0| 1| 2| 9| <-> | 9| 0| 1| 2|
>> > > | 3| 4| 5|10| <-> |10| 3| 4| 5|
>> > > | 6| 7| 8|11| <-> |11| 6| 7| 8|
>> > > -------------     -------------
>> > >
>> > > Then I should apply VecScatter routines to update ghost cells, right?
>> > 
>> > If you use VecCreateGhost() then it manages the scatters during the 
>> > VecGhostUpdateBegin/End() for you; you do not need to use IS or
>> VecScatter.
>> > 
>> > If you do not use VecCreateGhost() then you need to use IS followed by
>> > VecScatterCreate() to build the scatter data structures and 
>> > VecScatterBegin/End() to update the ghost values.
>> > 
>> >     Barry
>> > 
>> > >
>> > > Sorry for asking so many questions, but this is all very confusing to
>> me.
>> > >
>> > >
>> > > Billy.
>> > >
>> > >
>> > > Quoting Satish Balay <balay at mcs.anl.gov>:
>> > >
>> > >> On Fri, 24 Feb 2006, billy at dem.uminho.pt wrote:
>> > >>
>> > >>>
>> > >>> Hello,
>> > >>>
>> > >>>
>> > >>> "VecGetValues - Gets values from certain locations of a vector.
>> > Currently
>> > >> can
>> > >>> only get values on the same processor"
>> > >>>
>> > >>> How can I get a value of the vector belonging to a different
>> processor?
>> > >>>
>> > >>>
>> > >>> I am trying to learn how to adapt my code to work in parallel. Have
>> > looked
>> > >> at
>> > >>> src/snes/examples/tutorials/ex10d/ex10.c, but I am still confused on
>> how
>> > to
>> > >> use
>> > >>> petsc with unstructured meshes. Is there any simple step-by-step
>> > >> tutorial?
>> > >>
>> > >> Basically - you'll have to use VecScatter routines to specify the
>> > >> communication required. Then use VecScatterBegin/End() to invoke this
>> > >> communication. Some of this info is in the tutorial slides [check
>> > >> arround slide 150] in:
>> > >>
>> >
>> http://www-unix.mcs.anl.gov/petsc/petsc-as/documentation/tutorials/PetscTu06.pdf
>> > >>
>> > >> Not usre if there is an unstructured grid example code. [but there are
>> > >> examples using VecScatters in src/dm/da/examples/tutorials]
>> > >>
>> > >> Satish
>> > >>
>> > >>
>> > >
>> > >
>> > >
>> > 
>> > 
>> 
>> 
>> 
>
>
>
>

-- 
"Failure has a thousand explanations. Success doesn't need one" -- Sir Alec Guiness




More information about the petsc-users mailing list