CubbyFlow::VectorGrid< N > Class Template Referenceabstract

Abstract base class for N-D vector grid structure. More...

#include <Core/Grid/VectorGrid.hpp>

Inheritance diagram for CubbyFlow::VectorGrid< N >:
CubbyFlow::VectorField< N > CubbyFlow::Grid< N > CubbyFlow::Field< N > CubbyFlow::Serializable CubbyFlow::CollocatedVectorGrid< N > CubbyFlow::FaceCenteredGrid< N > CubbyFlow::CellCenteredVectorGrid< N > CubbyFlow::VertexCenteredVectorGrid< N >

Public Types

using VectorDataView = ArrayView< Vector< double, N >, N >
 Read-write array view type. More...
 
using ConstVectorDataView = ArrayView< const Vector< double, N >, N >
 Read-only array view type. More...
 

Public Member Functions

 VectorGrid ()=default
 Constructs an empty grid. More...
 
 ~VectorGrid () override=default
 Default virtual destructor. More...
 
 VectorGrid (const VectorGrid &other)
 Copy constructor. More...
 
 VectorGrid (VectorGrid &&other) noexcept
 Move constructor. More...
 
VectorGridoperator= (const VectorGrid &other)
 Copy assignment operator. More...
 
VectorGridoperator= (VectorGrid &&other) noexcept
 Move assignment operator. More...
 
void Clear ()
 Clears the contents of the grid. More...
 
void Resize (const Vector< size_t, N > &resolution, const Vector< double, N > &gridSpacing=Vector< double, N >::MakeConstant(1.0), const Vector< double, N > &origin=Vector< double, N >{}, const Vector< double, N > &initialValue=Vector< double, N >{})
 Resizes the grid using given parameters. More...
 
void Resize (const Vector< double, N > &gridSpacing, const Vector< double, N > &origin)
 Resizes the grid using given parameters. More...
 
virtual void Fill (const Vector< double, N > &value, ExecutionPolicy policy=ExecutionPolicy::Parallel)=0
 Fills the grid with given value. More...
 
virtual void Fill (const std::function< Vector< double, N >(const Vector< double, N > &)> &func, ExecutionPolicy policy=ExecutionPolicy::Parallel)=0
 Fills the grid with given position-to-value mapping function. More...
 
virtual std::shared_ptr< VectorGrid< N > > Clone () const =0
 Returns the copy of the grid instance. 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::VectorField< N >
 VectorField ()=default
 Default constructor. More...
 
 ~VectorField () override=default
 Default destructor. More...
 
 VectorField (const VectorField &)=default
 Default copy constructor. More...
 
 VectorField (VectorField &&) noexcept=default
 Default move constructor. More...
 
VectorFieldoperator= (const VectorField &)=default
 Default copy assignment operator. More...
 
VectorFieldoperator= (VectorField &&) noexcept=default
 Default move assignment operator. More...
 
virtual Vector< double, N > Sample (const Vector< double, N > &x) const =0
 Returns sampled value at given position x. More...
 
virtual double Divergence (const Vector< double, N > &x) const
 Returns divergence at given position x. More...
 
virtual GetCurl< N >::Type Curl (const Vector< double, N > &x) const
 Returns curl at given position x. More...
 
virtual std::function< Vector< double, N >const Vector< double, N > &)> Sampler () const
 Returns sampler function object. More...
 
- Public Member Functions inherited from CubbyFlow::Field< N >
 Field ()=default
 Default constructor. More...
 
virtual ~Field ()=default
 Default virtual destructor. More...
 
 Field (const Field &)=default
 Default copy constructor. More...
 
 Field (Field &&) noexcept=default
 Default move constructor. More...
 
Fieldoperator= (const Field &)=default
 Default copy assignment operator. More...
 
Fieldoperator= (Field &&) noexcept=default
 Default move assignment operator. More...
 
