FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
environment::WaterMap Class Reference

#include <WaterMap.h>

Classes

struct  Sample
 The state at a point. More...
 

Public Member Functions

 WaterMap (int rows, int cols, double northMin, double eastMin, double spacing, std::vector< float > cells)
 
Sample At (double north, double east) const
 
int Rows () const
 
int Cols () const
 
double NorthMin () const
 
double EastMin () const
 
double Spacing () const
 
bool HasFlow () const
 True when some cell has a flow.
 
const std::vector< float > & Cells () const
 The cells, rows * cols * kChannels, row 0 south.
 

Static Public Member Functions

static std::shared_ptr< const WaterMap > Load (const std::string &jsonPath)
 

Static Public Attributes

static constexpr int kChannels = 3
 Channels kept per cell.
 

Detailed Description

A map of the state of the water surface over the domain: wave shelter and surface flow (river and sheltered water, doc/plans/river-and-sheltered-water.md, Phase 1).

Per cell: shelter s in [0, 1] (0 fully sheltered, 1 open sea) and the surface flow (north, east) [m/s]. Outside the map s = 1 and there is no flow, so a map changes the water only where it covers it.

File format fhsim_environment.watermap/1: a JSON header and a raw grid, the layout of fhsim_fjord's elevation grid (its ADR 0001 D3):

{ "format": "fhsim_environment.watermap/1",
"north_min": -4000.0, "east_min": -1000.0, "spacing": 10.0, "rows": 400, "cols": 300,
"channels": ["shelter", "flow_north", "flow_east"], "raw": "munkholmen_watermap.raw" }

The raw file holds little-endian float32 values, rows * cols * channels, interleaved per cell, row-major with row 0 at the south edge; cell centres at north_min + (row + 0.5) spacing, east_min + (col + 0.5) spacing. channels is ["shelter"] or ["shelter", "flow_north", "flow_east"]. A relative raw path is relative to the JSON file.

No Ogre types: tested without visualization. Frame: NED.

Constructor & Destructor Documentation

◆ WaterMap()

environment::WaterMap::WaterMap ( int  rows,
int  cols,
double  northMin,
double  eastMin,
double  spacing,
std::vector< float >  cells 
)
Parameters
[in]rows,colsCells along north and east (at least 2 each).
[in]northMin,eastMinSouth-west corner of the map (the edge, not the first cell centre) [m].
[in]spacingCell size [m], positive.
[in]cellsrows * cols * kChannels values (shelter, flow north, flow east), row 0 south.
Exceptions
std::invalid_argumenton sizes or values out of range.

Member Function Documentation

◆ At()

Sample environment::WaterMap::At ( double  north,
double  east 
) const

The state at (north, east): bilinear between cell centres, the edge cells' values out to the map's edge, and the open sea (shelter 1, no flow) outside it.

◆ Load()

static std::shared_ptr< const WaterMap > environment::WaterMap::Load ( const std::string &  jsonPath)
static

Read a map from its JSON header (and the raw file it names).

Parameters
[in]jsonPathPath of the header.
Returns
The map.
Exceptions
std::runtime_errorwith the reason (missing file, wrong format, size mismatch, values out of range).

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