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)
      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


Reply via email to