FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
marenv::field::DepthLayeredScalarField Class Reference

#include <DepthLayeredScalarField.h>

+ Inheritance diagram for marenv::field::DepthLayeredScalarField:
+ Collaboration diagram for marenv::field::DepthLayeredScalarField:

Public Member Functions

 DepthLayeredScalarField (std::string name, Quantity quantity, std::string unit, std::vector< double > depthZ, std::vector< double > values, std::vector< Property > properties={})
 
 ~DepthLayeredScalarField () override=default
 Default destructor.
 
marenv::Status GetValue (double time, const double position[3], double &value) const override
 
bool IsTimeInvariant () const override
 
bool IsThreadSafe () const override
 
- Public Member Functions inherited from marenv::field::ScalarField
virtual ~ScalarField ()=default
 Virtual destructor.
 
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)
 

Additional Inherited Members

- Protected Member Functions inherited from marenv::field::ScalarField
 ScalarField (std::string name, Quantity quantity, std::string unit, std::vector< Property > properties)
 

Detailed Description

A scalar field defined by a vertical profile, linearly interpolated between layers.

Models thermocline- and halocline-style vertical structure, or the vertical distribution of a species: the value is given at a set of strictly increasing depths and interpolated linearly in between. Horizontal position and time have no effect.

The profile is marenv::calc::DepthProfile, the stack's one depth profile (owner ruling R122, W-30), which marenv::current::DepthVaryingCurrentField uses as well. Outside the layer range the value is clamped to the shallowest or deepest layer and marenv::Status::OUT_OF_RANGE_INACCURATE is returned: a temperature of 0 degC or a salinity of 0 PSU would be physically misleading. A NaN depth gives marenv::Status::ERROR_NOT_SET and the value 0.

Depths are in the NED frame, so they are positive downwards. Unlike marenv::current::DepthVaryingCurrentField the profile is not clamped at the surface, so a layer may sit at a negative depth, above mean sea level and inside the wave zone.

See also
ConstantScalarField

Constructor & Destructor Documentation

◆ DepthLayeredScalarField()

marenv::field::DepthLayeredScalarField::DepthLayeredScalarField ( std::string  name,
Quantity  quantity,
std::string  unit,
std::vector< double >  depthZ,
std::vector< double >  values,
std::vector< Property >  properties = {} 
)

Constructs a depth-layered scalar field.

Parameters
[in]nameUnique field name. Must not be empty.
[in]quantityAdvisory tag describing what the field measures.
[in]unitUnit of values, e.g. "degC". May be empty.
[in]depthZDepth [m] of each layer, positive down, strictly increasing. At least two entries.
[in]valuesValue at each layer. Same length as depthZ.
[in]propertiesStatic properties. Keys must be unique and non-empty.
Exceptions
std::invalid_argumentif depthZ and values differ in length, if fewer than two layers are given, if the depths are not strictly increasing, if a depth or a value is not finite (ENV-0060), if name is empty, or if a property key is empty or repeated.
Note
The constructor validates by throwing rather than asserting, because these profiles come from user input and a bad input file must fail in Release too.

Member Function Documentation

◆ GetValue()

marenv::Status marenv::field::DepthLayeredScalarField::GetValue ( double  time,
const double  position[3],
double &  value 
) const
overridevirtual

Returns the profile value at the depth of position, ignoring x, y and time.

Returns the scalar value at a given position and time.

Parameters
[in]timeSimulation time [s].
[in]positionPosition in the NED frame [x, y, z] [m].
[out]valueThe value at the given time and position.
Returns
marenv::Status::OK on success, or marenv::Status::OUT_OF_RANGE_INACCURATE when the position lay outside the field's domain and the returned value was clamped to the domain edge, or (a ParametricScalarField with mask_below_seabed) lay below the seabed and the value is 0. A status that is not usable (marenv::IsUsable), such as marenv::Status::ERROR_NOT_SET from a bathymetry without a depth there, comes with the value 0 (ENV-0061), and so does a depth profile at a NaN depth (marenv::Status::ERROR_NOT_SET, W-30). See marenv::Status for other values.

Implements marenv::field::ScalarField.

◆ IsThreadSafe()

bool marenv::field::DepthLayeredScalarField::IsThreadSafe ( ) const
inlineoverridevirtual

GetValue reads only the immutable profile.

Returns
Always true.

Reimplemented from marenv::field::ScalarField.

◆ IsTimeInvariant()

bool marenv::field::DepthLayeredScalarField::IsTimeInvariant ( ) const
inlineoverridevirtual

The profile is fixed at construction, so the value ignores time.

Returns
Always true.

Reimplemented from marenv::field::ScalarField.


The documentation for this class was generated from the following file: