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
63
namespace
marenv::wake
64
{
66
namespace
detail
67
{
77
double
DeficitFromMomentumFlux
(
double
flux);
78
86
double
MomentumFluxBound
(
double
sumOfBounds);
87
}
// namespace detail
88
100
class
MomentumFluxSum
101
{
102
public
:
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
124
private
:
125
double
m_flux = 0.0;
126
double
m_linear = 0.0;
127
int
m_count = 0;
128
};
129
}
// namespace marenv::wake
marenv::wake::MomentumFluxSum
Definition
Superposition.h:101
marenv::wake::MomentumFluxSum::Add
void Add(double deficit)
Definition
Superposition.h:106
marenv::wake::MomentumFluxSum::Deficit
double Deficit() const
Definition
Superposition.h:117
marenv::wake::detail::DeficitFromMomentumFlux
double DeficitFromMomentumFlux(double flux)
marenv::wake::detail::MomentumFluxBound
double MomentumFluxBound(double sumOfBounds)
marenv
include
marenv
wake
Superposition.h
Generated on Thu Nov 26 2026 15:19:32 for FhSim by
1.9.8