[petsc-users] Associate Values with DM variable

Barry Smith bsmith at mcs.anl.gov
Fri Aug 19 16:56:16 CDT 2011


On Aug 19, 2011, at 4:52 PM, Alan Wei wrote:

> Dear all,
>     I have a question of the access of the DM in PETSc.
> 1) I used 
>   DMDACreate2d(..., &da), where 'da' is a DM parameter;
> 
> 2) and a DMDASetUniformCoordinates(da, ...) was used to set up a coordinate system on 'da'. 
> 
> 3) Then I used 
>   DMDAGetCoordinateDA(da, &cda);
>   DMDAGetGhostedCoordinates(da, &gc);
>   DMDAVecGetArray(cda, gc, &coors); 
>   So that I can access the coordinate values of each points in 'da'. 
> 
> 4) My question is,
>   4.1) in spite of 'coors', is there any other values stored in 'da' for every points of it;

   Nope. 

>   4.2) I want to store other parameters associating with 'da', what should I do for that?

   Those are never stored directly in the DA, each of those would be stored in a separate Vec obtained with DMGetGlobalVector().   If you want to carry around a bunch of things like that then you can make a struct where you keep them together for easy moving around.

   Barry


> for example, since 'da' has a coordinate, I treat it as a uniform mesh. In addition to coordinate values, I hope I can store u and v (x/y-direction velocity magnitude) in each node of this coordinate. I thought about use DMDACreate2d to create other two distributed matrices. However, I'm not sure that these three DM (including 'da') has the same allocation in parallel computational nodes. Like, 'da' is assigned x = 0~4 to rank-0 and x = 5~10 to rank-1; while DM for 'u' is arranged x = 0~5 to rank-0 and x = 6~10 to rank-1.
> 
> Thanks,
> Alan



More information about the petsc-users mailing list