Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

pymrm.convect

Back to modules overview

Convective-flux operators and TVD limiter functions.

View module source on GitHub

Public API

SymbolTypeSummary
ConvFluxTVDclassTVD convective face flux with its exact Jacobians, for Newton solves.
clamfunctionCompute the CLAM TVD correction in normalized-variable space.
construct_convflux_bcfunctionConstruct boundary-face upwind corrections and source terms.
construct_convflux_upwindfunctionConstruct a first-order upwind convective-flux operator.
construct_convflux_upwind_intfunctionConstruct the internal-face upwind advection operator.
minmodfunctionCompute the Minmod TVD correction in normalized-variable space.
musclfunctionCompute the MUSCL TVD correction in normalized-variable space.
osherfunctionCompute the Osher TVD correction in normalized-variable space.
smartfunctionCompute the SMART TVD correction in normalized-variable space.
stoicfunctionCompute the STOIC TVD correction in normalized-variable space.
upwindfunctionReturn zero correction (first-order upwind limiter).
vanleerfunctionCompute the van-Leer TVD correction in normalized-variable space.

ConvFluxTVD(shape, x_f, x_c = None, bc = (None, None), tvd_limiter = minmod, axis = 0, shapes_d = (None, None), format = 'csc')

Open dedicated reference page

TVD convective face flux with its exact Jacobians, for Newton solves.

Build the object once per axis, then call it with the current state in every residual evaluation. It returns the face fluxes v * c_f, with c_f the TVD face values of interp_cntr_to_stagg_tvd, and the derivative of those fluxes with respect to the state: the upwind part, the limiter part and the boundary faces together. A steady problem solved with this Jacobian converges in a few Newton steps for every limiter; deferred correction (the TVD correction in the residual, the upwind Jacobian) converges only slowly with minmod and stalls with van Leer, MUSCL and SMART (pitfalls P10).

Parameters

Notes

Call flux, jac = tvd(c, v); with shapes_d, flux, jac, jac_bc_left, jac_bc_right = tvd(c, v, d=(ext_left, ext_right)); jac_v=True appends the Jacobian with respect to v. See __call__.

The face upwind of the first interior face is the boundary value, so the Jacobian there reaches the cells that boundary value depends on, and the boundary data. The flow direction of each interior face follows v > 0; an initial guess with v = 0 everywhere gives a zero convective Jacobian. Where c_D == c_U the face is upwind and its derivative is the upwind one (the built-in limiters are also zero outside 0 < c_norm < 1). Use newton(..., damping="monotone"): undamped Newton can cycle between the pieces of MUSCL, SMART and STOIC. The sparsity pattern covers both flow directions, so it does not change when v changes sign; it contains explicit zeros, which sparse products drop.

View source on GitHub

Members

__init__(shape, x_f, x_c = None, bc = (None, None), tvd_limiter = minmod, axis = 0, shapes_d = (None, None), format = 'csc')

View source on GitHub

__call__(c, v, d = None, jac_v = False)

Evaluate the face fluxes and their Jacobians.

Parameters

Returns

View source on GitHub

clam(normalized_c_c, normalized_x_c, normalized_x_d)

Open dedicated reference page

Compute the CLAM TVD correction in normalized-variable space.

CLAM, van Leer’s curved-line advection method, is the parabola through (0, 0), (x_c, x_d) and (1, 1); on a uniform grid c_f = 2 c_c - c_c**2. On a uniform grid this curve is also van Leer’s harmonic limiter, and pymrm uses the same parabola, with the same cap at c_f = 1, for both: clam and vanleer agree on every stencil. Before pymrm 2.5.0 clam returned the Osher curve.

View source on GitHub

construct_convflux_bc(shape, x_f, x_c = None, bc = (None, None), v = 1.0, axis = 0, shapes_d = (None, None), format = 'csc')

Open dedicated reference page

Construct boundary-face upwind corrections and source terms.

Parameters

Returns

View source on GitHub

construct_convflux_upwind(shape, x_f, x_c = None, bc = (None, None), v = 1.0, axis = 0, shapes_d = (None, None), format = 'csc')

Open dedicated reference page

Construct a first-order upwind convective-flux operator.

Parameters

Returns

View source on GitHub

construct_convflux_upwind_int(shape, v = 1.0, axis = 0, format = 'csc')

Open dedicated reference page

Construct the internal-face upwind advection operator.

Parameters

Returns

View source on GitHub

minmod(normalized_c_c, normalized_x_c, normalized_x_d)

Open dedicated reference page

Compute the Minmod TVD correction in normalized-variable space.

View source on GitHub

muscl(normalized_c_c, normalized_x_c, normalized_x_d)

Open dedicated reference page

Compute the MUSCL TVD correction in normalized-variable space.

Uniform grid: 2 c_c up to 1/4, c_c + 1/4 up to 3/4, then 1.

View source on GitHub

osher(normalized_c_c, normalized_x_c, normalized_x_d)

Open dedicated reference page

Compute the Osher TVD correction in normalized-variable space.

View source on GitHub

smart(normalized_c_c, normalized_x_c, normalized_x_d)

Open dedicated reference page

Compute the SMART TVD correction in normalized-variable space.

View source on GitHub

stoic(normalized_c_c, normalized_x_c, normalized_x_d)

Open dedicated reference page

Compute the STOIC TVD correction in normalized-variable space.

Piecewise: the SMART line c_f = k c_c up to its intersection with the central-difference line, then central differencing up to c_c = x_c, then QUICK, then c_f = 1. On a uniform grid (x_c = 1/2, x_d = 3/4) this is 3 c_c, (1 + c_c)/2, 3/8 + 3 c_c/4 and 1, with breaks at 1/5, 1/2 and 5/6.

View source on GitHub

upwind(normalized_c_c, normalized_x_c, normalized_x_d)

Open dedicated reference page

Return zero correction (first-order upwind limiter).

View source on GitHub

vanleer(normalized_c_c, normalized_x_c, normalized_x_d)

Open dedicated reference page

Compute the van-Leer TVD correction in normalized-variable space.

The curve is the parabola through (0, 0), (x_c, x_d) and (1, 1), which on a uniform grid is van Leer’s harmonic limiter and also his CLAM curve (c_f = 2 c_c - c_c**2); clam returns the same values. It rises above c_f = 1 when x_d - x_c > x_c (1 - x_c), for example next to a boundary where the upstream point is a face half a cell away (x_c = 1/3, x_d = 2/3); the correction is capped at 1 - c_c to stay bounded. The cap acts only above c_c = x_c and does not reduce the order.

View source on GitHub