<div dir="ltr"><div>You should be able to use PetscFECreateDefault instead of PetscFECreateLagrange here and set the "order" on the command line, which is recommended, but start with this and low order to debug.<br></div><div><br></div><div>Mark</div><div><br>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>  PetscErrorCode (*initu[1])(PetscInt, PetscReal, const PetscReal [], PetscInt, PetscScalar [], void *);<br>  PetscFE       fe;<br><div><br></div><div>  /* create coordinate DM */<br>  ierr = DMClone(dm, &crddm);CHKERRV(ierr);<br>  ierr = PetscFECreateLagrange(PETSC_COMM_SELF, dim, dim, PETSC_FALSE, order, PETSC_DECIDE, &fe);CHKERRV(ierr);<br>  ierr = PetscFESetFromOptions(fe);CHKERRV(ierr);<br>  ierr = DMSetField(crddm, 0, NULL, (PetscObject)fe);CHKERRV(ierr);<br>  ierr = DMCreateDS(crddm);CHKERRV(ierr);<br>  ierr = PetscFEDestroy(&fe);CHKERRV(ierr);<br>  /* 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></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 13, 2022 at 3:38 AM Yann Jobic <<a href="mailto:yann.jobic@univ-amu.fr">yann.jobic@univ-amu.fr</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"><br>
<br>
Le 12/13/2022 à 2:04 AM, Mark Adams a écrit :<br>
> PETSc does not store the coordinates for high order elements (ie, the <br>
> "midside nodes").<br>
> I get them by projecting a f(x) = x, function.<br>
> Not sure if that is what you want but I can give you a code snippet if <br>
> there are no better ideas.<br>
<br>
It could really help me !<br>
If i have the node coordinates in the reference element, then it's easy <br>
to project them to the real space. But i couldn't find a way to have <br>
them, so if you could give me some guidance, it could be really helpful.<br>
Thanks,<br>
Yann<br>
<br>
> <br>
> Mark<br>
> <br>
> <br>
> On Mon, Dec 12, 2022 at 6:06 PM Yann Jobic <<a href="mailto:yann.jobic@univ-amu.fr" target="_blank">yann.jobic@univ-amu.fr</a> <br>
> <mailto:<a href="mailto:yann.jobic@univ-amu.fr" target="_blank">yann.jobic@univ-amu.fr</a>>> wrote:<br>
> <br>
>     Hi all,<br>
> <br>
>     I'm trying to get the coords of the dofs of a DMPlex for a PetscFE<br>
>     discretization, for orders greater than 1.<br>
> <br>
>     I'm struggling to run dm/impls/plex/tutorials/ex8.c<br>
>     I've got the following error (with option -view_coord) :<br>
> <br>
>     [0]PETSC ERROR: --------------------- Error Message<br>
>     --------------------------------------------------------------<br>
>     [0]PETSC ERROR: Object is in wrong state<br>
>     [0]PETSC ERROR: DMGetCoordinatesLocalSetUp() has not been called<br>
>     [0]PETSC ERROR: See <a href="https://petsc.org/release/faq/" rel="noreferrer" target="_blank">https://petsc.org/release/faq/</a><br>
>     <<a href="https://petsc.org/release/faq/" rel="noreferrer" target="_blank">https://petsc.org/release/faq/</a>> for trouble shooting.<br>
>     [0]PETSC ERROR: Petsc Release Version 3.18.2, unknown<br>
>     [0]PETSC ERROR:<br>
>     /home/jobic/projet/fe-utils/petsc/fetools/cmake-build-debug/ex_closure_petsc<br>
>     on a  named luke by jobic Mon Dec 12 23:34:37 2022<br>
>     [0]PETSC ERROR: Configure options<br>
>     --prefix=/local/lib/petsc/3.18/p3/gcc/nompi_hdf5 --with-mpi=0<br>
>     --with-debugging=1 --with-blacs=1 --download-zlib,--download-p4est<br>
>     --download-hdf5=1 --download-triangle=1 --with-single-library=0<br>
>     --with-large-file-io=1 --with-shared-libraries=0 -CFLAGS=" -g -O0"<br>
>     -CXXFLAGS=" -g -O0" -FFLAGS=" -g -O0" PETSC_ARCH=nompi_gcc_hdf5<br>
>     [0]PETSC ERROR: #1 DMGetCoordinatesLocalNoncollective() at<br>
>     /home/devel/src_linux/petsc-3.18.0/src/dm/interface/dmcoordinates.c:621<br>
>     [0]PETSC ERROR: #2 DMPlexGetCellCoordinates() at<br>
>     /home/devel/src_linux/petsc-3.18.0/src/dm/impls/plex/plexgeometry.c:1291<br>
>     [0]PETSC ERROR: #3 main() at<br>
>     /home/jobic/projet/fe-utils/petsc/fetools/src/ex_closure_petsc.c:86<br>
>     [0]PETSC ERROR: PETSc Option Table entries:<br>
>     [0]PETSC ERROR: -dm_plex_box_faces 2,2<br>
>     [0]PETSC ERROR: -dm_plex_dim 2<br>
>     [0]PETSC ERROR: -dm_plex_simplex 0<br>
>     [0]PETSC ERROR: -petscspace_degree 1<br>
>     [0]PETSC ERROR: -view_coord<br>
>     [0]PETSC ERROR: ----------------End of Error Message -------send entire<br>
>     error message to petsc-maint@mcs.anl.gov----------<br>
> <br>
>     Maybe i've done something wrong ?<br>
> <br>
> <br>
>     Moreover, i don't quite understand the function DMPlexGetLocalOffsets,<br>
>     and how to use it with DMGetCoordinatesLocal. It seems that<br>
>     DMGetCoordinatesLocal do not have the coords of the dofs, but only the<br>
>     nodes defining the geometry.<br>
> <br>
>     I've made some small modifications of ex8.c, but i still have an error :<br>
>     [0]PETSC ERROR: --------------------- Error Message<br>
>     --------------------------------------------------------------<br>
>     [0]PETSC ERROR: Invalid argument<br>
>     [0]PETSC ERROR: Wrong type of object: Parameter # 1<br>
>     [0]PETSC ERROR: WARNING! There are option(s) set that were not used!<br>
>     Could be the program crashed before they were used or a spelling<br>
>     mistake, etc!<br>
>     [0]PETSC ERROR: Option left: name:-sol value: vtk:sol.vtu<br>
>     [0]PETSC ERROR: See <a href="https://petsc.org/release/faq/" rel="noreferrer" target="_blank">https://petsc.org/release/faq/</a><br>
>     <<a href="https://petsc.org/release/faq/" rel="noreferrer" target="_blank">https://petsc.org/release/faq/</a>> for trouble shooting.<br>
>     [0]PETSC ERROR: Petsc Release Version 3.18.2, unknown<br>
>     [0]PETSC ERROR:<br>
>     /home/jobic/projet/fe-utils/petsc/fetools/cmake-build-debug/view_coords<br>
>     on a  named luke by jobic Mon Dec 12 23:51:05 2022<br>
>     [0]PETSC ERROR: Configure options<br>
>     --prefix=/local/lib/petsc/3.18/p3/gcc/nompi_hdf5 --with-mpi=0<br>
>     --with-debugging=1 --with-blacs=1 --download-zlib,--download-p4est<br>
>     --download-hdf5=1 --download-triangle=1 --with-single-library=0<br>
>     --with-large-file-io=1 --with-shared-libraries=0 -CFLAGS=" -g -O0"<br>
>     -CXXFLAGS=" -g -O0" -FFLAGS=" -g -O0" PETSC_ARCH=nompi_gcc_hdf5<br>
>     [0]PETSC ERROR: #1 PetscFEGetHeightSubspace() at<br>
>     /home/devel/src_linux/petsc-3.18.0/src/dm/dt/fe/interface/fe.c:1692<br>
>     [0]PETSC ERROR: #2 DMPlexGetLocalOffsets() at<br>
>     /home/devel/src_linux/petsc-3.18.0/src/dm/impls/plex/plexceed.c:98<br>
>     [0]PETSC ERROR: #3 ViewOffsets() at<br>
>     /home/jobic/projet/fe-utils/petsc/fetools/src/view_coords.c:28<br>
>     [0]PETSC ERROR: #4 main() at<br>
>     /home/jobic/projet/fe-utils/petsc/fetools/src/view_coords.c:99<br>
>     [0]PETSC ERROR: PETSc Option Table entries:<br>
>     [0]PETSC ERROR: -heat_petscspace_degree 2<br>
>     [0]PETSC ERROR: -sol vtk:sol.vtu<br>
>     [0]PETSC ERROR: ----------------End of Error Message -------send entire<br>
>     error message to petsc-maint@mcs.anl.gov----------<br>
> <br>
> <br>
>     Is dm/impls/plex/tutorials/ex8.c a good example for viewing the coords<br>
>     of the dofs of a DMPlex ?<br>
> <br>
> <br>
>     Thanks,<br>
> <br>
>     Yann<br>
> <br>
</blockquote></div>