Jet  v1.3.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
jet::FaceCenteredGrid2 Class Referencefinal

2-D face-centered (a.k.a MAC or staggered) grid. More...

#include <jet/face_centered_grid2.h>

Inheritance diagram for jet::FaceCenteredGrid2:
jet::VectorGrid2 jet::VectorField2 jet::Grid2 jet::Field2 jet::Serializable

Classes

class  Builder
 Front-end to create FaceCenteredGrid2 objects step by step. More...
 

Public Types

typedef ArrayAccessor2< double > ScalarDataAccessor
 Read-write scalar data accessor type. More...
 
typedef ConstArrayAccessor2< double > ConstScalarDataAccessor
 Read-only scalar data accessor type. More...
 
- Public Types inherited from jet::VectorGrid2
typedef ArrayAccessor2< Vector2DVectorDataAccessor
 Read-write array accessor type. More...
 
typedef ConstArrayAccessor2< Vector2DConstVectorDataAccessor
 Read-only array accessor type. More...
 
- Public Types inherited from jet::Grid2
typedef std::function< Vector2D(size_t, size_t)> DataPositionFunc
 Function type for mapping data index to actual position. More...
 

Public Member Functions

 FaceCenteredGrid2 ()
 Constructs empty grid. More...
 
 FaceCenteredGrid2 (size_t resolutionX, size_t resolutionY, double gridSpacingX=1.0, double gridSpacingY=1.0, double originX=0.0, double originY=0.0, double initialValueU=0.0, double initialValueV=0.0)
 Resizes the grid using given parameters. More...
 
 FaceCenteredGrid2 (const Size2 &resolution, const Vector2D &gridSpacing=Vector2D(1.0, 1.0), const Vector2D &origin=Vector2D(), const Vector2D &initialValue=Vector2D())
 Resizes the grid using given parameters. More...
 
 FaceCenteredGrid2 (const FaceCenteredGrid2 &other)
 Copy constructor. More...
 
void swap (Grid2 *other) override
 Swaps the contents with the given other grid. More...
 
void set (const FaceCenteredGrid2 &other)
 Sets the contents with the given other grid. More...
 
FaceCenteredGrid2operator= (const FaceCenteredGrid2 &other)
 Sets the contents with the given other grid. More...
 
double & u (size_t i, size_t j)
 Returns u-value at given data point. More...
 
const double & u (size_t i, size_t j) const
 Returns u-value at given data point. More...
 
double & v (size_t i, size_t j)
 Returns v-value at given data point. More...
 
const double & v (size_t i, size_t j) const
 Returns v-value at given data point. More...
 
Vector2D valueAtCellCenter (size_t i, size_t j) const
 Returns interpolated value at cell center. More...
 
double divergenceAtCellCenter (size_t i, size_t j) const
 Returns divergence at cell-center location. More...
 
double curlAtCellCenter (size_t i, size_t j) const
 Returns curl at cell-center location. More...
 
ScalarDataAccessor uAccessor ()
 Returns u data accessor. More...
 
ConstScalarDataAccessor uConstAccessor () const
 Returns read-only u data accessor. More...
 
ScalarDataAccessor vAccessor ()
 Returns v data accessor. More...
 
ConstScalarDataAccessor vConstAccessor () const
 Returns read-only v data accessor. More...
 
DataPositionFunc uPosition () const
 Returns function object that maps u data point to its actual position. More...
 
DataPositionFunc vPosition () const
 Returns function object that maps v data point to its actual position. More...
 
Size2 uSize () const
 Returns data size of the u component. More...
 
Size2 vSize () const
 Returns data size of the v component. More...
 
Vector2D uOrigin () const
 Returns u-data position for the grid point at (0, 0). More...
 
Vector2D vOrigin () const
 Returns v-data position for the grid point at (0, 0). More...
 
void fill (const Vector2D &value, ExecutionPolicy policy=ExecutionPolicy::kParallel) override
 Fills the grid with given value. More...
 
void fill (const std::function< Vector2D(const Vector2D &)> &func, ExecutionPolicy policy=ExecutionPolicy::kParallel) override
 Fills the grid with given function. More...
 
std::shared_ptr< VectorGrid2clone () const override
 Returns the copy of the grid instance. More...
 
void forEachUIndex (const std::function< void(size_t, size_t)> &func) const
 Invokes the given function func for each u-data point. More...
 
void parallelForEachUIndex (const std::function< void(size_t, size_t)> &func) const
 Invokes the given function func for each u-data point parallelly. More...
 
void forEachVIndex (const std::function< void(size_t, size_t)> &func) const
 Invokes the given function func for each v-data point. More...
 
void parallelForEachVIndex (const std::function< void(size_t, size_t)> &func) const
 Invokes the given function func for each v-data point parallelly. More...
 
