Jet
v1.3.3
|
Abstract base class for 2-D scalar grid structure. More...
#include <jet/scalar_grid2.h>
Public Types | |
typedef ArrayAccessor2< double > | ScalarDataAccessor |
Read-write array accessor type. More... | |
typedef ConstArrayAccessor2< double > | ConstScalarDataAccessor |
Read-only array accessor type. More... | |
![]() | |
typedef std::function< Vector2D(size_t, size_t)> | DataPositionFunc |
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 | dataSize () const =0 |
Returns the size of the grid data. More... | |
virtual Vector2D | dataOrigin () 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 | dataAccessor () |
Returns the read-write data array accessor. More... | |
ConstScalarDataAccessor | constDataAccessor () const |
Returns the read-only data array accessor. More... | |
DataPositionFunc | dataPosition () const |
Returns the function that maps data point to its position. More... | |
void | fill (double value, ExecutionPolicy policy=ExecutionPolicy::kParallel) |
Fills the grid with given value. More... | |
void | fill (const std::function< double(const Vector2D &)> &func, ExecutionPolicy policy=ExecutionPolicy::kParallel) |
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 parallelly. 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... | |
![]() | |
ScalarField2 () | |
Default constructor. More... | |
virtual | ~ScalarField2 () |
Default destructor. More... | |
![]() | |
Field2 () | |
virtual | ~Field2 () |
![]() | |
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... | |
![]() | |
Serializable ()=default | |
virtual | ~Serializable ()=default |
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... | |
![]() | |
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... | |
Abstract base class for 2-D scalar grid structure.
typedef ConstArrayAccessor2<double> jet::ScalarGrid2::ConstScalarDataAccessor |
Read-only array accessor type.
typedef ArrayAccessor2<double> jet::ScalarGrid2::ScalarDataAccessor |
Read-write array accessor type.
jet::ScalarGrid2::ScalarGrid2 | ( | ) |
Constructs an empty grid.
|
virtual |
Default destructor.
void jet::ScalarGrid2::clear | ( | ) |
Clears the contents of the grid.
|
pure virtual |
Returns the copy of the grid instance.
Implemented in jet::CellCenteredScalarGrid2, and jet::VertexCenteredScalarGrid2.
ConstScalarDataAccessor jet::ScalarGrid2::constDataAccessor | ( | ) | const |
Returns the read-only data array accessor.
ScalarDataAccessor jet::ScalarGrid2::dataAccessor | ( | ) |
Returns the read-write data array accessor.
|
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 jet::VertexCenteredScalarGrid2, and jet::CellCenteredScalarGrid2.
DataPositionFunc jet::ScalarGrid2::dataPosition | ( | ) | const |
Returns the function that maps data point to its position.
|
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 jet::VertexCenteredScalarGrid2, and jet::CellCenteredScalarGrid2.
|
overridevirtual |
Deserializes the input buffer to the grid instance.
Implements jet::Serializable.
void jet::ScalarGrid2::fill | ( | const std::function< double(const Vector2D &)> & | func, |
ExecutionPolicy | policy = ExecutionPolicy::kParallel |
||
) |
Fills the grid with given position-to-value mapping function.
void jet::ScalarGrid2::fill | ( | double | value, |
ExecutionPolicy | policy = ExecutionPolicy::kParallel |
||
) |
Fills the grid with given value.
void jet::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.
|
overrideprotectedvirtual |
Fetches the data into a continuous linear array.
Implements jet::Grid2.
Returns the gradient vector at given position x
.
Reimplemented from jet::ScalarField2.
Vector2D jet::ScalarGrid2::gradientAtDataPoint | ( | size_t | i, |
size_t | j | ||
) | const |
Returns the gradient vector at given data point.
|
overridevirtual |
Returns the Laplacian at given position x
.
Reimplemented from jet::ScalarField2.
double jet::ScalarGrid2::laplacianAtDataPoint | ( | size_t | i, |
size_t | j | ||
) | const |
Returns the Laplacian at given data point.
double& jet::ScalarGrid2::operator() | ( | size_t | i, |
size_t | j | ||
) |
Returns the grid data at given data point.
const double& jet::ScalarGrid2::operator() | ( | size_t | i, |
size_t | j | ||
) | const |
Returns the grid data at given data point.
void jet::ScalarGrid2::parallelForEachDataPointIndex | ( | const std::function< void(size_t, size_t)> & | func | ) | const |
Invokes the given function func
for each data point parallelly.
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.
void jet::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.
Resizes the grid using given parameters.
void jet::ScalarGrid2::resize | ( | double | gridSpacingX, |
double | gridSpacingY, | ||
double | originX, | ||
double | originY | ||
) |
Resizes the grid using given parameters.
void jet::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.
|
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 jet::ScalarField2.
|
overridevirtual |
Returns the sampler function.
This function returns the data sampler function object. The sampling function is linear.
Reimplemented from jet::ScalarField2.
|
overridevirtual |
Serializes the grid instance to the output buffer.
Implements jet::Serializable.
|
overrideprotectedvirtual |
Sets the data from a continuous linear array.
Implements jet::Grid2.
|
protected |
Sets the data storage and predefined samplers with given grid.
|
protected |
Swaps the data storage and predefined samplers with given grid.