boundary_2d Module

BCs (reflecting wall / outflow / supersonic inlet), normal-aware on curvilinear grids, with an MPI dual-path for inter-rank edges.



Functions

private pure function reflect_velocity_2d(q, nrm) result(qr)

Reflect the velocity of a conserved state about unit normal nrm, preserving density and total energy (|v| is unchanged). Inviscid no-penetration wall. The density is floored to eps (matching limit_pos_2d): the halo fill runs BEFORE any residual-side positivity guard can fire, so a transient non-positive boundary-adjacent state (near-vacuum off a strong expansion) must not divide-by-zero / SIGFPE here (audit 2026-07-06 N2); the residual guards still abort cleanly on the interior state itself.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: q(:)
real(kind=wp), intent(in) :: nrm(2)

Return Value real(kind=wp), (size(q))

private pure function ref_state(state) result(q)

Conserved free-stream reference state from config.

Arguments

Type IntentOptional Attributes Name
type(solver_state_2d_t), intent(in) :: state

Return Value real(kind=wp), (size(state%ub,1))

private pure function set_farfield_ghost(q_int, q_inf, nrm, gam) result(q_ghost)

Characteristic (Riemann-invariant) far-field ghost state for an OUTWARD unit normal nrm. q_int is the boundary-adjacent interior conserved state, q_inf the free-stream. With interior/free-stream normal velocities Un_i, Un_inf and sound speeds c_i, c_inf: * supersonic in/out (|Un_i| >= c_i) short-circuit to pure free-stream / pure interior extrapolation; * otherwise combine the outgoing (interior) invariant R+ = Un_i + 2 c_i/(gam-1) with the incoming (free-stream) R- = Un_inf - 2 c_inf/(gam-1) to get Un_b = (R+ + R-)/2, c_b = (gam-1)/4 (R+ - R-). Entropy and tangential velocity are taken from the free-stream on inflow (Un_b <= 0) and from the interior on outflow; rho_b, p_b follow from entropy + c_b. gam is passed explicitly (no module-level thermodynamic state here).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: q_int(:)
real(kind=wp), intent(in) :: q_inf(:)
real(kind=wp), intent(in) :: nrm(2)
real(kind=wp), intent(in) :: gam

Return Value real(kind=wp), (size(q_int))


Subroutines

public subroutine wall_edges_2d(state, w_xlo, w_xhi, w_ylo, w_yhi)

Report which of the four block edges are PHYSICAL solid (reflecting) walls, for the curvilinear residual's weak pressure-wall flux. Mirrors apply_halos_2d's serial/MPI dual-path edge selection exactly (single source of truth): serial (np=1 or no Cart comm) => all four edges are physical; MPI => an edge is physical only if its Cartesian neighbour is MPI_PROC_NULL. An edge is a wall iff it is physical AND its cfg % bc_* is 'reflecting'.

Arguments

Type IntentOptional Attributes Name
type(solver_state_2d_t), intent(in) :: state
logical, intent(out) :: w_xlo
logical, intent(out) :: w_xhi
logical, intent(out) :: w_ylo
logical, intent(out) :: w_yhi

public subroutine apply_periodic_halos_2d(state)

Fill all four halo bands by periodic wrap of the opposite interior edge.

Arguments

Type IntentOptional Attributes Name
type(solver_state_2d_t), intent(inout) :: state

public subroutine apply_halos_2d(state)

Fill all four halo bands per cfg % bc_* edge type.

Read more…

Arguments

Type IntentOptional Attributes Name
type(solver_state_2d_t), intent(inout) :: state

private subroutine apply_bcs_fdm_2d(state)

Fill the four halo bands for the NODAL finite-difference (FDM) path.

Read more…

Arguments

Type IntentOptional Attributes Name
type(solver_state_2d_t), intent(inout) :: state

private subroutine fill_x_edge_fdm(state, is_min, bc)

Fill a left (is_min=.true.) or right x-edge band over rows j=1..ny, NODAL.

Arguments

Type IntentOptional Attributes Name
type(solver_state_2d_t), intent(inout) :: state
logical, intent(in) :: is_min
character(len=*), intent(in) :: bc

private subroutine fill_y_edge_fdm(state, is_min, bc)

Fill a bottom (is_min=.true.) or top y-edge band over columns i=1..nx, NODAL.

Arguments

Type IntentOptional Attributes Name
type(solver_state_2d_t), intent(inout) :: state
logical, intent(in) :: is_min
character(len=*), intent(in) :: bc

private subroutine fill_x_edge(state, is_min, bc)

Fill a left (is_min=.true.) or right x-edge band over rows j=1..ny.

Arguments

Type IntentOptional Attributes Name
type(solver_state_2d_t), intent(inout) :: state
logical, intent(in) :: is_min
character(len=*), intent(in) :: bc

private subroutine fill_y_edge(state, is_min, bc)

Fill a bottom (is_min=.true.) or top y-edge band over columns i=1..nx.

Arguments

Type IntentOptional Attributes Name
type(solver_state_2d_t), intent(inout) :: state
logical, intent(in) :: is_min
character(len=*), intent(in) :: bc