[petsc-users] Segmentation Violation in getting DMPlex coordinates
Danyang Su
danyang.su at gmail.com
Sat Apr 28 17:27:11 CDT 2018
Hi Matt and Barry,
Thanks for your quick response. After changing DMDAVecGetArrayF90 to
VecGetArrayF90, everything works now.
Thanks,
Danyang
On 18-04-28 01:38 PM, Smith, Barry F. wrote:
> 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/
More information about the petsc-users
mailing list