On Tue, Jan 27, 2026 at 3:34 PM neil liu <[email protected]> wrote:

> Dear Petsc users and developers,
>
> I am exploring the mapping between local, partition and global dofs.
> The following is my pseudo code, dof2Partitionmapping denotes the mapping
> between the local dof (20 local dofs each tetrahedra) and partition dof.
>

We usually say cell, local, and global dofs.


> Is this mapping determined by Petsc itself under the hood
> (PetscSectionGetOffset)?
>

Plex just iterates over the points in the canonical numbering (cells,
vertices, faces, edges). You can change the iteration order using


https://urldefense.us/v3/__https://petsc.org/main/manualpages/PetscSection/PetscSectionSetPermutation/__;!!G_uCfscf7eWS!d7O-UstRpLu6SVXJg9iUKL61tBvbPTcV2U07ko4ptaMdZ71evm1SJ5h_BdOA30VCeeLZU1IXr3PKorHeZBEJ$
 

You can use that, for example, to place all ghost dofs at the end.

  Thanks,

     Matt


> For now, I am coding this mapping (local to partition) myself just based
> on the edge and face number in the partition. It seems the results are
> reasonable. But with this kind of self-defined mapping, the owned dofs and
> ghost dofs are interleaved. Will this bring bad results for the
> communication of MatStash?
>
> Thanks,
> Xiaodong
>
> *1. set 2 dofs for each edge  and 2 dofs for each edge face respectively*
> PetscSectionSetChart(s, faceStart, edgeEnd);
> PetscSectionSetDof(s, faceIndex, 2);
> PetscSectionSetFieldDof(s, faceIndex, 0, 1);
> PetscSectionSetDof(s, edgeIndex, 2);
> PetscSectionSetFieldDof(s, edgeIndex, 0, 1);
> PetscSectionsetup(s)
>
> *2.  Create matrix based on DMPlex*
>  DMSetMatType(dm, MATAIJ);
>  DMCreateMatrix(dm, &A);
>
> *3. loop over elements to set local values for Matrix*
> MatSetValuesLocal(A, dof2Partitionmapping.size(),
> dof2Partitionmapping.data(), dof2Partitionmapping.size(),
> dof2Partitionmapping.data(), Matrix_Local.data(), ADD_VALUES);
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!d7O-UstRpLu6SVXJg9iUKL61tBvbPTcV2U07ko4ptaMdZ71evm1SJ5h_BdOA30VCeeLZU1IXr3PKotlKhVX5$
  
<https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!d7O-UstRpLu6SVXJg9iUKL61tBvbPTcV2U07ko4ptaMdZ71evm1SJ5h_BdOA30VCeeLZU1IXr3PKoiFbdkzM$
 >

Reply via email to