FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
environment::wake::detail::WakeGroupCaster Class Referencefinal

#include <WakeGroupCaster.h>

+ Inheritance diagram for environment::wake::detail::WakeGroupCaster:
+ Collaboration diagram for environment::wake::detail::WakeGroupCaster:

Public Member Functions

 WakeGroupCaster (std::string name, const SourceSetWakeSettings &settings, ISimObjectLogger &logger)
 
void Register (EnvironmentProvider &environment)
 
int Join (const std::string &member, double rho)
 
void Attach (int member, const WakeCastingObject &body, double T)
 
void Update (double T, const double *X)
 
marenv::wake::WakeQuery Query () const
 The members' query: the group's lumped field skipped, its private field composed in; empty before the first Join().
 
const WakeCaster * Caster () const
 The caster; null before the first Join().
 
const std::string & Name () const
 The group's name.
 
const SourceSetWakeSettings & Settings () const
 The group's wake parameters.
 
int NumBodies () const override
 Number of members.
 
WakeCastState Body (const double *X, int body) const override
 The member body's Reference().
 
double BodyRadius (int body) const override
 The member body's Radius().
 
SourceLoad BodyLoad (const double *X, int body, const double bodyVel[3], const double waterVel[3]) const override
 The member body's BodyLoad().
 

Detailed Description

The members of a wake group as one IndexedWakeCastingObject, and the WakeCaster that casts them.

Life cycle, whatever the order of the group and its members in the input:

Phase Group (WakeGroup SimObject) Member (BodyWake with WakeGroup)
SharedResourceSetup Register(): known to the environment by name –
FinalSetup – Join(): a member number; the first one creates and registers the caster with its density
PreOdeFcn Update() Attach() its body, then Update(), then its take with Query()

FhSim calls every SharedResourceSetup before any FinalSetup, and every FinalSetup before the first PreOdeFcn. The first Update() at a new time rebuilds when due, the later ones at that time do nothing, so every member's take sees the same build. A member hands its body only in its PreOdeFcn, so the first pass attaches them, and the group casts from the next step on, once every member's body is known: the result does not depend on the order (WakeBuildTime is then the time of the second step at the earliest).

The time alone tells a new pass from a repeated call: Update() at a new time, also an earlier one, updates the caster once; at the time of the last update it does nothing. So an FMU that rolls back and repeats a step at the same time keeps the first attempt's update, and a member's state changed through IStateUpdater later in the same pass is seen from the next time on (doc/user/wakes.md, "Wake groups").

Not thread-safe: FhSim runs SharedResourceSetup, FinalSetup and PreOdeFcn serially.

Constructor & Destructor Documentation

◆ WakeGroupCaster()

environment::wake::detail::WakeGroupCaster::WakeGroupCaster ( std::string  name,
const SourceSetWakeSettings &  settings,
ISimObjectLogger &  logger 
)
Parameters
[in]nameThe group's name: the registry id of its lumped field, the log prefix.
[in]settingsThe group's wake parameters (ReadSourceSetWakeSettings), with CastWake.
[in]loggerThe FhSim log; it must outlive the caster.

Member Function Documentation

◆ Attach()

void environment::wake::detail::WakeGroupCaster::Attach ( int  member,
const WakeCastingObject &  body,
double  T 
)

Hands over a member's body; it must outlive the caster. Call from the member's PreOdeFcn, before Update().

Parameters
[in]memberIts number from Join().
[in]bodyIts body, a shape caster.
[in]TSimulation time [s].
Exceptions
std::invalid_argumentwhen body cannot join a group (WakeCastingObject::Radius() is not positive).

◆ Join()

int environment::wake::detail::WakeGroupCaster::Join ( const std::string &  member,
double  rho 
)

Adds a member. The first creates the caster with its density and registers the group's lumped field. Call from the member's FinalSetup.

Parameters
[in]memberThe member's name.
[in]rhoThe member's fluid density [kg/m³].
Returns
The member's number, for Attach().
Exceptions
std::invalid_argumentwhen rho differs from the first member's.
std::logic_errorbefore Register(), and when member has joined already.

◆ Register()

void environment::wake::detail::WakeGroupCaster::Register ( EnvironmentProvider &  environment)

Makes the group known to the environment under its name (EnvironmentProvider::AddWakeGroup). Call from SharedResourceSetup.

Parameters
[in]environmentThe environment; it must outlive the caster.

◆ Update()

void environment::wake::detail::WakeGroupCaster::Update ( double  T,
const double *  X 
)

Rebuilds the group's wakes when due: once per time, from the first step after every member attached its body.

A member that has not attached a body by the second time Update() sees keeps the group from casting; that is logged once, as a warning naming such members.

Parameters
[in]TSimulation time at the start of the step [s].
[in]XThe global state vector.

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