- Public Member Functions inherited from CubbyFlow::Grid< N >
 Grid ()=default
 Constructs an empty grid. More...
 
 ~Grid () override=default
 Default virtual destructor. More...
 
 Grid (const Grid &other)
 Copy constructor. More...
 
 Grid (Grid &&other) noexcept
 Move constructor. More...
 
Gridoperator= (const Grid &other)
 Copy assignment operator. More...
 
Gridoperator= (Grid &&other) noexcept
 Move assignment operator. More...
 
virtual std::string TypeName () const =0
 Returns the type name of derived grid. More...
 
const Vector< size_t, N > & Resolution () const
 Returns the grid resolution. More...
 
const Vector< double, N > & Origin () const
 Returns the grid origin. More...
 
const Vector< double, N > & GridSpacing () const
 Returns the grid spacing. More...
 
const BoundingBox< double, N > & GetBoundingBox () const
 Returns the bounding box of the grid. More...
 
GridDataPositionFunc< N > CellCenterPosition () const
 Returns the function that maps grid index to the cell-center position. More...
 
void ForEachCellIndex (const std::function< void(const Vector< size_t, N > &)> &func) const
 Invokes the given function func for each grid cell. More...
 
template<size_t M = N>
std::enable_if_t< M==2, void > ForEachCellIndex (const std::function< void(size_t, size_t)> &func) const
 
template<size_t M = N>
std::enable_if_t< M==3, void > ForEachCellIndex (const std::function< void(size_t, size_t, size_t)> &func) const
 
void ParallelForEachCellIndex (const std::function< void(const Vector< size_t, N > &)> &func) const
 Invokes the given function func for each grid cell in parallel. More...
 
template<size_t M = N>
std::enable_if_t< M==2, void > ParallelForEachCellIndex (const std::function< void(size_t, size_t)> &func) const
 
template<size_t M = N>
std::enable_if_t< M==3, void > ParallelForEachCellIndex (const std::function< void(size_t, size_t, size_t)> &func) const
 
bool HasSameShape (const Grid &other) const
 Returns true if resolution, grid-spacing and origin are same. More...
 
virtual void Swap (Grid *other)=0
 Swaps the data with other grid. More...
 
- Public Member Functions inherited from CubbyFlow::Serializable
 Serializable ()=default
 Default constructor. More...
 
 Serializable (const Serializable &)=default
 Default copy constructor. More...
 
 Serializable (Serializable &&) noexcept=default
 Default move constructor. More...
 
virtual ~Serializable ()=default
 Default virtual destructor. More...
 
Serializableoperator= (const Serializable &)=default
 Default copy assignment operator. More...
 
Serializableoperator= (Serializable &&) noexcept=default
 Default move assignment operator. More...
 

Protected Member Functions

virtual void OnResize (const Vector< size_t, N > &resolution, const Vector< double, N > &gridSpacing, const Vector< double, N > &origin, const Vector< double, N > &initialValue)=0
 Invoked when the resizing happens. More...
 
- Protected Member Functions inherited from CubbyFlow::Grid< N >
void SetSizeParameters (const Vector< size_t, N > &resolution, const Vector< double, N > &gridSpacing, const Vector< double, N > &origin)
 
void SwapGrid (Grid *other)
 Swaps the size parameters with given grid other. More...
 
void SetGrid (const Grid &other)
 Sets the size parameters with given grid other. More...
 
virtual void GetData (Array1< double > &data) const =0
 Fetches the data into a continuous linear array. More...
 
virtual void SetData (const ConstArrayView1< double > &data)=0
 Sets the data from a continuous linear array. More...
 

Detailed Description

template<size_t N>
class CubbyFlow::VectorGrid< N >

Abstract base class for N-D vector grid structure.

Member Typedef Documentation

◆ ConstVectorDataView

template<size_t N>
using CubbyFlow::VectorGrid< N >::ConstVectorDataView = ArrayView<const Vector<double, N>, N>

Read-only array view type.

◆ VectorDataView

