<div dir="ltr"><div dir="ltr"><div dir="ltr">Good Evening Miguel,<div><br></div><div>I've successfully used the following to get the coordinates of all nodes/vertices from a DMPlex. The steps I use are as follow</div><div><br></div><div>----- CODE ------</div><div> Vec coordinates; // Define a Petsc vector to store the coordinates.</div><div> PetscInt cdm; // Define a PetscInt to store coordinate dimension of DMPlex</div><div> PetscInt *vSize; // PetscInt to store number of elements in vector (used below)</div><div> PetscErrorCode ierr;</div><div><br></div><div> ierr = DMGetCoordinateDM(dm, &cdm); CHKERRQ(ierr); // Get coordinate dimension of dm</div><div> ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr); // Populate Vector with (x, y, z) coordinates of all nodes/vectors in DM</div><div> ierr = VecGetSize(coordinates, &vSize); // Get Number of elements in coordinates vector</div><div> </div><div> PetscScalar coords[vSize]; // Define array where the (x, y, z) values will be stored</div><div> const PetscInt ix[vSize]; // Define array to store indices of coordinates you'd like to get values for</div><div><br></div><div> // Load ix[] with indices of Vector coordinate[] you want values for. In your case, you would like all of them</div><div> for (int ii = 0; ii < vSize; ++ii){</div><div> ix[ii] = ii; // Note: Petsc uses 0-based indexing</div><div> }</div><div><br></div><div> ierr = VecGetValues(coordinates, vSize, ix, coords); // Get (x, y, z) values from Vector coordinates and store in coords[] array.</div><div><br></div><div> // All (x, y, z) coordinates for all nodes/vertices should now be in the coords[] array.</div><div> // They are stored interlaced. i.e. (x_0, y_0, z_0, x_1, y_1, z_1, .... x_n-1, y_n-1, z_n-1)</div><div><br></div><div> // Print out each nodes (x, y, z) coordinates to screen. I assuming 3 dimensions</div><div> for (int ii = 0; ii < vSize; ii+3){</div><div> ierr = PetscPrintf(PETSC_COMM_SELF, " Node %d :: (x,y,z) = (%lf, %lf, %lf) \n", coords[ii], coords[ii+1],coords[ii+2]);</div><div> }</div><div><br></div><div>---- END OF CODE ----</div><div><br></div><div>Please forgive any coding errors/typos that may be above but the technique should work. I don't claim that this is the most elegant solution.</div><div><br></div><div>Good Luck</div><div><br></div><div>-Brandon</div><div><br></div><div><br></div><div> </div><div><br></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jul 24, 2021 at 9:58 AM Miguel Angel Tapia <<a href="mailto:miguel.td19@outlook.com">miguel.td19@outlook.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 style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hello. I am a master's student in Mexico. I am currently working on a project in which we are implementing DMPlex in a code for electromagnetic modeling. Right now I am working on understanding the tool in C. But I'm stuck on something and that's why my next
doubt:
<div><br>
</div>
<div>I am trying to get the coordinates of the nodes of a mesh in DMPlex. I already understood how the DAG is structured, how to obtain the nodes that make up some point. But the ordering of the nodes changes in DMPlex. So I need to know the coordinates of
each node to compare them with my initial mesh and confirm that the same nodes form the same point in the software I am using as well as in the DMPlex DAG.</div>
<div><br>
</div>
<div>It would be great if you could guide me a bit on how to do this or indicate which DMPlex examples would be good to review or which examples solve something similar to my situation.</div>
<div><br>
</div>
Thank you in advance. Regards.<br>
</div>
</div>
</blockquote></div>