|
FhSim
3.1.0
Marine systems simulation
|
#include <WakeBlend.h>
Classes | |
| struct | State |
| One immutable step of the blend chain. More... | |
Public Types | |
| using | Sum = WakeBlendSum |
| The sums over the snapshots that contributed at one point. | |
Public Member Functions | |
| std::shared_ptr< const State > | Load () const |
| The published state, one atomic load; null before the first Publish(). A query loads it once and uses it throughout. | |
| void | Publish (std::shared_ptr< const S > next, double start, double time) |
Static Public Member Functions | |
| static double | Weight (double t, double start, double time) |
| Smoothstep weight of the new snapshot at t; 1 without blending (time <= 0 or NaN). BlendWeight(). | |
| static Sum | Evaluate (const State &state, double t, const double pos[3]) |
| The sums of the snapshots of state at pos and t, weighted by the blend. | |
| static bool | Blends (const State &state, double t) |
| Whether the state blends at t or later: the weight of t is below 1, so it still changes (owner ruling R136). | |
| static WakeBlendSamples | Samples (const State &state, double t, const double pos[3]) |
| static bool | MayReach (const State &state, const WakeQueryRegion ®ion) |
A published wake that hands over smoothly from the previous one (CONTEXT.md, Wake blend).
State is an immutable node: the snapshot blended to, the state it blends from (null means no wake) and the blend start and time. Weights depend on t only: the new snapshot has the C1 smoothstep weight s = 3 tau^2 - 2 tau^3, tau = (t - start) / time, and the state blended from has 1 - s, so a multistep integrator sees a C1 right-hand side. A blend time of 0 gives weight 1 for every t.
Evaluate() returns the raw sums sum(share d) and sum(share d u_s) of the snapshots that contributed. The caller normalises them, because a wake decides for itself what a zero deficit reports as the source velocity.
Thread safety: Publish() swaps a new immutable State in through std::atomic<std::shared_ptr<const State>>, the pattern of marenv::wave::LinearWaveTheory, so a query evaluates the old or the new state, never a mix. Keep to one writer: Publish() reads the state in use to decide what the new state blends from, then stores the new one, so two concurrent writers could drop one of the two. Load() takes no mutex; the libstdc++ spin bit of the atomic shared pointer is the known caveat (see WakeField::Sample).
Publish() is the publish policy of lead ruling R22, the one policy of SourceSetWake and GriddedWake (MENV-0060): a new blend may not start while the previous one runs, so a state blends from the previous snapshot alone and no chain forms; with blend time 0 nothing is kept to blend from.
|
inlinestatic |
False only if no snapshot that has weight in [region.tBegin, region.tEnd] or later may reach the region (see WakeField::MayReach).
The snapshot blended to counts from the publish instant on, though its weight is 0 there, so a caller that holds SampleParts() taken at the publish instant and composes them later finds it (owner ruling R136). The state blended from counts while its weight at tBegin is above 0.
|
inline |
Publishes next by the R22 policy: it blends from the snapshot in use over time from start.
| [in] | next | The snapshot blended to; not null. |
| [in] | start | Start of the blend, s. |
| [in] | time | Duration of the blend, s; 0 replaces the state at once, for every t, and keeps nothing to blend from. |
| std::logic_error | if the blend in use has not ended by start (R22); the state in use stays. |
|
inlinestatic |
The samples of the state's snapshots at pos and t, to weigh at a later time (owner ruling R136).
Both snapshots are sampled, whatever their weight at t. The state blended from is a single snapshot (R22), so its full-weight sum does not depend on the time it is weighed at. Samples(state, t, pos).At(t2) equals Evaluate(state, t2, pos) bit for bit where the snapshots' samples at pos do not change from t to t2.