On Thu, 12 Sep 2019 at 20:21, Emmanuel Ayala via petsc-users < [email protected]> wrote:
> Hi everyone, it would be great if someone can give me a hint for this > issue, i have been trying to figure out how to solve it, but i did not > succeed > > I'm using DMDA to generate a 3D mesh (DMDA_ELEMENT_Q1). I'm trying to fill > a MPI matrix with some values wich are related to the dofs of each element > node, moreover i need to set this values based on the element number. > Something like: > > mpi_A(total_elements X total_dofs) > > total_dofs > row_0 (element_0) a_0 a_1 a_2 ... a_23 > row_1 (element_1) a_0 a_1 a_2 ... a_23 > row_2 (element_2) > a_0 a_1 a_2 ... a_23 > . > . > . > row_n (element_n) a_0 a_1 a_2 ... a_23 > > The element number is related to the row index. And the matrix values are > set depending of the DOFs related to the element. > > With DMDAGetElements i can read the LOCAL nodes connected to the element > and then the DOFs associated to the element. I can handle the local and > global relations with DMGetLocalToGlobalMapping, MatSetLocalToGlobalMapping > and MatSetValuesLocal. BUT i CAN NOT understand how to know the element > number in LOCAL or GLOBAL contex. DMDAGetElements gives the NUMBER OF > ELEMENTS owned in the local process, but there is not any information about > the local or global ELEMENT NUMBER. > > How to know the local or global element number related to the data > provided by DMDAGetElements? > The DMDA defines cells of the same type (quads (2D) or hex (3D), hence every cell defines the same number of vertices. DMDAGetElements(DM dm,PetscInt *nel,PetscInt *nen,const PetscInt *e[]) nel - number of local elements nen - number of element nodes e - the local indices of the elements' vertices e[] defines the ordering of the elements. e[] is an array containing all of the element-vertex maps. Since each element in the DMDA has the same number of vertices, the first nen values in e[] correspond to the vertices (local index) associated with the first element. The next nen values in e[] correspond to the vertices of the second element. The vertices for any (local) element with the index "cid" can be sought via e[nen*cid + i] where i would range from 0 to nen-1. Why would you ever want, or need, the global element number? What is the use case? Thanks, Dave > > Thank you. >
