mod_mesh Module

Mesh data structures and geometry definitions for hexahedral grids.

This module defines the core topological and geometric entities used by the finite-volume solver. The solver is specifically designed for hexahedral cells (8 nodes, 6 faces), and these structures encapsulate all necessary connectivity and metric information (volumes, areas, normals).

The mesh hierarchy is structured to support efficient flux-based computations:

  1. cell_t: Holds volumetric data and node connectivity. It represents the primary control volume.
  2. face_t: The fundamental entity for flux evaluation. Manages owner/neighbor relationships and boundary associations.
  3. patch_t: Groups faces into named boundary regions (e.g., "Inlet", "Outlet") for application of Boundary Conditions.
  4. mesh_t: The global container for all nodes, cells, and faces.

Gmsh Hexahedron Node Ordering (8-node):

      7 --------- 6
     /|          /|
    4 --------- 5 |
    | |         | |
    | 3 --------| 2
    |/          |/
    0 --------- 1


Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: max_cell_faces = 6

Maximum number of faces per cell. Fixed at 6 for hexahedral meshes.


Derived Types

type, public ::  cell_t

Hexahedral cell data structure. Contains local geometric properties and node-based connectivity.

Components

Type Visibility Attributes Name Initial
real(kind=rk), public :: center(3) = zero
integer, public :: id = 0
integer, public :: nodes(8) = 0
real(kind=rk), public :: volume = zero

type, public ::  face_t

Mesh face data structure. Faces are the primary entities for flux calculation. Each face is associated with an 'owner' and potentially a 'neighbor' cell.

Components

Type Visibility Attributes Name Initial
real(kind=rk), public :: area = zero
real(kind=rk), public :: center(3) = zero
integer, public :: id = 0
integer, public :: neighbor = 0
real(kind=rk), public :: normal(3) = zero
integer, public :: owner = 0
integer, public :: patch = 0
integer, public :: periodic_face = 0
integer, public :: periodic_neighbor = 0

type, public ::  mesh_t

Top-level mesh container. This structure holds all geometric data and connectivity arrays for the entire computational domain.

Components

Type Visibility Attributes Name Initial
integer, public, allocatable :: cell_faces(:,:)
type(cell_t), public, allocatable :: cells(:)
type(face_t), public, allocatable :: faces(:)
integer, public, allocatable :: ncell_faces(:)
integer, public :: ncells = 0
integer, public :: nfaces = 0
integer, public :: npatches = 0
integer, public :: npoints = 0
type(patch_t), public, allocatable :: patches(:)
real(kind=rk), public, allocatable :: points(:,:)

type, public ::  patch_t

Boundary patch data structure. Patches group faces together to allow bulk application of boundary conditions (e.g., all faces in the "inlet" patch).

Components

Type Visibility Attributes Name Initial
integer, public, allocatable :: face_ids(:)
integer, public :: id = 0
character(len=name_len), public :: name = ""
integer, public :: nfaces = 0

Subroutines

public subroutine mesh_finalize(m)

Safely deallocates all heap-allocated arrays in the mesh structure.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(inout) :: m

The mesh object to be cleared.