|
FhSim
3.1.0
Marine systems simulation
|
#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. | |
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):
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.
| environment::WaterMap::WaterMap | ( | int | rows, |
| int | cols, | ||
| double | northMin, | ||
| double | eastMin, | ||
| double | spacing, | ||
| std::vector< float > | cells | ||
| ) |
| [in] | rows,cols | Cells along north and east (at least 2 each). |
| [in] | northMin,eastMin | South-west corner of the map (the edge, not the first cell centre) [m]. |
| [in] | spacing | Cell size [m], positive. |
| [in] | cells | rows * cols * kChannels values (shelter, flow north, flow east), row 0 south. |
| std::invalid_argument | on sizes or values out of range. |
| 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.
|
static |
Read a map from its JSON header (and the raw file it names).
| [in] | jsonPath | Path of the header. |
| std::runtime_error | with the reason (missing file, wrong format, size mismatch, values out of range). |