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.
Is this mapping determined by Petsc itself under the hood
(PetscSectionGetOffset)?
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);

Reply via email to