Skip to main content

Module solver

Module solver 

Source
Expand description

The native solve: bounded execution of a Case, its state, and the result contract cfd-craft.result/0.1.

run is the entry point. It validates the case, builds the grid and the source and receptor weights, starts from the initial state or a restart State, and advances transactional steps until the steady checks pass, the transient interval is complete, or a budget, cancellation or failed step stops it. A Control supplies the wall-time allowance, cancellation, an optional external poll and optional profiling. The returned RunResult holds the Summary (the JSON result), the final state and the geometry evidence.

Keep the questions of the result separate:

  • Summary::termination says why execution stopped: completed, iteration_limit, wall_time_limit, cancelled or diverged.
  • Summary::assessment says what the recomputed Checks support: steady_discrete_solution, transient_interval_completed, failed_checks or incomplete.
  • Summary::experimental_validation is always not_validated: a numerically accepted run is not a validated urban flow.

A failed step never commits its candidate: the returned state is the last accepted one, and Summary::error records the failure. The result types derive JsonSchema; their doc comments are the description entries of the result_schema that cfd-craft describe prints. See the result contract.

The lower-level functions (step, assess, timestep, monitor) are research interfaces; they expect a grid built from the same case and state vectors of its dimensions.

Structs§

Budget
Cumulative mass budget of one constituent, in kg. At any accepted state the mass in the domain should equal initial_kg + emitted_kg + inflow_kg - outflow_kg; the mass_budget check bounds the relative defect. Every entry is finite and nonnegative.
Check
One numerical check, recomputed by the solver from the current fields. A check passes when its value is finite and at most its threshold. Continuity and residual values are normalized with the case’s velocity and length scales (neutral_rans: speed_m_s and reference_height_m; otherwise the reference speed, at least 1 m/s, and the shortest domain side).
Control
Cooperative execution control of one solve: a wall-time allowance, a cancellation flag, an optional external poll and optional phase profiling.
ParticulateEvidence
Sum over particle bins passing an aerodynamic-size cutoff.
PathEvidence
A path receptor sampled from one constituent’s returned concentration field.
RunResult
Everything a solve returns: the JSON summary, the final accepted state and the geometry evidence. output::write_run publishes it as a run archive.
ScalarEvidence
Evidence for one constituent at the returned state: mass budget, extrema, the steady residual, instantaneous rates and receptor values. Cumulative quantities are in kg, rates in kg/s, concentrations in kg/m3.
State
The complete solver state: what fields.json archives and a checkpoint restores. Vectors follow the grid layout of Grid: one value per face (in Grid::faces order) or per cell (x fastest), with solid cells included. Counters are cumulative from the cold start, across restarts.
Summary
The result of one native run (schema cfd-craft.result/0.1), written as summary.json: identities, the stopping reason and numerical verdict, work counters, geometry, the recomputed checks and per-constituent evidence. termination says why execution stopped; assessment says what the checks support; experimental validation is a separate question. Null means unavailable in the stated context, not zero.

Constants§

SCALAR_SUBSTEPS_MAX
Cap on explicit scalar sub-steps per implicit outer iteration (P5d). The constituents then advance by at most this many explicit stable steps per outer iteration; their steady state does not depend on the step sizes.

Functions§

assess
Recomputes the numerical checks of a state from its fields.
initial_state
The cold-start state of a case: face velocities from Flow::vector, zero pressure, the neutral_rans equilibrium k and epsilon in fluid cells, the initial concentrations and their initial masses, and zero counters.
monitor
One monitor row of the state: the RMS face velocity, then for each constituent its mass (kg) followed by its receptor values (kg/m3, in receptor order), then with neutral_rans the mean k and the mean epsilon over all cells. weights are the receptor weights of transport::receptor_weights, in receptor order.
monitor_change
Largest relative change between the column means of three successive windows of numerics.monitor_window rows, each change relative to the largest absolute mean of its column (at least 1e-30). The windows are the first three of the monitor history, which run keeps at the last three windows. None until the history holds three full windows.
run
Solves a case within the limits of control, from the cold-start state or from a restart state, and returns the inspectable outcome.
scalar_substeps
Sub-step count and size for a pseudo-time step dt with explicit stable step stable: the fewest equal sub-steps of at most stable, capped at SCALAR_SUBSTEPS_MAX steps of size stable.
step
Advances s by one step (one outer iteration with an implicit steady algorithm) of size dt, transactionally.
timestep
The next stable time step in seconds for the case’s steady algorithm, capped by numerics.max_time_step_s. explicit limits advection and diffusion together with numerics.advective_cfl_max (at most 0.45), implicit_viscous limits advection only, and implicit_projection follows the CFL ramp of momentum_solve::ramp_cfl. nut is the eddy viscosity per cell (flow::eddy_viscosity). run clips the step to the end time of a transient run.
validate_state
Checks that a state fits the case and grid before it is used, for example a restart: vector dimensions (CFD-E050), finite values, nonnegative k, epsilon and budgets, a scalar_time_s within time_s, a finite monitor history, and zero concentration in solid cells (all CFD-E051). It does not check the physics identity; output::read_checkpoint does that.