<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Dear Petsc Team,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Following my recent MR !5502, I noticed a bug in DMPlexDistribute related to the natural point SF. The section passed as an argument to DMPlexCreateGlobalToNaturalSF should be the natural section, instead of the section before distribution. In case of multiple
 call of DMPlexDistribute, the natural section and the section before distribution do not match. This bug is fixed by simply passing NULL to <span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important">DMPlexCreateGlobalToNaturalSF<span class="Apple-converted-space"> in
 DMPlexDistribute: line 1929 of plexdis</span><span class="Apple-converted-space" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">tribute.c.
</span><span class="Apple-converted-space"><span style="caret-color: rgb(0, 0, 0); font-size: 12pt; background-color: rgb(255, 255, 255); display: inline !important; font-family: Calibri, Helvetica, sans-serif;">Now, the natural section is constructed in
<span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important">
DMPlexCreateGlobalToNaturalSF,</span> thanks to PetscSFDistributeSection using the natural point SF (migrationSF) and the section after distribution.</span> It raises however an error</span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important"><span class="Apple-converted-space"><br>
</span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important"><span class="Apple-converted-space">
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: Invalid argument</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: Unknown discretization type for field 0</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: Petsc Development GIT revision: v3.17.4-1073-g78daca0807b<span class="Apple-converted-space"> 
</span>GIT Date: 2022-08-15 16:17:10 +0000</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: ../ex26 on a arch-darwin-c-debug named Alexiss-MacBook-Pro.local by alexismarboeuf Mon Aug 15 14:24:41 2022</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: Configure options --download-bison=1 --download-chaco=1 --download-exodusii=1 --download-hdf5=1 --download-hypre=1 --download-metis=1 --download-ml=1 --download-netcdf=1 --download-parmetis=1 --download-pnetcdf=1 --download-sowing=1 --download-triangle
 --download-yaml=1 --download-zlib=1 --with-boost-dir=/opt/homebrew/Cellar/boost/1.78.0_1/ --with-boost=1 --with-c2html=0 --with-clib-autodetect=0 --with-cmake=1 --with-debugging=1 --with-exodusii-fortran-bindings --with-fortran-datatypes=1 --with-fortranlib-autodetect=0
 --with-mpi-dir=/opt/homebrew/Cellar/mpich/4.0.2/ --with-ranlib=ranlib --with-shared-libraries=1 --with-sieve=1 --with-x11=1 PETSC_ARCH=arch-darwin-c-debug</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: #1 DMCreateLocalSection_Plex() at /Users/alexismarboeuf/Documents/mypetsc/src/dm/impls/plex/plexsection.c:458</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: #2 DMGetLocalSection() at /Users/alexismarboeuf/Documents/mypetsc/src/dm/interface/dm.c:4310</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: #3 DMPlexCreateGlobalToNaturalSF() at /Users/alexismarboeuf/Documents/mypetsc/src/dm/impls/plex/plexnatural.c:121</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: #4 DMPlexDistribute() at /Users/alexismarboeuf/Documents/mypetsc/src/dm/impls/plex/plexdistribute.c:1926</span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">#<span class="Apple-tab-span">
