Appearance
adam_flume_euler_library
ADAM, FLUME pointwise Euler physics shared by the CPU and FNL backends.
Every routine is pure, takes explicit-size dummies and is tagged !$acc routine seq + !$omp declare target, so CPU loops and FNL device kernels call the SAME source: CPU/FNL agreement is then a property of the loops only. Calorically perfect ideal gas: p = (gamma-1) (rE - rho |u|^2 / 2), T = p / (rho R), a = sqrt(gamma p / rho).
Eigensystem in direction d (issue #35, section 3.3): normal n = e_d, tangents taken cyclically, t1 = e_{mod(d,3)+1}, t2 = e_{mod(d+1,3)+1}; with b2 = (gamma-1)/a^2, b1 = b2 |u|^2 / 2, u_n = u.n:
r1 = (1, u - a n, H - a u_n) l1 = (b1 + u_n/a, -b2 u - n/a, b2) / 2
r2 = (1, u, |u|^2 / 2) l2 = (1 - b1, b2 u, -b2)
r3 = (0, t1, u.t1) l3 = (-u.t1, t1, 0)
r4 = (0, t2, u.t2) l4 = (-u.t2, t2, 0)
r5 = (1, u + a n, H + a u_n) l5 = (b1 - u_n/a, -b2 u + n/a, b2) / 2eigenvalues (u_n - a, u_n, u_n, u_n, u_n + a). Storage, stated once: el(k,:) is the row l_k, er(:,k) is the column r_k; projection w_k = sum_v el(k,v) q_v, back-projection q_v = sum_k er(v,k) w_k.
The WENO reconstruction primitive differs between host (adam_weno_object) and device (adam_fnl_weno_kernels), so the per-face flux is split in two physics halves around it (issue #35, section 7.1): compute_face_split_fluxes projects and splits the stencil, the backend reconstructs each field, compute_face_flux_back_projection returns to conservative variables.
Source: src/app/flume/common/adam_flume_euler_library.F90
Dependencies
Contents
- compute_eigenvalues
- compute_eigenvectors
- compute_face_flux_back_projection
- compute_face_interpolation_fields
- compute_face_split_fluxes
- compute_face_states
- compute_flux
- compute_roe_average
- compute_riemann_hll
- compute_riemann_hllc
- compute_riemann_llf
- conservative_to_auxiliary
- primitive_to_conservative
- compute_einfeldt_speeds
- compute_hllc_star_flux
- compute_state_magnitudes
Subroutines
compute_eigenvalues
Compute the eigenvalues of the flux Jacobian in direction d: (u_n - a, u_n, u_n, u_n, u_n + a).
Attributes: pure
fortran
subroutine compute_eigenvalues(d, qa, lambda)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
qa | real(kind=R8P) | in | Auxiliary variables. | |
lambda | real(kind=R8P) | out | Eigenvalues. |
Call graph
compute_eigenvectors
Compute the left (rows) and right (columns) eigenvectors of the flux Jacobian in direction d at state qa.
Attributes: pure
fortran
subroutine compute_eigenvectors(gamma, d, qa, el, er)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
qa | real(kind=R8P) | in | Auxiliary variables (e.g. a Roe average). | |
el | real(kind=R8P) | out | Left eigenvectors, el(k,:) = l_k. | |
er | real(kind=R8P) | out | Right eigenvectors, er(:,k) = r_k. |
Call graph
compute_face_flux_back_projection
Return the face flux in conservative variables from the reconstructed split fields, F = R (f+ + f-).
Attributes: pure
fortran
subroutine compute_face_flux_back_projection(is_characteristic, er, vr, flux)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
is_characteristic | logical | in | Reconstruction variables: characteristic or conservative. | |
er | real(kind=R8P) | in | Right eigenvectors, er(:,k) = r_k (unused if conservative). | |
vr | real(kind=R8P) | in | Reconstructed split fields at the face. | |
flux | real(kind=R8P) | out | Face flux. |
Call graph
compute_face_interpolation_fields
Return the fields of the stencil of face i+1/2 to be WENO-interpolated to the face (scheme weno-riemann).
The stencil holds cells m = 1-S ... S relative to cell i (cell i+1 is m = 1). Characteristic variant: the conservative states projected on the left eigenvectors of the Roe average of cells 0 and 1, w = L q; primitive variant: (rho, u, v, w, p). Stored in the layout of the WENO upwind primitive: fint(2,m,k) = field k of cell m for m = 1-S ... S-1 (interpolated toward the left state), fint(1,m,k) = field k of cell m+1 (toward the right state). er returns the right eigenvectors for compute_face_states. mu returns the magnitude of each field, the stencil mean of the absolute projection sum_v |l_kv| qm_v (qm the reference magnitudes of compute_state_magnitudes; |w_k| for the primitive fields), floored at tiny: the descaler of the scale-invariant WENO weights (issue #49). It scales exactly like the field and, unlike the field, does not vanish where the projection on the local state does.
Attributes: pure
fortran
subroutine compute_face_interpolation_fields(gamma, d, S, is_characteristic, qs, qas, fint, er, mu)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
S | integer(kind=I4P) | in | WENO stencil half-width, S <= S_MAX. | |
is_characteristic | logical | in | Characteristic (or primitive) variables. | |
qs | real(kind=R8P) | in | Stencil conservative variables. | |
qas | real(kind=R8P) | in | Stencil auxiliary variables. | |
fint | real(kind=R8P) | out | Fields in the WENO upwind layout. | |
er | real(kind=R8P) | out | Right eigenvectors (unused if primitive). | |
mu | real(kind=R8P) | out | Magnitude of each field (WENO descaler). |
Call graph
compute_face_split_fluxes
Project and Lax-Friedrichs-split the stencil of face i+1/2, ready for the WENO upwind reconstruction.
The stencil holds cells m = 1-S ... S relative to cell i (cell i+1 is m = 1). Characteristic variant: Roe eigenvectors of cells 0 and 1, per-wave speeds alpha_k = max_m |lambda_k(m)|, w = L q, g = L f_d(q); conservative variant: no projection, one speed alpha = max_m (|u_n| + a). Split f+ = (g + alpha w) / 2, f- = g - f+, stored in the layout of the WENO upwind primitive: fsplit(2,m,k) = f+ of cell m for m = 1-S ... S-1, fsplit(1,m,k) = f- of cell m+1. er returns the right eigenvectors for the back-projection. mu returns the magnitude of each split field, the stencil mean of sum_v |l_kv| (|f_v| + alpha_max qm_v) / 2, alpha_max the largest of the speeds alpha_k and qm_v >= |q_v| the reference magnitudes of compute_state_magnitudes: an upper bound of |f+-| cell by cell, floored at tiny, the descaler of the scale-invariant WENO weights (issue #49). It is exact under power-of-two scaling and never zero on a physical state, even for a field that vanishes identically or travels at zero speed, so round-off is never weighted as data.
Attributes: pure
fortran
subroutine compute_face_split_fluxes(gamma, d, S, is_characteristic, qs, qas, fsplit, er, mu)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
S | integer(kind=I4P) | in | WENO stencil half-width, S <= S_MAX. | |
is_characteristic | logical | in | Characteristic (or conservative) variables. | |
qs | real(kind=R8P) | in | Stencil conservative variables. | |
qas | real(kind=R8P) | in | Stencil auxiliary variables. | |
fsplit | real(kind=R8P) | out | Split fields in the WENO upwind layout. | |
er | real(kind=R8P) | out | Right eigenvectors (identity if conservative). | |
mu | real(kind=R8P) | out | Magnitude of each field (WENO descaler). |
Call graph
compute_face_states
Return the conservative left and right states of face i+1/2 from the WENO-interpolated fields.
vr(2,k) is field k interpolated from the left (left state), vr(1,k) from the right (right state), as returned by the WENO primitive on the layout of compute_face_interpolation_fields. A state with non-positive density or pressure is replaced by the state of its cell (q0 left, q1 right): the face falls back to first order.
Attributes: pure
fortran
subroutine compute_face_states(gamma, is_characteristic, er, vr, q0, q1, qL, qR)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
is_characteristic | logical | in | Characteristic (or primitive) variables. | |
er | real(kind=R8P) | in | Right eigenvectors (unused if primitive). | |
vr | real(kind=R8P) | in | Interpolated fields. | |
q0 | real(kind=R8P) | in | Conservative variables of cell 0 (left of the face). | |
q1 | real(kind=R8P) | in | Conservative variables of cell 1 (right of the face). | |
qL | real(kind=R8P) | out | Left state. | |
qR | real(kind=R8P) | out | Right state. |
Call graph
compute_flux
Compute the physical flux in direction d: rho u_d (1, u, v, w, H) + p (0, e_d, 0).
Attributes: pure
fortran
subroutine compute_flux(d, q, qa, f)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
q | real(kind=R8P) | in | Conservative variables. | |
qa | real(kind=R8P) | in | Auxiliary variables. | |
f | real(kind=R8P) | out | Physical flux. |
Call graph
compute_roe_average
Compute the Roe average of two states: sqrt(rho)-weighted velocity and total enthalpy.
The average holds density, velocity, total enthalpy, speed of sound and the matching pressure p = rho a^2 / gamma; temperature is not defined for the Roe state and is set to zero.
Attributes: pure
fortran
subroutine compute_roe_average(gamma, qaL, qaR, roe)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
qaL | real(kind=R8P) | in | Left state auxiliary variables. | |
qaR | real(kind=R8P) | in | Right state auxiliary variables. | |
roe | real(kind=R8P) | out | Roe average. |
Call graph
compute_riemann_hll
Compute the HLL flux of two states in direction d (Harten, Lax & van Leer 1983) with the Einfeldt speeds S_L = min(u_nL - a_L, u~_n - a~), S_R = max(u_nR + a_R, u~_n + a~) (Roe averages, Einfeldt et al. 1991): F = f(qL) if S_L >= 0, f(qR) if S_R <= 0, else (S_R f(qL) - S_L f(qR) + S_L S_R (qR - qL)) / (S_R - S_L).
Attributes: pure
fortran
subroutine compute_riemann_hll(gamma, d, qL, qR, f)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
qL | real(kind=R8P) | in | Left state. | |
qR | real(kind=R8P) | in | Right state. | |
f | real(kind=R8P) | out | Flux. |
Call graph
compute_riemann_hllc
Compute the HLLC flux of two states in direction d (Toro, Spruce & Speares 1994) with the Einfeldt outer speeds S_L, S_R of compute_riemann_hll and the contact speed of Batten et al. (1997) S_M = (p_R - p_L + rho_L u_nL (S_L - u_nL) - rho_R u_nR (S_R - u_nR)) / (rho_L (S_L - u_nL) - rho_R (S_R - u_nR)); star state q*_K = c_K (1, u with u_n replaced by S_M, E_K/rho_K + (S_M - u_nK)(S_M + p_K/(rho_K (S_K - u_nK)))), c_K = rho_K (S_K - u_nK) / (S_K - S_M); F = f(qL), f(qL) + S_L (q*_L - qL), f(qR) + S_R (q*_R - qR) or f(qR) by the sign of S_L, S_M, S_R.
Attributes: pure
fortran
subroutine compute_riemann_hllc(gamma, d, qL, qR, f)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
qL | real(kind=R8P) | in | Left state. | |
qR | real(kind=R8P) | in | Right state. | |
f | real(kind=R8P) | out | Flux. |
Call graph
compute_riemann_llf
Compute the local Lax-Friedrichs (Rusanov) flux of two states in direction d, F = (f(qL) + f(qR)) / 2 - alpha (qR - qL) / 2, alpha = max(|u_n| + a) of the two states.
Attributes: pure
fortran
subroutine compute_riemann_llf(gamma, d, qL, qR, f)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
qL | real(kind=R8P) | in | Left state. | |
qR | real(kind=R8P) | in | Right state. | |
f | real(kind=R8P) | out | Flux. |
Call graph
conservative_to_auxiliary
Compute the auxiliary (primitive and derived) variables of a cell from its conservative variables.
Attributes: pure
fortran
subroutine conservative_to_auxiliary(gamma, R, q, qa)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
R | real(kind=R8P) | in | Gas constant. | |
q | real(kind=R8P) | in | Conservative variables. | |
qa | real(kind=R8P) | out | Auxiliary variables. |
Call graph
primitive_to_conservative
Compute the conservative variables of a cell from its primitive variables.
Attributes: pure
fortran
subroutine primitive_to_conservative(gamma, r, u, v, w, p, q)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
r | real(kind=R8P) | in | Density. | |
u | real(kind=R8P) | in | Velocity components. | |
v | real(kind=R8P) | in | Velocity components. | |
w | real(kind=R8P) | in | Velocity components. | |
p | real(kind=R8P) | in | Pressure. | |
q | real(kind=R8P) | out | Conservative variables. |
Call graph
compute_einfeldt_speeds
Compute the Einfeldt outer wave speeds of two states in direction d: S_L = min(u_nL - a_L, u~_n - a~), S_R = max(u_nR + a_R, u~_n + a~), ~ the Roe average.
Attributes: pure
fortran
subroutine compute_einfeldt_speeds(gamma, d, qaL, qaR, sL, sR)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
qaL | real(kind=R8P) | in | Left auxiliary variables. | |
qaR | real(kind=R8P) | in | Right auxiliary variables. | |
sL | real(kind=R8P) | out | Left and right wave speeds. | |
sR | real(kind=R8P) | out | Left and right wave speeds. |
Call graph
compute_hllc_star_flux
Compute the HLLC star-region flux f_K + S_K (q*_K - q_K) of the side K with outer speed s = S_K.
Attributes: pure
fortran
subroutine compute_hllc_star_flux(d, s, sM, q, qa, fK, f)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
s | real(kind=R8P) | in | Outer wave speed of the side. | |
sM | real(kind=R8P) | in | Contact wave speed. | |
q | real(kind=R8P) | in | Conservative variables of the side. | |
qa | real(kind=R8P) | in | Auxiliary variables of the side. | |
fK | real(kind=R8P) | in | Physical flux of the side. | |
f | real(kind=R8P) | out | Star-region flux. |
Call graph
compute_state_magnitudes
Return the reference magnitude of each conservative variable of a cell, the scale entering the WENO descaler mu in place of |q_v|: |rho|, |E| and, for every momentum component, |rho u|_1 + sqrt(rho p).
Why: a characteristic row that touches only components vanishing identically (the shear field of the out-of-plane momentum of a 2-D flow) would otherwise get a descaler of round-off size, and the scale-invariant weights would treat round-off as data: full nonlinear weights on noise, which nothing damps (issue #49, MV-7). The magnitude of the whole vector plus sqrt(rho p) never vanishes and scales exactly like a momentum component under power-of-two scaling (rho p scales by a power of four); the three terms are summed in increasing order, so rotations of the problem are bitwise invariant.
Attributes: pure
fortran
subroutine compute_state_magnitudes(q, qa, qm)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
q | real(kind=R8P) | in | Conservative variables. | |
qa | real(kind=R8P) | in | Auxiliary variables. | |
qm | real(kind=R8P) | out | Reference magnitudes. |
Call graph