pub struct Simulation { /* private fields */ }Expand description
A set of domains sharing a clock.
Implementations§
Source§impl Simulation
impl Simulation
Sourcepub fn new(schedule: Schedule) -> Simulation
pub fn new(schedule: Schedule) -> Simulation
Domains are stepped in the order they are added. That order is part of the physics under a staggered schedule — put the quasi-static producers before the evolving consumers — and it is fixed rather than discovered, so two runs take the same path.
Sourcepub fn with_boxed(self, domain: Box<dyn Domain>) -> Simulation
pub fn with_boxed(self, domain: Box<dyn Domain>) -> Simulation
Add a domain whose type was chosen at run time.
What Simulation::with cannot do: building a domain from a scene file produces a
Box<dyn Domain>, and with wants a concrete type. The simulation has always stored
boxes internally, so this is the shorter path and not a wider one.
Sourcepub fn with(self, domain: impl Domain + 'static) -> Simulation
pub fn with(self, domain: impl Domain + 'static) -> Simulation
Add a domain. Order matters for Schedule::Staggered and its relatives: a domain
sees the output of those declared before it from this step, and of those after it from
the last one.
Sourcepub fn transfer_tolerance(self, tol: f64) -> Simulation
pub fn transfer_tolerance(self, tol: f64) -> Simulation
Absolute tolerance on the bus audit, in SI units of whatever is on the channel. Default 1e-12.
Sourcepub fn conservation_tolerance(self, tol: f64) -> Simulation
pub fn conservation_tolerance(self, tol: f64) -> Simulation
Relative tolerance on the whole-simulation conservation audit across a step. Default 1e-9.
Sourcepub fn domain(&self, name: &str) -> Option<&dyn Domain>
pub fn domain(&self, name: &str) -> Option<&dyn Domain>
A domain by name, through the trait. For the concrete type, see
Simulation::domain_as.
Sourcepub fn field(&self, name: &str) -> Option<&dyn ScalarField>
pub fn field(&self, name: &str) -> Option<&dyn ScalarField>
A domain’s ScalarField, if it has one and opted in.
The domain-agnostic counterpart of Simulation::domain_as: a renderer can sample
every field in a simulation without knowing what any of them are. That was the whole
point of ScalarField and it was not reachable until Domain::as_field existed.
Sourcepub fn domain_as<T: Any>(&self, name: &str) -> Option<&T>
pub fn domain_as<T: Any>(&self, name: &str) -> Option<&T>
A domain by name and concrete type, for a caller that needs more than the
Domain trait exposes — a temperature profile, a body’s position.
Returns None if the name is not here, if the type is wrong, or if that domain did
not implement Domain::as_any. Prefer Simulation::field when what is wanted is
a field to sample: that one does not need the concrete type at all.