mod_bc Module

Boundary condition (BC) management, parsing, and physical evaluation.

This module provides the infrastructure to map user-defined case configuration (case.nml) to the geometric patches of the mesh. It handles the storage of boundary data (velocity, projection pressure, species, and temperature/enthalpy) and provides low-level evaluation routines used by the spatial operators (e.g., flux calculation, gradient evaluation).

Supported BC Types: 1. bc_wall: No-slip/No-penetration condition. - Velocity is set to the specified wall velocity (default zero). - Pressure gradient is zero (Neumann). 2. bc_symmetry: Zero-gradient for parallel components, zero for normal. - Enforces no-flow across the boundary while allowing slip. 3. bc_periodic: Topology-linked faces for repeating domains. - Requires a valid periodic.dat file created by the mesh converter. 4. bc_dirichlet: Fixed field value. - Explicitly sets the field value at the face. 5. bc_neumann: Fixed gradient (Zero-Gradient Outlet). - Sets the face value equal to the adjacent interior cell value.



Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: bc_dirichlet = 4
integer, public, parameter :: bc_inlet_mass_flux = 7
integer, public, parameter :: bc_mass_flux = 6
integer, public, parameter :: bc_neumann = 5
integer, public, parameter :: bc_outlet_mass_flux = 8
integer, public, parameter :: bc_periodic = 3
integer, public, parameter :: bc_symmetry = 2
integer, public, parameter :: bc_unknown = 0
integer, public, parameter :: bc_wall = 1

Derived Types

type, public ::  bc_patch_t

Container for boundary data assigned to a specific mesh patch.

Read more…

Components

Type Visibility Attributes Name Initial
real(kind=rk), public :: dpdn = zero
real(kind=rk), public :: mass_flux = zero
character(len=name_len), public :: name = ""
integer, public :: patch_id = 0
real(kind=rk), public :: pressure = zero
integer, public :: pressure_type_id = bc_unknown
real(kind=rk), public :: species_Y(max_species) = zero
integer, public :: species_type_id = bc_unknown

Species boundary settings.

real(kind=rk), public :: temperature = 300.0_rk
integer, public :: temperature_type_id = bc_unknown

Temperature/enthalpy boundary settings.

integer, public :: type_id = bc_unknown
character(len=name_len), public :: type_name = ""
real(kind=rk), public :: velocity(3) = zero

positive magnitude for inlet/outlet_mass_flux.

integer, public :: velocity_type_id = bc_unknown

Field-specific overrides.

type, public ::  bc_set_t

Global set of boundary conditions covering all mesh patches.

Components

Type Visibility Attributes Name Initial
integer, public :: npatches = 0
type(bc_patch_t), public, allocatable :: patches(:)

Functions

public function boundary_pressure_type(mesh, bc, face_id) result(type_id)

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(bc_set_t), intent(in) :: bc
integer, intent(in) :: face_id

Return Value integer

public function face_effective_neighbor(mesh, bc, face_id, cell_id) result(neighbor)

Returns the neighbor cell index, accounting for periodic connectivity.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh

The computational mesh.

type(bc_set_t), intent(in) :: bc

The active BC set.

integer, intent(in) :: face_id

Global index of the face.

integer, intent(in) :: cell_id

Index of the cell requesting the neighbor.

Return Value integer

public function is_periodic_face(mesh, bc, face_id)

Returns true if the face belongs to a periodic boundary.

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(bc_set_t), intent(in) :: bc
integer, intent(in) :: face_id

Return Value logical

public function patch_type_for_face(mesh, bc, face_id) result(type_id)

Retrieves the master BC type for a given face ID.

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh

The computational mesh.

type(bc_set_t), intent(in) :: bc

The active BC set.

integer, intent(in) :: face_id

Global index of the face.

Return Value integer

private function parse_bc_type(text) result(type_id)

Converts a case-insensitive string to its corresponding internal BC type ID.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: text

String representation (e.g., "Wall", "Periodic", "Dirichlet").

Return Value integer


Subroutines

public subroutine boundary_pressure(mesh, bc, face_id, interior_p, ext_p, is_dirichlet)

Evaluates projection pressure at a boundary face.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(bc_set_t), intent(in) :: bc
integer, intent(in) :: face_id
real(kind=rk), intent(in) :: interior_p
real(kind=rk), intent(out) :: ext_p
logical, intent(out) :: is_dirichlet

public subroutine boundary_species(mesh, bc, face_id, k, interior_Y, ext_Y, is_dirichlet)

Evaluates species mass fractions at a boundary face.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(bc_set_t), intent(in) :: bc
integer, intent(in) :: face_id
integer, intent(in) :: k
real(kind=rk), intent(in) :: interior_Y
real(kind=rk), intent(out) :: ext_Y
logical, intent(out) :: is_dirichlet

public subroutine boundary_temperature(mesh, bc, face_id, interior_T, ext_T, is_dirichlet)

Evaluates temperature at a boundary face.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
type(bc_set_t), intent(in) :: bc
integer, intent(in) :: face_id
real(kind=rk), intent(in) :: interior_T
real(kind=rk), intent(out) :: ext_T
logical, intent(out) :: is_dirichlet

public subroutine boundary_velocity(mesh, bc, face_id, interior_velocity, value, boundary_density)

Evaluates the velocity vector at a boundary face.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh

Mesh data structure.

type(bc_set_t), intent(in) :: bc

Boundary condition set.

integer, intent(in) :: face_id

ID of the boundary face.

real(kind=rk), intent(in) :: interior_velocity(3)
real(kind=rk), intent(out) :: value(3)
real(kind=rk), intent(in), optional :: boundary_density

Optional density used by mass_flux boundaries [kg/m^3].

public subroutine build_bc_set(mesh, params, bc)

Synchronizes namelist parameters with mesh patches to create a complete BC set.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh

The computational mesh containing patch definitions.

type(case_params_t), intent(in) :: params

Parsed case configuration from case.nml.

type(bc_set_t), intent(inout) :: bc

The boundary condition set to be populated.

public subroutine finalize_bc_set(bc)

Safely deallocates the boundary condition patch array.

Arguments

Type IntentOptional Attributes Name
type(bc_set_t), intent(inout) :: bc

private subroutine ensure_periodic_links(mesh, patch_id)

Validates that periodic patches have correctly established links.

Arguments

Type IntentOptional Attributes Name
type(mesh_t), intent(in) :: mesh
integer, intent(in) :: patch_id