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

#include <Core/Grid/FaceCenteredGrid3.h>

Inheritance diagram for CubbyFlow::FaceCenteredGrid3:
CubbyFlow::VectorGrid3 CubbyFlow::VectorField3 CubbyFlow::Grid3 CubbyFlow::Field3 CubbyFlow::Serializable

Classes

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

Public Types

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

Public Member Functions

 FaceCenteredGrid3 ()
 Constructs empty grid. More...
 
 FaceCenteredGrid3 (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 initialValueU=0.0, double initialValueV=0.0, double initialValueW=0.0)
 Resizes the grid using given parameters. More...
 
 FaceCenteredGrid3 (const Size3 &resolution, const Vector3D &gridSpacing=Vector3D(1.0, 1.0, 1.0), const Vector3D &origin=Vector3D(), const Vector3D &initialValue=Vector3D())
 Resizes the grid using given parameters. More...
 
 FaceCenteredGrid3 (const FaceCenteredGrid3 &other)
 Copy constructor. More...
 
void Swap (Grid3 *other) override
 Swaps the contents with the given other grid. More...
 
void Set (const FaceCenteredGrid3 &other)
 Sets the contents with the given other grid. More...
 
FaceCenteredGrid3operator= (const FaceCenteredGrid3 &other)
 Sets the contents with the given other grid. More...
 
double & GetU (size_t i, size_t j, size_t k)
 Returns u-value at given data point. More...
 
const double & GetU (size_t i, size_t j, size_t k) const
 Returns u-value at given data point. More...
 
double & GetV (size_t i, size_t j, size_t k)
 Returns v-value at given data point. More...
 
const double & GetV (size_t i, size_t j, size_t k) const
 Returns v-value at given data point. More...
 
double & GetW (size_t i, size_t j, size_t k)
 Returns w-value at given data point. More...
 
const double & GetW (size_t i, size_t j, size_t k) const
 Returns w-value at given data point. More...
 
Vector3D ValueAtCellCenter (size_t i, size_t j, size_t k) const
 Returns interpolated value at cell center. More...
 
double DivergenceAtCellCenter (size_t i, size_t j, size_t k) const
 Returns divergence at cell-center location. More...
 
Vector3D CurlAtCellCenter (size_t i, size_t j, size_t k) const
 Returns curl at cell-center location. More...
 
ScalarDataAccessor GetUAccessor ()
 Returns u data accessor. More...
 
ConstScalarDataAccessor GetUConstAccessor () const
 Returns read-only u data accessor. More...
 
ScalarDataAccessor GetVAccessor ()
 Returns v data accessor. More...
 
ConstScalarDataAccessor GetVConstAccessor () const
 Returns read-only v data accessor. More...
 
ScalarDataAccessor GetWAccessor ()
 Returns w data accessor. More...
 
ConstScalarDataAccessor GetWConstAccessor () const
 Returns read-only w data accessor. More...
 
DataPositionFunc GetUPosition () const
 Returns function object that maps u data point to its actual position. More...
 
DataPositionFunc GetVPosition () const
 Returns function object that maps v data point to its actual position. More...
 
DataPositionFunc GetWPosition () const
 Returns function object that maps w data point to its actual position. More...
 
Size3 GetUSize () const
 Returns data size of the u component. More...
 
Size3 GetVSize () const
 Returns data size of the v component. More...
 
Size3 GetWSize () const
 Returns data size of the w component. More...
 
Vector3D GetUOrigin () const
 Returns u-data position for the grid point at (0, 0, 0). More...
 
Vector3D GetVOrigin () const
 Returns v-data position for the grid point at (0, 0, 0). More...
 
Vector3D GetWOrigin () const
 Returns w-data position for the grid point at (0, 0, 0). More...
 
void Fill (const Vector3D &value, ExecutionPolicy policy=ExecutionPolicy::Parallel) override
 Fills the grid with given value. More...
 
void Fill (const std::function< Vector3D(const Vector3D &)> &func, ExecutionPolicy policy=ExecutionPolicy::Parallel) override
 Fills the grid with given function. More...
 
