Hi Matthew,
Thank you for your answer ! So I tried to add those steps, and I have the same behavior as the one described in this thread :
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: Object is in wrong state
[0]PETSC ERROR: DM global to natural SF was not created.
You must call DMSetUseNatural() before DMPlexDistribute().
[0]PETSC ERROR: See https://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.
[0]PETSC ERROR: Petsc Development GIT revision: v3.14.4-671-g707297fd510 GIT Date: 2021-02-24 22:50:05 +0000
[0]PETSC ERROR: /ccc/work/cont001/ocre/bridelbert/EULERIAN2D/bin/eulerian2D on a named inti1401 by bridelbert Thu Jul 8 07:50:24 2021
[0]PETSC ERROR: Configure options --with-clean=1 --prefix=/ccc/work/cont001/ocre/bridelbert/04-PETSC/build_uns3D_inti --with-make-np=8 --with-windows-graphics=0 --with-debugging=1 --download-mpich-shared=0 --with-x=0 --with-pthread=0 --with-valgrind=0 --PETSC_ARCH=INTI_UNS3D --with-fc=/ccc/products/openmpi-2.0.4/gcc--8.3.0/default/bin/mpifort --with-cc=/ccc/products/openmpi-2.0.4/gcc--8.3.0/default/bin/mpicc --with-cxx=/ccc/products/openmpi-2.0.4/gcc--8.3.0/default/bin/mpicxx --with-openmp=0 --download-sowing=/ccc/work/cont001/ocre/bridelbert/v1.1.26-p1.tar.gz --download-metis=/ccc/work/cont001/ocre/bridelbert/git.metis.tar.gz --download-parmetis=/ccc/work/cont001/ocre/bridelbert/git.parmetis.tar.gz --download-fblaslapack=/ccc/work/cont001/ocre/bridelbert/git.fblaslapack.tar.gz --with-cmake-dir=/ccc/products/cmake-3.13.3/system/default
[0]PETSC ERROR: #1 DMPlexGlobalToNaturalBegin() line 247 in /ccc/work/cont001/ocre/bridelbert/04-PETSC/src/dm/impls/plex/plexnatural.c
[0]PETSC ERROR: #2 User provided function() line 0 in User file
The creation of my DM is as follow :
! Read mesh from file name 'meshname'
call DMPlexCreateFromFile(PETSC_COMM_WORLD, meshname, PETSC_TRUE, dm, ierr); CHKERRA(ierr)
! Distribute on processors
call DMSetUseNatural(dm, PETSC_TRUE, ierr) ; CHKERRA(ierr)
! Start with connectivity
call DMSetBasicAdjacency(dm, PETSC_TRUE, PETSC_FALSE, ierr) ; CHKERRA(ierr)
! Distribute on processors
call DMPlexDistribute(dm, overlap, PETSC_NULL_SF, dmDist, ierr) ; CHKERRA(ierr)
! Security check
if (dmDist /= PETSC_NULL_DM) then
! Destroy previous dm
call DMDestroy(dm, ierr) ; CHKERRA(ierr)
! Replace with dmDist
dm = dmDist
end if
! Finalize setup of the object
call DMSetFromOptions(dm, ierr) ; CHKERRA(ierr)
! Boundary condition with ghost cells
call DMPlexConstructGhostCells(dm, PETSC_NULL_CHARACTER, PETSC_NULL_INTEGER, dmGhost, ierr); CHKERRA(ierr)
! Security check
if (dmGhost /= PETSC_NULL_DM) then
! Destroy previous dm
call DMDestroy(dm, ierr) ; CHKERRA(ierr)
! Replace with dmGhost
dm = dmGhost
end if
And I write my vector as follow :
call DMCreateGlobalVector(dm, Xnat, ierr); CHKERRA(ierr)
call PetscObjectSetName(Xnat, "NaturalSolution", ierr); CHKERRA(ierr)
call DMPlexGlobalToNaturalBegin(dm, X, Xnat, ierr); CHKERRA(ierr)
call DMPlexGlobalToNaturalEnd(dm, X, Xnat, ierr); CHKERRA(ierr)
call DMGetOutputSequenceNumber(dm, save_seqnum, save_seqval, ierr); CHKERRA(ierr)
call DMSetOutputSequenceNumber(dm, -1, 0.d0, ierr); CHKERRA(ierr)
write(filename,'(A,I8.8,A)') "restart_", stepnum, ".bin"
call PetscViewerCreate(PETSC_COMM_WORLD, binViewer, ierr); CHKERRA(ierr)
call PetscViewerSetType(binViewer, PETSCVIEWERBINARY, ierr); CHKERRA(ierr)
call PetscViewerFileSetMode(binViewer, FILE_MODE_WRITE, ierr); CHKERRA(ierr);
call PetscViewerBinarySetUseMPIIO(binViewer, PETSC_TRUE, ierr); CHKERRA(ierr);
call PetscViewerFileSetName(binViewer, trim(filename), ierr); CHKERRA(ierr)
! call VecView(X, binViewer, ierr); CHKERRA(ierr)
call VecView(Xnat, binViewer, ierr); CHKERRA(ierr)
call PetscViewerDestroy(binViewer, ierr); CHKERRA(ierr)
call DMSetOutputSequenceNumber(dm, save_seqnum, save_seqval, ierr); CHKERRA(ierr)
Did you find the time to fix the bug you are mentioning in the thread above regarding the passing of the natural property when calling DMPlexConstructGhostCells ?
Thanks !!