zoomy_core.symsolver.discretization.residual

zoomy_core.symsolver.discretization.residual#

The semi-discrete residual and the pieces of one time step, written once for every backend: RK stage, MOOD, aux, implicit slots and hygiene. They compose the vocabulary and are composed by the strategies.

Module Contents#

Functions#

residual

Semi-discrete right-hand side -div(face terms) - interior NCP, plus the explicit source and diffusion slots, and the implicit ones unless an implicit stage takes them.

stage_aux

Pointwise aux of a stage state (e.g. hinv = 1/h).

explicit_step

One SSP-RK step of the method of lines, of order rk (default the reconstruction order).

mood_step

A-posteriori MOOD: an order-2 candidate step, inadmissible cells redone at first order, and the whole step at first order if that still fails. The repairs keep the candidate’s dt; with dt_rule (the step from the face wave speeds) at most that, from their own face speeds, as the candidate’s are those of the order-2 states and do not bound the first-order Riemann problems (ANALYSIS 48).

full_aux

Pointwise aux, then the derivative (mesh-gradient) aux, whose boundary samples are the BC ghosts at time; coupled: (own, face) per coupled face, whose ghost samples are then the mirror images 2 face - own of the coupling’s face states.

derivative_rows

(rows, functions): the state rows the derivative aux differentiates (static tuple) and whether it differentiates aux functions too.

check_derivative_aux

Raise at setup on a derivative aux the backend would read as 0: an entry of a system’s aux_registry / aux_input_registry that is not a plain derivative (a limited_derivative no symbolic solver computes), or whose target this backend does not differentiate (targets, e.g. ("state", "function"); unknown: a compound such as h*zeta that no backend computes, which the model must write by the chain rule over its state rows).

post_step

Model hygiene on the new state, then its aux; returns (Q, Qaux).

implicit_source

Implicit Euler on the source at time, Y - Q - dt S(Y, aux(Y)) = 0, by a per-cell root solve with the derivative aux frozen at Q.

implicit_step

The SystemModel’s implicit slots over the step ending at time: implicit diffusion, then implicit Euler on the source.

implicit_stage

The implicit part of an IMEX-RK stage at time over dt (A_ii times the step): X - Y - dt (D(X) + S(X)) = 0, D the two-point part of the implicit diffusion (diffusion_tpfa), S the implicit source. Without diffusion a per-cell root (implicit_source), else one Newton solve over the mesh with the pointwise aux following the iterate and the derivative aux frozen at Y.

imex_step

One step of the IMEX Runge-Kutta tableau: each stage is an explicit (MOOD-guarded) Euler step of the residual without implicit slots plus the implicit solve of the stage (implicit_stage). The implicit part g is the source and the two-point part of the implicit diffusion; the rest of that diffusion’s flux (diffusion_correction, zero in 1-D and on Cartesian faces without mixed entries) is in the explicit part f.

API#

zoomy_core.symsolver.discretization.residual.residual(nsm, Q, Qaux, p, time, dt, mesh, order, demote=False, coupled=None, implicit_terms=True, dt_rule=None, split_diffusion=False)#

Semi-discrete right-hand side -div(face terms) - interior NCP, plus the explicit source and diffusion slots, and the implicit ones unless an implicit stage takes them.

Args

  • demote: MOOD demotion of the reconstruction (see reconstruct).

  • coupled: (mask, flux), faces carrying a shared answer.

  • dt_rule: dt is not known yet; the face kernel also returns the wave speed S and dt = dt_rule(S); with the order-2 edge source at most dt_rule of the cells’ own speeds too, as that term moves the cell states (ANALYSIS 48).

  • split_diffusion: without implicit_terms, the implicit diffusion’s part beyond its two-point fluxes (diffusion_correction) stays explicit, here (IMEX-RK: the two-point part is the stage’s implicit term).

Returns

dQ, or (dQ, dt) with dt_rule.

References

zoomy_core.symsolver.discretization.residual.stage_aux(nsm, Q, Qaux, p, time, dt, mesh)#

Pointwise aux of a stage state (e.g. hinv = 1/h).