std::shared_ptr< VectorGrid3Clone () const override
 Returns the copy of the grid instance. More...
 
void ForEachUIndex (const std::function< void(size_t, 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, size_t)> &func) const
 Invokes the given function func for each u-data point in parallel. More...
 
void ForEachVIndex (const std::function< void(size_t, 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, size_t)> &func) const
 Invokes the given function func for each v-data point in parallel. More...
 
void ForEachWIndex (const std::function< void(size_t, size_t, size_t)> &func) const
 Invokes the given function func for each w-data point. More...
 
void ParallelForEachWIndex (const std::function< void(size_t, size_t, size_t)> &func) const
 Invokes the given function func for each w-data point in parallel. More...
 
Vector3D Sample (const Vector3D &x) const override
 Returns sampled value at given position x. More...
 
double Divergence (const Vector3D &x) const override
 Returns divergence at given position x. More...
 
Vector3D Curl (const Vector3D &x) const override
 Returns curl at given position x. More...
 
std::function< Vector3D(const Vector3D &)> Sampler () const override
 Returns the sampler function. More...
 
- Public Member Functions inherited from CubbyFlow::VectorGrid3
 VectorGrid3 ()
 Constructs an empty grid. More...
 
virtual ~VectorGrid3 ()
 Default destructor. 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 initialValueX=0.0, double initialValueY=0.0, double initialValueZ=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(), const Vector3D &initialValue=Vector3D())
 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...
 
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::VectorField3
 VectorField3 ()
 Default constructor. More...
 
virtual ~VectorField3 ()
 Default destructor. More...
 
- Public Member Functions inherited from CubbyFlow::Field3
 Field3 ()
 
virtual ~Field3 ()
 
- Public Member Functions inherited from CubbyFlow::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 in parallel. More...
 
bool HasSameShape (const Grid3 &other) const
 Returns true if resolution, grid-spacing and origin are same. More...
 

Static Public Member Functions

static Builder GetBuilder ()
 Returns builder fox FaceCenteredGrid3. More...
 

Protected Member Functions

