pub struct Case {Show 18 fields
pub schema_version: String,
pub name: String,
pub domain: Domain,
pub grid: GridSpec,
pub boundaries: Boundaries,
pub flow: Flow,
pub geometry: Vec<Block>,
pub building_roughness_m: Option<f64>,
pub geometry_min_passage_cells: Option<usize>,
pub moving_walls: Vec<MovingWall>,
pub constituents: Vec<Constituent>,
pub vegetation: Vec<Vegetation>,
pub sources: Vec<Source>,
pub initial_conditions: Vec<Initial>,
pub receptors: Vec<Receptor>,
pub numerics: Numerics,
pub run: Run,
pub output: Output,
}Expand description
A complete native case, schema version cfd-craft.case/0.1. Nothing
outside the case configures the solver. Unknown fields are rejected; the
lists default to empty when omitted. Deserialization checks only the
types: the semantic checks (ranges, units, budgets, geometry) are those of
cfd-craft check, which reports coded diagnostics with field paths.
Fields§
§schema_version: StringContract version; must be cfd-craft.case/0.1 (CFD-E001).
name: StringNonempty experiment label (CFD-E002), copied into the result. It is excluded from the physics hash, so renaming keeps checkpoints compatible.
domain: DomainPhysical extent of the domain; see Domain.
grid: GridSpecUniform cell counts per axis; see GridSpec.
boundaries: BoundariesBoundary condition per axis; see Boundaries.
flow: FlowFlow model; see Flow.
geometry: Vec<Block>Axis-aligned solid boxes (buildings, obstacles). A cell is solid when
its center lies inside a box. Not allowed with prescribed_uniform
flow (CFD-E013). Optional footprint_m selects polygon prisms.
Masked multigrid is supported. Default: empty.
building_roughness_m: Option<f64>Optional aerodynamic roughness of building walls in meters, independent of cell width. Omission reproduces the legacy wall recipe (CFD-E085).
geometry_min_passage_cells: Option<usize>Warn if a represented street between solids is narrower than this number of horizontal cells. Omitted for legacy cases (CFD-W011).
moving_walls: Vec<MovingWall>Tangentially moving wall faces of the domain, such as a cavity lid;
laminar flow only (CFD-E021). Default: empty.
constituents: Vec<Constituent>Passive gases transported by the flow. Default: empty, which solves the flow only.
vegetation: Vec<Vegetation>Opt-in porous canopy boxes; zero leaf density has no numerical effect.
sources: Vec<Source>Continuous emissions into the constituents. Default: empty.
initial_conditions: Vec<Initial>Initial concentration fields, at most one per constituent (CFD-E018); a constituent without one starts at zero. Default: empty.
receptors: Vec<Receptor>Named concentration samples, reported for every constituent in the
result’s receptors_kg_m3 and in probes.csv. Default: empty.
numerics: NumericsDiscretization choices, tolerances and the steady monitor window; see Numerics.
run: RunMode, endpoint and execution budgets; see Run.
output: OutputArtifact retention and output budget; see Output.
Implementations§
Source§impl Case
impl Case
Sourcepub fn physics_hash(&self) -> String
pub fn physics_hash(&self) -> String
SHA-256 (lowercase hex) of the case’s compact JSON without name,
run and output: the identity of the physical and numerical
problem. A checkpoint restarts only a case with the same physics hash
(CFD-E060), so budgets, the endpoint and the output policy may change
between a run and its restart, while grid, physics, sources, receptors
and numerics may not.
use cfd_craft::case::{Case, Source};
let case: Case = serde_json::from_str(json).unwrap();
let mut longer = case.clone();
longer.name = "tiny, longer budget".into();
longer.run.max_steps *= 10;
assert_eq!(case.physics_hash(), longer.physics_hash());
let mut weaker = case.clone();
if let Source::Point { rate_kg_s, .. } = &mut weaker.sources[0] {
*rate_kg_s *= 0.5;
}
assert_ne!(case.physics_hash(), weaker.physics_hash());Sourcepub fn check(&self) -> CheckReport
pub fn check(&self) -> CheckReport
The semantic checks that need no grid: schema version, ranges and
units, budgets, physical combinations, IDs, and that geometry, sources,
receptors and initial conditions lie inside the domain. It also
estimates peak memory and output size and checks them against
run.memory_limit_mib (CFD-E006) and output.max_total_mib
(CFD-E007).
Every problem is reported at once; the report is invalid when any
diagnostic is an error. It never fails or allocates the grid. The
checks that need the built grid are in
input::full_check, which the CLI and
the Python binding run, and are repeated by
solver::run.
use cfd_craft::case::Case;
let mut case: Case = serde_json::from_str(json).unwrap();
case.numerics.advective_cfl_max = 0.9;
case.run.threads = 0;
let report = case.check();
assert!(!report.valid);
let found: Vec<_> = report
.diagnostics
.iter()
.map(|d| (d.code.as_str(), d.path.as_str()))
.collect();
assert!(found.contains(&("CFD-E010", "numerics.advective_cfl_max")));
assert!(found.contains(&("CFD-E008", "run.threads")));Sourcepub fn validate(&self) -> Result<CheckReport>
pub fn validate(&self) -> Result<CheckReport>
check as a Result: the report when the case is
valid (it may still carry warnings), otherwise an error whose text is
the report serialized as JSON, so its codes and paths can be parsed
back.
use cfd_craft::case::{Case, CheckReport};
let mut case: Case = serde_json::from_str(json).unwrap();
assert!(case.validate().is_ok());
case.schema_version = "cfd-craft.case/9".into();
let error = case.validate().unwrap_err();
let report: CheckReport = serde_json::from_str(&error).unwrap();
assert_eq!(report.diagnostics[0].code, "CFD-E001");
assert_eq!(report.diagnostics[0].path, "schema_version");Trait Implementations§
Source§impl<'de> Deserialize<'de> for Case
impl<'de> Deserialize<'de> for Case
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Case
impl JsonSchema for Case
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreAuto Trait Implementations§
impl Forget for Case
impl Freeze for Case
impl Move for Case
impl RefUnwindSafe for Case
impl Send for Case
impl Sync for Case
impl Unpin for Case
impl UnsafeUnpin for Case
impl UnwindSafe for Case
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more