[petsc-dev] [petsc-users] Segmentation Violation in getting DMPlex coordinates
Patrick Sanan
patrick.sanan at gmail.com
Sun Apr 29 06:19:05 CDT 2018
For functions like this (only for one impl), should this new check be
considered new best practices (as opposed to the composition approach,
defining things with names like DMDASetUniformCoordinates_DMDA())? It seems
like less boilerplate, as well as avoiding a function on the stack (and the
check itself if it's turned off in optimized mode).
2018-04-28 22:38 GMT+02:00 Smith, Barry F. <bsmith at mcs.anl.gov>:
>
> Added runtime error checking for such incorrect calls in
> barry/dmda-calls-type-check
>
>
> > On Apr 28, 2018, at 9:19 AM, Matthew Knepley <knepley at gmail.com> wrote:
> >
> > On Sat, Apr 28, 2018 at 2:08 AM, Danyang Su <danyang.su at gmail.com>
> wrote:
> > Hi All,
> >
> > I use DMPlex and need to get coordinates back after distribution.
> However, I always get segmentation violation in getting coords values in
> the following codes if using multiple processors. If only one processor is
> used, it works fine.
> >
> > For each processors, the off value starts from 0 which looks good. I
> also tried 0-based index, which gives the same error. Would any one help to
> check what is wrong here?
> >
> > idof 1 off 0
> > idof 2 off 0
> > idof 1 off 2
> > idof 2 off 2
> > idof 1 off 4
> > idof 2 off 4
> > idof 1 off 6
> > idof 2 off 6
> > idof 1 off 8
> > idof 2 off 8
> >
> >
> > DM :: distributedMesh, cda
> > Vec :: gc
> > PetscScalar, pointer :: coords(:)
> > PetscSection :: cs
> >
> > ...
> >
> > call DMGetCoordinatesLocal(dmda_flow%da,gc,ierr)
> > CHKERRQ(ierr)
> >
> > call DMGetCoordinateDM(dmda_flow%da,cda,ierr)
> > CHKERRQ(ierr)
> >
> > call DMGetDefaultSection(cda,cs,ierr)
> > CHKERRQ(ierr)
> >
> > call PetscSectionGetChart(cs,istart,iend,ierr)
> > CHKERRQ(ierr)
> >
> > !c get coordinates array
> > call DMDAVecGetArrayF90(cda,gc,coords,ierr)
> >
> > You cannot call DMDA function if you have a DMPlex. You jsut call
> VecGetArrayF90()
> >
> > Matt
> >
> > CHKERRQ(ierr)
> >
> > do ipoint = istart, iend-1
> >
> > call PetscSectionGetDof(cs,ipoint,dof,ierr)
> > CHKERRQ(ierr)
> >
> > call PetscSectionGetOffset(cs,ipoint,off,ierr)
> > CHKERRQ(ierr)
> >
> > inode = ipoint-istart+1
> >
> > if (cell_coords == coords_xyz) then
> > nodes(inode)%x = coords(off+1)
> > nodes(inode)%y = coords(off+2)
> > nodes(inode)%z = coords(off+3)
> > else if (cell_coords == coords_xy) then
> > nodes(inode)%x = coords(off+1)
> > nodes(inode)%y = coords(off+2)
> > nodes(inode)%z = 0.0d0
> > else if (cell_coords == coords_yz) then
> > nodes(inode)%x = 0.0d0
> > nodes(inode)%y = coords(off+1)
> > nodes(inode)%z = coords(off+2)
> > else if (cell_coords ==coords_xz) then
> > nodes(inode)%x = coords(off+1)
> > nodes(inode)%y = 0.0d0
> > nodes(inode)%z = coords(off+2)
> > end if
> > end do
> >
> > call DMDAVecRestoreArrayF90(cda,gc,coords,ierr)
> > CHKERRQ(ierr)
> >
> > Thanks,
> >
> > 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
> >
> > https://www.cse.buffalo.edu/~knepley/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20180429/a5ed187f/attachment.html>
More information about the petsc-dev
mailing list