FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
Ship::PropulsorWakeField< State > Class Template Reference

#include <PropulsorWakeField.h>

+ Inheritance diagram for Ship::PropulsorWakeField< State >:
+ Collaboration diagram for Ship::PropulsorWakeField< State >:

Public Types

using Jet = std::function< marenv::Status(const State &state, double time, const double position[3], double currentVelocity[3])>
 The jet formula: the current at position and time from the copied state.
 

Public Member Functions

 PropulsorWakeField (Jet jet)
 
void Update (const State &state)
 Replaces the state copy; call it only between steps (AcceptedStep).
 
marenv::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

template<class State>
class Ship::PropulsorWakeField< State >

The jet behind a propulsor, as a marenv::current::CurrentField that follows the simulation one step late (owner ruling G4, marenv order rule).

The field holds a copy of the propulsor's wake state State (for example its position, axis and jet speed). The owner calls Update() only from its AcceptedStep. GetCurrent() reads only that copy and the constants the jet formula holds from setup, so it does not depend on the order in which the objects evaluate in a step, nor on the number of threads. Before the first Update() the state is State{}; a State must make that a zero jet.

Template Parameters
StateThe wake state the jet formula needs; default-constructible and copyable.

Member Function Documentation

◆ GetCurrent()

template<class State >
marenv::Status Ship::PropulsorWakeField< State >::GetCurrent ( double  time,
const double  position[3],
double  currentVelocity[3] 
)
inlineoverridevirtual

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: