<div dir="ltr"><div dir="ltr">On Sun, Jul 26, 2020 at 3:42 PM Swarnava Ghosh <<a href="mailto:swarnava89@gmail.com">swarnava89@gmail.com</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"><div dir="ltr">Dear Mark and Matt,<div><br></div><div>Thank you for your suggestions. I tried what you mentioned. It works for one call of DMPlexVecGetClosure+DMPlexVecRestoreClosure. </div><div>However, in my code, I would need to loop over cell values, and this is when it crashes. A vanilla code snippet is</div></div></blockquote><div><br></div><div>Reset the input array to NULL for each invocation of GetClosure().</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>ierr=DMGetCoordinateDM(pCgdft->dmplexloc,&pCgdft->cdm);CHKERRQ(ierr);<br> ierr=DMGetCoordinatesLocal(pCgdft->dmplexloc,&pCgdft->VCloc);CHKERRQ(ierr);<br> ierr=DMConvert(pCgdft->cdm,DMPLEX,&pCgdft->cdmplexloc);CHKERRQ(ierr);<br> <br> ierr=DMGetCoordinatesLocal(pCgdft->dmplexloc,&pCgdft->VCloc);CHKERRQ(ierr);<br> ierr=DMPlexVecGetClosure(pCgdft->cdmplexloc,NULL,pCgdft->VCloc,cell,&closureSize,&coef);CHKERRQ(ierr);<br><br> // first call<br> if(rank==0)<br> {<br> for(i=0;i<closureSize;i++)<br> {<br> printf("&& cell=0, first call, coef[%d]=%lf \n",i,coef[i]);<br> }<br> }<br> ierr=DMPlexVecRestoreClosure(pCgdft->cdmplexloc,NULL,pCgdft->VCloc,cell,&closureSize,&coef);CHKERRQ(ierr);<br><br> // second call<br> ierr=DMPlexVecGetClosure(pCgdft->cdmplexloc,NULL,pCgdft->VCloc,cell,&closureSize,&coef);CHKERRQ(ierr);<br><br> if(rank==0)<br> {<br> for(i=0;i<closureSize;i++)<br> {<br> printf("&& cell=0, second call, coef[%d]=%lf \n",i,coef[i]);<br> }<br> }<br> ierr=DMPlexVecRestoreClosure(pCgdft->cdmplexloc,NULL,pCgdft->VCloc,cell,&closureSize,&coef);CHKERRQ(ierr);<br></div><div> <br></div><div><br></div><div>the first printf statement gets printed, and then it crashes with the following error message</div><div><br></div><div>[44]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>[44]PETSC ERROR: Object is in wrong state<br>[44]PETSC ERROR: Array was not checked out<br>[44]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br>[44]PETSC ERROR: Petsc Release Version 3.8.4, Mar, 24, 2018<br>[44]PETSC ERROR: ../lib/cgdft on a arch-linux2-c-opt named hpc-82-22.cm.cluster by swarnava Sun Jul 26 12:26:40 2020<br>[44]PETSC ERROR: Configure options --prefix=/software/PETSc/3.8.4-intel --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90 --with-blaslapack-dir=/software/Intel/2018.1/compilers_and_libraries_2018.1.163/linux/mkl\<br>/lib/intel64_lin --with-debugging=no --with-shared-libraries=0 --download-metis --download-parmetis --download-superlu_dist<br>[44]PETSC ERROR: #1 DMRestoreWorkArray() line 1281 in /groups/hpc-support/install/PETSc/petsc-3.8.4_intel_no-debug/src/dm/interface/dm.c<br>[44]PETSC ERROR: #2 DMPlexVecRestoreClosure() line 4099 in /groups/hpc-support/install/PETSc/petsc-3.8.4_intel_no-debug/src/dm/impls/plex/plex.c<br>[44]PETSC ERROR: #3 CreateLocalDMPLEX() line 749 in ./src/cgdft_localdmplex.cc</div><div><br></div><div>Also attached is the error file.</div><div><br></div><div>Sincerely,</div><div>SG</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jul 25, 2020 at 8:15 AM Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Sat, Jul 25, 2020 at 4:10 AM Swarnava Ghosh <<a href="mailto:swarnava89@gmail.com" target="_blank">swarnava89@gmail.com</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"><div dir="ltr">Dear Petsc users,<div><br></div><div>I had a trivial question about DMPlex. Suppose I have a 3D mesh of tetrahedrons. I want to find out the 3D coordinates of the vertices of a particular cell. What would be the function to do this?</div></div></blockquote><div><br></div><div>Lots of good responses. You can see that it is taking some time for canonical patterns to emerge as the "right way" to do something. The reason we provide</div><div>multiple layers of interface is that user codes rely on different abstractions and would like to interact with PETSc using different assumptions.</div><div><br></div><div>If you just want the coordinates of each vertex in some cell with the vertices in a canonical ordering, you can do as Mark suggested, with a slight modification:</div><div><br></div><div>DM plex, cdm;<br></div><div>Vec coordinates;</div><div><br></div><div>ierr = DMGetCoordinateDM(dm, &cdm);CHKERRQ(ierr);</div><div></div><div>ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr);</div><div>ierr = DMConvert(cdm, DMPLEX, &plex);CHKERRQ(ierr);<br>ierr = DMPlexVecGetClosure(plex, NULL, coordinates, cell, NULL, &coef);CHKERRQ(ierr);<br>....<br>ierr = DMPlexVecRestoreClosure(plex, NULL, coordinates, cell, NULL, &coef);CHKERRQ(ierr);<br></div><div><br></div><div>We get a local coordinate vector, because local vectors are guaranteed to store everything in the closure of anything in the Plex. Global vectors</div><div>are non-overlapping partitions, suitable for solvers, and might not have some of the values.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Thank you,</div><div>SG</div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><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>
</blockquote></div>
</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>