FhSim  3.1.0
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:
46 WaveComponents(std::vector<double> amplitude, std::vector<double> phaseAngle, std::vector<double> frequency, std::vector<double> direction, SpectrumType spectrumType);
48
49 ~WaveComponents() = default;
50
52
53 void Sort();
55
60 [[nodiscard]] std::string GetSpectrumType() const;
62
68
69private:
70 // [1] alignedvec is a typedef for std::vector<double, xsimd::aligned_allocator<double,64>>.
71 // It is defined in WaveComponents.cpp. The private constructor below (used by
72 // WaveEnergySpectrum) takes pre-built aligned vectors to avoid an extra copy.
73 friend class WaveEnergySpectrum;
74 using alignedvec = std::vector<double, xsimd::aligned_allocator<double, 64>>;
75 WaveComponents(alignedvec amplitude, alignedvec phaseAngle, alignedvec frequency, alignedvec direction, SpectrumType spectrumType);
76
77 alignedvec zetaA;
78 alignedvec epsilon;
79 alignedvec omega;
80 alignedvec waveNumber;
81 alignedvec theta;
82 alignedvec cosTheta;
83 alignedvec sinTheta;
84 alignedvec remainingAccumulatedAmplitude;
85 // [3] numWaves mirrors the sizes of the above vectors. It is stored as int (not size_t)
86 // because SIMD loop indices are int and sign-mixing warnings are undesirable.
87 // The constructor throws for more than 52 components (see the constructor).
88 int numWaves;
89 SpectrumType spectrumType;
90};
91} // 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.
~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:16
Policy mixin: this type is movable but not copyable.
Definition marenv.h:126
Pointers to wave component details.
Definition WaveField.h:46