Marine systems simulation
Loading...
Searching...
No Matches
WaveComponents.h
1#pragma once
3
4#include "marenv/marenv.h"
5#include <marenv/wave/WaveField.h>
6
7#include <memory>
8#include <string>
9#include <vector>
10#include <xsimd/xsimd.hpp>
11
12namespace marenv::wave
13{
14// [1] alignedvec is an internal implementation detail; it is defined in WaveComponents.cpp
15// and is NOT part of the public API. Only the std::vector<double> constructor is public.
17
18enum class SpectrumType
19{
20 JONSWAP,
21 ISSC,
22 Components
23};
24
33{
34public:
44 WaveComponents(std::vector<double> amplitude, std::vector<double> phaseAngle, std::vector<double> frequency, std::vector<double> direction, SpectrumType spectrumType);
46
47 ~WaveComponents() = default;
48
59 [[nodiscard]] std::shared_ptr<WaveComponents> Blend(WaveComponentData& other, double alpha) const;
61
62 void Sort();
64
69 [[nodiscard]] std::string GetSpectrumType() const;
71
77
78private:
79 // [1] alignedvec is a typedef for std::vector<double, xsimd::aligned_allocator<double,64>>.
80 // It is defined in WaveComponents.cpp. The private constructor below (used by
81 // WaveEnergySpectrum) takes pre-built aligned vectors to avoid an extra copy.
82 friend class WaveEnergySpectrum;
83 using alignedvec = std::vector<double, xsimd::aligned_allocator<double, 64>>;
84 WaveComponents(alignedvec amplitude, alignedvec phaseAngle, alignedvec frequency, alignedvec direction, SpectrumType spectrumType);
85
86 alignedvec zetaA;
87 alignedvec epsilon;
88 alignedvec omega;
89 alignedvec waveNumber;
90 alignedvec theta;
91 alignedvec cosTheta;
92 alignedvec sinTheta;
93 alignedvec remainingAccumulatedAmplitude;
94 // [3] numWaves mirrors the sizes of the above vectors. It is stored as int (not size_t)
95 // because SIMD loop indices are int and sign-mixing warnings are undesirable.
96 // Maximum supported wave count is INT_MAX (well above any practical limit).
97 int numWaves;
98 SpectrumType spectrumType;
99};
100} // namespace marenv::wave
Definition WaveComponents.h:33
WaveComponents(std::vector< double > amplitude, std::vector< double > phaseAngle, std::vector< double > frequency, std::vector< double > direction, SpectrumType spectrumType)
std::string GetSpectrumType() const
Spectrum type.
std::shared_ptr< WaveComponents > Blend(WaveComponentData &other, double alpha) const
~WaveComponents()=default
Default destructor.
WaveField::InsecureDatapointers GetInsecureDatapointers() const
Gives access to temporary pointers to internal structures, for performance reasons.
void Sort()
Sorts the wave components.
Represents a wave field.
Definition WaveEnergySpectrum.h:14
Policy mixin: this type is default copyable but not movable.
Definition marenv.h:100
Details of a wave component.
Definition WaveField.h:23
Pointers to wave component details.
Definition WaveField.h:40