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

#include <ConstantScalarField.h>

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

Public Member Functions

 ConstantScalarField (std::string name, Quantity quantity, std::string unit, double value, std::vector< Property > properties={})
 
 ~ConstantScalarField () 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 with the same value at every position and time.

Used for a uniform temperature, salinity or species concentration, and as the simplest field to register from a SimObject that has no profile to offer.

See also
DepthLayeredScalarField

Constructor & Destructor Documentation

◆ ConstantScalarField()

marenv::field::ConstantScalarField::ConstantScalarField ( std::string  name,
Quantity  quantity,
std::string  unit,
double  value,
std::vector< Property >  properties = {} 
)
inline

Constructs a uniform scalar field.

Parameters
[in]nameUnique field name. Must not be empty.
[in]quantityAdvisory tag describing what the field measures.
[in]unitUnit of value, e.g. "degC". May be empty.
[in]valueThe value returned for every position and time. Must be finite.
[in]propertiesStatic properties. Keys must be unique and non-empty.
Exceptions
std::invalid_argumentif name is empty, if a property key is empty or repeated, or if value is not finite (ENV-0060).

Member Function Documentation

◆ GetValue()

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

Returns the constant value, always with marenv::Status::OK.

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::ConstantScalarField::IsThreadSafe ( ) const
inlineoverridevirtual

GetValue reads only the immutable configured value.

Returns
Always true.

Reimplemented from marenv::field::ScalarField.

◆ IsTimeInvariant()

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

The value is the same at all times.

Returns
Always true.

Reimplemented from marenv::field::ScalarField.


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