Appearance
adam_flume_fnl_mhd_glm_kernels
ADAM, FLUME FNL device kernels of the ideal MHD with GLM cleaning model.
The model-agnostic auxiliary-variables kernel (adam_flume_fnl_aux_kernels_agnostic.INC) and the MHD dt and conservation kernels (adam_flume_fnl_mhd_kernels_agnostic.INC) instantiated with NV_K = NV_MHD_GLM, NV_AUX_K = NV_AUX_MHD (issue #41, section 4). The face-flux kernel is the shared body with the MHD split (M2-P3). Same kernel rules as adam_flume_fnl_kernels (issue #35, D-11/D-12).
Source: src/app/flume/fnl/adam_flume_fnl_mhd_glm_kernels.F90
Dependencies
Contents
- compute_face_fluxes_dev
- add_gravity_edge_correction_dev
- compute_q_aux_dev
- count_nonfinite_dev
- compute_conservation_dev
- compute_lambda_max_dev
- compute_lambda_max_dissipative_dev
- apply_floors_dev
- compute_speed_max_dev
- compute_divb_norms_dev
- blend_inadmissible_ghosts_dev
- add_glm_damping_dev
- face_split_fluxes
- cleaning_energy
- internal_energy
Subroutines
compute_face_fluxes_dev
Compute the WENO face fluxes of direction d: face (i,j,k) lies between cells (i,j,k) and (i+di,j+dj,k+dk), so the face array starts at index 0 along d.
Per face (device twin of the CPU compute_face_fluxes): gather the stencil m = 1-S ... S into constant-bound privates, project and split it, reconstruct every field (the private v is the packed stencil of the WENO primitive), back-project.
fortran
subroutine compute_face_fluxes_dev(d, di, dj, dk, ni, nj, nk, ngc, blocks_number, S, gamma, ch, is_characteristic, weno_a_gpu, weno_p_gpu, weno_d_gpu, weno_zeps, weno_sigma, q_gpu, q_aux_gpu, fl_gpu)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
di | integer(kind=I4P) | in | Unit step along d. | |
dj | integer(kind=I4P) | in | Unit step along d. | |
dk | integer(kind=I4P) | in | Unit step along d. | |
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
S | integer(kind=I4P) | in | WENO stencil half-width. | |
gamma | real(kind=R8P) | in | Specific heats ratio. | |
ch | real(kind=R8P) | in | GLM cleaning speed (models with GLM only). | |
is_characteristic | logical | in | Characteristic (or conservative) variables. | |
weno_a_gpu | real(kind=R8P) | in | WENO optimal weights. | |
weno_p_gpu | real(kind=R8P) | in | WENO polynomials coefficients. | |
weno_d_gpu | real(kind=R8P) | in | WENO smoothness indicators coefficients. | |
weno_zeps | real(kind=R8P) | in | WENO parameter avoiding division by zero. | |
weno_sigma | real(kind=R8P) | in | WENO descaler switch (0 Jiang-Shu, 1 SI). | |
q_gpu | real(kind=R8P) | in | Conservative variables. | |
q_aux_gpu | real(kind=R8P) | in | Auxiliary variables. | |
fl_gpu | real(kind=R8P) | inout | Face fluxes of direction d. |
Call graph
add_gravity_edge_correction_dev
Add the faces beyond the block to the gravity energy correction of direction d (issue #73, M7-G2a; device twin of the CPU add_gravity_edge_correction): cell 1 takes -g_d F^rho / 24 of face -1, cell n_d that of face n_d + 1, each face computed as compute_face_fluxes_dev does (the same body, its mass component kept).
fortran
subroutine add_gravity_edge_correction_dev(d, di, dj, dk, ni, nj, nk, ngc, blocks_number, S, gamma, ch, is_characteristic, weno_a_gpu, weno_p_gpu, weno_d_gpu, weno_zeps, weno_sigma, ir, gd, q_gpu, q_aux_gpu, gc_gpu)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
d | integer(kind=I4P) | in | Direction, 1=x, 2=y, 3=z. | |
di | integer(kind=I4P) | in | Unit step along d. | |
dj | integer(kind=I4P) | in | Unit step along d. | |
dk | integer(kind=I4P) | in | Unit step along d. | |
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
S | integer(kind=I4P) | in | WENO stencil half-width. | |
gamma | real(kind=R8P) | in | Specific heats ratio. | |
ch | real(kind=R8P) | in | GLM cleaning speed (models with GLM only). | |
is_characteristic | logical | in | Characteristic (or conservative) variables. | |
weno_a_gpu | real(kind=R8P) | in | WENO optimal weights. | |
weno_p_gpu | real(kind=R8P) | in | WENO polynomials coefficients. | |
weno_d_gpu | real(kind=R8P) | in | WENO smoothness indicators coefficients. | |
weno_zeps | real(kind=R8P) | in | WENO parameter avoiding division by zero. | |
weno_sigma | real(kind=R8P) | in | WENO descaler switch (0 Jiang-Shu, 1 SI). | |
ir | integer(kind=I4P) | in | Index of the density (mass) variable. | |
gd | real(kind=R8P) | in | Gravity along d. | |
q_gpu | real(kind=R8P) | in | Conservative variables. | |
q_aux_gpu | real(kind=R8P) | in | Auxiliary variables. | |
gc_gpu | real(kind=R8P) | inout | Gravity energy correction [..., 1]. |
Call graph
compute_q_aux_dev
Compute the auxiliary variables on every cell, ghost cells included.
fortran
subroutine compute_q_aux_dev(ni, nj, nk, ngc, blocks_number, gamma, R, q_gpu, q_aux_gpu)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
gamma | real(kind=R8P) | in | Specific heats ratio. | |
R | real(kind=R8P) | in | Gas constant. | |
q_gpu | real(kind=R8P) | in | Conservative variables. | |
q_aux_gpu | real(kind=R8P) | inout | Auxiliary variables. |
Call graph
count_nonfinite_dev
Count the non-finite (NaN or infinite) conservative values of the interior cells (issue #45): the exponent field has all its bits set. Tested on the bit pattern, so that no floating point mode (-fast) can fold the test away.
fortran
subroutine count_nonfinite_dev(ni, nj, nk, ngc, blocks_number, q_gpu, n)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
q_gpu | real(kind=R8P) | in | Conservative variables. | |
n | integer(kind=I8P) | out | Non-finite values number. |
Call graph
compute_conservation_dev
Compute the volume integrals of the conservative variables (interior cells), one reduction per variable. The cell volume includes the null directions (issue #37).
fortran
subroutine compute_conservation_dev(ni, nj, nk, ngc, blocks_number, dxyz_gpu, q_gpu, integrals)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
dxyz_gpu | real(kind=R8P) | in | Blocks space steps [nb, 3]. | |
q_gpu | real(kind=R8P) | in | Conservative variables. | |
integrals | real(kind=R8P) | out | Volume integrals. |
Call graph
compute_lambda_max_dev
Compute max(sum_d (|u_d| + c_{f,d}) / dx_d) over the interior cells (null directions excluded), c_{f,d} the fast magnetosonic speed along d (issue #41, section 3.5).
fortran
subroutine compute_lambda_max_dev(ni, nj, nk, ngc, blocks_number, gamma, R, dxyz_gpu, is_null, q_gpu, lambda_max)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
gamma | real(kind=R8P) | in | Specific heats ratio. | |
R | real(kind=R8P) | in | Gas constant. | |
dxyz_gpu | real(kind=R8P) | in | Blocks space steps [nb, 3]. | |
is_null | logical | in | Null directions. | |
q_gpu | real(kind=R8P) | in | Conservative variables. | |
lambda_max | real(kind=R8P) | out | Maximum of sum_d (|u_d| + c_{f,d}) / dx_d. |
Call graph
compute_lambda_max_dissipative_dev
Device twin of the CPU MHD compute_lambda_max_dissipative (issue #65, D-M4-3).
fortran
subroutine compute_lambda_max_dissipative_dev(ni, nj, nk, ngc, blocks_number, gamma, R, cp, mu0, k0, eta, t_wall, tref, omega_mu, omega_k, dxyz_gpu, is_null, q_gpu, lambda_max, lambda_hyp, lambda_dif, re_cell_min)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
gamma | real(kind=R8P) | in | Specific heats ratio, gas constant, cp. | |
R | real(kind=R8P) | in | Specific heats ratio, gas constant, cp. | |
cp | real(kind=R8P) | in | Specific heats ratio, gas constant, cp. | |
mu0 | real(kind=R8P) | in | Dissipative coefficients. | |
k0 | real(kind=R8P) | in | Dissipative coefficients. | |
eta | real(kind=R8P) | in | Dissipative coefficients. | |
t_wall | real(kind=R8P) | in | Hottest isothermal wall temperature, 0 if none. | |
tref | real(kind=R8P) | in | Temperature laws. | |
omega_mu | real(kind=R8P) | in | Temperature laws. | |
omega_k | real(kind=R8P) | in | Temperature laws. | |
dxyz_gpu | real(kind=R8P) | in | Blocks space steps [nb, 3]. | |
is_null | logical | in | Null directions. | |
q_gpu | real(kind=R8P) | in | Conservative variables. | |
lambda_max | real(kind=R8P) | out | Maximum of the sum. | |
lambda_hyp | real(kind=R8P) | out | Maximum of the hyperbolic part. | |
lambda_dif | real(kind=R8P) | out | Maximum of the diffusive part. | |
re_cell_min | real(kind=R8P) | out | Minimum cell Reynolds number. |
Call graph
apply_floors_dev
Apply the MHD positivity floors to the interior cells of a stage state, before its ghost exchange (issue #41, section 3.8): a cell with rho < rho_floor or p < p_floor gets rho = max(rho, rho_floor) at fixed velocity and p = max(p, p_floor) (internal energy added; the model's cleaning_energy adapter adds psi^2 / 2 under EGLM, zero otherwise). Interior only: the exchange then carries the floored values to the ghost cells, and ghost cells that no map fills (never read by the stencils) are not inspected. Returns the floored cells, the cells with a non-positive density or pressure (counted before flooring) and the minimum density and pressure. Floors are not conservative: the caller logs the counters.
fortran
subroutine apply_floors_dev(ni, nj, nk, ngc, blocks_number, gamma, R, rho_floor, p_floor, q_gpu, floored, nonpositive, rho_min, p_min)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
gamma | real(kind=R8P) | in | Specific heats ratio. | |
R | real(kind=R8P) | in | Gas constant. | |
rho_floor | real(kind=R8P) | in | Density and pressure floors. | |
p_floor | real(kind=R8P) | in | Density and pressure floors. | |
q_gpu | real(kind=R8P) | inout | Conservative variables. | |
floored | integer(kind=I4P) | out | Floored cells. | |
nonpositive | integer(kind=I4P) | out | Cells with non-positive density or pressure. | |
rho_min | real(kind=R8P) | out | Minimum density and pressure. | |
p_min | real(kind=R8P) | out | Minimum density and pressure. |
Call graph
compute_speed_max_dev
Compute max(|u_d| + c_{f,d}) over the interior cells and the active directions, the fastest wave speed (the GLM c_h check, issue #41, section 3.5).
fortran
subroutine compute_speed_max_dev(ni, nj, nk, ngc, blocks_number, gamma, R, is_null, q_gpu, speed_max)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
gamma | real(kind=R8P) | in | Specific heats ratio. | |
R | real(kind=R8P) | in | Gas constant. | |
is_null | logical | in | Null directions. | |
q_gpu | real(kind=R8P) | in | Conservative variables. | |
speed_max | real(kind=R8P) | out | Maximum of |u_d| + c_{f,d}. |
Call graph
compute_divb_norms_dev
Compute the div(B) norms over the interior cells (issue #41, D-10): max|div B|, sum |div B| dV and the maximum over the seam-local cells (within band cells of a block face with seam(b,face) /= 0, a 2:1 AMR or inter-realm seam). div B is the centred finite difference of the library (half stencil hs <= HS_MAX), null directions weighted zero; the cell volume includes the null directions (issue #37). The caller has refreshed the ghost cells.
fortran
subroutine compute_divb_norms_dev(ni, nj, nk, ngc, blocks_number, hs, band, dxyz_gpu, is_null, seam_gpu, q_gpu, divb_max, divb_l1, divb_seam_max)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
hs | integer(kind=I4P) | in | Finite difference half stencil, <= min(ngc, HS_MAX). | |
band | integer(kind=I4P) | in | Seam-local band width, in cells. | |
dxyz_gpu | real(kind=R8P) | in | Blocks space steps [nb, 3]. | |
is_null | logical | in | Null directions. | |
seam_gpu | integer(kind=I4P) | in | Seam faces flags [nb, 6] (0: not a seam face). | |
q_gpu | real(kind=R8P) | in | Conservative variables. | |
divb_max | real(kind=R8P) | out | Maximum of |div B|. | |
divb_l1 | real(kind=R8P) | out | Sum of |div B| dV. | |
divb_seam_max | real(kind=R8P) | out | Maximum of |div B| over the seam-local cells. |
Call graph
blend_inadmissible_ghosts_dev
Blend every inadmissible face ghost of q_gpu toward the adjacent interior cell and count the ghosts blended (device twin of the CPU blend_inadmissible_ghosts).
fortran
subroutine blend_inadmissible_ghosts_dev(ni, nj, nk, ngc, blocks_number, is_null, q_gpu, blended)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
is_null | logical | in | Null directions. | |
q_gpu | real(kind=R8P) | inout | Conservative variables (ghosts updated). | |
blended | integer(kind=I4P) | out | Ghosts blended. |
Call graph
add_glm_damping_dev
Add the GLM damping source to the residuals of the interior cells, dq(psi) = dq(psi) - (c_h^2 / c_p^2) psi (mixed GLM, Dedner et al. 2002; issue #41, section 3.1): a local source, in every Runge-Kutta stage and never in the fluxes, so the reflux and the conservation of the other variables are untouched.
fortran
subroutine add_glm_damping_dev(ni, nj, nk, ngc, blocks_number, damping, q_gpu, dq_gpu)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ni | integer(kind=I4P) | in | Grid dimensions. | |
nj | integer(kind=I4P) | in | Grid dimensions. | |
nk | integer(kind=I4P) | in | Grid dimensions. | |
ngc | integer(kind=I4P) | in | Grid dimensions. | |
blocks_number | integer(kind=I4P) | in | Actual blocks number. | |
damping | real(kind=R8P) | in | Damping rate c_h^2 / c_p^2. | |
q_gpu | real(kind=R8P) | in | Conservative variables. | |
dq_gpu | real(kind=R8P) | inout | Residuals. |
Call graph
face_split_fluxes
Split adapter of the shared face kernel (issue #41, M2-P3): the MHD split with GLM cleaning.
Attributes: pure
fortran
subroutine face_split_fluxes(gamma, ch, d, S, is_characteristic, qs, qas, fsplit, er, mu)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
gamma | real(kind=R8P) | in | Specific heats ratio. | |
ch | real(kind=R8P) | in | GLM cleaning speed. | |
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. | |
mu | real(kind=R8P) | out | Magnitude of each field (WENO descaler). |
Call graph
Functions
cleaning_energy
Cleaning-energy adapter of the floors kernel: zero, psi (if any) is not part of the energy of this model.
Attributes: pure
Returns: real(kind=R8P)
fortran
function cleaning_energy(q) result(e)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
q | real(kind=R8P) | in | Conservative variables. |
Call graph
internal_energy
Internal-energy adapter of the ghost positivity blend: E minus the kinetic and magnetic energies, per unit volume (the mixed GLM keeps psi out of the energy).
Attributes: pure
Returns: real(kind=R8P)
fortran
function internal_energy(q) result(e)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
q | real(kind=R8P) | in | Conservative variables. |
Call graph