</span>[0]PETSC ERROR: #5 main() at /Users/alexismarboeuf/Documents/mypetsc/src/dm/impls/plex/tests/ex26.c:272</span></p>
</span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important"><span class="Apple-converted-space"><br>
</span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important"><span class="Apple-converted-space">in all the following tests:</span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important"><span class="Apple-converted-space"><br>
</span></span></div>
<div style="color: rgb(0, 0, 0);" class="elementToProof"><span style="caret-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;"><span class="Apple-converted-space">
<p style="font-family: Menlo; font-size: 11px; margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; line-height: normal; color: rgb(0, 0, 0);" class="elementToProof">
<span style="font-variant-ligatures:no-common-ligatures">dm_impls_plex_tests-ex15_0 dm_impls_plex_tests-ex64_4 dm_impls_plex_tests-ex64_8 dm_impls_plex_tests-ex26f90_10 dm_impls_plex_tests-ex26_8 dm_impls_plex_tests-ex26_6 dm_impls_plex_tests-ex26f90_16 dm_impls_plex_tests-ex26_19
 dm_impls_plex_tests-ex26f90_6 dm_impls_plex_tests-ex47_0 dm_impls_plex_tests-ex26_17 dm_impls_plex_tests-ex26f90_8 dm_impls_plex_tests-ex26f90_18 dm_impls_plex_tests-ex26_9 dm_impls_plex_tests-ex64_5 dm_impls_plex_tests-ex64_9 dm_impls_plex_tests-ex26_10 dm_impls_plex_tests-ex26_7
 dm_impls_plex_tests-ex47_1 dm_impls_plex_tests-ex26_18 dm_impls_plex_tests-ex64_3 dm_impls_plex_tests-ex26f90_7 dm_impls_plex_tests-ex26f90_17 dm_impls_plex_tests-ex26f90_19 dm_impls_plex_tests-ex26_16 dm_impls_plex_tests-ex26f90_9</span></p>
<p style="font-family: Menlo; font-size: 11px; margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; line-height: normal; color: rgb(0, 0, 0);">
<span style="font-variant-ligatures:no-common-ligatures"><br>
</span></p>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; line-height: normal; color: rgb(0, 0, 0);" class="elementToProof">
<font face="Calibri, Helvetica, sans-serif"><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">At this point of DMPlexDistribute, it seems that the distributed DM does not have a section. The distributed section, also computed with
 PetscSFDistributeSection, is set to the distributed DM later in </span><span style="caret-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">DMPlexCreateGlobalToNaturalSF:
 line 134 in plexnatural.c. DMCreateLocalSection_Plex is then called by DMGetLocalSection (line 121 in plexnatural.c) which raises the error. Wouldn't it be more convenient to</span></font></div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; line-height: normal; color: rgb(0, 0, 0);" class="elementToProof">
<ul>
<li style="font-family:Calibri, Helvetica, sans-serif;font-size:12pt"><span><font face="Calibri, Helvetica, sans-serif"><span style="caret-color:rgb(0, 0, 0);background-color:rgb(255, 255, 255);display:inline !important"></span></font></span><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">compute
 the distributed section in DMPlexDistribute before the call of </span><span><span style="caret-color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; text-align: start; background-color: rgb(255, 255, 255); display: inline !important;">DMPlexCreateGlobalToNaturalSF.
 On that subject, it means that the distributed section is never set to the distributed DM if useNatural = PETSC_FALSE? Where one distributes the section in DMPlexDistribute?</span></span></li><li style="font-family:Calibri, Helvetica, sans-serif;font-size:12pt"><span><span style="caret-color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; text-align: start; background-color: rgb(255, 255, 255); display: inline !important;">in
</span><span style="caret-color:rgb(0, 0, 0);font-family:Calibri, Helvetica, sans-serif;font-size:14px;text-align:start;background-color:rgb(255, 255, 255);display:inline !important"><span style="margin: 0px; caret-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">DMPlexCreateGlobalToNaturalSF, </span></span><span style="caret-color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; text-align: start; background-color: rgb(255, 255, 255); display: inline !important;">compute
 the remoteOffsets</span><span style="caret-color:rgb(0, 0, 0);font-family:Calibri, Helvetica, sans-serif;font-size:14px;text-align:start;background-color:rgb(255, 255, 255);display:inline !important"><span style="caret-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;"> calling
 PetscSFCreateRemoteOffsets instead of PetscSFDistributeSection, and get the distributed section thanks to DMGetLocalSection on the distributed DM.</span></span></span></li></ul>
<div><font face="Calibri, Helvetica, sans-serif">Thanks a lot for your help.</font></div>
<div><font face="Calibri, Helvetica, sans-serif">Best,</font></div>
<div><font face="Calibri, Helvetica, sans-serif">Alexis</font></div>
</div>
</span></span></div>
</body>
</html>