|
FhSim
3.1.0
Marine systems simulation
|
#include <ScalarField.h>
Inheritance diagram for marenv::field::ScalarField:
Collaboration diagram for marenv::field::ScalarField:Public Member Functions | |
| virtual | ~ScalarField ()=default |
| Virtual destructor. | |
| virtual marenv::Status | GetValue (double time, const double position[3], double &value) const =0 |
| virtual bool | IsTimeInvariant () const |
| virtual bool | IsThreadSafe () const |
| virtual void | GetValues (double time, std::span< const std::array< double, 3 > > positions, std::span< double > values, std::span< marenv::Status > statuses) const |
| const std::string & | Name () const |
| Quantity | GetQuantity () const |
| const std::string & | Unit () const |
| const std::vector< Property > & | Properties () const |
| bool | Has (const std::string &key) const |
| double | Get (const std::string &key, double fallback=0.0) const |
| const std::string & | Species () const |
| void | SetSpecies (std::string species) |
Protected Member Functions | |
| ScalarField (std::string name, Quantity quantity, std::string unit, std::vector< Property > properties) | |
A named scalar quantity varying over space and time.
Implementations return a single value at a position in the NED frame (x North, y East, z Down) at a simulation time. One instance models one quantity: a temperature profile, a salinity profile, or the concentration of a single species. Each instance carries its own name, an advisory Quantity tag, a unit string and a set of static properties, so the same class serves every quantity and no per-quantity subclass is needed.
This class deliberately computes no derived physics. In particular, a species concentration field does not compute an acoustic signature: it reports how much of the species is present and what its static properties are, leaving the frequency-dependent backscatter to the observer that needs it.
Nor does it offer a gradient or any other derivative, by design. A consumer that needs a spatial sensitivity finite-differences GetValue itself.
const OdeFcn and is therefore evaluated at rejected integrator trial states as well as at accepted ones, so a field that cached or mutated anything per call would make its results depend on the step sequence.
|
protected |
Constructs the shared identity and metadata of a scalar field.
| [in] | name | Unique field name. Must not be empty. |
| [in] | quantity | Advisory tag describing what the field measures. |
| [in] | unit | Unit of the values returned by GetValue. May be empty. |
| [in] | properties | Static properties. Keys must be unique and non-empty. |
| std::invalid_argument | if name is empty, or if a property key is empty or repeated. |
| double marenv::field::ScalarField::Get | ( | const std::string & | key, |
| double | fallback = 0.0 |
||
| ) | const |
Returns a property value, or a fallback when the key is absent.
| [in] | key | Property key to look for. |
| [in] | fallback | Value returned when the key is absent. |
fallback.
|
inline |
The advisory tag describing what this field measures.
|
pure virtual |
Returns the scalar value at a given position and time.
| [in] | time | Simulation time [s]. |
| [in] | position | Position in the NED frame [x, y, z] [m]. |
| [out] | value | The value at the given time and position. |
Implemented in util::EnvironmentQuantityField, marenv::field::ConstantScalarField, marenv::field::DepthLayeredScalarField, and marenv::field::ParametricScalarField.
|
virtual |
Returns the values at many points at one time: GetValue() at each.
| [in] | time | Simulation time [s]. |
| [in] | positions | Positions in the NED frame [m]. |
| [out] | values | One value per position; as many as positions. |
| [out] | statuses | One status per position; as many as positions. |
The default calls GetValue() at each point. A field that samples a row more cheaply overrides it, as util::EnvironmentQuantityField does (each wake field is loaded once per call instead of once per point); util::BakeScalarField samples its grid row by row.
| bool marenv::field::ScalarField::Has | ( | const std::string & | key | ) | const |
Returns true if the given property key is present.
| [in] | key | Property key to look for. |
|
inlinevirtual |
True when GetValue may be called concurrently from several threads.
Defaults to false, so the class-level note that implementations need not be thread-safe stays true for every field that does not opt in. A field delegating to a marenv::seafloor::BathymetryField may only return true when that bathymetry is itself safe for concurrent GetDepth calls, which BathymetryField.h does not guarantee.
Reimplemented in util::EnvironmentQuantityField, marenv::field::ConstantScalarField, marenv::field::DepthLayeredScalarField, and marenv::field::ParametricScalarField.
|
inlinevirtual |
True when the field's value at a given position never changes with time.
A caller may evaluate a time-invariant field once and reuse the result for the whole simulation. Defaults to false, so a field that does vary with time needs no change.
Reimplemented in marenv::field::ConstantScalarField, marenv::field::DepthLayeredScalarField, and marenv::field::ParametricScalarField.
|
inline |
The field's unique name, which is also its identifier in the registry.
|
inline |
All static properties of this field, in the order they were declared.
|
inline |
Names the species this field holds (parameter ScalarField.<Name>.Species); call before registering the field.
| [in] | species | The species key, e.g. "mackerel". May be empty. |
|
inline |
The species this field holds, a key of the echosounder's Parameter library such as "herring".
|
inline |
The unit of the values returned by GetValue, e.g. "degC", "PSU" or "kg/m^3".