Vector2D sample (const Vector2D &x) const override
 Returns sampled value at given position x. More...
 
double divergence (const Vector2D &x) const override
 Returns divergence at given position x. More...
 
double curl (const Vector2D &x) const override
 Returns curl at given position x. More...
 
std::function< Vector2D(const Vector2D &)> sampler () const override
 Returns the sampler function. More...
 
- Public Member Functions inherited from jet::VectorGrid2
 VectorGrid2 ()
 Constructs an empty grid. More...
 
virtual ~VectorGrid2 ()
 Default destructor. 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 initialValueX=0.0, double initialValueY=0.0)
 Resizes the grid using given parameters. More...
 
void resize (const Size2 &resolution, const Vector2D &gridSpacing=Vector2D(1, 1), const Vector2D &origin=Vector2D(), const Vector2D &initialValue=Vector2D())
 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...
 
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::VectorField2
 VectorField2 ()
 Default constructor. More...
 
virtual ~VectorField2 ()
 Default destructor. More...
 
- Public Member Functions inherited from jet::Field2
 Field2 ()
 
virtual ~Field2 ()
 
- Public Member Functions inherited from jet::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 Size2resolution () const
 Returns the grid resolution. More...
 
const Vector2Dorigin () const
 Returns the grid origin. More...
 
const Vector2DgridSpacing () const
 Returns the grid spacing. More...
 
const BoundingBox2DboundingBox () 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...
 
- Public Member Functions inherited from jet::Serializable
 Serializable ()=default
 
virtual ~Serializable ()=default
 

Static Public Member Functions

static Builder builder ()
 Returns builder fox FaceCenteredGrid2. More...
 

Protected Member Functions

void onResize (const Size2 &resolution, const Vector2D &gridSpacing, const Vector2D &origin, const Vector2D &initialValue) final
 Invoked when the resizing happens. 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::Grid2
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...
 

Detailed Description

2-D face-centered (a.k.a MAC or staggered) grid.

This class implements face-centered grid which is also known as marker-and-cell (MAC) or staggered grid. This vector grid stores each vector component at face center. Thus, u and v components are not collocated.

Member Typedef Documentation

◆ ConstScalarDataAccessor

Read-only scalar data accessor type.

◆ ScalarDataAccessor

Read-write scalar data accessor type.

Constructor & Destructor Documentation

◆ FaceCenteredGrid2() [1/4]

jet::FaceCenteredGrid2::FaceCenteredGrid2 ( )

Constructs empty grid.

◆ FaceCenteredGrid2() [2/4]

jet::FaceCenteredGrid2::FaceCenteredGrid2 ( size_t  resolutionX,
size_t  resolutionY,
double  gridSpacingX = 1.0,
double  gridSpacingY = 1.0,
double  originX = 0.0,
double  originY = 0.0,
double  initialValueU = 0.0,
double  initialValueV = 0.0 
)

Resizes the grid using given parameters.

◆ FaceCenteredGrid2() [3/4]

jet::FaceCenteredGrid2::FaceCenteredGrid2 ( const Size2 resolution,
const Vector2D gridSpacing = Vector2D(1.0, 1.0),
const Vector2D origin = Vector2D(),
const Vector2D initialValue = Vector2D() 
)

Resizes the grid using given parameters.

◆ FaceCenteredGrid2() [4/4]

jet::FaceCenteredGrid2::FaceCenteredGrid2 ( const FaceCenteredGrid2 other)

Copy constructor.

Member Function Documentation

◆ builder()

static Builder jet::FaceCenteredGrid2::builder ( )
static

Returns builder fox FaceCenteredGrid2.

◆ clone()

std::shared_ptr<VectorGrid2> jet::FaceCenteredGrid2::clone ( ) const
overridevirtual

Returns the copy of the grid instance.

Implements jet::VectorGrid2.

◆ curl()

double jet::FaceCenteredGrid2::curl ( const Vector2D x) const
overridevirtual

Returns curl at given position x.

Reimplemented from jet::VectorField2.

◆ curlAtCellCenter()

double jet::FaceCenteredGrid2::curlAtCellCenter ( size_t  i,
size_t  j 
) const

Returns curl at cell-center location.

◆ divergence()

double jet::FaceCenteredGrid2::divergence ( const Vector2D x) const
overridevirtual

Returns divergence at given position x.

Reimplemented from jet::VectorField2.

◆ divergenceAtCellCenter()

double jet::FaceCenteredGrid2::divergenceAtCellCenter ( size_t  i,
size_t  j 
) const

Returns divergence at cell-center location.

◆ fill() [1/2]

void jet::FaceCenteredGrid2::fill ( const std::function< Vector2D(const Vector2D &)> &  func,
ExecutionPolicy  policy = ExecutionPolicy::kParallel 
)
overridevirtual

Fills the grid with given function.

Implements jet::VectorGrid2.

