Skip to content

Mesh

The mesh structure sources can be found in Tolosa-lib/src/m_mesh.f90 and Tolosa-lib/src/submodule/m_mesh_tools.f90.

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 Cell
  • cell( order_max ) : Neighboring Cells Index (referenced to upper Nodes list)
  • edge( order_max ) : Edges Indexes
  • glob : Global Cell Index when MPI Partitionned Mesh
  • order : Number of Neighboring Cells/Edges
  • lim : Boundary Cell Index
  • surf : Cell surface
  • invsurf : Inverse of Cell surface
  • peri : Cell perimeter
  • grav : Cell gravity center
  • subdomain : True boolean if Ghost Cell is in SubDomain Boundary
  • boundary : True boolean if Ghost Cell is in Physical Boundary

Mesh connectivities

type(msh) :: mesh
mesh%cell(2)%node(1) = 2
mesh%cell(2)%node(2) = 1
mesh%cell(2)%node(3) = 4
mesh%cell(2)%cell(1) = 1
mesh%cell(2)%cell(2) = 3
mesh%cell(2)%cell(3) = 4
mesh%cell(2)%edge(1) = 2
mesh%cell(2)%edge(2) = 4
mesh%cell(2)%edge(3) = 5
mesh%cell(2)%boundary = .false.
mesh%cell(4)%boundary = .true.
[...]
  • node(:) : The mesh’s nodes are contained in a node(:) 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

Mesh connectivities

type(msh) :: mesh
mesh%node(1)%cell(1) = 3
mesh%node(1)%cell(2) = 1
mesh%node(1)%edge(1) = 1
mesh%node(1)%edge(2) = 2
mesh%node(1)%edge(3) = 4
mesh%node(1)%edge(4) = 6
mesh%node(1)%coord%x = 1.2
mesh%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 Indexes
  • node(2) : Connected Nodes Indexes
  • lim : Boundary Edge Index
  • boundary : True boolean if Edge is at Physical Mesh Boundary
  • subdomain : True boolean if Edge is at SubDomain Boundary
  • perio : True boolean if Edge is at Periodic Boundary
  • length : Edge length
  • center : Edge center
  • normal : Edge normal oriented from the connected cell 1 to the connected cell 2 (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”

![Mesh connectivities](./images/mesh.svg)
```fortran
type(msh) :: mesh
mesh%edge(5)%cell(1) = 2 ! In this order (from the furthest cell from
mesh%edge(5)%cell(2) = 4 ! the physical boundary to the closest one)
mesh%edge(5)%node(1) = 4
mesh%edge(5)%node(2) = 2
[...]
```

=== “Edge’s vectors”

![Mesh connectivities](./images/mesh_edge_vect.svg)

This structure also encapsulates the numbers of geometrical elements and other usefull ones :

  • surf : Mesh surface
  • name : Name of the mesh file if existing
  • nc : Number of Local (MPI use) Primal Cells
  • ncd : Number of Local (MPI use) Primal Cells in SubDomain Boundary
  • ncb : Number of Local (MPI use) Primal Cells in Physical Boundary
  • ncp : Number of Local (MPI use) Primal Cells in Periodic Boundary
  • ncdb : Number of Local (MPI use) Primal Cells in SubDomain+Physical Boundary
  • ncdbp : Number of Local (MPI use) Primal Cells in SubDomain+Physical+Perodic Boundary
  • ncg : Number of Global (MPI use) Primal Cells
  • nn : Number of Local (MPI use) Primal Nodes
  • nnb : Number of Local (MPI use) Primal Nodes at Physical Boundary
  • nne : Number of Local (MPI use) Primal Nodes in SubDomain Boundary
  • nneb : Number of Local (MPI use) Primal Nodes in SubDomain Boundary at Physical Boundary
  • nng : Number of Global (MPI use) Primal Nodes
  • ne : Number of Local (MPI use) Primal Edges
  • neb : Number of Local (MPI use) Primal Edges at Physical Boundary
  • nee : Number of Extra (MPI use) Primal Edges in SubDomain Boundary
  • neeb : Number of Extra (MPI use) Primal Edges in SubDomain Boundary at Physical Boundary
  • neg : 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 = 24
mesh%nng = 17
mesh%neg = 43
!=====================================================================!
! Local for process 0
!=====================================================================!
mesh%nc = 6
mesh%ncd = 4
mesh%ncb = 0
mesh%ncp = 0
mesh%ncdb = 0
mesh%ncdbp = 0
mesh%nn = 8
mesh%nnb = 0
mesh%nne = 6
mesh%nneb = 0
mesh%ne = 13
mesh%neb = 0
mesh%nee = 5
mesh%neeb = 0
```

=== “Process 1” ```fortran type(msh) :: mesh

!=====================================================================!
! Global for all MPI processes
!=====================================================================!
mesh%ncg = 24
mesh%nng = 17
mesh%neg = 43
!=====================================================================!
! Local for process 1
!=====================================================================!
mesh%nc = 8
mesh%ncd = 5
mesh%ncb = 2
mesh%ncp = 0
mesh%ncdb = 1
mesh%ncdbp = 0
mesh%nn = 9
mesh%nnb = 2
mesh%nne = 6
mesh%nneb = 1
mesh%ne = 16
mesh%neb = 1
mesh%nee = 6
mesh%neeb = 0
```

=== “Process 2” ```fortran type(msh) :: mesh

!=====================================================================!
! Global for all MPI processes
!=====================================================================!
mesh%ncg = 24
mesh%nng = 17
mesh%neg = 43
!=====================================================================!
! Local for process 2
!=====================================================================!
mesh%nc = 10
mesh%ncd = 5
mesh%ncb = 4
mesh%ncp = 0
mesh%ncdb = 3
mesh%ncdbp = 0
mesh%nn = 11
mesh%nnb = 3
mesh%nne = 7
mesh%nneb = 2
mesh%ne = 19
mesh%neb = 2
mesh%nee = 7
mesh%neeb = 0
```

The mesh structure also contains the boundary conditions informations:

  • nbc is the number of boundary conditions defined for this model (the boundary conditions are at the domain’s edges).
  • bc(:) is an array of dimension nbc and contains, per boundary condition :
    • typlim : name of the BC.
    • group : physical group attached to this BC (defined in Gmsh generated .msh file).
    • ne : number of edges involved in this BC.
    • edgeb(:) : list of edges’ indexes involved in this BC.

The structure also contains MPI communicators (see Features : MPI) :

  • comm (type(mpi_pool)) :
  • mpi(4) (type(mpi_grph)) :
  • mpid (type(mpi_grph)) :
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