API Contracts
HyperCloudCore is extended by subtyping one of its abstract types and implementing a few methods. This page lists, per extension point, what is required and what is optional, followed by the reference for every method in API.jl.
Import the methods you extend (import HyperCloudCore: flux, max_eigenvalue, ...) or qualify them (HyperCloudCore.flux(...) = ...).
A new PDE (HyperbolicPDE{D, M, T})
| Method | Required | Used by |
|---|---|---|
flux(eq, U) -> Flux{D,M,T} | always | all schemes |
max_eigenvalue(eq, U, d) -> T | always | Rusanov flux, CFL estimate |
velocity(eq, U, d) -> SMatrix{M,M,T} | for Upwind (Tiwari, Praveen), WENO, UpwindFlux | advection speed / Jacobian |
evaluate_nc_jump(eq, f_L, f_R, dist) -> Flux | for non-conservative PDEs | MUSCL, Upwind Classic |
fluid_velocity(eq, U) -> Space{D,T} | for Lagrangian movers | LagrangianMover, ScaledLagrangianMover |
max_eigenvalue(eq, U, d, shift) -> T | optional | exact relative wave speed on moving grids |
is_admissible(eq, U) -> Bool | optional | MOOD's physical admissibility detection (default: all components finite) |
prim2cons, cons2prim | optional | conversions (identity by default) |
Write PDE-dependent code against these methods rather than against fields of eq. On moving grids the schemes receive the PDE wrapped in an ALEFrame, and only the API methods are forwarded through that wrapper.
A new source term
| Kind | Methods |
|---|---|
AbstractExplicitSourceTerm | evaluate_source(st, U, i, pg, t) |
AbstractImplicitSourceTerm | evaluate_source(st, U, i, pg, t), implicit_solve(st, U_in, γ, i, pg, t); optional pre_solve_update!(st, Y, pg, t) |
implicit_solve must return the solution $U$ of $U - \gamma S(U) = U_{\text{in}}$ for the particle i.
A new spatial scheme (DivergenceInterpolator)
| Method | Required | Purpose |
|---|---|---|
(interp)(eq, i, f_i, nb_slice, pg, ib, strategy::MOODStrategy) -> State | always | $\nabla\cdot F$ at particle i |
_extract_order(interp) -> Int | always | maximum consistency order |
update_size!(interp, N) | always (may be a no-op) | grow internal per-particle buffers |
update_content!(interp, i, f_i, nb_slice, pg, ib) | optional | pre-gather pass (e.g. cache gradients) |
_divergence_degree(interp) -> Int | optional | MLS degree for the CFL estimate (default: the order) |
_order_reach(interp, strategy) -> Int | optional | hops over which fluxes depend on neighbours' orders (default 0) |
has_cached_gradients(interp), cached_gradients(interp) | optional | enables MOODu2's curvature test |
Inside the functor:
- Read the particle's order from
pg.core.particle_orders[i](the consistency order) and lower it locally if the neighbourhood is too small. - Neighbour states are in
ib.f[k]and differences inib.df[k]fork ∈ nb_slice;pg.neighbor.indices[k]is the neighbour's particle index. - Write per-neighbour scratch only to slots
k ∈ nb_sliceofib(they are disjoint between particles, which makes the passes thread-safe). - If the scheme caches per-particle data in
update_content!,_order_reachmust cover how far that data is read: MUSCL reads neighbours' gradients, so its reach is at least 1.
Define the optional hooks after the scheme's type, next to the scheme; the time-stepping files only refer to the abstract type.
A new MOOD criterion or strategy
See Multi-Dimensional Optimal Order Detection (MOOD) for the signatures of the criterion functor, _get_interface_orders and trigger_halo!.
A new grid mover, boundary condition or weight function
- Grid mover:
grid_velocity(mover, eq, p, U, pg, t) -> Space{D,T}; see Moving Grids (ALE). - Boundary condition: functor
(bc)(pg, rhos_buffer, tag, ts, eq, t); see Boundary Conditions. - Weight function: functor on the squared distance plus
get_cutoff; see MLS Weight Functions.
Reference
HyperCloudCore._divergence_degree — Method
_divergence_degree(interp::DivergenceInterpolator) -> IntPolynomial degree of the MLS fit used for the divergence at the maximum order (CFL estimate). Defaults to the consistency order; MUSCL overrides with order - 1.
HyperCloudCore._extract_order — Method
_extract_order(interp::DivergenceInterpolator) -> IntReturns the maximum structural polynomial order of the configured spatial scheme.
HyperCloudCore._order_reach — Method
_order_reach(interp::DivergenceInterpolator, strategy::MOODStrategy) -> IntHops to which the flux of a particle depends on neighbours' orders. Drives the MOOD recompute set C ⊕ reach. Defaults to 0; MUSCL overrides (1, or 2 for EPD2).
HyperCloudCore.cons2prim — Method
cons2prim(eq::HyperbolicPDE, W::State)Converts a state vector from conservative to primitive variables. Defaults to identity mapping if not overridden.
Arguments
eq::HyperbolicPDE: The physical equation system.W::State: The conservative state vector.
Returns
- The transformed primitive
State.
HyperCloudCore.evaluate_nc_jump — Method
evaluate_nc_jump(eq::HyperbolicPDE, f_L, f_R, dist_k)Evaluates the non-conservative path integral jump across an interface. Has to be overwritten explicitly for non-conservative PDEs.
Arguments
eq::HyperbolicPDE: The physical equation system.f_L::State,f_R::State: The reconstructed left and right interface states.dist_k::Space: The spatial distance vector between the two points.
Returns
- A
Flux{D, M, T}representing the path-dependent non-conservative jump. Defaults to strictly zero.
HyperCloudCore.evaluate_source — Method
evaluate_source(st::AbstractSourceTerm, U::State, p_idx::Int, pg::ParticleGrid, t::Real)Evaluates volumetric source terms (both explicit and implicit).
Arguments
st::AbstractSourceTerm: The specific source term to evaluate.U::State: The local state vector.p_idx::Int: The index of the current particle.pg::ParticleGrid: The global particle grid.t::Real: The current physical time (or stage time).
Returns
- A
State{M, T}containing the computed source components. Defaults to zero if the source term is empty.
HyperCloudCore.fluid_velocity — Method
fluid_velocity(eq::HyperbolicPDE{D, M, T}, U::State{M, T}) -> Space{D, T}The material (transport) velocity of the state. Only required by Lagrangian-type grid movers (LagrangianMover, ScaledLagrangianMover).
HyperCloudCore.flux — Method
flux(eq::HyperbolicPDE{D, M, T}, U::State{M, T})Computes the physical flux vector for a given state across all spatial dimensions.
Arguments
eq::HyperbolicPDE: The physical equation system.U::State{M, T}: The local conservative state vector.
Returns
- A
Flux{D, M, T}object containing the flux evaluations for allDdimensions.
HyperCloudCore.grid_velocity — Function
grid_velocity(mover::GridMover, eq, p_idx, U, pg, t) -> Space{D, T}Velocity of particle p_idx under the mover, evaluated at the current stage geometry and state. NoGridMover returns zero and disables the moving-grid machinery at compile time.
HyperCloudCore.has_cached_gradients — Method
has_cached_gradients(interp) -> Bool
cached_gradients(interp) -> AbstractVector{SVector{B_LEN, State}}Trait for schemes that keep per-particle reconstruction coefficients between the pre-gather and flux passes (MUSCL). MOODu2 uses the second-order coefficients D+1 … 2D for its curvature test.
HyperCloudCore.implicit_solve — Method
implicit_solve(st::AbstractImplicitSourceTerm, U_in::State, dt_coeff::Real, p_idx::Int, pg::ParticleGrid, t::Real)Executes the local implicit solve: U_out - dt_coeff * S(U_out) = U_in.
Arguments
st::AbstractImplicitSourceTerm: The implicit source term configuration.U_in::State: The accumulated explicit/implicit state prior to the solve.dt_coeff::Real: The stage-specific time step multiplier (e.g.,dt * a_ii).p_idx::Int: The local particle index.pg::ParticleGrid: The global particle grid.t::Real: The current stage time.
Returns
- The strictly solved
State{M, T}(U_out). Defaults toU_infor empty sources.
HyperCloudCore.is_admissible — Method
is_admissible(eq::HyperbolicPDE, U::State) -> BoolPhysical admissibility of a state (the PAD of MOOD): a MOOD time stepper drops the order of a particle whose candidate state is not admissible, whatever its criterion says. The default only rejects non-finite states (NaN or Inf); systems with an admissible set (e.g. positive density and pressure for the Euler equations) add a method. Runs inside kernels.
HyperCloudCore.max_eigenvalue — Method
max_eigenvalue(eq::HyperbolicPDE, U::State, d::Int, shift::Real)Maximum absolute eigenvalue of the flux Jacobian along d after shifting the spectrum by -shift (used by ALEFrame on moving grids). The default max_eigenvalue(eq, U, d) + |shift| is a safe bound; PDEs whose spectrum is known can override it with the exact max |λ - shift| to recover the full dissipation reduction of a Lagrangian frame.
HyperCloudCore.max_eigenvalue — Method
max_eigenvalue(eq::HyperbolicPDE{D, M, T}, U::State{M, T}, d::Int)Calculates the maximum absolute wave speed of the system along a specific spatial axis.
Arguments
eq::HyperbolicPDE: The physical equation system.U::State{M, T}: The local conservative state.d::Int: The spatial dimension index.
Returns
- A scalar of type
Trepresenting the highest observed eigenvalue for that dimension.
HyperCloudCore.pre_solve_update! — Method
pre_solve_update!(st::AbstractImplicitSourceTerm, Y_stage, pg::ParticleGrid, t::Real)Executes global state updates or reductions prior to the implicit solve step. Defaults to a no-op.
HyperCloudCore.prepare_geometry! — Method
prepare_geometry!(interp::DivergenceInterpolator, pg::ParticleGrid)Called by the time stepper before every right-hand-side pass. Schemes that cache geometry-dependent data (MUSCL caches its inverse MLS moment matrices) refresh it here when pg.meta.geometry_version has moved on since the last call. Defaults to a no-op.
HyperCloudCore.prim2cons — Method
prim2cons(eq::HyperbolicPDE, U::State)Converts a state vector from primitive to conservative variables. Defaults to identity mapping if not overridden.
Arguments
eq::HyperbolicPDE: The physical equation system.U::State: The primitive state vector.
Returns
- The transformed conservative
State.
HyperCloudCore.update_content! — Method
update_content!(interp::DivergenceInterpolator, i::Int, f_i::State, nb_slice::OrdinalRange, pg::ParticleGrid, U::AbstractVector{State}, ib::InteractionBuffer)Executes the pre-pass computations (such as resolving MLS gradients or limiting slopes) prior to the primary flux pass; U is the stage state vector. Defaults to a no-op for stateless algorithms.
HyperCloudCore.update_size! — Method
update_size!(interp::DivergenceInterpolator, N_particles::Int)Dynamically resizes internal evaluation buffers (like cached gradients) to match the particle grid capacity.
HyperCloudCore.update_size! — Method
update_size!(ts::TimeStepper, N_particles::Int, M_neighbors::Int)Dynamically resizes all internal Runge-Kutta / IMEX stage buffers and interaction masks.
HyperCloudCore.velocity — Method
velocity(eq::HyperbolicPDE{D, M, T}, U::State{M, T}, d::Int)Evaluates the exact advective velocity matrix (the flux Jacobian) for a specified spatial dimension. Required for Upwind flux algorithms.
Arguments
eq::HyperbolicPDE: The physical equation system.U::State{M, T}: The local conservative state.d::Int: The spatial dimension index.
Returns
- An
SMatrix{M, M, T, M*M}representing the exact flux Jacobian.