I get all the coordinates with this method: static PetscErrorCode crd_func(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nf_dummy, PetscScalar *u, void *actx) { int i; PetscFunctionBeginUser; for (i = 0; i < dim; ++i) u[i] = x[i]; PetscFunctionReturn(0); }
PetscErrorCode (*initu[1])(PetscInt, PetscReal, const PetscReal [], PetscInt, PetscScalar [], void *); /* project coordinates to vertices */ ierr = DMCreateGlobalVector(crddm, &crd_vec);CHKERRV(ierr); initu[0] = crd_func; ierr = DMProjectFunction(crddm, 0.0, initu, NULL, INSERT_ALL_VALUES, crd_vec);CHKERRV(ierr); ierr = VecViewFromOptions(crd_vec, NULL, "-coord_view");CHKERRV(ierr); /* iterate over mesh data and get indices */ ierr = VecGetArrayRead(crd_vec,&xx);CHKERRV(ierr); ierr = VecGetLocalSize(rho,&N);CHKERRV(ierr); /* access grid data here */ for (p=0;p<N;p++) { for (i=0;i<dim;i++) ..... = xx[p*dim+i]; PetscPrintf(PETSC_COMM_SELF,"xx = (%g, %g)\n", xx[p*dim+0], xx[p*dim+1]); } ierr = VecRestoreArrayRead(crd_vec,&xx);CHKERRV(ierr); ierr = VecDestroy(&crd_vec);CHKERRV(ierr); On Sat, Jul 25, 2020 at 4:10 AM Swarnava Ghosh <swarnav...@gmail.com> wrote: > Dear Petsc users, > > 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? > > Thank you, > SG >