[petsc-users] Creating a 2d geometry by using vector
Alan Wei
zhenglun.wei at gmail.com
Thu Aug 18 21:40:09 CDT 2011
Dear Barry,
That is really a great idea, and it is something that I want. I've never
noticed that the structure in C is so marvelous. However, I have a further
question. In that example, a variable x is defined like Field **x, and
DAVecGetArray<http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-2.3.2/docs/manualpages/DA/DAVecGetArray.html#DAVecGetArray>(da,X,&x).
I wonder if there is any relationship between da, X and x after using
DAVecGetArray. Or it just a prerequisite for using the nice notation of 'x'.
thanks,
Alan
On Thu, Aug 18, 2011 at 9:09 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
> Alan,
>
> I'm not sure what you are getting at but we commonly use tricks like (see
> src/snes/examples/tutorials/ex19.c)
>
> typedef struct {
> PetscScalar u,v,omega,temp;
> } Field;
>
> Then in this case use a DMDAVecGetArray() to get f and x and then have
> nice notation like
>
> f[j][i].u = x[j][i].u;
> f[j][i].v = x[j][i].v;
> f[j][i].omega = x[j][i].omega - (x[j][i+1].v - x[j][i].v)*dhx;
> f[j][i].temp = x[j][i].temp;
>
> note that this means the values are stored interlaced in the vector.
>
> Barry
>
> On Aug 18, 2011, at 9:03 PM, Alan Wei wrote:
>
> > Dear All,
> > I'm trying to 'draw' a 2-D cylinder in PETSc. It simply restore the x
> and y coordinate values in two arrays. I wonder if I can use Vec in PETSc to
> implement it (i.e. defining a vec circle) so that I can call its x or y
> coordinate by circle.x or circle.y. Is this possible? also, is this a better
> way than just defining it as two arrays, i.e. x[ ] and y[ ].
> >
> > thanks in advance,
> > Alan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110818/a04d8d8e/attachment.htm>
More information about the petsc-users
mailing list