Convective-flux operators and TVD limiter functions.
Public API¶
| Symbol | Type | Summary |
|---|---|---|
clam | function | Compute the CLAM TVD correction in normalized-variable space. |
construct_convflux_bc | function | Construct boundary-face upwind corrections and source terms. |
construct_convflux_upwind | function | Construct a first-order upwind convective-flux operator. |
construct_convflux_upwind_int | function | Construct the internal-face upwind advection operator. |
minmod | function | Compute the Minmod TVD correction in normalized-variable space. |
muscl | function | Compute the MUSCL TVD correction in normalized-variable space. |
osher | function | Compute the Osher TVD correction in normalized-variable space. |
smart | function | Compute the SMART TVD correction in normalized-variable space. |
stoic | function | Compute the STOIC TVD correction in normalized-variable space. |
upwind | function | Return zero correction (first-order upwind limiter). |
vanleer | function | Compute the van-Leer TVD correction in normalized-variable space. |
clam(normalized_c_c, normalized_x_c, normalized_x_d)¶
Compute the CLAM TVD correction in normalized-variable space.
construct_convflux_bc(shape, x_f, x_c = None, bc = (None, None), v = 1.0, axis = 0, shapes_d = (None, None), format = 'csc')¶
Construct boundary-face upwind corrections and source terms.
Parameters¶
shape(tuple[int, ...]) Cell-centered field shape.x_f(array_like) Face coordinates alongaxis.x_c(array_like, optional) Cell-center coordinates.bc(tuple[dict | None, dict | None], optional) Left and right boundary-condition dictionaries with keysa,b, anddfora * dc/dn + b * c = dwithnthe outward normal;{"outflow": True}marks a pure-outflow boundary.v(float or array_like, optional) Face velocity field.axis(int, optional) Convection axis.shapes_d(tuple[tuple | None, tuple | None], optional) Optional source-vector shapes for inhomogeneous boundary terms;dis then a coefficient on the external vector.format({‘csc’, ‘csr’}, optional) Sparse format for returned operator matrices.
Returns¶
tuple(conv_matrix_bc, conv_bc)whenshapes_dis not supplied, or(conv_matrix_left, conv_bc_left, conv_matrix_right, conv_bc_right)otherwise.
construct_convflux_upwind(shape, x_f, x_c = None, bc = (None, None), v = 1.0, axis = 0, shapes_d = (None, None), format = 'csc')¶
Construct a first-order upwind convective-flux operator.
Parameters¶
shape(tuple[int, ...] or int) Cell-centered field shape.x_f(array_like) Face coordinates alongaxis.x_c(array_like, optional) Cell-center coordinates. If omitted, arithmetic midpoints are used.bc(tuple[dict | None, dict | None], optional) Left and right boundary-condition dictionaries with keysa,b, anddfora * dc/dn + b * c = dwithnthe outward normal (at the left enddc/dn = -dc/dx).{"outflow": True}marks a pure-outflow boundary: the face value is the adjacent cell value (a stirred volume’s exit). It is meant for faces where material leaves; if flow enters there, the face still carries the adjacent cell value.v(float or array_like, optional) Face velocity field. Scalars and broadcastable arrays are accepted.axis(int, optional) Convection axis.shapes_d(tuple[tuple | None, tuple | None], optional) Optional source-vector shapes for boundary inhomogeneities. Withshapes_dthe dictionary’sdis a coefficient on that external vector (used = 1to pass the values through the vector).format({‘csc’, ‘csr’}, optional) Sparse format for returned operator matrices.
Returns¶
tupleWithoutshapes_d:(conv_matrix, conv_bc). Withshapes_d:(conv_matrix, conv_bc_left, conv_bc_right).
construct_convflux_upwind_int(shape, v = 1.0, axis = 0, format = 'csc')¶
Construct the internal-face upwind advection operator.
Parameters¶
shape(tuple[int, ...]) Cell-centered field shape.v(float or array_like, optional) Face velocity field.axis(int, optional) Convection axis.format({‘csc’, ‘csr’}, optional) Sparse format of the returned matrix.
Returns¶
scipy.sparse.csc_array or scipy.sparse.csr_arraySparse matrix mapping cell-centered values to interior face fluxes.
minmod(normalized_c_c, normalized_x_c, normalized_x_d)¶
Compute the Minmod TVD correction in normalized-variable space.
muscl(normalized_c_c, normalized_x_c, normalized_x_d)¶
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.
osher(normalized_c_c, normalized_x_c, normalized_x_d)¶
Compute the Osher TVD correction in normalized-variable space.
smart(normalized_c_c, normalized_x_c, normalized_x_d)¶
Compute the SMART TVD correction in normalized-variable space.
stoic(normalized_c_c, normalized_x_c, normalized_x_d)¶
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.
upwind(normalized_c_c, normalized_x_c, normalized_x_d)¶
Return zero correction (first-order upwind limiter).
vanleer(normalized_c_c, normalized_x_c, normalized_x_d)¶
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). 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.