FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
Superposition.h
1#pragma once
58
59#include <marenv/wake/WakeConstants.h> // kMomentumFluxBranchDeficit
60
61#include <algorithm>
62
63namespace marenv::wake
64{
66namespace detail
67{
77double DeficitFromMomentumFlux(double flux);
78
86double MomentumFluxBound(double sumOfBounds);
87} // namespace detail
88
101{
102public:
106 void Add(double deficit)
107 {
108 if (!(deficit > 0.0))
109 return; // also a NaN
110 const double d = std::min(deficit, 1.0);
111 m_flux += d * (1.0 - d);
112 m_linear += d;
113 ++m_count;
114 }
115
117 double Deficit() const
118 {
119 if (m_count <= 1)
120 return m_linear; // 0, or the one deficit unchanged
121 return std::max(detail::DeficitFromMomentumFlux(m_flux), std::min(1.0, m_linear)); // the linear sum where it is larger (R95)
122 }
123
124private:
125 double m_flux = 0.0;
126 double m_linear = 0.0;
127 int m_count = 0;
128};
129} // namespace marenv::wake
Definition Superposition.h:101
void Add(double deficit)
Definition Superposition.h:106
double Deficit() const
Definition Superposition.h:117
double DeficitFromMomentumFlux(double flux)
double MomentumFluxBound(double sumOfBounds)