Mesh
The mesh structure sources can be found in Tolosa-lib/src/m_mesh.f90 and Tolosa-lib/src/submodule/m_mesh_tools.f90.
Elements of a mesh
Section titled “Elements of a mesh”The mesh is defined by a mesh structure msh, and contains geometrical primal objects.
The mesh’s cells are contained in an cell(:) table. Each cell is defined by :
node( order_max ): Suited list of Nodes connecting the Cellcell( order_max ): Neighboring Cells Index (referenced to upper Nodes list)edge( order_max ): Edges Indexesglob: Global Cell Index when MPI Partitionned Meshorder: Number of Neighboring Cells/Edgeslim: Boundary Cell Indexsurf: Cell surfaceinvsurf: Inverse of Cell surfaceperi: Cell perimetergrav: Cell gravity centersubdomain: True boolean if Ghost Cell is in SubDomain Boundaryboundary: True boolean if Ghost Cell is in Physical Boundary
type(msh) :: mesh
mesh%cell(2)%node(1) = 2mesh%cell(2)%node(2) = 1mesh%cell(2)%node(3) = 4
mesh%cell(2)%cell(1) = 1mesh%cell(2)%cell(2) = 3mesh%cell(2)%cell(3) = 4
mesh%cell(2)%edge(1) = 2mesh%cell(2)%edge(2) = 4mesh%cell(2)%edge(3) = 5
mesh%cell(2)%boundary = .false.mesh%cell(4)%boundary = .true.
[...]-
node(:): The mesh’s nodes are contained in anode(:)table. Each node is defined by : -
cell(:): Connected Cells Indexes -
edge(:): Connected Edges Indexes -
lim: Boundary Node Index -
glob: Global Node Index when MPI Partitionned Mesh -
boundary: True boolean if Node is at Mesh Boundary -
subdomain: True boolean if Node is at SubDomain Boundary -
perio: True boolean if Node belong to a Periodic Boundary -
coord: Node coordinates
type(msh) :: mesh
mesh%node(1)%cell(1) = 3mesh%node(1)%cell(2) = 1
mesh%node(1)%edge(1) = 1mesh%node(1)%edge(2) = 2mesh%node(1)%edge(3) = 4mesh%node(1)%edge(4) = 6
mesh%node(1)%coord%x = 1.2mesh%node(1)%coord%y = 0.85
mesh%node(1)%boundary = .false.mesh%node(4)%boundary = .true.
[...]The mesh’s edges ar contained in a edge(:) table. Each edge is defined by :
cell(2): Connected Cells Indexesnode(2): Connected Nodes Indexeslim: Boundary Edge Indexboundary: True boolean if Edge is at Physical Mesh Boundarysubdomain: True boolean if Edge is at SubDomain Boundaryperio: True boolean if Edge is at Periodic Boundarylength: Edge lengthcenter: Edge centernormal: Edge normal oriented from the connected cell1to the connected cell2(or from the cell inside to the cell outside of the domain)tangent: Edge tangent (oriented from 1 to 2 linked nodes)vcell: Cells(1&2) gravity center vector (oriented from 1 to 2)v_edge_cell(2): Vector going from the edge center to the cell(1&2) gravity center
=== “Edge’s components”

