FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
marenv::current::ConstantCurrent Class Reference

#include <ConstantCurrent.h>

+ Inheritance diagram for marenv::current::ConstantCurrent:
+ Collaboration diagram for marenv::current::ConstantCurrent:

Public Member Functions

 ConstantCurrent (const double velocity[3])
 
 ConstantCurrent (double velocity, double directionRad)
 
Status GetCurrent (double time, const double position[3], double currentVelocity[3]) override
 
- Public Member Functions inherited from marenv::current::CurrentField
virtual ~CurrentField ()=default
 Virtual destructor.
 

Detailed Description

An ocean current providing a time- and position-independent current.

Example usage:

double velocity = 1.0;
double direction = 0.5;
auto current = std::make_shared<marenv::current::ConstantCurrent>(velocity, direction);
double pos[3] = {0.0, 0.0, -5.0};
double currentVelocity[3];
current->GetCurrent(0.0, pos, currentVelocity);

Constructor & Destructor Documentation

◆ ConstantCurrent() [1/2]

marenv::current::ConstantCurrent::ConstantCurrent ( const double  velocity[3])
explicit

Constructor for the ocean current

Parameters
[in]velocityThe 3 DOF ocean current velocity [m/s], NED components; the direction the water goes to
Exceptions
std::invalid_argumentif a component is not finite (MENV-0093).

◆ ConstantCurrent() [2/2]

marenv::current::ConstantCurrent::ConstantCurrent ( double  velocity,
double  directionRad 
)

Constructor for the ocean current

Parameters
[in]velocityThe ocean current speed [m/s]
[in]directionRadThe direction the water goes to [rad], from North (x) towards East (y): the velocity is (v cos d, v sin d, 0)
Exceptions
std::invalid_argumentif the speed or the direction is not finite (MENV-0093).

Member Function Documentation

◆ GetCurrent()

Status marenv::current::ConstantCurrent::GetCurrent ( double  time,
const double  position[3],
double  currentVelocity[3] 
)
overridevirtual

Return the ocean current velocity in a given position and time.

Parameters
[in]timeTime stamp in simulation time.
[in]positionThe position to query for.
[out]currentVelocityThe velocity of the ocean current in the given time and position.
Returns
marenv::Status::OK on success. See marenv::Status for other values.

Threading contract, for every implementation: GetCurrent() may be called from several threads at once (a visualiser sampling in parallel while the simulation waits), so it must not change the field's state; it is non-const for historical reasons only. A field may read state the simulation writes between steps, so it need not be safe against a writer. Registration (EnvironmentFacade::AddCurrentField()) happens during setup.

Order rule (owner ruling D46): the answer depends only on time, position and state that is fixed during a step. A field that depends on simulation state (a propeller jet that follows its propeller) reads its own copy of that state, written between steps (for example in AcceptedStep), never members that port functions or OdeFcn write during the step. Such a field lags the simulation by one step, the same for any number of threads.

Implements marenv::current::CurrentField.


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