FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
environment::TunableWaveField Class Reference

#include <TunableWaveField.h>

+ Inheritance diagram for environment::TunableWaveField:
+ Collaboration diagram for environment::TunableWaveField:

Public Types

using Spectrum = marenv::wave::WaveEnergySpectrum::SpectrumParameters
 

Public Member Functions

 TunableWaveField (const Spectrum &spectrum, marenv::wave::WaveTheory theory, int numWaves, std::uint32_t seed, double depth=marenv::wave::kDeepWater, const marenv::wave::WaveCutoffs &cutoffs={})
 
double Hs () const
 Significant wave height [m].
 
double MeanPeriod () const
 Mean period [s].
 
double MainDirectionDeg () const
 Main direction as Waves.MainDirectionDeg: where the sea comes from, from north towards east [deg].
 
void SetSeaState (double hs, double meanPeriod, double mainDirectionDeg)
 A new sea state; the change fades in over CrossFade() seconds from the next query.
 
const std::shared_ptr< marenv::wave::WaveField > & Model () const
 The marenv model of the current sea state.
 
std::string SpectrumName () const override
 
std::string WaveTheoryName () const override
 
marenv::Status ComputeSurfaceElevation (double time, const double pos[2], double &elevationOut) override
 
marenv::Status ComputeDynamicPressure (double time, const double pos[3], double &pressureOut) override
 
marenv::Status ComputeTotalPressure (double time, const double pos[3], double &pressureOut) override
 
marenv::Status ComputeSurfaceUnitNormal (double time, const double pos[2], double unitNormalOut[3]) override
 
marenv::Status ComputeParticleVelocity (double time, const double pos[3], double velOut[3]) override
 
marenv::Status ComputeParticleAcceleration (double time, const double pos[3], double accOut[3]) override
 
marenv::Status ComputePointQuery (double time, const double pos[3], double &surface_elevation, double surface_unit_normal[3], double particle_velocity[3], double particle_acceleration[3], double &pressure) override
 
InsecureDatapointers GetWaveComponents () const override
 
marenv::wave::WaveComponentData GetWaveComponentsCopy () const override
 
marenv::wave::WaveComponentData GetWaveComponentsCopy (double time, size_t maxComponents=0) const override
 
double MaxWaveElevation () const override
 
- Public Member Functions inherited from marenv::wave::WaveField
virtual ~WaveField ()=default
 

Static Public Member Functions

static constexpr double CrossFade ()
 Duration of the fade from the old to the new waves [s].
 

Additional Inherited Members

- Protected Member Functions inherited from marenv::wave::WaveField
 WaveField ()=default
 Constructor.
 

Detailed Description

Spectrum waves whose significant height, mean period and main direction may change while the simulation runs (Waves.Hs, Waves.MeanPeriod, Waves.MainDirectionDeg as tunable parameters, core ADR 0025; ADR 0009 D26).

It forwards every query to a marenv wave model built from the spectrum. SetSeaState builds a new model with the same seed; for CrossFade() seconds after the first query that follows, the queries return the old and the new field blended (exact for linear waves: the fields superpose), and the component copies (for the sea surface) both sets with their amplitudes scaled, so neither the floating bodies nor the picture jump. The wrappers of this library (ShelteredWaveField, TidalWaveField) go around it; they and every user keep the same pointer.

Constructor & Destructor Documentation

◆ TunableWaveField()

