FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
marenv::grid::UniformGrid3< T > Class Template Reference

#include <UniformGrid3.h>

Public Member Functions

 UniformGrid3 ()=default
 An empty grid; Contains() is false everywhere.
 
 UniformGrid3 (const double lower[3], const double spacing[3], const int numCells[3], const T &initial=T {})
 
int NumCells (int axis) const
 Number of cells along axis.
 
double Spacing (int axis) const
 Node spacing along axis.
 
double NodeCoordinate (int axis, int index) const
 Coordinate of node index along axis.
 
T & At (int i, int j, int k)
 Value at node (i, j, k); no bounds check.
 
const T & At (int i, int j, int k) const
 Value at node (i, j, k); no bounds check.
 
bool Contains (const double pos[3]) const
 
bool Interpolate (const double pos[3], T &out) const
 

Detailed Description

template<class T>
class marenv::grid::UniformGrid3< T >

Values at the nodes of an axis-aligned uniform 3D grid, read back by trilinear interpolation.

The grid spans the box [lower[a], lower[a] + numCells[a] * spacing[a]] along each axis a and holds numCells[a] + 1 nodes along it. Coordinates are those of whatever frame the caller works in; the grid knows no world frame.

Generalised from the trilinear code of marenv::current::CurrentField3DArray, which keeps its own copy (its depth layers are not uniformly spaced).

Template Parameters
TNode value type; needs T{} as zero, T + T and double * T.

Constructor & Destructor Documentation

◆ UniformGrid3()

template<class T >
marenv::grid::UniformGrid3< T >::UniformGrid3 ( const double  lower[3],
const double  spacing[3],
const int  numCells[3],
const T &  initial = T {} 
)
inline

Creates a grid with every node set to initial.

Parameters
[in]lowerCoordinates of node (0, 0, 0).
[in]spacingNode spacing along each axis, > 0.
[in]numCellsNumber of cells along each axis, >= 1.
[in]initialInitial node value.
Exceptions
std::invalid_argumentfor a non-positive spacing or cell count.

Member Function Documentation

◆ Contains()

template<class T >
bool marenv::grid::UniformGrid3< T >::Contains ( const double  pos[3]) const
inline

Tells whether a point lies in the grid box, boundaries included.

A point within boundarySlack cells outside a face counts as on it, so that nodes on the boundary stay inside after a rounding frame transform.

Parameters
[in]posPoint in grid coordinates.

◆ Interpolate()

template<class T >
bool marenv::grid::UniformGrid3< T >::Interpolate ( const double  pos[3],
T &  out 
) const
inline

Interpolates the node values trilinearly at a point.

Parameters
[in]posPoint in grid coordinates.
[out]outInterpolated value; T{} outside the grid.
Returns
true inside the grid box (boundaries included), false outside.

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