zoomy_core.symsolver.discretization.residual.explicit_step(nsm, Q, Qaux, p, time, dt, mesh, order, demote=False, coupled=None, implicit_terms=True, rk=None, dt_rule=None, split_diffusion=False)#

One SSP-RK step of the method of lines, of order rk (default the reconstruction order).

Args

  • dt_rule: the first stage picks dt from its own face wave speeds.

  • split_diffusion: see residual.

Returns

Q, or (Q, dt) with dt_rule.

References

zoomy_core.symsolver.discretization.residual.mood_step(nsm, Q, Qaux, p, time, dt, mesh, order, coupled=None, implicit_terms=True, rk=None, dt_rule=None, split_diffusion=False)#

A-posteriori MOOD: an order-2 candidate step, inadmissible cells redone at first order, and the whole step at first order if that still fails. The repairs keep the candidate’s dt; with dt_rule (the step from the face wave speeds) at most that, from their own face speeds, as the candidate’s are those of the order-2 states and do not bound the first-order Riemann problems (ANALYSIS 48).

References

zoomy_core.symsolver.discretization.residual.full_aux(nsm, Q, Qaux, p, time, dt, mesh, coupled=None)#

Pointwise aux, then the derivative (mesh-gradient) aux, whose boundary samples are the BC ghosts at time; coupled: (own, face) per coupled face, whose ghost samples are then the mirror images 2 face - own of the coupling’s face states.

zoomy_core.symsolver.discretization.residual.derivative_rows(nsm)#

(rows, functions): the state rows the derivative aux differentiates (static tuple) and whether it differentiates aux functions too.

zoomy_core.symsolver.discretization.residual.check_derivative_aux(systems, targets, backend)#

Raise at setup on a derivative aux the backend would read as 0: an entry of a system’s aux_registry / aux_input_registry that is not a plain derivative (a limited_derivative no symbolic solver computes), or whose target this backend does not differentiate (targets, e.g. ("state", "function"); unknown: a compound such as h*zeta that no backend computes, which the model must write by the chain rule over its state rows).

Args

  • systems: the NSMs the backend runs (a Chorin split: predictor, pressure, corrector).

  • targets: the target_kinds of derivative entries this backend computes.

  • backend: its name, for the message.

zoomy_core.symsolver.discretization.residual.post_step(nsm, Q, Qaux, p, time, dt, mesh)#

Model hygiene on the new state, then its aux; returns (Q, Qaux).

zoomy_core.symsolver.discretization.residual.implicit_source(nsm, Q, Qaux, p, time, dt, mesh)#

Implicit Euler on the source at time, Y - Q - dt S(Y, aux(Y)) = 0, by a per-cell root solve with the derivative aux frozen at Q.

zoomy_core.symsolver.discretization.residual.implicit_step(nsm, Q, Qaux, p, time, dt, mesh)#

The SystemModel’s implicit slots over the step ending at time: implicit diffusion, then implicit Euler on the source.

zoomy_core.symsolver.discretization.residual.implicit_stage(nsm, Y, Qaux, p, time, dt, mesh)#

The implicit part of an IMEX-RK stage at time over dt (A_ii times the step): X - Y - dt (D(X) + S(X)) = 0, D the two-point part of the implicit diffusion (diffusion_tpfa), S the implicit source. Without diffusion a per-cell root (implicit_source), else one Newton solve over the mesh with the pointwise aux following the iterate and the derivative aux frozen at Y.

References

zoomy_core.symsolver.discretization.residual.imex_step(nsm, Q, Qaux, p, time, dt, mesh, order, tableau, mood=False, coupled=None, dt_rule=None, project=None)#

One step of the IMEX Runge-Kutta tableau: each stage is an explicit (MOOD-guarded) Euler step of the residual without implicit slots plus the implicit solve of the stage (implicit_stage). The implicit part g is the source and the two-point part of the implicit diffusion; the rest of that diffusion’s flux (diffusion_correction, zero in 1-D and on Cartesian faces without mixed entries) is in the explicit part f.

Args

  • project: Chorin: project(Y, time, dt, i) -> (Y', B) maps stage i (the final combination: i omitted) onto the constraint, B = Y' - Y on the corrected rows.

  • dt_rule: dt from the cell states’ wave speeds; returns (Q, dt).

References