template<size_t N>
using CubbyFlow::VectorGrid< N >::VectorDataView = ArrayView<Vector<double, N>, N>

Read-write array view type.

Constructor & Destructor Documentation

◆ VectorGrid() [1/3]

template<size_t N>
CubbyFlow::VectorGrid< N >::VectorGrid ( )
default

Constructs an empty grid.

◆ ~VectorGrid()

template<size_t N>
CubbyFlow::VectorGrid< N >::~VectorGrid ( )
overridedefault

Default virtual destructor.

◆ VectorGrid() [2/3]

template<size_t N>
CubbyFlow::VectorGrid< N >::VectorGrid ( const VectorGrid< N > &  other)

Copy constructor.

◆ VectorGrid() [3/3]

template<size_t N>
CubbyFlow::VectorGrid< N >::VectorGrid ( VectorGrid< N > &&  other)
noexcept

Move constructor.

Member Function Documentation

◆ Clear()

template<size_t N>
void CubbyFlow::VectorGrid< N >::Clear ( )

Clears the contents of the grid.

◆ Clone()

template<size_t N>
virtual std::shared_ptr<VectorGrid<N> > CubbyFlow::VectorGrid< N >::Clone ( ) const
pure virtual

◆ Deserialize()

template<size_t N>
void CubbyFlow::VectorGrid< N >::Deserialize ( const std::vector< uint8_t > &  buffer)
overridevirtual

Deserializes the input buffer to the grid instance.

Implements CubbyFlow::Serializable.

◆ Fill() [1/2]

template<size_t N>
virtual void CubbyFlow::VectorGrid< N >::Fill ( const Vector< double, N > &  value,
ExecutionPolicy  policy = ExecutionPolicy::Parallel 
)
pure virtual

◆ Fill() [2/2]

template<size_t N>
virtual void CubbyFlow::VectorGrid< N >::Fill ( const std::function< Vector< double, N >(const Vector< double, N > &)> &  func,
ExecutionPolicy  policy = ExecutionPolicy::Parallel 
)
pure virtual

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

Implemented in CubbyFlow::FaceCenteredGrid< N >, CubbyFlow::VertexCenteredVectorGrid< N >, and CubbyFlow::CellCenteredVectorGrid< N >.

◆ OnResize()

template<size_t N>
virtual void CubbyFlow::VectorGrid< N >::OnResize ( const Vector< size_t, N > &  resolution,
const Vector< double, N > &  gridSpacing,
const Vector< double, N > &  origin,
const Vector< double, N > &  initialValue 
)
protectedpure virtual

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.

Implemented in CubbyFlow::FaceCenteredGrid< N >.

◆ operator=() [1/2]

template<size_t N>
VectorGrid& CubbyFlow::VectorGrid< N >::operator= ( const VectorGrid< N > &  other)

Copy assignment operator.

◆ operator=() [2/2]

template<size_t N>
VectorGrid& CubbyFlow::VectorGrid< N >::operator= ( VectorGrid< N > &&  other)
noexcept

Move assignment operator.

◆ Resize() [1/2]

template<size_t N>
void CubbyFlow::VectorGrid< N >::Resize ( const Vector< size_t, N > &  resolution,
const Vector< double, N > &  gridSpacing = Vector< double, N >::MakeConstant(1.0),
const Vector< double, N > &  origin = Vector< double, N >{},
const Vector< double, N > &  initialValue = Vector< double, N >{} 
)

Resizes the grid using given parameters.

◆ Resize() [2/2]

template<size_t N>
void CubbyFlow::VectorGrid< N >::Resize ( const Vector< double, N > &  gridSpacing,
const Vector< double, N > &  origin 
)

Resizes the grid using given parameters.

◆ Serialize()

template<size_t N>
void CubbyFlow::VectorGrid< N >::Serialize ( std::vector< uint8_t > *  buffer) const
overridevirtual

Serializes the grid instance to the output buffer.

Implements CubbyFlow::Serializable.


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