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

Abstract base class for 3-D scalar grid structure. More...

#include <jet/scalar_grid3.h>

Inheritance diagram for jet::ScalarGrid3:
jet::ScalarField3 jet::Grid3 jet::Field3 jet::Serializable jet::CellCenteredScalarGrid3 jet::VertexCenteredScalarGrid3

Public Types

typedef ArrayAccessor3< double > ScalarDataAccessor
 Read-write array accessor type. More...
 
typedef ConstArrayAccessor3< double > ConstScalarDataAccessor
 Read-only array accessor type. More...
 
- Public Types inherited from jet::Grid3
typedef std::function< Vector3D(size_t, size_t, size_t)> DataPositionFunc
 Function type for mapping data index to actual position. More...
 

Public Member Functions

 ScalarGrid3 ()
 Constructs an empty grid. More...
 
virtual ~ScalarGrid3 ()
 Default destructor. More...
 
virtual Size3 dataSize () const =0
 Returns the size of the grid data. More...
 
virtual Vector3D dataOrigin () const =0
 Returns the origin of the grid data. More...
 
virtual std::shared_ptr< ScalarGrid3clone () 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, size_t resolutionZ, double gridSpacingX=1.0, double gridSpacingY=1.0, double gridSpacingZ=1.0, double originX=0.0, double originY=0.0, double originZ=0.0, double initialValue=0.0)
 Resizes the grid using given parameters. More...
 
void resize (const Size3 &resolution, const Vector3D &gridSpacing=Vector3D(1, 1, 1), const Vector3D &origin=Vector3D(), double initialValue=0.0)
 Resizes the grid using given parameters. More...
 
void resize (double gridSpacingX, double gridSpacingY, double gridSpacingZ, double originX, double originY, double originZ)
 Resizes the grid using given parameters. More...
 
void resize (const Vector3D &gridSpacing, const Vector3D &origin)
 Resizes the grid using given parameters. More...
 
const double & operator() (size_t i, size_t j, size_t k) const
 Returns the grid data at given data point. More...
 
double & operator() (size_t i, size_t j, size_t k)
 Returns the grid data at given data point. More...
 
Vector3D gradientAtDataPoint (size_t i, size_t j, size_t k) const
 Returns the gradient vector at given data point. More...
 
double laplacianAtDataPoint (size_t i, size_t j, size_t k) 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 Vector3D &)> &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, size_t)> &func) const
 Invokes the given function func for each data point. More...
 
void parallelForEachDataPointIndex (const std::function< void(size_t, size_t, size_t)> &func) const
 Invokes the given function func for each data point parallelly. More...
 
double sample (const Vector3D &x) const override
 Returns the sampled value at given position x. More...
 
std::function< double(const Vector3D &)> sampler () const override
 Returns the sampler function. More...
 
Vector3D gradient (const Vector3D &x) const override
 Returns the gradient vector at given position x. More...
 
double laplacian (const Vector3D &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 jet::ScalarField3
 ScalarField3 ()
 Default constructor. More...
 
virtual ~ScalarField3 ()
 Default destructor. More...
 
- Public Member Functions inherited from jet::Field3
 Field3 ()
 
virtual ~Field3 ()
 
- Public Member Functions inherited from jet::Grid3
 Grid3 ()
 Constructs an empty grid. More...
 
virtual ~Grid3 ()
 Default destructor. More...
 
virtual std::string typeName () const =0
 Returns the type name of derived grid. More...
 
const Size3resolution () const
 Returns the grid resolution. More...
 
const Vector3Dorigin () const
 Returns the grid origin. More...
 
const Vector3DgridSpacing () const
 Returns the grid spacing. More...
 
const BoundingBox3DboundingBox () 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, size_t)> &func) const
 Invokes the given function func for each grid cell. More...
 
void parallelForEachCellIndex (const std::function< void(size_t, size_t, size_t)> &func) const
 Invokes the given function func for each grid cell parallelly. More...
 
bool hasSameShape (const Grid3 &other) const
 Returns true if resolution, grid-spacing and origin are same. More...
 
virtual void swap (Grid3 *other)=0
 Swaps the data with other grid. More...
 
- Public Member Functions inherited from jet::Serializable
 Serializable ()=default
 
virtual ~Serializable ()=default
 

Protected Member Functions

void swapScalarGrid (ScalarGrid3 *other)
 Swaps the data storage and predefined samplers with given grid. More...
 
