<div dir="ltr"><div dir="ltr">On Wed, Dec 14, 2022 at 3:58 AM Berend van Wachem <<a href="mailto:berend.vanwachem@ovgu.de">berend.vanwachem@ovgu.de</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Dear PETSc team and users,<br>
<br>
I have asked a few times about this before, but we haven't really gotten <br>
this to work yet.<br>
<br>
In our code, we use the DMPlex framework and are also interested in <br>
periodic geometries.<br>
<br>
As our simulations typically require many time-steps, we would like to <br>
be able to save the DM to file and to read it again to resume the <br>
simulation (a restart).<br>
<br>
Although this works for a non-periodic DM, we haven't been able to get <br>
this to work for a periodic one. To illustrate this, I have made a <br>
working example, consisting of 2 files, createandwrite.c and <br>
readandcreate.c. I have attached these 2 working examples. We are using <br>
Petsc-3.18.2.<br>
<br>
In the first file (createandwrite.c) a DMPlex is created and written to <br>
a file. Periodicity is activated on lines 52-55 of the code.<br>
<br>
In the second file (readandcreate.c) a DMPlex is read from the file. <br>
When a periodic DM is read, this does not work. Also, trying to <br>
'enforce' periodicity, lines 55 - 66, does not work if the number of <br>
processes is larger than 1 - the code "hangs" without producing an error.<br>
<br>
Could you indicate what I am missing? I have really tried many different <br>
options, without finding a solution.<br></blockquote><div><br></div><div>Hi Berend,</div><div><br></div><div>There are several problems. I will eventually fix all of them, but I think we can get this working quickly.</div><div><br></div><div>1) Periodicity information is not saved. I will fix this, but forcing it should work.</div><div><br></div><div>2) You were getting a hang because the blocksize on the local coordinates was not set correctly after loading</div><div>     since the vector had zero length. This does not happen in any test because HDF5 loads a global vector, but</div><div>     most other things create local coordinates. I have a fix for this, which I will get in an MR, Also, I moved DMLocalizeCoordinates()</div><div>     after distribution, since this is where it belongs.</div><div><br></div><div>knepley/fix-plex-periodic-faces *$:/PETSc3/petsc/petsc-dev$ git diff<br>diff --git a/src/dm/interface/dmcoordinates.c b/src/dm/interface/dmcoordinates.c<br>index a922348f95b..6437e9f7259 100644<br>--- a/src/dm/interface/dmcoordinates.c<br>+++ b/src/dm/interface/dmcoordinates.c<br>@@ -551,10 +551,14 @@ PetscErrorCode DMGetCoordinatesLocalSetUp(DM dm)<br>   PetscFunctionBegin;<br>   PetscValidHeaderSpecific(dm, DM_CLASSID, 1);<br>   if (!dm->coordinates[0].xl && dm->coordinates[0].x) {<br>-    DM cdm = NULL;<br>+    DM       cdm = NULL;<br>+    PetscInt bs;<br><br>     PetscCall(DMGetCoordinateDM(dm, &cdm));<br>     PetscCall(DMCreateLocalVector(cdm, &dm->coordinates[0].xl));<br>+    // If the size of the vector is 0, it will not get the right block size<br>+    PetscCall(VecGetBlockSize(dm->coordinates[0].x, &bs));<br>+    PetscCall(VecSetBlockSize(dm->coordinates[0].xl, bs));<br>     PetscCall(PetscObjectSetName((PetscObject)dm->coordinates[0].xl, "coordinates"));<br>     PetscCall(DMGlobalToLocalBegin(cdm, dm->coordinates[0].x, INSERT_VALUES, dm->coordinates[0].xl));<br>     PetscCall(DMGlobalToLocalEnd(cdm, dm->coordinates[0].x, INSERT_VALUES, dm->coordinates[0].xl));<br><br></div><div> 3) If I comment out forcing the periodicity, your example does not run for me. I will try to figure it out</div><div><br></div><div>[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>[0]PETSC ERROR: Nonconforming object sizes<br>[0]PETSC ERROR: SF roots 4400 < pEnd 6000<br>[1]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>[0]PETSC ERROR: WARNING! There are option(s) set that were not used! Could be the program crashed before they were used or a spelling mistake, etc!<br>[1]PETSC ERROR: Nonconforming object sizes<br>[0]PETSC ERROR: Option left: name:-start_in_debugger_no (no value) source: command line<br>[1]PETSC ERROR: SF roots 4400 < pEnd 6000<br>[0]PETSC ERROR: See <a href="https://petsc.org/release/faq/">https://petsc.org/release/faq/</a> for trouble shooting.<br>[0]PETSC ERROR: Petsc Development GIT revision: v3.18.1-494-g16200351da0  GIT Date: 2022-12-12 23:42:20 +0000<br>[1]PETSC ERROR: WARNING! There are option(s) set that were not used! Could be the program crashed before they were used or a spelling mistake, etc!<br>[1]PETSC ERROR: Option left: name:-start_in_debugger_no (no value) source: command line<br>[0]PETSC ERROR: ./readandcreate on a arch-master-debug named <a href="http://MacBook-Pro.cable.rcn.com">MacBook-Pro.cable.rcn.com</a> by knepley Thu Dec 15 12:50:26 2022<br>[1]PETSC ERROR: See <a href="https://petsc.org/release/faq/">https://petsc.org/release/faq/</a> for trouble shooting.<br>[0]PETSC ERROR: Configure options --PETSC_ARCH=arch-master-debug --download-bamg --download-bison --download-chaco --download-ctetgen --download-egads --download-eigen --download-exodusii --download-fftw --download-hpddm --download-ks --download-libceed --download-libpng --download-metis --download-ml --download-mumps --download-muparser --download-netcdf --download-opencascade --download-p4est --download-parmetis --download-pnetcdf --download-pragmatic --download-ptscotch --download-scalapack --download-slepc --download-suitesparse --download-superlu_dist --download-tetgen --download-triangle --with-cmake-exec=/PETSc3/petsc/apple/bin/cmake --with-ctest-exec=/PETSc3/petsc/apple/bin/ctest --with-hdf5-dir=/PETSc3/petsc/apple --with-mpi-dir=/PETSc3/petsc/apple --with-petsc4py=1 --with-shared-libraries --with-slepc --with-zlib<br>[1]PETSC ERROR: Petsc Development GIT revision: v3.18.1-494-g16200351da0  GIT Date: 2022-12-12 23:42:20 +0000<br>[0]PETSC ERROR: #1 PetscSectionCreateGlobalSection() at /PETSc3/petsc/petsc-dev/src/vec/is/section/interface/section.c:1322<br>[1]PETSC ERROR: ./readandcreate on a arch-master-debug named <a href="http://MacBook-Pro.cable.rcn.com">MacBook-Pro.cable.rcn.com</a> by knepley Thu Dec 15 12:50:26 2022<br>[0]PETSC ERROR: #2 DMGetGlobalSection() at /PETSc3/petsc/petsc-dev/src/dm/interface/dm.c:4527<br>[1]PETSC ERROR: Configure options --PETSC_ARCH=arch-master-debug --download-bamg --download-bison --download-chaco --download-ctetgen --download-egads --download-eigen --download-exodusii --download-fftw --download-hpddm --download-ks --download-libceed --download-libpng --download-metis --download-ml --download-mumps --download-muparser --download-netcdf --download-opencascade --download-p4est --download-parmetis --download-pnetcdf --download-pragmatic --download-ptscotch --download-scalapack --download-slepc --download-suitesparse --download-superlu_dist --download-tetgen --download-triangle --with-cmake-exec=/PETSc3/petsc/apple/bin/cmake --with-ctest-exec=/PETSc3/petsc/apple/bin/ctest --with-hdf5-dir=/PETSc3/petsc/apple --with-mpi-dir=/PETSc3/petsc/apple --with-petsc4py=1 --with-shared-libraries --with-slepc --with-zlib<br>[0]PETSC ERROR: #3 DMPlexSectionLoad_HDF5_Internal() at /PETSc3/petsc/petsc-dev/src/dm/impls/plex/plexhdf5.c:2750<br>[1]PETSC ERROR: #1 PetscSectionCreateGlobalSection() at /PETSc3/petsc/petsc-dev/src/vec/is/section/interface/section.c:1322<br>[0]PETSC ERROR: #4 DMPlexSectionLoad() at /PETSc3/petsc/petsc-dev/src/dm/impls/plex/plex.c:2364<br>[1]PETSC ERROR: #2 DMGetGlobalSection() at /PETSc3/petsc/petsc-dev/src/dm/interface/dm.c:4527<br>[0]PETSC ERROR: #5 main() at /Users/knepley/Downloads/tmp/Berend/readandcreate.c:85<br>[1]PETSC ERROR: #3 DMPlexSectionLoad_HDF5_Internal() at /PETSc3/petsc/petsc-dev/src/dm/impls/plex/plexhdf5.c:2750<br>[0]PETSC ERROR: PETSc Option Table entries:<br>[0]PETSC ERROR: -malloc_debug (source: environment)<br>[1]PETSC ERROR: #4 DMPlexSectionLoad() at /PETSc3/petsc/petsc-dev/src/dm/impls/plex/plex.c:2364<br>[1]PETSC ERROR: #5 main() at /Users/knepley/Downloads/tmp/Berend/readandcreate.c:85<br>[0]PETSC ERROR: -start_in_debugger_no (source: command line)<br>[1]PETSC ERROR: PETSc Option Table entries:<br>[0]PETSC ERROR: ----------------End of Error Message -------send entire error message to petsc-maint@mcs.anl.gov----------<br>[1]PETSC ERROR: -malloc_debug (source: environment)<br>application called MPI_Abort(MPI_COMM_SELF, 60) - process 0<br>[1]PETSC ERROR: -start_in_debugger_no (source: command line)<br>[1]PETSC ERROR: ----------------End of Error Message -------send entire error message to petsc-maint@mcs.anl.gov----------<br>application called MPI_Abort(MPI_COMM_SELF, 60) - process 0<br></div><div> </div><div>4) We now have parallel HDF5 loading, so you should not have to manually distribute. I will change your example to use it</div><div>     and send it back when I am done.</div><div><br></div><div>  Thanks!</div><div><br></div><div>     Matt</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Many thanks and kind regards,<br>
Berend.</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>