void OnResize (const Size3 &resolution, const Vector3D &gridSpacing, const Vector3D &origin, const Vector3D &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 CubbyFlow::Grid3
void SetSizeParameters (const Size3 &resolution, const Vector3D &gridSpacing, const Vector3D &origin)
 Sets the size parameters including the resolution, grid spacing, and origin. More...
 
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

3-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, v, and w components are not collocated.

Member Typedef Documentation

◆ ConstScalarDataAccessor

Read-only scalar data accessor type.

◆ ScalarDataAccessor

Read-write scalar data accessor type.

Constructor & Destructor Documentation

◆ FaceCenteredGrid3() [1/4]

CubbyFlow::FaceCenteredGrid3::FaceCenteredGrid3 ( )

Constructs empty grid.

◆ FaceCenteredGrid3() [2/4]

CubbyFlow::FaceCenteredGrid3::FaceCenteredGrid3 ( 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  initialValueU = 0.0,
double  initialValueV = 0.0,
double  initialValueW = 0.0 
)

Resizes the grid using given parameters.

◆ FaceCenteredGrid3() [3/4]

CubbyFlow::FaceCenteredGrid3::FaceCenteredGrid3 ( const Size3 resolution,
const Vector3D gridSpacing = Vector3D(1.0, 1.0, 1.0),
const Vector3D origin = Vector3D(),
const Vector3D initialValue = Vector3D() 
)

Resizes the grid using given parameters.

◆ FaceCenteredGrid3() [4/4]

CubbyFlow::FaceCenteredGrid3::FaceCenteredGrid3 ( const FaceCenteredGrid3 other)

Copy constructor.

Member Function Documentation

◆ Clone()

std::shared_ptr<VectorGrid3> CubbyFlow::FaceCenteredGrid3::Clone ( ) const
overridevirtual

Returns the copy of the grid instance.

Implements CubbyFlow::VectorGrid3.

◆ Curl()

Vector3D CubbyFlow::FaceCenteredGrid3::Curl ( const Vector3D x) const
overridevirtual

Returns curl at given position x.

Reimplemented from CubbyFlow::VectorField3.

◆ CurlAtCellCenter()

Vector3D CubbyFlow::FaceCenteredGrid3::CurlAtCellCenter ( size_t  i,
size_t  j,
size_t  k 
) const

Returns curl at cell-center location.

◆ Divergence()

double CubbyFlow::FaceCenteredGrid3::Divergence ( const Vector3D x) const
overridevirtual

Returns divergence at given position x.

Reimplemented from CubbyFlow::VectorField3.

◆ DivergenceAtCellCenter()

double CubbyFlow::FaceCenteredGrid3::DivergenceAtCellCenter ( size_t  i,
size_t  j,
size_t  k 
) const

Returns divergence at cell-center location.

◆ Fill() [1/2]

void CubbyFlow::FaceCenteredGrid3::Fill ( const Vector3D value,
ExecutionPolicy  policy = ExecutionPolicy::Parallel 
)
overridevirtual

Fills the grid with given value.

Implements CubbyFlow::VectorGrid3.

◆ Fill() [2/2]

void CubbyFlow::FaceCenteredGrid3::Fill ( const std::function< Vector3D(const Vector3D &)> &  func,
ExecutionPolicy  policy = ExecutionPolicy::Parallel 
)
overridevirtual

Fills the grid with given function.

Implements CubbyFlow::VectorGrid3.

◆ ForEachUIndex()

void CubbyFlow::FaceCenteredGrid3::ForEachUIndex ( const std::function< void(size_t, 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 CubbyFlow::FaceCenteredGrid3::ForEachVIndex ( const std::function< void(size_t, 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.

◆ ForEachWIndex()

void CubbyFlow::FaceCenteredGrid3::ForEachWIndex ( const std::function< void(size_t, size_t, size_t)> &  func) const

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

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

◆ GetBuilder()

static Builder CubbyFlow::FaceCenteredGrid3::GetBuilder ( )
static

Returns builder fox FaceCenteredGrid3.

◆ GetData()

void CubbyFlow::FaceCenteredGrid3::GetData ( std::vector< double > *  data) const
overrideprotectedvirtual

Fetches the data into a continuous linear array.

Implements CubbyFlow::Grid3.

◆ GetU() [1/2]

double& CubbyFlow::FaceCenteredGrid3::GetU ( size_t  i,
size_t  j,
size_t  k 
)

Returns u-value at given data point.

◆ GetU() [2/2]

const double& CubbyFlow::FaceCenteredGrid3::GetU ( size_t  i,
size_t  j,
size_t  k 
) const

Returns u-value at given data point.

◆ GetUAccessor()

ScalarDataAccessor CubbyFlow::FaceCenteredGrid3::GetUAccessor ( )

Returns u data accessor.

◆ GetUConstAccessor()

ConstScalarDataAccessor CubbyFlow::FaceCenteredGrid3::GetUConstAccessor ( ) const

Returns read-only u data accessor.

◆ GetUOrigin()

Vector3D CubbyFlow::FaceCenteredGrid3::GetUOrigin ( ) const

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

◆ GetUPosition()

DataPositionFunc CubbyFlow::FaceCenteredGrid3::GetUPosition ( ) const

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

◆ GetUSize()

Size3 CubbyFlow::FaceCenteredGrid3::GetUSize ( ) const

Returns data size of the u component.

◆ GetV() [1/2]

double& CubbyFlow::FaceCenteredGrid3::GetV ( size_t  i,
size_t  j,
size_t  k 
)

Returns v-value at given data point.

◆ GetV() [2/2]

const double& CubbyFlow::FaceCenteredGrid3::GetV ( size_t  i,
size_t  j,
size_t  k 
) const

Returns v-value at given data point.

◆ GetVAccessor()

ScalarDataAccessor CubbyFlow::FaceCenteredGrid3::GetVAccessor ( )

Returns v data accessor.

◆ GetVConstAccessor()

ConstScalarDataAccessor CubbyFlow::FaceCenteredGrid3::GetVConstAccessor ( ) const

Returns read-only v data accessor.

◆ GetVOrigin()

Vector3D CubbyFlow::FaceCenteredGrid3::GetVOrigin ( ) const

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

◆ GetVPosition()

DataPositionFunc CubbyFlow::FaceCenteredGrid3::GetVPosition ( ) const

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

◆ GetVSize()

Size3 CubbyFlow::FaceCenteredGrid3::GetVSize ( ) const

Returns data size of the v component.

◆ GetW() [1/2]

double& CubbyFlow::FaceCenteredGrid3::GetW ( size_t  i,
size_t  j,
size_t  k 
)

Returns w-value at given data point.

◆ GetW() [2/2]

const double& CubbyFlow::FaceCenteredGrid3::GetW ( size_t  i,
size_t  j,
size_t  k 
) const

Returns w-value at given data point.

◆ GetWAccessor()

ScalarDataAccessor CubbyFlow::FaceCenteredGrid3::GetWAccessor ( )

Returns w data accessor.

◆ GetWConstAccessor()

ConstScalarDataAccessor CubbyFlow::FaceCenteredGrid3::GetWConstAccessor ( ) const

Returns read-only w data accessor.

◆ GetWOrigin()

Vector3D CubbyFlow::FaceCenteredGrid3::GetWOrigin ( ) const

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

◆ GetWPosition()

DataPositionFunc CubbyFlow::FaceCenteredGrid3::GetWPosition ( ) const

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

◆ GetWSize()

Size3 CubbyFlow::FaceCenteredGrid3::GetWSize ( ) const

Returns data size of the w component.

◆ OnResize()

void CubbyFlow::FaceCenteredGrid3::OnResize ( const Size3 resolution,
const Vector3D gridSpacing,
const Vector3D origin,
const Vector3D 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 CubbyFlow::VectorGrid3.

◆ operator=()

FaceCenteredGrid3& CubbyFlow::FaceCenteredGrid3::operator= ( const FaceCenteredGrid3 other)

Sets the contents with the given other grid.

◆ ParallelForEachUIndex()

void CubbyFlow::FaceCenteredGrid3::ParallelForEachUIndex ( const std::function< void(size_t, size_t, size_t)> &  func) const

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

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 CubbyFlow::FaceCenteredGrid3::ParallelForEachVIndex ( const std::function< void(size_t, size_t, size_t)> &  func) const

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

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.

◆ ParallelForEachWIndex()

void CubbyFlow::FaceCenteredGrid3::ParallelForEachWIndex ( const std::function< void(size_t, size_t, size_t)> &  func) const

Invokes the given function func for each w-data point in parallel.

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

◆ Sample()

Vector3D CubbyFlow::FaceCenteredGrid3::Sample ( const Vector3D x) const
overridevirtual

Returns sampled value at given position x.

Implements CubbyFlow::VectorField3.

◆ Sampler()

std::function<Vector3D(const Vector3D&)> CubbyFlow::FaceCenteredGrid3::Sampler ( ) const
overridevirtual

Returns the sampler function.

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

Reimplemented from CubbyFlow::VectorField3.

◆ Set()

void CubbyFlow::FaceCenteredGrid3::Set ( const FaceCenteredGrid3 other)

Sets the contents with the given other grid.

◆ SetData()

void CubbyFlow::FaceCenteredGrid3::SetData ( const std::vector< double > &  data)
overrideprotectedvirtual

Sets the data from a continuous linear array.

Implements CubbyFlow::Grid3.

◆ Swap()

void CubbyFlow::FaceCenteredGrid3::Swap ( Grid3 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 CubbyFlow::Grid3.

◆ ValueAtCellCenter()

Vector3D CubbyFlow::FaceCenteredGrid3::ValueAtCellCenter ( size_t  i,
size_t  j,
size_t  k 
) const

Returns interpolated value at cell center.


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