8#include <marenv/wave/WaveField.h>
32 const double depth = std::max(z, 0.0);
33 double sumSquares = 0.0;
34 for (
int i = 0; i < components.numWaves; i++) {
35 const double k = components.waveNumber[i];
36 const double h = components.depth[i];
37 const double decay = std::isinf(h) ? std::exp(-k * depth) : std::cosh(k * (h - depth)) / std::sinh(k * h);
38 const double amplitude = components.omega[i] * components.zetaA[i] * decay;
39 sumSquares += amplitude * amplitude;
41 return std::sqrt(sumSquares);
49 for (
int i = 0; i < components.numWaves; i++) {
50 if (peak < 0 || components.zetaA[i] > components.zetaA[peak])
53 return peak < 0 ? 0.0 : 2.0 * std::numbers::pi / components.
omega[peak];
57inline constexpr const char* kDefaultWaveEffectMaxDepth =
"Auto";
67 double depth = std::numeric_limits<double>::infinity();
75inline bool ParseWaveEffectMaxDepth(
const std::string& text,
WaveEffectDepth& setting)
82 setting = WaveEffectDepth {
true, std::numeric_limits<double>::infinity()};
88 const double depth = std::strtod(text.c_str(), &end);
89 if (end != text.c_str() + text.size() || !std::isfinite(depth) || depth < 0.0)
91 setting = WaveEffectDepth {
false, depth};
102 if (!setting.automatic)
103 return setting.depth;
105 if (components.numWaves <= 0)
106 return std::numeric_limits<double>::infinity();
107 double smallest = components.waveNumber[0];
108 double bottom = components.depth[0];
109 for (
int i = 1; i < components.numWaves; i++) {
110 smallest = std::min(smallest, components.waveNumber[i]);
111 bottom = std::min(bottom, components.depth[i]);
113 if (!(smallest > 0.0))
114 return std::numeric_limits<double>::infinity();
115 const double depth = std::log(100.0) / smallest;
116 return depth >= bottom ? std::numeric_limits<double>::infinity() : depth;
Definition WaveField.h:50
virtual InsecureDatapointers GetWaveComponents() const =0
const double *RESTRICT omega
Pointer to wave frequency array.
Definition WaveField.h:58
Definition NetWaveKc.h:65
bool automatic
"Auto": the depth follows the wave field.
Definition NetWaveKc.h:66
double depth
The depth [m] if not automatic; +infinity is no cut.
Definition NetWaveKc.h:67