```fortrantype(msh) :: mesh
mesh%edge(5)%cell(1) = 2 ! In this order (from the furthest cell frommesh%edge(5)%cell(2) = 4 ! the physical boundary to the closest one)
mesh%edge(5)%node(1) = 4mesh%edge(5)%node(2) = 2
[...]```=== “Edge’s vectors”
Other variables defining a mesh
Section titled “Other variables defining a mesh”This structure also encapsulates the numbers of geometrical elements and other usefull ones :
surf: Mesh surfacename: Name of the mesh file if existingnc: Number of Local (MPI use) Primal Cellsncd: Number of Local (MPI use) Primal Cells in SubDomain Boundaryncb: Number of Local (MPI use) Primal Cells in Physical Boundaryncp: Number of Local (MPI use) Primal Cells in Periodic Boundaryncdb: Number of Local (MPI use) Primal Cells in SubDomain+Physical Boundaryncdbp: Number of Local (MPI use) Primal Cells in SubDomain+Physical+Perodic Boundaryncg: Number of Global (MPI use) Primal Cellsnn: Number of Local (MPI use) Primal Nodesnnb: Number of Local (MPI use) Primal Nodes at Physical Boundarynne: Number of Local (MPI use) Primal Nodes in SubDomain Boundarynneb: Number of Local (MPI use) Primal Nodes in SubDomain Boundary at Physical Boundarynng: Number of Global (MPI use) Primal Nodesne: Number of Local (MPI use) Primal Edgesneb: Number of Local (MPI use) Primal Edges at Physical Boundarynee: Number of Extra (MPI use) Primal Edges in SubDomain Boundaryneeb: Number of Extra (MPI use) Primal Edges in SubDomain Boundary at Physical Boundaryneg: Number of Global (MPI use) Primal Edges
For example, here is a mesh partitionned between three MPI processes. We consider the physical boundary to be not periodic. As mentionned before, the global mesh has been partitionned in three local meshes each associated to an MPI process. Therefore, the geometrical components and their numbers will differ from process to process.
A detail of some msh variables per process is given :
=== “Process 0” ```fortran type(msh) :: mesh
!=====================================================================!! Global for all MPI processes!=====================================================================!mesh%ncg = 24mesh%nng = 17mesh%neg = 43
!=====================================================================!! Local for process 0!=====================================================================!mesh%nc = 6mesh%ncd = 4mesh%ncb = 0mesh%ncp = 0mesh%ncdb = 0mesh%ncdbp = 0mesh%nn = 8mesh%nnb = 0mesh%nne = 6mesh%nneb = 0mesh%ne = 13mesh%neb = 0mesh%nee = 5mesh%neeb = 0```=== “Process 1” ```fortran type(msh) :: mesh
!=====================================================================!! Global for all MPI processes!=====================================================================!mesh%ncg = 24mesh%nng = 17mesh%neg = 43
!=====================================================================!! Local for process 1!=====================================================================!mesh%nc = 8mesh%ncd = 5mesh%ncb = 2mesh%ncp = 0mesh%ncdb = 1mesh%ncdbp = 0mesh%nn = 9mesh%nnb = 2mesh%nne = 6mesh%nneb = 1mesh%ne = 16mesh%neb = 1mesh%nee = 6mesh%neeb = 0```=== “Process 2” ```fortran type(msh) :: mesh
!=====================================================================!! Global for all MPI processes!=====================================================================!mesh%ncg = 24mesh%nng = 17mesh%neg = 43
!=====================================================================!! Local for process 2!=====================================================================!mesh%nc = 10mesh%ncd = 5mesh%ncb = 4mesh%ncp = 0mesh%ncdb = 3mesh%ncdbp = 0mesh%nn = 11mesh%nnb = 3mesh%nne = 7mesh%nneb = 2mesh%ne = 19mesh%neb = 2mesh%nee = 7mesh%neeb = 0```Boundary conditions
Section titled “Boundary conditions”The mesh structure also contains the boundary conditions informations:
nbcis the number of boundary conditions defined for this model (the boundary conditions are at the domain’s edges).bc(:)is an array of dimensionnbcand contains, per boundary condition :typlim: name of the BC.group: physical group attached to this BC (defined in Gmsh generated.mshfile).ne: number of edges involved in this BC.edgeb(:): list of edges’ indexes involved in this BC.
MPI communicators
Section titled “MPI communicators”The structure also contains MPI communicators (see Features : MPI) :
comm(type(mpi_pool)) :mpi(4)(type(mpi_grph)) :mpid(type(mpi_grph)) :
Fortran Type Source
Section titled “Fortran Type Source”TYPE msh
!================================================================================================================! ! Primal Mesh Array of Geometrical Elements !================================================================================================================!
type(cell_ ), allocatable :: cell (:) type(node_ ), allocatable :: node (:) type(edge_ ), allocatable :: edge (:) type(cell_bd), allocatable :: cellb(:) type(node_bd), allocatable :: nodeb(:) type(edge_bd), allocatable :: edgeb(:) !================================================================================================================! ! Numbers of Geometrical Elements as other Usefull Ones !================================================================================================================!
integer(ip) :: nc ! Number of Local (MPI use) Primal Cells integer(ip) :: ncd ! Number of Local (MPI use) Primal Cells in SubDomain Boundary integer(ip) :: ncb ! Number of Local (MPI use) Primal Cells in Physical Boundary integer(ip) :: ncp ! Number of Local (MPI use) Primal Cells in Periodic Boundary integer(ip) :: ncdb ! Number of Local (MPI use) Primal Cells in SubDomain+Physical Boundary integer(ip) :: ncdbp ! Number of Local (MPI use) Primal Cells in SubDomain+Physical+Perodic Boundary integer(ip) :: ncg ! Number of Global (MPI use) Primal Cells
integer(ip) :: nn ! Number of Local (MPI use) Primal Nodes integer(ip) :: nnb ! Number of Local (MPI use) Primal Nodes at Physical Boundary integer(ip) :: nne ! Number of Local (MPI use) Primal Nodes in SubDomain Boundary integer(ip) :: nneb ! Number of Local (MPI use) Primal Nodes in SubDomain Boundary at Physical Boundary integer(ip) :: nng ! Number of Global (MPI use) Primal Nodes
integer(ip) :: ne ! Number of Local (MPI use) Primal Edges integer(ip) :: neb ! Number of Local (MPI use) Primal Edges at Physical Boundary integer(ip) :: nee ! Number of Extra (MPI use) Primal Edges in SubDomain Boundary integer(ip) :: neeb ! Number of Extra (MPI use) Primal Edges in SubDomain Boundary at Physical Boundary integer(ip) :: neg ! Number of Global (MPI use) Primal Edges
!================================================================================================================! ! Boundary Conditions Infos !================================================================================================================!
integer(ip) :: nbc
type(bc_), allocatable :: bc(:)
!================================================================================================================! ! MPI communicators for Primal and Dual Meshes !================================================================================================================!
type(mpi_pool), pointer :: comm => null()
type(mpi_grph) :: mpi(4) type(mpi_grph) :: mpid
!================================================================================================================! ! Other usefull variables !================================================================================================================!
real(rp) :: surf
character(lchar) :: name ! Name of the mesh file
CONTAINS
procedure, pass( self ) :: equal_mesh procedure, pass( mesh ) :: dealloc => dealloc_mesh procedure, pass( mesh ) :: realloc_cell => reallocate_cell procedure, pass( mesh ) :: realloc_cellb => reallocate_cellb procedure, pass( mesh ) :: realloc_node => reallocate_node procedure, pass( mesh ) :: realloc_nodeb => reallocate_nodeb procedure, pass( mesh ) :: realloc_edge => reallocate_edge procedure, pass( mesh ) :: realloc_edgeb => reallocate_edgeb procedure, pass( mesh ) :: output => output_partition
generic :: assignment(=) => equal_mesh
END TYPE msh