Marine systems simulation
Loading...
Searching...
No Matches
marenv::wave::AiryWavesSimd Class Reference

#include <AiryWavesSimd.h>

+ Inheritance diagram for marenv::wave::AiryWavesSimd:
+ Collaboration diagram for marenv::wave::AiryWavesSimd:

Classes

struct  SimdSnapshot
 
struct  WaveDynamicSIMD
 
struct  WaveDynamicSIMDExpAmp
 Extended dynamic SIMD data including depth-dependent terms. See also WaveDynamicSIMD. More...
 
struct  WaveDynamicStack
 
struct  WaveStaticSIMD
 

Public Member Functions

 AiryWavesSimd (std::shared_ptr< WaveComponents > waveComponents)
 
 AiryWavesSimd (WaveEnergySpectrum::SpectrumParameters spectrumParameters, int numWaves, uint32_t randomSeed)
 
 ~AiryWavesSimd () override=default
 Default destructor.
 
bool PositionIsInWater (double time, const double pos[3])
 
Status ComputeSurfaceElevation (double time, const double pos[2], double &elevationOut) override
 
Status ComputeSurfaceUnitNormal (double time, const double pos[2], double unitNormalOut[3]) override
 
Status ComputeParticleVelocity (double time, const double pos[3], double velOut[3]) override
 
Status ComputeParticleAcceleration (double time, const double pos[3], double accOut[3]) override
 
Status ComputeDynamicPressure (double time, const double pos[3], double &pressureOut) override
 
Status ComputeTotalPressure (double time, const double pos[3], double &pressureOut) override
 
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
 
void BlendInPlace (WaveComponentData &other, double alpha) override
 
const WaveStaticSIMDGetSimdStatic () const
 
- Public Member Functions inherited from marenv::wave::LinearWaveTheory
 LinearWaveTheory (std::shared_ptr< WaveComponents > waveComponents, std::string waveTheoryName)
 
WaveField::InsecureDatapointers GetWaveComponents () const override
 
std::string SpectrumName () const override
 
std::string WaveTheoryName () const override
 
WaveComponentData GetWaveComponentsCopy () const override
 
void BlendInPlace (WaveComponentData &other, double alpha) override
 
- Public Member Functions inherited from marenv::wave::WaveField
virtual ~WaveField ()=default
 Virtual destructor.
 
virtual marenv::wave::WaveComponentData GetWaveComponentsCopy (double time, size_t maxComponents=0) const
 

Additional Inherited Members

- Protected Member Functions inherited from marenv::wave::LinearWaveTheory
std::shared_ptr< WaveSnapshotLoadSnapshot () const
 
void StoreSnapshot (std::shared_ptr< WaveSnapshot > snap)
 
- Protected Member Functions inherited from marenv::wave::WaveField
 WaveField ()=default
 Constructor.
 
- Protected Attributes inherited from marenv::wave::LinearWaveTheory
std::string m_spectrumName
 The name of the wave spectrum.
 
std::string m_waveTheoryName
 The name of the wave theory.
 

Detailed Description

Calculates physical properties in a sea state from a set of for Airy theory

gravity waves (first-order Stokes waves). This class is based on SIMD (Single Instruction Multiple Data) operations for efficient computation of wave properties. This makes it more efficient for larger number of wave components. For a smaller number of wave components, please consider using the AiryWavesScalar class instead. Tests show that AiryWavesScalar is about 10% faster for one wave component and one call to the simplest function per iteration. Otherwise AiryWavesSimd is faster. See the image below for a comparison between AiryWavesScalar and AiryWavesSimd.

Thread safety**: concurrent calls to any Compute* method on the same instance are safe. A concurrent BlendInPlace call is also safe: it atomically publishes a new snapshot; in-flight Compute* calls complete against the old consistent snapshot and are unaffected.

Constructor & Destructor Documentation

◆ AiryWavesSimd() [1/2]

marenv::wave::AiryWavesSimd::AiryWavesSimd ( std::shared_ptr< WaveComponents waveComponents)
explicit

Constructor of Airy waves from wave component specifications.

Parameters
[in]waveComponentsShared pointer to wave component specifications.

◆ AiryWavesSimd() [2/2]

marenv::wave::AiryWavesSimd::AiryWavesSimd ( WaveEnergySpectrum::SpectrumParameters  spectrumParameters,
int  numWaves,
uint32_t  randomSeed 
)

Constructor of Airy waves from wave spectrum specification.

Parameters
[in]spectrumParametersWave spectrum specifications.
[in]numWavesNumber of waves to construct from the spectrum.
[in]randomSeedThe random seed to use.

Member Function Documentation

◆ BlendInPlace()

void marenv::wave::AiryWavesSimd::BlendInPlace ( WaveComponentData other,
double  alpha 
)
overridevirtual

Atomically blend wave components towards another set and rebuild the SIMD

Parameters
[in]otherTarget wave component data.
[in]alphaBlend factor (0=keep current, 1=use other).

snapshot. Safe to call concurrently with any Compute* method.

Implements marenv::wave::WaveField.

◆ ComputeDynamicPressure()

Status marenv::wave::AiryWavesSimd::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()

Status marenv::wave::AiryWavesSimd::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.

Includes effects of both current and waves.

Implements marenv::wave::WaveField.

◆ ComputeParticleVelocity()

Status marenv::wave::AiryWavesSimd::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.

Includes effects of both current and waves.

Implements marenv::wave::WaveField.

◆ ComputePointQuery()

Status marenv::wave::AiryWavesSimd::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()

Status marenv::wave::AiryWavesSimd::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()

Status marenv::wave::AiryWavesSimd::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()

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

Returns the total 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.

◆ GetSimdStatic()

const WaveStaticSIMD & marenv::wave::AiryWavesSimd::GetSimdStatic ( ) const
inline

Static SIMD parameters used by AiryWaves computations.

Returns a reference into the current snapshot; for a stable view across multiple calls acquire a snapshot explicitly via LoadSnapshot().

◆ PositionIsInWater()

bool marenv::wave::AiryWavesSimd::PositionIsInWater ( double  time,
const double  pos[3] 
)

Decides if a given point is below the water surface.

Parameters
[in]timeTime in seconds.
[in]pos3D position (x,y,z) in meters.
Returns
True if the position is in water at given time, false otherwise.

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