environment::TunableWaveField::TunableWaveField ( const Spectrum &  spectrum,
marenv::wave::WaveTheory  theory,
int  numWaves,
std::uint32_t  seed,
double  depth = marenv::wave::kDeepWater,
const marenv::wave::WaveCutoffs &  cutoffs = {} 
)
Parameters
[in]spectrumThe spectrum (Theta in marenv's convention: radians, the direction the waves come from + pi).
[in]theoryWave theory.
[in]numWavesNumber of components.
[in]seedRandom seed.
[in]depthWater depth [m], marenv::wave::kDeepWater (default) for deep water (MENV-0089); Airy only.
[in]cutoffsOpt-in cuts at depth (HP-6, HP-7), default off; Airy only.

Member Function Documentation

◆ ComputeDynamicPressure()

marenv::Status environment::TunableWaveField::ComputeDynamicPressure ( double  time,
const double  pos[3],
double &  pressureOut 
)
overridevirtual

Returns the dynamic pressure at a specific position.

Parameters
[in]timeCurrent simulation time.
[in]posPosition (x,y,z) for which the pressure is desired.
[out]pressureOutThe pressure at pos.
Returns
marenv::Status::OK on success. See marenv::Status for other values.

Implements marenv::wave::WaveField.

◆ ComputeParticleAcceleration()

marenv::Status environment::TunableWaveField::ComputeParticleAcceleration ( double  time,
const double  pos[3],
double  accOut[3] 
)
overridevirtual

Returns the particle acceleration at a specific position.

Parameters
[in]timeCurrent simulation time.
[in]posPosition (x,y,z) for which the particle acceleration is desired.
[out]accOutThe particle acceleration at pos.
Returns
marenv::Status::OK on success. See marenv::Status for other values.

The wave particle acceleration only; a current is not included.

Implements marenv::wave::WaveField.

◆ ComputeParticleVelocity()

marenv::Status environment::TunableWaveField::ComputeParticleVelocity ( double  time,
const double  pos[3],
double  velOut[3] 
)
overridevirtual

Returns the particle velocity at a specific position.

Parameters
[in]timeCurrent simulation time.
[in]posPosition (x,y,z) for which the particle velocity is desired.
[out]velOutThe particle velocity at pos.
Returns
marenv::Status::OK on success. See marenv::Status for other values.

The wave particle velocity only; a current is not included (EnvironmentFacade adds it).

Implements marenv::wave::WaveField.

◆ ComputePointQuery()

marenv::Status environment::TunableWaveField::ComputePointQuery ( double  time,
const double  pos[3],
double &  surface_elevation,
double  surface_unit_normal[3],
double  particle_velocity[3],
double  particle_acceleration[3],
double &  pressure 
)
overridevirtual

Calculates multiple properties of the environment in one call.

Parameters
[in]timeSimulation time.
[in]posPosition.
[out]surface_elevationThe surface elevation above this point.
[out]surface_unit_normalThe surface unit normal above this point.
[out]particle_velocityThe particle velocity in this point.
[out]particle_accelerationThe particle acceleration in this point.
[out]pressureThe pressure. The pressure in this point.
Returns
marenv::Status::OK on success. See marenv::Status for other values.

Implements marenv::wave::WaveField.

◆ ComputeSurfaceElevation()

marenv::Status environment::TunableWaveField::ComputeSurfaceElevation ( double  time,
const double  pos[2],
double &  elevationOut 
)
overridevirtual

Returns the surface elevation at a specific position.

Parameters
[in]timeCurrent simulation time.
[in]posPosition (x,y) for which surface elevation is desired.
[out]elevationOutSurface elevation at pos.
Returns
marenv::Status::OK on success. See marenv::Status for other values.

Implements marenv::wave::WaveField.

◆ ComputeSurfaceUnitNormal()

marenv::Status environment::TunableWaveField::ComputeSurfaceUnitNormal ( double  time,
const double  pos[2],
double  unitNormalOut[3] 
)
overridevirtual

Returns the unit normal vector of the surface at a specific position.

Parameters
[in]timeCurrent simulation time.
[in]posPosition (x,y) for which the unit normal surface vector is desired.
[out]unitNormalOutThe unit normal surface vector at pos.
Returns
marenv::Status::OK on success. See marenv::Status for other values.

Implements marenv::wave::WaveField.

◆ ComputeTotalPressure()

marenv::Status environment::TunableWaveField::ComputeTotalPressure ( double  time,
const double  pos[3],
double &  pressureOut 
)
overridevirtual

Returns the total (gauge) pressure at a specific position.

Parameters
[in]timeCurrent simulation time.
[in]posPosition (x,y,z) for which the pressure is desired.
[out]pressureOutThe pressure at pos, relative to the atmosphere.
Returns
marenv::Status::OK on success. See marenv::Status for other values.

Owner ruling D8: the total pressure is rho g z + the dynamic pressure of ComputeDynamicPressure() (z positive down), and 0 for a point above the free surface. The dynamic pressure already holds the free-surface elevation, so the elevation is not added again.

Implements marenv::wave::WaveField.

◆ GetWaveComponents()

InsecureDatapointers environment::TunableWaveField::GetWaveComponents ( ) const
inlineoverridevirtual

Getter for wave component pointers.

Returns
A structure with pointers to wave component data.

Their use focus on efficiency. The views live as long as the field: its component snapshot is set only in the constructor, so the pointers stay valid until the field is destroyed. Do not use them after that.

Implements marenv::wave::WaveField.

◆ GetWaveComponentsCopy() [1/2]

marenv::wave::WaveComponentData environment::TunableWaveField::GetWaveComponentsCopy ( ) const
inlineoverridevirtual

Getter for a copy of wave component specifications.

Returns
A structure with wave component data.

Implements marenv::wave::WaveField.

◆ GetWaveComponentsCopy() [2/2]

marenv::wave::WaveComponentData environment::TunableWaveField::GetWaveComponentsCopy ( double  time,
size_t  maxComponents = 0 
) const
overridevirtual

Getter for a copy of wave component specifications at a given time.

Parameters
[in]timeSimulation time used to evaluate the interpolation factor.
[in]maxComponentsMaximum number of components to return (0 = all).
Returns
A structure with wave component data.

During a transition this may return the merged components from both source and destination fields with amplitudes scaled by the interpolation factor. The default implementation ignores time: it takes the components of the time-independent overload and returns them sorted by descending amplitude (a signed zetaA, with std::sort or std::partial_sort, so components of equal amplitude come in an unspecified order). When limited, the components with the largest amplitudes are kept.

Reimplemented from marenv::wave::WaveField.

◆ MaxWaveElevation()

double environment::TunableWaveField::MaxWaveElevation ( ) const
overridevirtual

Returns an upper bound of |elevation| at every position and time (owner ruling R66).

Returns
B >= |eta(t, x, y)| for the wave components published by the field, which never changes them. A point at depth z > B + h (NED, z down), with h the half-size of a body around it, is submerged whatever the waves, so its wave elevation need not be evaluated.

The linear theories (AiryWavesScalar, AiryWavesSimd, GerstnerWaves) return the sum of the component amplitudes |zeta_A|, with a relative margin of 1e-10 for rounding; the Gerstner surface is the same sum at the Lagrangian point. NullWaveField returns 0. The default, for a wave field that cannot tell (an imported or gridded surface), is +infinity, which never skips an evaluation. Cheap: one pass over the components.

0 means no waves: no elevation, particle velocity or particle acceleration anywhere, so a caller may skip evaluating them (MENV-0064). A wave field that returns 0 must give zero for all three.

Reimplemented from marenv::wave::WaveField.

◆ SpectrumName()

std::string environment::TunableWaveField::SpectrumName ( ) const
inlineoverridevirtual

Getter for the name of the wave spectrum used for the realisation of the waves.

Returns
Ittc or Jonswap.

Implements marenv::wave::WaveField.

◆ WaveTheoryName()

std::string environment::TunableWaveField::WaveTheoryName ( ) const
inlineoverridevirtual

Getter for the name of the wave theory used for the realisation of the waves.

Returns
Airy or Gerstner.

Implements marenv::wave::WaveField.


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