Jet  v1.3.3
Public Types | Public Member Functions | Protected Member Functions | List of all members
jet::Grid2 Class Referenceabstract

Abstract base class for 2-D cartesian grid structure. More...

#include <jet/grid2.h>

Inheritance diagram for jet::Grid2:
jet::Serializable jet::ScalarGrid2 jet::VectorGrid2 jet::CellCenteredScalarGrid2 jet::VertexCenteredScalarGrid2 jet::CollocatedVectorGrid2 jet::FaceCenteredGrid2 jet::CellCenteredVectorGrid2 jet::VertexCenteredVectorGrid2

Public Types

typedef std::function< Vector2D(size_t, size_t)> DataPositionFunc
 Function type for mapping data index to actual position. More...
 

Public Member Functions

 Grid2 ()
 Constructs an empty grid. More...
 
virtual ~Grid2 ()
 Default destructor. More...
 
virtual std::string typeName () const =0
 Returns the type name of derived grid. More...
 
const Size2 & resolution () const
 Returns the grid resolution. More...
 
const Vector2D & origin () const
 Returns the grid origin. More...
 
const Vector2D & gridSpacing () const
 Returns the grid spacing. More...
 
const BoundingBox2D & boundingBox () const
 Returns the bounding box of the grid. More...
 
DataPositionFunc cellCenterPosition () const
 Returns the function that maps grid index to the cell-center position. More...
 
void forEachCellIndex (const std::function< void(size_t, size_t)> &func) const
 Invokes the given function func for each grid cell. More...
 
void parallelForEachCellIndex (const std::function< void(size_t, size_t)> &func) const
 Invokes the given function func for each grid cell parallelly. More...
 
bool hasSameShape (const Grid2 &other) const
 Returns true if resolution, grid-spacing and origin are same. More...
 
virtual void swap (Grid2 *other)=0
 Swaps the data with other grid. More...
 
- Public Member Functions inherited from jet::Serializable
 Serializable ()=default
 
virtual ~Serializable ()=default
 
virtual void serialize (std::vector< uint8_t > *buffer) const =0
 Serializes this instance into the flat buffer. More...
 
virtual void deserialize (const std::vector< uint8_t > &buffer)=0
 Deserializes this instance from the flat buffer. More...
 

Protected Member Functions

void setSizeParameters (const Size2 &resolution, const Vector2D &gridSpacing, const Vector2D &origin)
 
void swapGrid (Grid2 *other)
 Swaps the size parameters with given grid other. More...
 
void setGrid (const Grid2 &other)
 Sets the size parameters with given grid other. More...
 
virtual void getData (std::vector< double > *data) const =0
 Fetches the data into a continuous linear array. More...
 
virtual void setData (const std::vector< double > &data)=0
 Sets the data from a continuous linear array. More...
 

Detailed Description

Abstract base class for 2-D cartesian grid structure.

This class represents 2-D cartesian grid structure. This class is an abstract base class and does not store any data. The class only stores the shape of the grid. The grid structure is axis-aligned and can have different grid spacing per axis.

Member Typedef Documentation

◆ DataPositionFunc

typedef std::function<Vector2D(size_t, size_t)> jet::Grid2::DataPositionFunc

Function type for mapping data index to actual position.

Constructor & Destructor Documentation

◆ Grid2()

jet::Grid2::Grid2 ( )

Constructs an empty grid.

◆ ~Grid2()

virtual jet::Grid2::~Grid2 ( )
virtual

Default destructor.

Member Function Documentation

◆ boundingBox()

const BoundingBox2D& jet::Grid2::boundingBox ( ) const

Returns the bounding box of the grid.

◆ cellCenterPosition()

DataPositionFunc jet::Grid2::cellCenterPosition ( ) const

Returns the function that maps grid index to the cell-center position.

◆ forEachCellIndex()

void jet::Grid2::forEachCellIndex ( const std::function< void(size_t, size_t)> &  func) const

Invokes the given function func for each grid cell.

This function invokes the given function object func for each grid cell in serial manner. The input parameters are i and j indices of a grid cell. The order of execution is i-first, j-last.

◆ getData()

virtual void jet::Grid2::getData ( std::vector< double > *  data) const
protectedpure virtual

Fetches the data into a continuous linear array.

Implemented in jet::FaceCenteredGrid2, jet::ScalarGrid2, and jet::CollocatedVectorGrid2.

◆ gridSpacing()

const Vector2D& jet::Grid2::gridSpacing ( ) const

Returns the grid spacing.

◆ hasSameShape()

bool jet::Grid2::hasSameShape ( const Grid2 &  other) const

Returns true if resolution, grid-spacing and origin are same.

◆ origin()

const Vector2D& jet::Grid2::origin ( ) const

Returns the grid origin.

◆ parallelForEachCellIndex()

void jet::Grid2::parallelForEachCellIndex ( const std::function< void(size_t, size_t)> &  func) const

Invokes the given function func for each grid cell parallelly.

This function invokes the given function object func for each grid cell in parallel manner. The input parameters are i and j indices of a grid cell. The order of execution can be arbitrary since it's multi-threaded.

◆ resolution()

const Size2& jet::Grid2::resolution ( ) const

Returns the grid resolution.

◆ setData()

virtual void jet::Grid2::setData ( const std::vector< double > &  data)
protectedpure virtual

Sets the data from a continuous linear array.

Implemented in jet::FaceCenteredGrid2, jet::ScalarGrid2, and jet::CollocatedVectorGrid2.

◆ setGrid()

void jet::Grid2::setGrid ( const Grid2 &  other)
protected

Sets the size parameters with given grid other.

◆ setSizeParameters()

void jet::Grid2::setSizeParameters ( const Size2 &  resolution,
const Vector2D &  gridSpacing,
const Vector2D &  origin 
)
protected

Sets the size parameters including the resolution, grid spacing, and origin.

◆ swap()

virtual void jet::Grid2::swap ( Grid2 *  other)
pure virtual

◆ swapGrid()

void jet::Grid2::swapGrid ( Grid2 *  other)
protected

Swaps the size parameters with given grid other.

◆ typeName()

virtual std::string jet::Grid2::typeName ( ) const
pure virtual

Returns the type name of derived grid.


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