<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Mark<div class=""><br class=""></div><div class="">This will only work if you have a vector space for the function</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 25, 2020, at 1:13 PM, Mark Adams <<a href="mailto:mfadams@lbl.gov" class="">mfadams@lbl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I get all the coordinates with this method:<div class=""><br class=""></div><div class="">static PetscErrorCode crd_func(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nf_dummy, PetscScalar *u, void *actx)<br class="">{<br class=""> int i;<br class=""> PetscFunctionBeginUser;<br class=""> for (i = 0; i < dim; ++i) u[i] = x[i];<br class=""> PetscFunctionReturn(0);<br class="">}<br class=""></div><div class=""><br class=""></div><div class=""> PetscErrorCode (*initu[1])(PetscInt, PetscReal, const PetscReal [], PetscInt, PetscScalar [], void *);<br class=""></div><div class=""> /* project coordinates to vertices */<br class=""> ierr = DMCreateGlobalVector(crddm, &crd_vec);CHKERRV(ierr);<br class=""> initu[0] = crd_func;<br class=""> ierr = DMProjectFunction(crddm, 0.0, initu, NULL, INSERT_ALL_VALUES, crd_vec);CHKERRV(ierr);<br class=""> ierr = VecViewFromOptions(crd_vec, NULL, "-coord_view");CHKERRV(ierr);<br class=""> /* iterate over mesh data and get indices */<br class=""> ierr = VecGetArrayRead(crd_vec,&xx);CHKERRV(ierr);<br class=""> ierr = VecGetLocalSize(rho,&N);CHKERRV(ierr);<br class=""> /* access grid data here */<br class=""> for (p=0;p<N;p++) { <br class=""> for (i=0;i<dim;i++) ..... = xx[p*dim+i];<br class=""> PetscPrintf(PETSC_COMM_SELF,"xx = (%g, %g)\n", xx[p*dim+0], xx[p*dim+1]); <br class=""> }<br class=""> ierr = VecRestoreArrayRead(crd_vec,&xx);CHKERRV(ierr);<br class=""> ierr = VecDestroy(&crd_vec);CHKERRV(ierr);<br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jul 25, 2020 at 4:10 AM Swarnava Ghosh <<a href="mailto:swarnava89@gmail.com" class="">swarnava89@gmail.com</a>> wrote:<br class=""></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" class="">Dear Petsc users,<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Thank you,</div><div class="">SG</div></div>
</blockquote></div>
</div></blockquote></div><br class=""></div></body></html>