<div dir="ltr">Yea, I did not get all the code you need. Here is an example of making crddm. I'm not sure if this is all best practices (Matt?)<div><br></div><div> /* create coordinate DM */<br> ierr = DMClone(dm, &crddm);CHKERRV(ierr);<br> ierr = PetscFECreateDefault(PETSC_COMM_SELF, dim, dim, PETSC_FALSE, "", PETSC_DECIDE, &fe);CHKERRV(ierr);<br> // ierr = PetscFECreateLagrange(PETSC_COMM_SELF, dim, dim, PETSC_FALSE, "", PETSC_DECIDE, &fe);CHKERRQ(ierr);<br> ierr = PetscFESetFromOptions(fe);CHKERRV(ierr);<br> ierr = DMSetField(crddm, field, NULL, (PetscObject)fe);CHKERRV(ierr);<br> ierr = DMCreateDS(crddm);CHKERRV(ierr);<br> ierr = PetscFEDestroy(&fe);CHKERRV(ierr);<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jul 25, 2020 at 7:40 AM Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@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>Mark<div><br></div><div>This will only work if you have a vector space for the function</div><div><br><div><br><blockquote type="cite"><div>On Jul 25, 2020, at 1:13 PM, Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> wrote:</div><br><div><div dir="ltr">I get all the coordinates with this method:<div><br></div><div>static PetscErrorCode crd_func(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nf_dummy, PetscScalar *u, void *actx)<br>{<br> int i;<br> PetscFunctionBeginUser;<br> for (i = 0; i < dim; ++i) u[i] = x[i];<br> PetscFunctionReturn(0);<br>}<br></div><div><br></div><div> PetscErrorCode (*initu[1])(PetscInt, PetscReal, const PetscReal [], PetscInt, PetscScalar [], void *);<br></div><div> /* project coordinates to vertices */<br> ierr = DMCreateGlobalVector(crddm, &crd_vec);CHKERRV(ierr);<br> initu[0] = crd_func;<br> ierr = DMProjectFunction(crddm, 0.0, initu, NULL, INSERT_ALL_VALUES, crd_vec);CHKERRV(ierr);<br> ierr = VecViewFromOptions(crd_vec, NULL, "-coord_view");CHKERRV(ierr);<br> /* iterate over mesh data and get indices */<br> ierr = VecGetArrayRead(crd_vec,&xx);CHKERRV(ierr);<br> ierr = VecGetLocalSize(rho,&N);CHKERRV(ierr);<br> /* access grid data here */<br> for (p=0;p<N;p++) { <br> for (i=0;i<dim;i++) ..... = xx[p*dim+i];<br> PetscPrintf(PETSC_COMM_SELF,"xx = (%g, %g)\n", xx[p*dim+0], xx[p*dim+1]); <br> }<br> ierr = VecRestoreArrayRead(crd_vec,&xx);CHKERRV(ierr);<br> ierr = VecDestroy(&crd_vec);CHKERRV(ierr);<br></div></div><br><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" target="_blank">swarnava89@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">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><br></div><div>Thank you,</div><div>SG</div></div>
</blockquote></div>
</div></blockquote></div><br></div></div></blockquote></div>