void setScalarGrid (const ScalarGrid3 &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 jet::Grid3
void setSizeParameters (const Size3 &resolution, const Vector3D &gridSpacing, const Vector3D &origin)
 
void swapGrid (Grid3 *other)
 Swaps the size parameters with given grid other. More...
 
void setGrid (const Grid3 &other)
 Sets the size parameters with given grid other. More...
 

Detailed Description

Abstract base class for 3-D scalar grid structure.

Member Typedef Documentation

◆ ConstScalarDataAccessor

Read-only array accessor type.

◆ ScalarDataAccessor

Read-write array accessor type.

Constructor & Destructor Documentation

◆ ScalarGrid3()

jet::ScalarGrid3::ScalarGrid3 ( )

Constructs an empty grid.

◆ ~ScalarGrid3()

virtual jet::ScalarGrid3::~ScalarGrid3 ( )
virtual

Default destructor.

Member Function Documentation

◆ clear()

void jet::ScalarGrid3::clear ( )

Clears the contents of the grid.

◆ clone()

virtual std::shared_ptr<ScalarGrid3> jet::ScalarGrid3::clone ( ) const
pure virtual

Returns the copy of the grid instance.

Implemented in jet::VertexCenteredScalarGrid3, and jet::CellCenteredScalarGrid3.

◆ constDataAccessor()

ConstScalarDataAccessor jet::ScalarGrid3::constDataAccessor ( ) const

Returns the read-only data array accessor.

◆ dataAccessor()

ScalarDataAccessor jet::ScalarGrid3::dataAccessor ( )

Returns the read-write data array accessor.

◆ dataOrigin()

virtual Vector3D jet::ScalarGrid3::dataOrigin ( ) const
pure virtual

Returns the origin of the grid data.

This function returns data position for the grid point at (0, 0, 0). Note that this is different from origin() since origin() returns the lower corner point of the bounding box.

Implemented in jet::VertexCenteredScalarGrid3, and jet::CellCenteredScalarGrid3.

◆ dataPosition()

DataPositionFunc jet::ScalarGrid3::dataPosition ( ) const

Returns the function that maps data point to its position.

◆ dataSize()

virtual Size3 jet::ScalarGrid3::dataSize ( ) const
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::VertexCenteredScalarGrid3, and jet::CellCenteredScalarGrid3.

◆ deserialize()

void jet::ScalarGrid3::deserialize ( const std::vector< uint8_t > &  buffer)
overridevirtual

Deserializes the input buffer to the grid instance.

Implements jet::Grid3.

◆ fill() [1/2]

void jet::ScalarGrid3::fill ( const std::function< double(const Vector3D &)> &  func,
ExecutionPolicy  policy = ExecutionPolicy::kParallel 
)

Fills the grid with given position-to-value mapping function.

◆ fill() [2/2]

void jet::ScalarGrid3::fill ( double  value,
ExecutionPolicy  policy = ExecutionPolicy::kParallel 
)

Fills the grid with given value.

◆ forEachDataPointIndex()

void jet::ScalarGrid3::forEachDataPointIndex ( const std::function< void(size_t, 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.

◆ getData()

void jet::ScalarGrid3::getData ( std::vector< double > *  data) const
overrideprotectedvirtual

Fetches the data into a continuous linear array.

Implements jet::Grid3.

◆ gradient()

Vector3D jet::ScalarGrid3::gradient ( const Vector3D x) const
overridevirtual

Returns the gradient vector at given position x.

Reimplemented from jet::ScalarField3.

◆ gradientAtDataPoint()

Vector3D jet::ScalarGrid3::gradientAtDataPoint ( size_t  i,
size_t  j,
size_t  k 
) const

Returns the gradient vector at given data point.

◆ laplacian()

double jet::ScalarGrid3::laplacian ( const Vector3D x) const
overridevirtual

Returns the Laplacian at given position x.

Reimplemented from jet::ScalarField3.

◆ laplacianAtDataPoint()

double jet::ScalarGrid3::laplacianAtDataPoint ( size_t  i,
size_t  j,
size_t  k 
) const

Returns the Laplacian at given data point.

◆ operator()() [1/2]

double& jet::ScalarGrid3::operator() ( size_t  i,
size_t  j,
size_t  k 
)

Returns the grid data at given data point.

◆ operator()() [2/2]

const double& jet::ScalarGrid3::operator() ( size_t  i,
size_t  j,
size_t  k 
) const

Returns the grid data at given data point.

◆ parallelForEachDataPointIndex()

void jet::ScalarGrid3::parallelForEachDataPointIndex ( const std::function< void(size_t, 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.

◆ resize() [1/4]

void jet::ScalarGrid3::resize ( const Size3 resolution,
const Vector3D gridSpacing = Vector3D(1, 1, 1),
const Vector3D origin = Vector3D(),
double  initialValue = 0.0 
)

Resizes the grid using given parameters.

◆ resize() [2/4]

void jet::ScalarGrid3::resize ( const Vector3D gridSpacing,
const Vector3D origin 
)

Resizes the grid using given parameters.

◆ resize() [3/4]

void jet::ScalarGrid3::resize ( double  gridSpacingX,
double  gridSpacingY,
double  gridSpacingZ,
double  originX,
double  originY,
double  originZ 
)

Resizes the grid using given parameters.

◆ resize() [4/4]

void jet::ScalarGrid3::resize ( size_t  resolutionX,
size_t  resolutionY,
size_t  resolutionZ,
double  gridSpacingX = 1.0,
double  gridSpacingY = 1.0,
double  gridSpacingZ = 1.0,
double  originX = 0.0,
double  originY = 0.0,
double  originZ = 0.0,
double  initialValue = 0.0 
)

Resizes the grid using given parameters.

◆ sample()

double jet::ScalarGrid3::sample ( const Vector3D x) const
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::ScalarField3.

◆ sampler()

std::function<double(const Vector3D&)> jet::ScalarGrid3::sampler ( ) const
overridevirtual

Returns the sampler function.

This function returns the data sampler function object. The sampling function is linear.

Reimplemented from jet::ScalarField3.

◆ serialize()

void jet::ScalarGrid3::serialize ( std::vector< uint8_t > *  buffer) const
overridevirtual

Serializes the grid instance to the output buffer.

Implements jet::Grid3.

◆ setData()

void jet::ScalarGrid3::setData ( const std::vector< double > &  data)
overrideprotectedvirtual

Sets the data from a continuous linear array.

Implements jet::Grid3.

◆ setScalarGrid()

void jet::ScalarGrid3::setScalarGrid ( const ScalarGrid3 other)
protected

Sets the data storage and predefined samplers with given grid.

◆ swapScalarGrid()

void jet::ScalarGrid3::swapScalarGrid ( ScalarGrid3 other)
protected

Swaps the data storage and predefined samplers with given grid.


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