[petsc-users] Question about DMDA local vector and global vector
Danyang Su
danyang.su at gmail.com
Tue May 20 16:49:31 CDT 2014
Hi Matthew,
How about the matview output? Is this automatically permuted to the
natural ordering too?
Thanks,
Danyang
On 20/05/2014 12:25 PM, Matthew Knepley wrote:
> On Tue, May 20, 2014 at 1:31 PM, Danyang Su <danyang.su at gmail.com
> <mailto:danyang.su at gmail.com>> wrote:
>
> Hi All,
>
> I use DMDA for a flow problem and found the local vector and
> global vector does not match for 2D and 3D problem when dof >1.
>
> For example, the mesh is as follows:
>
> |proc 1| proc 2 | proc 3 |
> |7 8 9|16 17 18|25 26 27|
> |4 5 6|13 14 15|22 23 24|
> |1 2 3|10 11 12|19 20 21|
>
> /The following functions are used to create DMDA object, global
> vector and local vector./
>
> call DMDACreate2d(Petsc_Comm_World,DMDA_BOUNDARY_NONE, &
> DMDA_BOUNDARY_NONE,
> DMDA_STENCIL_BOX, &
> nvxgbl,nvzgbl,PETSC_DECIDE,PETSC_DECIDE, &
> dmda_flow%dof,
> dmda_flow%swidth, &
> PETSC_NULL_INTEGER,PETSC_NULL_INTEGER, &
> dmda_flow%da,ierr)
> call DMCreateGlobalVector(dmda_flow%da,x_flow,ierr)
> call VecDuplicate(x_flow,b_flow,ierr)
> call DMCreateLocalVector(dmda_flow%da,x_flow_loc,ierr)
> call VecDuplicate(x_flow_loc,b_flow_loc,ierr)
>
> /The following functions are used to compute the function
> (b_flow_loc)/
>
> call VecGetArrayF90(b_flow_loc, vecpointer, ierr)
> vecpointer = (compute the values here...)
> call VecRestoreArrayF90(b_flow_loc,vecpointer,ierr)
> call DMLocalToGlobalBegin(dmda_flow%,b_flow_loc,INSERT_VALUES, &
> b_flow,ierr)
> call DMLocalToGlobalEnd(dmda_flow%,b_flow_loc,INSERT_VALUES, &
> b_flow,ierr)
>
>
> /The data of local vector b_flow_loc for proc1, proc2 and proc3
> are as follows (just an example, without ghost value)/
> proc 1 proc 2 proc 3
> 1 10 19
> 2 11 20
> 3 12 21
> 4 13 22
> 5 14 23
> 6 15 24
> ... ... ...
>
> /But the global vector b_flow from Vecview shows that the data is
> stored as follows (left column). I thought the global vector
> b_flow is like the right column. Is anything wrong here?/
>
>
> On output, the global vectors are automatically permuted to the
> natural ordering.
>
> Matt
>
>
> Process [0] Process [0]
> 1 1
> 2 2
> 3 3
> 10 4
> 11 5
> 12 6
> ... ...
> Process [1] Process [1]
> 4 10
> 5 11
> 6 12
> 13 13
> 14 14
> 15 15
> ... ...
> Process [2] Process [2]
> ... ...
>
> Though the data distribution is different from what I thought
> before, the code works well for 1D problem and most of the 2D and
> 3D problem, but failed in newton iteration for some 2D problem
> with dof > 1. I use KSP solver, not SNES solver at present.
>
> Thanks and regards,
>
> Danyang
>
>
>
>
>
> --
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140520/619ae17b/attachment.html>
More information about the petsc-users
mailing list