◆ fill() [2/2]

void jet::FaceCenteredGrid2::fill ( const Vector2D value,
ExecutionPolicy  policy = ExecutionPolicy::kParallel 
)
overridevirtual

Fills the grid with given value.

Implements jet::VectorGrid2.

◆ forEachUIndex()

void jet::FaceCenteredGrid2::forEachUIndex ( const std::function< void(size_t, size_t)> &  func) const

Invokes the given function func for each u-data point.

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

◆ forEachVIndex()

void jet::FaceCenteredGrid2::forEachVIndex ( const std::function< void(size_t, size_t)> &  func) const

Invokes the given function func for each v-data point.

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

◆ getData()

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

Fetches the data into a continuous linear array.

Implements jet::Grid2.

◆ onResize()

void jet::FaceCenteredGrid2::onResize ( const Size2 resolution,
const Vector2D gridSpacing,
const Vector2D origin,
const Vector2D initialValue 
)
finalprotectedvirtual

Invoked when the resizing happens.

This callback function is called when the grid gets resized. The overriding class should allocate the internal storage based on its data layout scheme.

Implements jet::VectorGrid2.

◆ operator=()

FaceCenteredGrid2& jet::FaceCenteredGrid2::operator= ( const FaceCenteredGrid2 other)

Sets the contents with the given other grid.

◆ parallelForEachUIndex()

void jet::FaceCenteredGrid2::parallelForEachUIndex ( const std::function< void(size_t, size_t)> &  func) const

Invokes the given function func for each u-data point parallelly.

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

◆ parallelForEachVIndex()

void jet::FaceCenteredGrid2::parallelForEachVIndex ( const std::function< void(size_t, size_t)> &  func) const

Invokes the given function func for each v-data point parallelly.

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

◆ sample()

Vector2D jet::FaceCenteredGrid2::sample ( const Vector2D x) const
overridevirtual

Returns sampled value at given position x.

Implements jet::VectorField2.

◆ sampler()

std::function<Vector2D(const Vector2D&)> jet::FaceCenteredGrid2::sampler ( ) const
overridevirtual

Returns the sampler function.

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

Reimplemented from jet::VectorField2.

◆ set()

void jet::FaceCenteredGrid2::set ( const FaceCenteredGrid2 other)

Sets the contents with the given other grid.

◆ setData()

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

Sets the data from a continuous linear array.

Implements jet::Grid2.

◆ swap()

void jet::FaceCenteredGrid2::swap ( Grid2 other)
overridevirtual

Swaps the contents with the given other grid.

This function swaps the contents of the grid instance with the given grid object other only if other has the same type with this grid.

Implements jet::Grid2.

◆ u() [1/2]

double& jet::FaceCenteredGrid2::u ( size_t  i,
size_t  j 
)

Returns u-value at given data point.

◆ u() [2/2]

const double& jet::FaceCenteredGrid2::u ( size_t  i,
size_t  j 
) const

Returns u-value at given data point.

◆ uAccessor()

ScalarDataAccessor jet::FaceCenteredGrid2::uAccessor ( )

Returns u data accessor.

◆ uConstAccessor()

ConstScalarDataAccessor jet::FaceCenteredGrid2::uConstAccessor ( ) const

Returns read-only u data accessor.

◆ uOrigin()

Vector2D jet::FaceCenteredGrid2::uOrigin ( ) const

Returns u-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.

◆ uPosition()

DataPositionFunc jet::FaceCenteredGrid2::uPosition ( ) const

Returns function object that maps u data point to its actual position.

◆ uSize()

Size2 jet::FaceCenteredGrid2::uSize ( ) const

Returns data size of the u component.

◆ v() [1/2]

double& jet::FaceCenteredGrid2::v ( size_t  i,
size_t  j 
)

Returns v-value at given data point.

◆ v() [2/2]

const double& jet::FaceCenteredGrid2::v ( size_t  i,
size_t  j 
) const

Returns v-value at given data point.

◆ vAccessor()

ScalarDataAccessor jet::FaceCenteredGrid2::vAccessor ( )

Returns v data accessor.

◆ valueAtCellCenter()

Vector2D jet::FaceCenteredGrid2::valueAtCellCenter ( size_t  i,
size_t  j 
) const

Returns interpolated value at cell center.

◆ vConstAccessor()

ConstScalarDataAccessor jet::FaceCenteredGrid2::vConstAccessor ( ) const

Returns read-only v data accessor.

◆ vOrigin()

Vector2D jet::FaceCenteredGrid2::vOrigin ( ) const

Returns v-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.

◆ vPosition()

DataPositionFunc jet::FaceCenteredGrid2::vPosition ( ) const

Returns function object that maps v data point to its actual position.

◆ vSize()

Size2 jet::FaceCenteredGrid2::vSize ( ) const

Returns data size of the v component.


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