Skip to content

adam_flume_cpu_mhd_eglm_kernels ​

ADAM, FLUME CPU kernels of the ideal MHD with EGLM cleaning model.

The model-agnostic auxiliary-variables loop (adam_flume_cpu_aux_kernels_agnostic.INC) and the MHD dt loop (adam_flume_cpu_mhd_kernels_agnostic.INC) instantiated with NV_K = NV_MHD_EGLM, NV_AUX_K = NV_AUX_MHD; the face-flux kernel is the shared body with the EGLM split (Derigs et al. 2018; issue #47, D-8, section 3.3). The energy includes psi^2 / 2 (the auxiliary variables and the floors read the thermal pressure from the energy without it); the nonconservative sources and the damping are local residual terms.

Source: src/app/flume/cpu/adam_flume_cpu_mhd_eglm_kernels.F90

Dependencies

Contents ​

Subroutines ​

compute_face_fluxes ​

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: gather the stencil m = 1-S ... S into constant-bound locals, project and split it, reconstruct every field (the local v is the packed stencil of the WENO primitive), back-project.

fortran
subroutine compute_face_fluxes(d, di, dj, dk, ni, nj, nk, ngc, blocks_number, gamma, ch, is_characteristic, weno, q, q_aux, fl)

Arguments

NameTypeIntentAttributesDescription
dinteger(kind=I4P)inDirection, 1=x, 2=y, 3=z.
diinteger(kind=I4P)inUnit step along d.
djinteger(kind=I4P)inUnit step along d.
dkinteger(kind=I4P)inUnit step along d.
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
gammareal(kind=R8P)inSpecific heats ratio.
chreal(kind=R8P)inGLM cleaning speed (models with GLM only).
is_characteristiclogicalinCharacteristic (or conservative) variables.
wenotype(weno_object)inWENO coefficients.
qreal(kind=R8P)inConservative variables.
q_auxreal(kind=R8P)inAuxiliary variables.
flreal(kind=R8P)inoutFace fluxes of direction d.

Call graph

add_gravity_edge_correction ​

Add the faces beyond the block to the gravity energy correction of direction d (issue #73, M7-G2a): cell 1 takes -g_d F^rho / 24 of face -1 (between cells -1 and 0), cell n_d that of face n_d + 1 (between cells n_d + 1 and n_d + 2), the two terms of g_d (-F_{i-3/2} + F_{i-1/2} + F_{i+1/2} - F_{i+3/2}) / 24 whose faces the block does not hold. Each face is computed as compute_face_fluxes does (the same body, its mass component kept), from the ghosts: its stencil reaches S + 1 ghost cells, which the initialisation requires with gravity.

fortran
subroutine add_gravity_edge_correction(d, di, dj, dk, ni, nj, nk, ngc, blocks_number, gamma, ch, is_characteristic, weno, ir, gd, q, q_aux, gc)

Arguments

NameTypeIntentAttributesDescription
dinteger(kind=I4P)inDirection, 1=x, 2=y, 3=z.
diinteger(kind=I4P)inUnit step along d.
djinteger(kind=I4P)inUnit step along d.
dkinteger(kind=I4P)inUnit step along d.
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
gammareal(kind=R8P)inSpecific heats ratio.
chreal(kind=R8P)inGLM cleaning speed (models with GLM only).
is_characteristiclogicalinCharacteristic (or conservative) variables.
wenotype(weno_object)inWENO coefficients.
irinteger(kind=I4P)inIndex of the density (mass) variable.
gdreal(kind=R8P)inGravity along d.
qreal(kind=R8P)inConservative variables.
q_auxreal(kind=R8P)inAuxiliary variables.
gcreal(kind=R8P)inoutGravity energy correction [1, ...].

Call graph

compute_q_aux ​

Compute the auxiliary variables on every cell, ghost cells included.

fortran
subroutine compute_q_aux(ni, nj, nk, ngc, blocks_number, gamma, R, q, q_aux)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
gammareal(kind=R8P)inSpecific heats ratio.
Rreal(kind=R8P)inGas constant.
qreal(kind=R8P)inConservative variables.
q_auxreal(kind=R8P)inoutAuxiliary variables.

Call graph

count_nonfinite ​

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 can fold the test away.

fortran
subroutine count_nonfinite(ni, nj, nk, ngc, blocks_number, q, n)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
qreal(kind=R8P)inConservative variables.
ninteger(kind=I8P)outNon-finite values number.

Call graph

compute_lambda_max ​

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(ni, nj, nk, ngc, blocks_number, gamma, R, dxyz, is_null, q, lambda_max)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
gammareal(kind=R8P)inSpecific heats ratio.
Rreal(kind=R8P)inGas constant.
dxyzreal(kind=R8P)inBlocks space steps [3, nb].
is_nulllogicalinNull directions.
qreal(kind=R8P)inConservative variables.
lambda_maxreal(kind=R8P)outMaximum of sum_d (|u_d| + c_{f,d}) / dx_d.

Call graph

compute_lambda_max_dissipative ​

Compute max(sum_d (|u_d| + c_{f,d}) / dx_d + 2 nu sum_d 1 / dx_d^2) over the interior cells (issue #65, D-M4-3), nu the largest diffusivity of the cell (Ohmic included), with the maxima of the two parts and the minimum cell Reynolds number; the MHD twin of the Euler compute_lambda_max_dissipative.

fortran
subroutine compute_lambda_max_dissipative(ni, nj, nk, ngc, blocks_number, gamma, R, cp, mu0, k0, eta, t_wall, tref, omega_mu, omega_k, dxyz, is_null, q, lambda_max, lambda_hyp, lambda_dif, re_cell_min)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
gammareal(kind=R8P)inSpecific heats ratio, gas constant, cp.
Rreal(kind=R8P)inSpecific heats ratio, gas constant, cp.
cpreal(kind=R8P)inSpecific heats ratio, gas constant, cp.
mu0real(kind=R8P)inDissipative coefficients.
k0real(kind=R8P)inDissipative coefficients.
etareal(kind=R8P)inDissipative coefficients.
t_wallreal(kind=R8P)inHottest isothermal wall temperature, 0 if none.
trefreal(kind=R8P)inTemperature laws.
omega_mureal(kind=R8P)inTemperature laws.
omega_kreal(kind=R8P)inTemperature laws.
dxyzreal(kind=R8P)inBlocks space steps [3, nb].
is_nulllogicalinNull directions.
qreal(kind=R8P)inConservative variables.
lambda_maxreal(kind=R8P)outMaximum of the sum.
lambda_hypreal(kind=R8P)outMaximum of the hyperbolic part.
lambda_difreal(kind=R8P)outMaximum of the diffusive part.
re_cell_minreal(kind=R8P)outMinimum cell Reynolds number.

Call graph

apply_floors ​

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(ni, nj, nk, ngc, blocks_number, gamma, R, rho_floor, p_floor, q, floored, nonpositive, rho_min, p_min)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
gammareal(kind=R8P)inSpecific heats ratio.
Rreal(kind=R8P)inGas constant.
rho_floorreal(kind=R8P)inDensity and pressure floors.
p_floorreal(kind=R8P)inDensity and pressure floors.
qreal(kind=R8P)inoutConservative variables.
flooredinteger(kind=I4P)outFloored cells.
nonpositiveinteger(kind=I4P)outCells with non-positive density or pressure.
rho_minreal(kind=R8P)outMinimum density and pressure.
p_minreal(kind=R8P)outMinimum density and pressure.

Call graph

compute_speed_max ​

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(ni, nj, nk, ngc, blocks_number, gamma, R, is_null, q, speed_max)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
gammareal(kind=R8P)inSpecific heats ratio.
Rreal(kind=R8P)inGas constant.
is_nulllogicalinNull directions.
qreal(kind=R8P)inConservative variables.
speed_maxreal(kind=R8P)outMaximum of |u_d| + c_{f,d}.

Call graph

compute_divb_norms ​

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), 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(ni, nj, nk, ngc, blocks_number, hs, band, dxyz, is_null, seam, q, divb_max, divb_l1, divb_seam_max)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
hsinteger(kind=I4P)inFinite difference half stencil, <= ngc.
bandinteger(kind=I4P)inSeam-local band width, in cells.
dxyzreal(kind=R8P)inBlocks space steps [3, nb].
is_nulllogicalinNull directions.
seaminteger(kind=I4P)inSeam faces flags [nb, 6] (0: not a seam face).
qreal(kind=R8P)inConservative variables.
divb_maxreal(kind=R8P)outMaximum of |div B|.
divb_l1real(kind=R8P)outSum of |div B| dV.
divb_seam_maxreal(kind=R8P)outMaximum of |div B| over the seam-local cells.

Call graph

compute_positivity_factors ​

Compute the cell factor Lambda of every interior cell into lam(1,:,:,:,:) (the other components untouched) and count the cells whose backbone is not admissible (Lambda = 0 there: the floors, if enabled, take over) and those with a non-finite high-order face flux (Lambda = 0 too: a NaN or infinite flux carries no information, and every comparison with it is false, so the corner factors would keep it; tested on the bit pattern as count_nonfinite).

fortran
subroutine compute_positivity_factors(ni, nj, nk, ngc, blocks_number, gamma, ch, damping, hs, dt, g, has_phi, phi, dxyz, is_null, q, q_aux, flx, fly, flz, gc, lam, bad, nonfinite)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
gammareal(kind=R8P)inSpecific heats ratio.
chreal(kind=R8P)inGLM cleaning speed (EGLM only).
dampingreal(kind=R8P)inGLM damping rate (EGLM only).
hsinteger(kind=I4P)inHalf stencil of the high-order sources.
dtreal(kind=R8P)inForward-Euler step of the stage.
greal(kind=R8P)inGravity (issue #73), zero without it.
has_philogicalinThe cell potential is applied (issue #81).
phireal(kind=R8P)inGravitational potential (read with has_phi).
dxyzreal(kind=R8P)inBlocks space steps [3, nb].
is_nulllogicalinNull directions.
qreal(kind=R8P)inConservative variables (ghosts updated).
q_auxreal(kind=R8P)inAuxiliary variables.
flxreal(kind=R8P)inX-face high-order fluxes.
flyreal(kind=R8P)inY-face high-order fluxes.
flzreal(kind=R8P)inZ-face high-order fluxes.
gcreal(kind=R8P)inGravity energy correction (zero without it).
lamreal(kind=R8P)inoutCell factors (component 1).
badinteger(kind=I4P)outCells with an inadmissible backbone.
nonfiniteinteger(kind=I4P)outCells with a non-finite high-order face flux.

Call graph

compute_seam_positivity_factors ​

Recompute the factor of the cells beside a 2:1 seam with the seam faces' backbone and high-order fluxes overridden (issue #50, D1: per-stage seam flux synchronisation). Cell n is cell(1:4,n) = (i, j, k, b); its face fec (1..6: -x, +x, -y, +y, -z, +z) takes olo(:,fec,n) and ohi(:,fec,n) where omask(fec,n), the backbone flux of q and the high-order flux of flx/fly/flz elsewhere, exactly as compute_positivity_factors. dbad and dnonfinite return the change of the two counts against the factors without the overrides, which compute_positivity_factors has already counted.

fortran
subroutine compute_seam_positivity_factors(ngc, gamma, ch, damping, hs, dt, g, has_phi, phi, dxyz, is_null, q, q_aux, flx, fly, flz, gc, ncells, cell, omask, olo, ohi, lam, dbad, dnonfinite)

Arguments

NameTypeIntentAttributesDescription
ngcinteger(kind=I4P)inGhost cells number.
gammareal(kind=R8P)inSpecific heats ratio.
chreal(kind=R8P)inGLM cleaning speed (EGLM only).
dampingreal(kind=R8P)inGLM damping rate (EGLM only).
hsinteger(kind=I4P)inHalf stencil of the high-order sources.
dtreal(kind=R8P)inForward-Euler step of the stage.
greal(kind=R8P)inGravity (issue #73), zero without it.
has_philogicalinThe cell potential is applied (issue #81).
phireal(kind=R8P)inGravitational potential (read with has_phi).
dxyzreal(kind=R8P)inBlocks space steps [3, nb].
is_nulllogicalinNull directions.
qreal(kind=R8P)inConservative variables (ghosts updated).
q_auxreal(kind=R8P)inAuxiliary variables.
flxreal(kind=R8P)inX-face high-order fluxes.
flyreal(kind=R8P)inY-face high-order fluxes.
flzreal(kind=R8P)inZ-face high-order fluxes.
gcreal(kind=R8P)inGravity energy correction (zero without it).
ncellsinteger(kind=I4P)inSeam cells.
cellinteger(kind=I4P)inSeam cells (i, j, k, b) [4, ncells].
omasklogicalinOverridden faces [6, ncells].
oloreal(kind=R8P)inOverride backbone fluxes [nv, 6, ncells].
ohireal(kind=R8P)inOverride high-order fluxes [nv, 6, ncells].
lamreal(kind=R8P)inoutCell factors (component 1).
dbadinteger(kind=I4P)outChange of the inadmissible backbones count.
dnonfiniteinteger(kind=I4P)outChange of the non-finite cells count.

Call graph

compute_backbone_fluxes ​

Compute the backbone flux of n face state pairs of direction d (issue #50: the fine faces of a 2:1 seam take the coarse donor cell as their outer state).

fortran
subroutine compute_backbone_fluxes(n, d, gamma, ch, qL, qR, flo)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I4P)inFaces number.
dinteger(kind=I4P)inDirection, 1=x, 2=y, 3=z.
gammareal(kind=R8P)inSpecific heats ratio.
chreal(kind=R8P)inGLM cleaning speed (EGLM only).
qLreal(kind=R8P)inLeft states [nv, n].
qRreal(kind=R8P)inRight states [nv, n].
floreal(kind=R8P)outBackbone fluxes [nv, n].

Call graph

positivity_cell_factor ​

The factor of one cell from its backbone update qb, the antidiffusive differences dlt(:,1:nf) of its active faces and the source difference dsrc: status 1 (and lc = 0) if the backbone is not admissible, 2 (and lc = 0) if a face difference is not finite (a NaN passes every comparison of the corners), else 0 with lc the largest factor of the corner box.

Attributes: pure

fortran
subroutine positivity_cell_factor(nf, qb, dlt, dsrc, lc, status)

Arguments

NameTypeIntentAttributesDescription
nfinteger(kind=I4P)inActive faces.
qbreal(kind=R8P)inBackbone update.
dltreal(kind=R8P)inAntidiffusive differences.
dsrcreal(kind=R8P)inSource difference.
lcreal(kind=R8P)outCell factor.
statusinteger(kind=I4P)out0 admissible, 1 inadmissible backbone, 2 non-finite.

Call graph

blend_positivity_fluxes ​

Blend the face fluxes of direction d with the backbone: F <- F^LLF + theta (F - F^LLF), theta the smaller factor of the two cells (ghost factors from the exchange; a ghost never written keeps 1, so a physical-boundary face takes the interior cell's factor). Faces with theta = 1 are left untouched (bitwise), and counted otherwise; a face with theta = 0 takes the backbone flux itself (0 * NaN would keep a non-finite high-order flux).

fortran
subroutine blend_positivity_fluxes(d, di, dj, dk, ni, nj, nk, ngc, blocks_number, gamma, ch, q, lam, fl, limited)

Arguments

NameTypeIntentAttributesDescription
dinteger(kind=I4P)inDirection, 1=x, 2=y, 3=z.
diinteger(kind=I4P)inUnit step along d.
djinteger(kind=I4P)inUnit step along d.
dkinteger(kind=I4P)inUnit step along d.
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
gammareal(kind=R8P)inSpecific heats ratio.
chreal(kind=R8P)inGLM cleaning speed (EGLM only).
qreal(kind=R8P)inConservative variables.
lamreal(kind=R8P)inCell factors (component 1).
flreal(kind=R8P)inoutFace fluxes of direction d.
limitedinteger(kind=I4P)outFaces with theta < 1.

Call graph

blend_inadmissible_ghosts ​

Blend every inadmissible face ghost of q toward the adjacent interior cell and count the ghosts blended.

fortran
subroutine blend_inadmissible_ghosts(ni, nj, nk, ngc, blocks_number, is_null, q, blended)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
is_nulllogicalinNull directions.
qreal(kind=R8P)inoutConservative variables (ghosts updated).
blendedinteger(kind=I4P)outGhosts blended.

Call graph

add_eglm_sources ​

Add the nonconservative EGLM sources to the residuals of the interior cells (Derigs et al. 2018, eqs. 3.16-3.18; issue #47, section 3.3): -(div B) (0, B, u.B, u, 0) - (u.grad psi) (0, 0, psi, 0, 1) in the order (rho, rho u, E, B, psi). div B and grad psi are the centred finite differences of the library, half stencil hs (order 2 hs, the WENO order: second-order sources drop the Alfven wave to order 2.26, P0), null directions weighted zero. Local sources in every Runge-Kutta stage, never in the fluxes: momentum, energy and B are conserved up to these O(div B) terms. The 3-term sums are order-independent (mhd_sum3). The caller has refreshed the ghost cells and the auxiliary variables of q.

fortran
subroutine add_eglm_sources(ni, nj, nk, ngc, blocks_number, hs, dxyz, is_null, q, q_aux, dq)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
hsinteger(kind=I4P)inFinite difference half stencil, <= ngc.
dxyzreal(kind=R8P)inBlocks space steps [3, nb].
is_nulllogicalinNull directions.
qreal(kind=R8P)inConservative variables.
q_auxreal(kind=R8P)inAuxiliary variables.
dqreal(kind=R8P)inoutResiduals.

Call graph

add_eglm_sources_limited ​

Add the EGLM sources with the positivity limiter (issue #47, D-9): in a cell with factor Lambda < 1 the second-order sources plus Lambda times the difference to the order-2 hs ones (the sources are linear in div B and u.grad psi, so the two scalars are blended); with Lambda = 1 the arithmetic of add_eglm_sources.

fortran
subroutine add_eglm_sources_limited(ni, nj, nk, ngc, blocks_number, hs, dxyz, is_null, q, q_aux, lam, dq)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
hsinteger(kind=I4P)inFinite difference half stencil, <= ngc.
dxyzreal(kind=R8P)inBlocks space steps [3, nb].
is_nulllogicalinNull directions.
qreal(kind=R8P)inConservative variables.
q_auxreal(kind=R8P)inAuxiliary variables.
lamreal(kind=R8P)inCell factors (component 1).
dqreal(kind=R8P)inoutResiduals.

Call graph

add_glm_damping ​

Add the damping source to the residuals of the interior cells, dq(psi) = dq(psi) - (alpha c_h / L) psi, as GLM (issue #47, section 3.3). Only psi is damped: the total energy is unchanged, so the removed cleaning energy psi^2 / 2 becomes thermal energy (the pressure grows) and the energy drift stays bounded by the div(B) sources.

fortran
subroutine add_glm_damping(ni, nj, nk, ngc, blocks_number, damping, q, dq)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid dimensions.
njinteger(kind=I4P)inGrid dimensions.
nkinteger(kind=I4P)inGrid dimensions.
ngcinteger(kind=I4P)inGrid dimensions.
blocks_numberinteger(kind=I4P)inActual blocks number.
dampingreal(kind=R8P)inDamping rate alpha c_h / L.
qreal(kind=R8P)inConservative variables.
dqreal(kind=R8P)inoutResiduals.

Call graph

face_split_fluxes ​

Split adapter of the shared face kernel: the MHD split with EGLM cleaning.

Attributes: pure

fortran
subroutine face_split_fluxes(gamma, ch, d, S, is_characteristic, qs, qas, fsplit, er, mu)

Arguments

NameTypeIntentAttributesDescription
gammareal(kind=R8P)inSpecific heats ratio.
chreal(kind=R8P)inGLM cleaning speed.
dinteger(kind=I4P)inDirection, 1=x, 2=y, 3=z.
Sinteger(kind=I4P)inWENO stencil half-width, S <= S_MAX.
is_characteristiclogicalinCharacteristic (or conservative) variables.
qsreal(kind=R8P)inStencil conservative variables.
qasreal(kind=R8P)inStencil auxiliary variables.
fsplitreal(kind=R8P)outSplit fields in the WENO upwind layout.
erreal(kind=R8P)outRight eigenvectors.
mureal(kind=R8P)outMagnitude of each field (WENO descaler).

Call graph

backbone_face_flux ​

Backbone adapter of the positivity limiter: the Lax-Friedrichs flux with the Wu speed, at least ch.

Attributes: pure

fortran
subroutine backbone_face_flux(gamma, ch, d, qL, qR, f)

Arguments

NameTypeIntentAttributesDescription
gammareal(kind=R8P)inSpecific heats ratio.
chreal(kind=R8P)inGLM cleaning speed.
dinteger(kind=I4P)inDirection, 1=x, 2=y, 3=z.
qLreal(kind=R8P)inLeft state.
qRreal(kind=R8P)inRight state.
freal(kind=R8P)outFlux.

Call graph

cell_sources ​

Sources adapter of the positivity limiter (EGLM): the nonconservative sources with second-order (s_lo, the backbone's) and order-2 hs (s_hi) centred differences, both with the damping of psi.

Attributes: pure

fortran
subroutine cell_sources(ngc, hs, damping, dxyz, is_null, q, q_aux, i, j, k, b, s_lo, s_hi)

Arguments

NameTypeIntentAttributesDescription
ngcinteger(kind=I4P)inGhost cells number.
hsinteger(kind=I4P)inHalf stencil of the high-order sources.
dampingreal(kind=R8P)inGLM damping rate.
dxyzreal(kind=R8P)inBlock space steps.
is_nulllogicalinNull directions.
qreal(kind=R8P)inConservative variables.
q_auxreal(kind=R8P)inAuxiliary variables.
iinteger(kind=I4P)inCell indexes.
jinteger(kind=I4P)inCell indexes.
kinteger(kind=I4P)inCell indexes.
binteger(kind=I4P)inCell indexes.
s_loreal(kind=R8P)outBackbone sources.
s_hireal(kind=R8P)outHigh-order sources.

Call graph

eglm_source_scalars ​

Return div B and u.grad psi of a cell by the centred differences of half stencil hs (the arithmetic of add_eglm_sources).

Attributes: pure

fortran
subroutine eglm_source_scalars(ngc, hs, dxyz, is_null, q, q_aux, i, j, k, b, divb, upsi)

Arguments

NameTypeIntentAttributesDescription
ngcinteger(kind=I4P)inGhost cells number.
hsinteger(kind=I4P)inHalf stencil.
dxyzreal(kind=R8P)inBlock space steps.
is_nulllogicalinNull directions.
qreal(kind=R8P)inConservative variables.
q_auxreal(kind=R8P)inAuxiliary variables.
iinteger(kind=I4P)inCell indexes.
jinteger(kind=I4P)inCell indexes.
kinteger(kind=I4P)inCell indexes.
binteger(kind=I4P)inCell indexes.
divbreal(kind=R8P)outdiv B, u.grad psi.
upsireal(kind=R8P)outdiv B, u.grad psi.

Call graph

eglm_source_vector ​

Return the EGLM source vector of a cell from its div B and u.grad psi (linear in both).

Attributes: pure

fortran
subroutine eglm_source_vector(q, qa, divb, upsi, s)

Arguments

NameTypeIntentAttributesDescription
qreal(kind=R8P)inConservative variables.
qareal(kind=R8P)inAuxiliary variables.
divbreal(kind=R8P)indiv B, u.grad psi.
upsireal(kind=R8P)indiv B, u.grad psi.
sreal(kind=R8P)outSources.

Call graph

Functions ​

cleaning_energy ​

Cleaning-energy adapter of the floors kernel: psi^2 / 2, part of the EGLM energy.

Attributes: pure

Returns: real(kind=R8P)

fortran
function cleaning_energy(q) result(e)

Arguments

NameTypeIntentAttributesDescription
qreal(kind=R8P)inConservative variables.

Call graph

internal_energy ​

Internal-energy adapter of the positivity limiter: E minus the kinetic, magnetic and cleaning energies, per unit volume.

Attributes: pure

Returns: real(kind=R8P)

fortran
function internal_energy(q) result(e)

Arguments

NameTypeIntentAttributesDescription
qreal(kind=R8P)inConservative variables.

Call graph