FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
EnvironmentFacade.h
1#pragma once
3
4#include <marenv/Environment.h>
5#include <marenv/current/CurrentField.h>
6#include <marenv/seafloor/BathymetryField.h>
7#include <marenv/seafloor/FlatSeafloor.h>
8#include <marenv/wake/WakeField.h>
9#include <marenv/wake/WakeRegistry.h>
10#include <marenv/wave/NullWaveField.h>
11#include <marenv/wave/WaveEnergySpectrum.h>
12#include <marenv/wave/WaveFactory.h>
13#include <marenv/wave/WaveField.h>
14
15#include <memory>
16#include <string>
17#include <unordered_map>
18#include <utility>
19#include <vector>
20
21namespace marenv
22{
27{
28 double ambient[3];
29 double waked[3];
30 double deficit;
32};
33
42{
43public:
51 : m_waves(std::make_shared<wave::NullWaveField>())
52 , m_depths(std::make_shared<seafloor::FlatSeafloor>())
53 {
54 }
55 ~EnvironmentFacade() override = default;
56
57 // Environment's setter and getter functions
63 void SetWaves(std::shared_ptr<wave::WaveField> wave);
64
74 wave::WaveTheory waveTheory,
75 int numWaves,
76 uint32_t seed);
82 void SetBathymetry(std::shared_ptr<seafloor::BathymetryField> bathymetry);
87 std::shared_ptr<wave::WaveField> GetWaves();
88
102 double MaxWaveElevation() const;
107 std::shared_ptr<seafloor::BathymetryField> GetBathymetry();
108
118 void AddCurrentField(const std::string& id, std::shared_ptr<current::CurrentField> field);
119
127 void RemoveCurrentField(const std::string& id);
128
134 bool HasCurrentField(const std::string& id) const;
135
144 std::shared_ptr<current::CurrentField> GetCurrentField(const std::string& id) const;
145
154 void AddWakeField(const std::string& id, std::shared_ptr<wake::WakeField> field);
155
163 void RemoveWakeField(const std::string& id);
164
170 bool HasWakeField(const std::string& id) const;
171
180 std::shared_ptr<wake::WakeField> GetWakeField(const std::string& id) const;
181
186 std::vector<std::string> GetWakeFieldIds() const;
187
192 std::vector<std::string> GetCurrentFieldIds() const;
193
194 // Accessor functions
196
197 Status GetSubmergence(double time, const double pos[3], double& submergence) override;
199
200 Status GetSurfaceElevation(double time, const double pos[2], double& elevationOut) override;
202
203 Status GetSurfaceUnitNormal(double time, const double pos[2], double* unitNormalOut) override;
210 Status GetParticleVelocity(double time, const double pos[3], double* velOut) override;
212
213 Status GetParticleAcceleration(double time, const double pos[3], double* accOut) override;
215
216 Status GetDynamicPressure(double time, const double pos[3], double& pressureOut) override;
218
219 Status GetTotalPressure(double time, const double pos[3], double& pressureOut) override;
221
222 Status GetSeaDepth(const double pos[2], double& depthOut) override;
224
225 Status ComputeRayIntersection(const double origin[3], const double direction[3], double& distanceOut, double maxSearchDistance = 100, double startSearchDistance = -1, double stepSize = 1.0, double convergenceTolerance = 0.01) override;
237 Status GetCurrentVelocity(double time, const double pos[3], double* velOut) override;
239
240 Status GetDensity(double time, const double pos[3], double& density) override;
252 Status PointEnvironmentQuery(double time, const double pos[3], EnvironmentQuery& queryResult) override;
253
275 Status GetWakedFlow(double time, const double pos[3], WakedFlow& out) const;
276
293 Status GetWakedFlow(double time, const double pos[3], const wake::WakeQuery& query, WakedFlow& out) const;
294
300 std::vector<std::shared_ptr<const wake::WakeField>> SelectReachingWakeFields(const wake::WakeQueryRegion& region, const wake::WakeField* exclude = nullptr) const;
301
302protected:
304
305 std::shared_ptr<wave::WaveField> m_waves;
307
308 std::unordered_map<std::string, std::shared_ptr<current::CurrentField>> m_currentFields;
310
311 std::shared_ptr<seafloor::BathymetryField> m_depths;
313
318 Status ComputeTotalCurrent(double time, const double pos[3], double vel[3]) const;
319};
320
321} // namespace marenv
Definition EnvironmentFacade.h:42
std::vector< std::shared_ptr< const wake::WakeField > > SelectReachingWakeFields(const wake::WakeQueryRegion &region, const wake::WakeField *exclude=nullptr) const
std::shared_ptr< current::CurrentField > GetCurrentField(const std::string &id) const
Status GetSurfaceElevation(double time, const double pos[2], double &elevationOut) override
EnvironmentFacade()
Definition EnvironmentFacade.h:50
std::shared_ptr< wake::WakeField > GetWakeField(const std::string &id) const
std::vector< std::string > GetWakeFieldIds() const
Status GetDensity(double time, const double pos[3], double &density) override
Status ComputeTotalCurrent(double time, const double pos[3], double vel[3]) const
bool HasCurrentField(const std::string &id) const
std::shared_ptr< wave::WaveField > m_waves
Wave field model providing wave-induced quantities.
Definition EnvironmentFacade.h:305
Status GetParticleAcceleration(double time, const double pos[3], double *accOut) override
Status ComputeRayIntersection(const double origin[3], const double direction[3], double &distanceOut, double maxSearchDistance=100, double startSearchDistance=-1, double stepSize=1.0, double convergenceTolerance=0.01) override
Status GetParticleVelocity(double time, const double pos[3], double *velOut) override
Status GetSurfaceUnitNormal(double time, const double pos[2], double *unitNormalOut) override
std::shared_ptr< seafloor::BathymetryField > GetBathymetry()
Status PointEnvironmentQuery(double time, const double pos[3], EnvironmentQuery &queryResult) override
Status GetCurrentVelocity(double time, const double pos[3], double *velOut) override
Status GetDynamicPressure(double time, const double pos[3], double &pressureOut) override
void SetWaves(std::shared_ptr< wave::WaveField > wave)
double MaxWaveElevation() const
std::unordered_map< std::string, std::shared_ptr< current::CurrentField > > m_currentFields
Registry of current fields indexed by unique identifier; velocities are summed for the total current.
Definition EnvironmentFacade.h:308
void AddCurrentField(const std::string &id, std::shared_ptr< current::CurrentField > field)
std::shared_ptr< wave::WaveField > GetWaves()
Status GetSubmergence(double time, const double pos[3], double &submergence) override
std::shared_ptr< seafloor::BathymetryField > m_depths
Bathymetry field model providing seafloor geometry and properties.
Definition EnvironmentFacade.h:311
void SetBathymetry(std::shared_ptr< seafloor::BathymetryField > bathymetry)
Status GetWakedFlow(double time, const double pos[3], const wake::WakeQuery &query, WakedFlow &out) const
wake::WakeRegistry m_wakes
The registered wake fields in registration order (MENV-0035: the composition order is the same on eve...
Definition EnvironmentFacade.h:314
Status GetTotalPressure(double time, const double pos[3], double &pressureOut) override
std::vector< std::string > GetCurrentFieldIds() const
bool HasWakeField(const std::string &id) const
Status GetWakedFlow(double time, const double pos[3], WakedFlow &out) const
void RemoveCurrentField(const std::string &id)
void RemoveWakeField(const std::string &id)
void SetWaves(const wave::WaveEnergySpectrum::SpectrumParameters &params, wave::WaveTheory waveTheory, int numWaves, uint32_t seed)
void AddWakeField(const std::string &id, std::shared_ptr< wake::WakeField > field)
Status GetSeaDepth(const double pos[2], double &depthOut) override
Definition Environment.h:20
Definition WakeField.h:50
Definition WakeRegistry.h:50
Status
Definition marenv.h:40
WaveTheory
Definition WaveFactory.h:18
The marenv root namespace.
Definition PorousDiscWakeSource.h:15
Struct for containing the data for a environment query.
Definition Environment.h:25
Definition EnvironmentFacade.h:27
int numSources
Number of the composed wake fields that contributed a non-zero deficit.
Definition EnvironmentFacade.h:31
double waked[3]
Ambient current with the wake composition applied, plus the wave particle velocity,...
Definition EnvironmentFacade.h:29
double ambient[3]
Ambient current without any wake, m/s, NED.
Definition EnvironmentFacade.h:28
double deficit
Combined deficit d_tot in [0, 1] of the wake fields the query composes (by default all registered fie...
Definition EnvironmentFacade.h:30
Definition WakeField.h:17
Definition WakeRegistry.h:24
The parameters defining a certain wave field.
Definition WaveEnergySpectrum.h:41