Hi Noam,

I think you want
https://urldefense.us/v3/__https://petsc.org/release/manualpages/DMPlex/DMPlexGetClosureIndices/__;!!G_uCfscf7eWS!f8v1_ty7e_mf4QhytGsCFXSd_APEy50GjoLrAL_o294K-EBz1Xa8kEDmeq3UmehbZvBL-u72r4GN6mjxAFf6Ljw$
 

Indices are ordered globally on the first process (0) first, the proc 1,
etc., so the global index is the local index + "my start index". You can
get this local start index in a number of ways, eg,
https://urldefense.us/v3/__https://petsc.org/main/manualpages/Mat/MatGetOwnershipRange__;!!G_uCfscf7eWS!f8v1_ty7e_mf4QhytGsCFXSd_APEy50GjoLrAL_o294K-EBz1Xa8kEDmeq3UmehbZvBL-u72r4GN6mjxh3g3zew$
  if you have a
scalar matrix from the DM/section.

Thanks,
Mark
ps, we are at the PETSc annual meeting this week, so may be slow to respond

On Mon, May 19, 2025 at 6:58 PM Noam T. via petsc-users <
petsc-users@mcs.anl.gov> wrote:

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

Reply via email to