zoomy_core.symsolver.strategies.chorin

zoomy_core.symsolver.strategies.chorin#

The Chorin projection solver, written once for every backend: a hyperbolic predictor, a pressure solve and a correction, from the three systems of the model’s pressure split (pred, press, corr). time_order 2 / 3 wraps stages in SSP-RK2 / RK3 and imex=Imex.ssp2 uses IMEX-SSP2(2,2,2) with projected stages.

Module Contents#

Classes#

Projection

What a projection stage solves for: the pressure, or its increment over a lagged one.

ChorinTemplate

The projection solver of a pressure split pred / press / corr, with nsm the predictor pred; step is the projection step and march, dt and initial_aux are inherited from HyperbolicTemplate.

Functions#

check_overlap

Raise unless layers overlap rings cover template’s step (overlap_rings).

pressure

Solve press for its own rows with the rest of Q frozen: one linear solve (GMRES) of the affine residual A(P) = R(P) - R(0), or Newton from the current pressure with newton=(tol, maxit). dirichlet=(mask, G): the cells mask keep the pressure G (the rows of the cells mask are the identity: the subdomain solve of overlapping Schwarz, the other cells’ equations reading G there).

correct

Overwrite the rows of corr by its update formula (the correction by the solved pressure).

predictor_nsm

The predictor NSM of a pressure split on the full state (pad_to_square): positive Rusanov, the hydrostatic rescaling on every row but h, b and the pressure rows, press and corr sizing the LSQ stencil; reconstruction a ReconstructionSpec (default order 1). Pass it with press, corr to a symbolic Chorin solver’s setup.

API#

class zoomy_core.symsolver.strategies.chorin.Projection#

Bases: zoomy_core.misc.options.Option

What a projection stage solves for: the pressure, or its increment over a lagged one.

Initialization

Initialize self. See help(type(self)) for accurate signature.

standard#

‘standard’

increment#

‘increment’

class zoomy_core.symsolver.strategies.chorin.ChorinTemplate(pred, press, corr, *, cfl, time_order=1, pressure_newton=None, projection=Projection.standard, **config)#

Bases: zoomy_core.symsolver.strategies.hyperbolic.HyperbolicTemplate

The projection solver of a pressure split pred / press / corr, with nsm the predictor pred; step is the projection step and march, dt and initial_aux are inherited from HyperbolicTemplate.

References

Initialization

Set the split and the configuration of HyperbolicTemplate; cfl is divided by 2 order - 1.

Args

  • pressure_newton: (tol, maxit) for a nonlinear pressure constraint solved by Newton, else None.

  • projection: a Projection.

step(Q, Qaux, p, time, dt, mesh, *, dt_rule=None, dirichlet=None, pressures=None)#

One time step: the outer SSP-RK over projection stages; with imex=Imex.ssp2 every stage solves the implicit source and is then projected.

Args

  • dt_rule: the first stage picks dt.

  • dirichlet: (mask, (P_1, .., P_m)): the pressure solve of SSP-RK stage i keeps the cells mask at the pressure P_i (the overlap of a Schwarz-coupled participant, precice_march); not with Imex.ssp2.

  • pressures: a list that receives each stage’s pressure.

Returns

(Q, Qaux, dt).

overlap_rings()#

The fewest overlap rings of precice_march in this configuration: 2 per SSP-RK projection stage (the predictor’s flux and its derivative aux each reach one ring further), plus one. Measured at reconstruction order 1 with a one-ring LSQ stencil (gate 54, VAM(1)): one ring less is off by 1e-13 .. 5e-8 in some configurations (the increment projection’s lagged correction reaches one ring further); wider derivative stencils need more.

precice_march(Q, Qaux, p, time, mesh)#

The march as one preCICE participant coupled by overlapping Schwarz: the mesh reaches across the coupled interface into the peer’s domain (the overlap, zoomy_core.mesh.overlap), one step per time window of an implicit coupling scheme. Every coupling iteration takes the whole step from the window start, the overlap holding the peer’s state at the window start: the predictor and the aux run over the overlap too (the overlap must be wide enough that their invalid outer rings do not reach the own cells’ stencils), the pressure solve keeps the overlap’s pressure at the peer’s of its last iteration (a Dirichlet subdomain solve) and the participant writes its mirror cells (overlap_states, all rows). preCICE repeats the window until the exchanged data converge; at the fixed point every own-cell equation of the step reads the peer’s values, the single-domain step (to the coupling and pressure tolerances). With several SSP-RK stages (time_order 2, 3) the exchanged rows are the state, then each stage’s pressure (the Dirichlet data of that stage’s solve); the overlap must then cover the stencils of every stage (overlap_rings, which the backends enforce). Constant step = the window, reconstruction order 1, no MOOD, no IMEX-SSP2, no implicit diffusion (a second solve over both domains).

References

stage(Q, Qaux, p, time, dt, mesh, dt_rule=None, dirichlet=None)#

One projection stage: predictor, pressure solve, correction; returns (Q, dt).

Args

  • dt_rule: dt is chosen only by the predictor’s flux, so the stage keeps the aux it is given.

  • dirichlet: see step.

project(Q, p, time, dt, mesh, lag=None, dirichlet=None)#

The pressure solve and the correction of Q.

Args

  • lag: None: solve for the pressure. Else the lagged pressure P^n: correct with it, solve press on that state for dP (the corrector is linear in the pressure) and correct Q with P^n + dP.

  • dirichlet: (mask, P): the pressure of the cells mask is P (with lag, the increment there is P - P^n).

predictor(Q, Qaux, p, time, dt, mesh, dt_rule=None)#

Euler flux step, then the implicit slots as Lie sub-steps (implicit with imex, else explicit Euler); returns (Q, dt).

zoomy_core.symsolver.strategies.chorin.check_overlap(template, layers)#

Raise unless layers overlap rings cover template’s step (overlap_rings).

zoomy_core.symsolver.strategies.chorin.pressure(press, Q, p, time, dt, mesh, newton=None, dirichlet=None)#

Solve press for its own rows with the rest of Q frozen: one linear solve (GMRES) of the affine residual A(P) = R(P) - R(0), or Newton from the current pressure with newton=(tol, maxit). dirichlet=(mask, G): the cells mask keep the pressure G (the rows of the cells mask are the identity: the subdomain solve of overlapping Schwarz, the other cells’ equations reading G there).

References

zoomy_core.symsolver.strategies.chorin.correct(corr, Q, p, time, dt, mesh)#

Overwrite the rows of corr by its update formula (the correction by the solved pressure).

zoomy_core.symsolver.strategies.chorin.predictor_nsm(pred, press, corr, reconstruction=None)#

The predictor NSM of a pressure split on the full state (pad_to_square): positive Rusanov, the hydrostatic rescaling on every row but h, b and the pressure rows, press and corr sizing the LSQ stencil; reconstruction a ReconstructionSpec (default order 1). Pass it with press, corr to a symbolic Chorin solver’s setup.