FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
marenv::wake::WakeBuilder Class Reference

#include <WakeBuilder.h>

Public Member Functions

 WakeBuilder (const WakeFrame &frame, const GridSpec &grid, const KernelParams &params)
 
double SampleDeficit (const double pos[3]) const
 
void AddSource (const ElementarySource &source)
 
std::shared_ptr< const GriddedSnapshot > Finish (const double velocity[3])
 

Detailed Description

Builds a GriddedSnapshot one source at a time.

The grid is the GridSpec box in the WakeFrame at its build time t0: xi along frame.axes[0] from -upstreamMargin to lengthDownstream, and +-halfWidth, +-halfHeight along axes[1] and axes[2], with grid.n[a] cells along axis a. Each source adds log(1 - d) at the grid nodes inside its truncated footprint, so the composed deficit 1 - prod(1 - d_i) of plan B1 is 1 - exp(sum log(1 - d_i)).

Marching protocol (plan B1). The builder is incremental so that a casting structure can resolve wake-on-wake shading in one pass; the builder itself never evaluates a load law:

  1. Sort the sources by position along the mean relative flow, frame.axes[0].
  2. For each source in that order, call SampleDeficit() at its centroid. This is the deficit of all sources upstream of it (a source is never in its own kernel, which starts at x_start, and kernels act only downstream).
  3. Re-evaluate the source's load at that waked inflow and set its momentumDeficit from it.
  4. AddSource() it. Finish(velocity) then returns the immutable snapshot for GriddedWake::Publish().

Deposit. The kernel is that of ElementaryDeficit(). Where its width sigma is below sigma_grid = 0.6 h, the Gaussian is deposited with width sigma_grid and its amplitude scaled by (sigma / sigma_grid)^2, which keeps the cross-section integral of d (C4, review B-5 d). h is the largest grid spacing seen across the source's flow, max_a h_a sqrt(1 - f_a^2) with f the flow direction in the frame; for a source aligned with axes[0] it is max(h_1, h_2). Nodes where the deposited deficit is below KernelParams::cutoff are skipped.

Images (owner rulings R53, R98). AddSource() also deposits each image of MirrorImages(params) at the build time: the source mirrored at each plane, position and flow direction, and with both planes the source shifted by 2 H up and down (the image of each mirror image at the other plane), flow direction unchanged; only the sources count for the resolution warning. The grid translates with the frame, so the images do not follow a vertical frame velocity mirrored.

Constructor & Destructor Documentation

◆ WakeBuilder()

marenv::wake::WakeBuilder::WakeBuilder ( const WakeFrame &  frame,
const GridSpec &  grid,
const KernelParams &  params 
)

Starts an empty field; the velocity of the field is given at the end, to Finish(velocity) (MENV-0058).

Parameters
[in]frameFrame of the grid at its build time frame.t0; its axes must be orthonormal. frame.velocity is not used while building (every sample is at t0) and is replaced by Finish(velocity); it must be finite.
[in]gridExtent and resolution of the grid in the frame.
[in]paramsKernel parameters.
Exceptions
std::invalid_argumentfor non-orthonormal axes, a non-finite frame origin, axes, velocity or t0, a non-positive extent, fewer than one cell along an axis, params for which Validate() throws (MENV-0049) or params.superposition other than Product (the builder composes by the product rule only; it builds a net's private field, R88, R95).

Member Function Documentation

◆ AddSource()

void marenv::wake::WakeBuilder::AddSource ( const ElementarySource &  source)

Adds the kernel of one source to the field.

Parameters
[in]sourceThe elementary source, world NED at frame.t0; flowDir is normalised here. A source with no momentum deficit adds nothing.
Exceptions
std::invalid_argumentif the position, area or momentum deficit is not finite, the area is not positive, the momentum deficit is negative or flowDir has zero length; std::logic_error after Finish().

◆ Finish()

std::shared_ptr< const GriddedSnapshot > marenv::wake::WakeBuilder::Finish ( const double  velocity[3])

Finishes the build with the field's velocity, known only now (after the caster's R50 snap); the builder is empty afterwards (MENV-0058).

Parameters
[in]velocityVelocity of the field, m/s, NED: the snapshot's frame translates with it from frame.t0 on and its sources drag the water at it (u_s).
Returns
The immutable snapshot, with frame.velocity and sourceVelocity set to velocity. Its warning is set if x_start is below 1.5 cells for any source, measured along the source's flow as sum_a h_a |f_a|, because trilinear smear over one cell can then reach the source's own centroid (self-shadowing, plan B3). marenv has no logger, so the casting structure writes the warning to its own log.
Exceptions
std::invalid_argumentfor a non-finite velocity; std::logic_error when called twice.

◆ SampleDeficit()

double marenv::wake::WakeBuilder::SampleDeficit ( const double  pos[3]) const

Returns the deficit of the partial field built so far.

Parameters
[in]posQuery position, m, world NED at the build time frame.t0.
Returns
Deficit d in [0, 1]; 0 outside the grid.
Exceptions
std::logic_errorafter Finish().

The documentation for this class was generated from the following file: