FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
WakeGroupCaster.h
1#pragma once
2
13#include <fhsim/ISimObjectLogger.h>
14#include <WakeCaster.h>
15#include <fhsim_environment/WakeSourceSet.h>
16#include <limits>
17#include <memory>
18#include <string>
19#include <unordered_map>
20#include <vector>
21
22namespace environment
23{
24class EnvironmentProvider;
25} // namespace environment
26
28{
29
30class WakeGroupCaster;
31
34{
35public:
36 std::unordered_map<std::string, WakeGroupCaster*> groups;
37};
38
46void AddWakeGroup(EnvironmentProvider& environment, const std::string& name, WakeGroupCaster& group);
47
54WakeGroupCaster* FindWakeGroup(const EnvironmentProvider& environment, const std::string& name);
55
81class WakeGroupCaster final : public IndexedWakeCastingObject
82{
83public:
88 WakeGroupCaster(std::string name, const SourceSetWakeSettings& settings, ISimObjectLogger& logger);
89 ~WakeGroupCaster() override;
90
95 void Register(EnvironmentProvider& environment);
96
105 int Join(const std::string& member, double rho);
106
114 void Attach(int member, const WakeCastingObject& body, double T);
115
124 void Update(double T, const double* X);
125
129 const WakeCaster* Caster() const { return m_caster.get(); }
131 const std::string& Name() const { return m_name; }
133 const SourceSetWakeSettings& Settings() const { return m_settings; }
134
136 int NumBodies() const override { return static_cast<int>(m_members.size()); }
138 WakeCastState Body(const double* X, int body) const override { return m_bodies[body]->Reference(m_lastUpdate, X); }
140 double BodyRadius(int body) const override { return m_bodies[body]->Radius(); }
142 SourceLoad BodyLoad(const double* X, int body, const double bodyVel[3], const double waterVel[3]) const override { return m_bodies[body]->BodyLoad(m_lastUpdate, X, bodyVel, waterVel); }
143
144private:
146 void LogNoMembers(double T);
148 void LogMembersWithoutABody(double T);
150 std::string MembersWithoutABody() const;
151
152 std::string m_name;
153 SourceSetWakeSettings m_settings;
154 ISimObjectLogger& m_logger;
155 EnvironmentProvider* m_environment = nullptr;
156 std::unique_ptr<WakeCaster> m_caster;
157 double m_rho = 0.0;
158 std::vector<std::string> m_members;
159 std::vector<const WakeCastingObject*> m_bodies;
160 double m_completeAt = std::numeric_limits<double>::quiet_NaN();
161 double m_lastUpdate = std::numeric_limits<double>::quiet_NaN();
162 double m_firstUpdate = std::numeric_limits<double>::quiet_NaN();
163 bool m_noMembersLogged = false;
164 bool m_membersWithoutABodyLogged = false;
165};
166
167} // namespace environment::wake::detail
Definition WakeCaster.h:202
Definition WakeGroupCaster.h:82
double BodyRadius(int body) const override
The member body's Radius().
Definition WakeGroupCaster.h:140
const std::string & Name() const
The group's name.
Definition WakeGroupCaster.h:131
void Register(EnvironmentProvider &environment)
const WakeCaster * Caster() const
The caster; null before the first Join().
Definition WakeGroupCaster.h:129
const SourceSetWakeSettings & Settings() const
The group's wake parameters.
Definition WakeGroupCaster.h:133
WakeGroupCaster(std::string name, const SourceSetWakeSettings &settings, ISimObjectLogger &logger)
int NumBodies() const override
Number of members.
Definition WakeGroupCaster.h:136
marenv::wake::WakeQuery Query() const
The members' query: the group's lumped field skipped, its private field composed in; empty before the...
void Attach(int member, const WakeCastingObject &body, double T)
SourceLoad BodyLoad(const double *X, int body, const double bodyVel[3], const double waterVel[3]) const override
The member body's BodyLoad().
Definition WakeGroupCaster.h:142
void Update(double T, const double *X)
WakeCastState Body(const double *X, int body) const override
The member body's Reference().
Definition WakeGroupCaster.h:138
int Join(const std::string &member, double rho)
The wake groups of an EnvironmentProvider by name; the provider owns it (EnvironmentProvider::WakeGro...
Definition WakeGroupCaster.h:34
std::unordered_map< std::string, WakeGroupCaster * > groups
The groups by name.
Definition WakeGroupCaster.h:36
The casters behind BodyWake; internal, not for SimObjects (ENV-0102).
Definition CasterStep.h:19
void AddWakeGroup(EnvironmentProvider &environment, const std::string &name, WakeGroupCaster &group)
WakeGroupCaster * FindWakeGroup(const EnvironmentProvider &environment, const std::string &name)
Definition WakeSelection.h:33