Abstract base class for 2-D scalar grid structure. More...
#include <Core/Grid/ScalarGrid2.h>
Public Types | |
using | ScalarDataAccessor = ArrayAccessor2< double > |
Read-write array accessor type. More... | |
using | ConstScalarDataAccessor = ConstArrayAccessor2< double > |
Read-only array accessor type. More... | |
Public Types inherited from CubbyFlow::Grid2 | |
using | DataPositionFunc = std::function< Vector2D(size_t, size_t)> |
Function type for mapping data index to actual position. More... | |
Public Member Functions | |
ScalarGrid2 () | |
Constructs an empty grid. More... | |
virtual | ~ScalarGrid2 () |
Default destructor. More... | |
virtual Size2 | GetDataSize () const =0 |
Returns the size of the grid data. More... | |
virtual Vector2D | GetDataOrigin () const =0 |
Returns the origin of the grid data. More... | |
virtual std::shared_ptr< ScalarGrid2 > | Clone () const =0 |
Returns the copy of the grid instance. More... | |
void | Clear () |
Clears the contents of the grid. More... | |
void | Resize (size_t resolutionX, size_t resolutionY, double gridSpacingX=1.0, double gridSpacingY=1.0, double originX=0.0, double originY=0.0, double initialValue=0.0) |
Resizes the grid using given parameters. More... | |
void | Resize (const Size2 &resolution, const Vector2D &gridSpacing=Vector2D(1, 1), const Vector2D &origin=Vector2D(), double initialValue=0.0) |
Resizes the grid using given parameters. More... | |
void | Resize (double gridSpacingX, double gridSpacingY, double originX, double originY) |
Resizes the grid using given parameters. More... | |
void | Resize (const Vector2D &gridSpacing, const Vector2D &origin) |
Resizes the grid using given parameters. More... | |
const double & | operator() (size_t i, size_t j) const |
Returns the grid data at given data point. More... | |
double & | operator() (size_t i, size_t j) |
Returns the grid data at given data point. More... | |
Vector2D | GradientAtDataPoint (size_t i, size_t j) const |
Returns the gradient vector at given data point. More... | |
double | LaplacianAtDataPoint (size_t i, size_t j) const |
Returns the Laplacian at given data point. More... | |
ScalarDataAccessor | GetDataAccessor () |
Returns the read-write data array accessor. More... | |
ConstScalarDataAccessor | GetConstDataAccessor () const |
Returns the read-only data array accessor. More... | |
DataPositionFunc | GetDataPosition () const |
Returns the function that maps data point to its position. More... | |
void | Fill (double value, ExecutionPolicy policy=ExecutionPolicy::Parallel) |
Fills the grid with given value. More... | |
void | Fill (const std::function< double(const Vector2D &)> &func, ExecutionPolicy policy=ExecutionPolicy::Parallel) |
Fills the grid with given position-to-value mapping function. More... | |
void | ForEachDataPointIndex (const std::function< void(size_t, size_t)> &func) const |
Invokes the given function func for each data point. More... | |
void | ParallelForEachDataPointIndex (const std::function< void(size_t, size_t)> &func) const |
Invokes the given function func for each data point in parallel. More... | |
double | Sample (const Vector2D &x) const override |
Returns the sampled value at given position x . More... | |
std::function< double(const Vector2D &)> | Sampler () const override |
Returns the sampler function. More... | |
Vector2D | Gradient (const Vector2D &x) const override |
Returns the gradient vector at given position x . More... | |
double | Laplacian (const Vector2D &x) const override |
Returns the Laplacian at given position x . More... | |
void | Serialize (std::vector< uint8_t > *buffer) const override |
Serializes the grid instance to the output buffer. More... | |
void | Deserialize (const std::vector< uint8_t > &buffer) override |
Deserializes the input buffer to the grid instance. More... | |
Public Member Functions inherited from CubbyFlow::ScalarField2 | |
ScalarField2 () | |
Default constructor. More... | |
virtual | ~ScalarField2 () |
Default destructor. More... | |
Public Member Functions inherited from CubbyFlow::Field2 | |
Field2 () | |
virtual | ~Field2 () |
Public Member Functions inherited from CubbyFlow::Grid2 | |
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 in parallel. 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... | |
Protected Member Functions | |
void | SwapScalarGrid (ScalarGrid2 *other) |
Swaps the data storage and predefined samplers with given grid. More... | |
void | SetScalarGrid (const ScalarGrid2 &other) |
Sets the data storage and predefined samplers with given grid. More... | |
void | GetData (std::vector< double > *data) const override |
Fetches the data into a continuous linear array. More... | |
void | SetData (const std::vector< double > &data) override |
Sets the data from a continuous linear array. More... | |
Protected Member Functions inherited from CubbyFlow::Grid2 | |
void | SetSizeParameters (const Size2 &resolution, const Vector2D &gridSpacing, const Vector2D &origin) |
Sets the size parameters including the resolution, grid spacing, and origin. More... | |
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... | |
Detailed Description
Abstract base class for 2-D scalar grid structure.
Member Typedef Documentation
◆ ConstScalarDataAccessor
using CubbyFlow::ScalarGrid2::ConstScalarDataAccessor = ConstArrayAccessor2<double> |
Read-only array accessor type.
◆ ScalarDataAccessor
using CubbyFlow::ScalarGrid2::ScalarDataAccessor = ArrayAccessor2<double> |
Read-write array accessor type.
Constructor & Destructor Documentation
◆ ScalarGrid2()
CubbyFlow::ScalarGrid2::ScalarGrid2 | ( | ) |
Constructs an empty grid.
◆ ~ScalarGrid2()
|
virtual |
Default destructor.
Member Function Documentation
◆ Clear()
void CubbyFlow::ScalarGrid2::Clear | ( | ) |
Clears the contents of the grid.
◆ Clone()
|
pure virtual |
Returns the copy of the grid instance.
Implemented in CubbyFlow::CellCenteredScalarGrid2, and CubbyFlow::VertexCenteredScalarGrid2.
◆ Deserialize()
|
overridevirtual |
Deserializes the input buffer to the grid instance.
Implements CubbyFlow::Serializable.
◆ Fill() [1/2]
void CubbyFlow::ScalarGrid2::Fill | ( | double | value, |
ExecutionPolicy | policy = ExecutionPolicy::Parallel |
||
) |
Fills the grid with given value.
◆ Fill() [2/2]
void CubbyFlow::ScalarGrid2::Fill | ( | const std::function< double(const Vector2D &)> & | func, |
ExecutionPolicy | policy = ExecutionPolicy::Parallel |
||
) |
Fills the grid with given position-to-value mapping function.
◆ ForEachDataPointIndex()
void CubbyFlow::ScalarGrid2::ForEachDataPointIndex | ( | const std::function< void(size_t, size_t)> & | func | ) | const |
Invokes the given function func
for each data point.
This function invokes the given function object func
for each data point in serial manner. The input parameters are i and j indices of a data point. The order of execution is i-first, j-last.
◆ GetConstDataAccessor()
ConstScalarDataAccessor CubbyFlow::ScalarGrid2::GetConstDataAccessor | ( | ) | const |
Returns the read-only data array accessor.
◆ GetData()
|
overrideprotectedvirtual |
Fetches the data into a continuous linear array.
Implements CubbyFlow::Grid2.
◆ GetDataAccessor()
ScalarDataAccessor CubbyFlow::ScalarGrid2::GetDataAccessor | ( | ) |
Returns the read-write data array accessor.
◆ GetDataOrigin()
|
pure virtual |
Returns the origin of the grid data.
This function returns data position for the grid point at (0, 0). Note that this is different from origin() since origin() returns the lower corner point of the bounding box.
Implemented in CubbyFlow::CellCenteredScalarGrid2, and CubbyFlow::VertexCenteredScalarGrid2.
◆ GetDataPosition()
DataPositionFunc CubbyFlow::ScalarGrid2::GetDataPosition | ( | ) | const |
Returns the function that maps data point to its position.
◆ GetDataSize()
|
pure virtual |
Returns the size of the grid data.
This function returns the size of the grid data which is not necessarily equal to the grid resolution if the data is not stored at cell-center.
Implemented in CubbyFlow::CellCenteredScalarGrid2, and CubbyFlow::VertexCenteredScalarGrid2.
◆ Gradient()
Returns the gradient vector at given position x
.
Reimplemented from CubbyFlow::ScalarField2.
◆ GradientAtDataPoint()
Vector2D CubbyFlow::ScalarGrid2::GradientAtDataPoint | ( | size_t | i, |
size_t | j | ||
) | const |
Returns the gradient vector at given data point.
◆ Laplacian()
|
overridevirtual |
Returns the Laplacian at given position x
.
Reimplemented from CubbyFlow::ScalarField2.
◆ LaplacianAtDataPoint()
double CubbyFlow::ScalarGrid2::LaplacianAtDataPoint | ( | size_t | i, |
size_t | j | ||
) | const |
Returns the Laplacian at given data point.
◆ operator()() [1/2]
const double& CubbyFlow::ScalarGrid2::operator() | ( | size_t | i, |
size_t | j | ||
) | const |
Returns the grid data at given data point.
◆ operator()() [2/2]
double& CubbyFlow::ScalarGrid2::operator() | ( | size_t | i, |
size_t | j | ||
) |
Returns the grid data at given data point.
◆ ParallelForEachDataPointIndex()
void CubbyFlow::ScalarGrid2::ParallelForEachDataPointIndex | ( | const std::function< void(size_t, size_t)> & | func | ) | const |
Invokes the given function func
for each data point in parallel.
This function invokes the given function object func
for each data point in parallel manner. The input parameters are i and j indices of a data point. The order of execution can be arbitrary since it's multi-threaded.
◆ Resize() [1/4]
void CubbyFlow::ScalarGrid2::Resize | ( | size_t | resolutionX, |
size_t | resolutionY, | ||
double | gridSpacingX = 1.0 , |
||
double | gridSpacingY = 1.0 , |
||
double | originX = 0.0 , |
||
double | originY = 0.0 , |
||
double | initialValue = 0.0 |
||
) |
Resizes the grid using given parameters.
◆ Resize() [2/4]
void CubbyFlow::ScalarGrid2::Resize | ( | const Size2 & | resolution, |
const Vector2D & | gridSpacing = Vector2D(1, 1) , |
||
const Vector2D & | origin = Vector2D() , |
||
double | initialValue = 0.0 |
||
) |
Resizes the grid using given parameters.
◆ Resize() [3/4]
void CubbyFlow::ScalarGrid2::Resize | ( | double | gridSpacingX, |
double | gridSpacingY, | ||
double | originX, | ||
double | originY | ||
) |
Resizes the grid using given parameters.
◆ Resize() [4/4]
Resizes the grid using given parameters.
◆ Sample()
|
overridevirtual |
Returns the sampled value at given position x
.
This function returns the data sampled at arbitrary position x
. The sampling function is linear.
Implements CubbyFlow::ScalarField2.
◆ Sampler()
|
overridevirtual |
Returns the sampler function.
This function returns the data sampler function object. The sampling function is linear.
Reimplemented from CubbyFlow::ScalarField2.
◆ Serialize()
|
overridevirtual |
Serializes the grid instance to the output buffer.
Implements CubbyFlow::Serializable.
◆ SetData()
|
overrideprotectedvirtual |
Sets the data from a continuous linear array.
Implements CubbyFlow::Grid2.
◆ SetScalarGrid()
|
protected |
Sets the data storage and predefined samplers with given grid.
◆ SwapScalarGrid()
|
protected |
Swaps the data storage and predefined samplers with given grid.
The documentation for this class was generated from the following file:
- Core/Grid/ScalarGrid2.h