<div>Hello,</div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">I am trying to build the connectivity matrix for a mesh; i.e. the indices of the nodes that compose each cell.</div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Example:</div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">0-------1</span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">|.\.....|  </span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;"><span>|...\...|</span> <br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">|.....\.|<br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">3</span><span style="font-family: Menlo, Consolas, Courier New, monospace;">-------2</span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Arial, sans-serif;">the matrix would look like  [ [0, 3, 2], [2, 1, 0] ] (possibly different ordering).<br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Arial, sans-serif;">One option is using </span><span style="font-family: Menlo, Consolas, Courier New, monospace;"><span style="font-family: Arial, sans-serif;">DMPlexGetTransitiveClosure</span></span><span style="font-family: Arial, sans-serif;">, and accessing the last elements in the output "points", which contain the vertex indices. </span><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Arial, sans-serif;">However, these indices are local per process (both for vertices and  cells). Is it possible to get the global indices?</span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Arial, sans-serif;">I tried a mapping, as in example 14f (</span><span style="font-family: Menlo, Consolas, Courier New, monospace;"><span><a target="_blank" rel="noreferrer nofollow noopener" href="https://urldefense.us/v3/__https://petsc.org/release/src/ksp/ksp/tutorials/ex14f.F90.html__;!!G_uCfscf7eWS!ezMKlDED-8WxXpg_Elxus7WhYkZzCA5OmmLe6vHZGFoj4se5S5RD5ZgTrC3TYErx8znYKebSW-s0H0mt1_MEMAzpmFDwr0PH$"><span style="font-family: Arial, sans-serif;">https://petsc.org/release/src/ksp/ksp/tutorials/ex14f.F90.html</span></a></span></span><span style="font-family: Arial, sans-serif;">)</span><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">---</span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">DM :: dm</span><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;"><span><span style="font-family: Menlo, Consolas, Courier New, monospace;">ISLocalToGlobalMapping :: ltog_map</span></span></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;"><span><span style="font-family: Menlo, Consolas, Courier New, monospace;"><span><span>PetscInt, pointer :: ltog_idx(:)</span></span><br></span></span></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">! ... </span><br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">! Create a dm from a mesh file</span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">! ...</span><br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">DMGetLocalToGlobalMapping(dm,ltog_map,ierr)</span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">ISLocalToGlobalMappingGetIndices(ltog_map, ltog_idx, ierr)</span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;">---</span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Arial, sans-serif;">but the returned array </span><span style="font-family: Menlo, Consolas, Courier New, monospace;">ltog</span><span style="font-family: Arial, sans-serif;"> is empty (ISLocalToGlobalMappingGetSize() returns zero)</span><span style="font-family: Arial, sans-serif;">.  Are there other functions calls needed before being able to create this mapping? Or is this mapping simply not usable in this case?<br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Arial, sans-serif;">Is there perhaps better/simpler way to get this connectivity?</span><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Arial, sans-serif;">Thank you.</span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="font-family: Arial, sans-serif;">Noam</span><span style="font-family: Menlo, Consolas, Courier New, monospace;"><br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br></div>