CubbyFlow::GridSystemData< N > Class Template Reference

N-D grid system data. More...

#include <Core/Grid/GridSystemData.hpp>

Inheritance diagram for CubbyFlow::GridSystemData< N >:
CubbyFlow::Serializable

Public Member Functions

 GridSystemData ()
 Constructs empty grid system. More...
 
 GridSystemData (const Vector< size_t, N > &resolution, const Vector< double, N > &gridSpacing, const Vector< double, N > &origin)
 Constructs a grid system with given resolution, grid spacing and origin. More...
 
 ~GridSystemData () override=default
 Default virtual destructor. More...
 
 GridSystemData (const GridSystemData &other)
 Copy constructor. More...
 
 GridSystemData (GridSystemData &&other) noexcept
 Move constructor. More...
 
GridSystemDataoperator= (const GridSystemData &other)
 Copy assignment operator. More...
 
GridSystemDataoperator= (GridSystemData &&other) noexcept
 Move assignment operator. More...
 
void Resize (const Vector< size_t, N > &resolution, const Vector< double, N > &gridSpacing, const Vector< double, N > &origin)
 Resizes the whole system with given resolution, grid spacing, and origin. More...
 
Vector< size_t, N > Resolution () const
 Returns the resolution of the grid. More...
 
Vector< double, N > GridSpacing () const
 Return the grid spacing. More...
 
Vector< double, N > Origin () const
 Returns the origin of the grid. More...
 
BoundingBox< double, N > GetBoundingBox () const
 Returns the bounding box of the grid. More...
 
size_t AddScalarData (const std::shared_ptr< ScalarGridBuilder< N >> &builder, double initialVal=0.0)
 Adds a non-advectable scalar data grid by passing its builder and initial value. More...
 
size_t AddVectorData (const std::shared_ptr< VectorGridBuilder< N >> &builder, const Vector< double, N > &initialVal=Vector< double, N >{})
 Adds a non-advectable vector data grid by passing its builder and initial value. More...
 
size_t AddAdvectableScalarData (const std::shared_ptr< ScalarGridBuilder< N >> &builder, double initialVal=0.0)
 Adds an advectable scalar data grid by passing its builder and initial value. More...
 
size_t AddAdvectableVectorData (const std::shared_ptr< VectorGridBuilder< N >> &builder, const Vector< double, N > &initialVal=Vector< double, N >{})
 Adds an advectable vector data grid by passing its builder and initial value. More...
 
const std::shared_ptr< FaceCenteredGrid< N > > & Velocity () const
 Returns the velocity field. More...
 
size_t VelocityIndex () const
 Returns the index of the velocity field. More...
 
const std::shared_ptr< ScalarGrid< N > > & ScalarDataAt (size_t idx) const
 Returns the non-advectable scalar data at given index. More...
 
const std::shared_ptr< VectorGrid< N > > & VectorDataAt (size_t idx) const
 Returns the non-advectable vector data at given index. More...
 
const std::shared_ptr< ScalarGrid< N > > & AdvectableScalarDataAt (size_t idx) const
 Returns the advectable scalar data at given index. More...
 
const std::shared_ptr< VectorGrid< N > > & AdvectableVectorDataAt (size_t idx) const
 Returns the advectable vector data at given index. More...
 
size_t NumberOfScalarData () const
 Returns the number of non-advectable scalar data. More...
 
size_t NumberOfVectorData () const
 Returns the number of non-advectable vector data. More...
 
size_t NumberOfAdvectableScalarData () const
 Returns the number of advectable scalar data. More...
 
size_t NumberOfAdvectableVectorData () const
 Returns the number of advectable vector data. More...
 
void Serialize (std::vector< uint8_t > *buffer) const override
 Serialize the data to the given buffer. More...
 
void Deserialize (const std::vector< uint8_t > &buffer) override
 Serialize the data from the given buffer. 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...
 

Detailed Description

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

N-D grid system data.

This class is the key data structure for storing grid system data. To represent a grid system for fluid simulation, velocity field is defined as a face-centered (MAC) grid by default. It can also have additional scalar or vector attributes by adding extra data layer.

Constructor & Destructor Documentation

◆ GridSystemData() [1/4]

template<size_t N>
CubbyFlow::GridSystemData< N >::GridSystemData ( )

Constructs empty grid system.

◆ GridSystemData() [2/4]

template<size_t N>
CubbyFlow::GridSystemData< N >::GridSystemData ( const Vector< size_t, N > &  resolution,
const Vector< double, N > &  gridSpacing,
const Vector< double, N > &  origin 
)

Constructs a grid system with given resolution, grid spacing and origin.

This constructor builds the entire grid layers within the system. Note, the resolution is the grid resolution, not the data size of each grid. Depending on the layout of the grid, the data point may lie on different part of the grid (vertex, cell-center, or face-center), thus can have different array size internally. The resolution of the grid means the grid cell resolution.

Parameters
[in]resolutionThe resolution.
[in]gridSpacingThe grid spacing.
[in]originThe origin.

◆ ~GridSystemData()

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

Default virtual destructor.

◆ GridSystemData() [3/4]

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

Copy constructor.

◆ GridSystemData() [4/4]

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

Move constructor.

Member Function Documentation

◆ AddAdvectableScalarData()

template<size_t N>
size_t CubbyFlow::GridSystemData< N >::AddAdvectableScalarData ( const std::shared_ptr< ScalarGridBuilder< N >> &  builder,
double  initialVal = 0.0 
)

Adds an advectable scalar data grid by passing its builder and initial value.

This function adds a new scalar data grid. This layer is advectable, meaning that during the computation of fluid flow, this layer will follow the flow. For the future access of this layer, its index is returned.

Parameters
[in]builderThe grid builder.
[in]initialValThe initial value.
Returns
Index of the data.

◆ AddAdvectableVectorData()

template<size_t N>
size_t CubbyFlow::GridSystemData< N >::AddAdvectableVectorData ( const std::shared_ptr< VectorGridBuilder< N >> &  builder,
const Vector< double, N > &  initialVal = Vector< double, N >{} 
)

Adds an advectable vector data grid by passing its builder and initial value.

This function adds a new vector data grid. This layer is advectable, meaning that during the computation of fluid flow, this layer will follow the flow. For the future access of this layer, its index is returned.

Parameters
[in]builderThe grid builder.
[in]initialValThe initial value.
Returns
Index of the data.

◆ AddScalarData()

template<size_t N>
size_t CubbyFlow::GridSystemData< N >::AddScalarData ( const std::shared_ptr< ScalarGridBuilder< N >> &  builder,
double  initialVal = 0.0 
)

Adds a non-advectable scalar data grid by passing its builder and initial value.

This function adds a new scalar data grid. This layer is not advectable, meaning that during the computation of fluid flow, this layer won't follow the flow. For the future access of this layer, its index is returned.

Parameters
[in]builderThe grid builder.
[in]initialValThe initial value.
Returns
Index of the data.

◆ AddVectorData()

template<size_t N>
size_t CubbyFlow::GridSystemData< N >::AddVectorData ( const std::shared_ptr< VectorGridBuilder< N >> &  builder,
const Vector< double, N > &  initialVal = Vector< double, N >{} 
)

Adds a non-advectable vector data grid by passing its builder and initial value.

This function adds a new vector data grid. This layer is not advectable, meaning that during the computation of fluid flow, this layer won't follow the flow. For the future access of this layer, its index is returned.

Parameters
[in]builderThe grid builder.
[in]initialValThe initial value.
Returns
Index of the data.

◆ AdvectableScalarDataAt()

template<size_t N>
const std::shared_ptr<ScalarGrid<N> >& CubbyFlow::GridSystemData< N >::AdvectableScalarDataAt ( size_t  idx) const

Returns the advectable scalar data at given index.

◆ AdvectableVectorDataAt()

template<size_t N>
const std::shared_ptr<VectorGrid<N> >& CubbyFlow::GridSystemData< N >::AdvectableVectorDataAt ( size_t  idx) const

Returns the advectable vector data at given index.

◆ Deserialize()

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

Serialize the data from the given buffer.

Implements CubbyFlow::Serializable.

◆ GetBoundingBox()

template<size_t N>
BoundingBox<double, N> CubbyFlow::GridSystemData< N >::GetBoundingBox ( ) const

Returns the bounding box of the grid.

◆ GridSpacing()

template<size_t N>
Vector<double, N> CubbyFlow::GridSystemData< N >::GridSpacing ( ) const

Return the grid spacing.

◆ NumberOfAdvectableScalarData()

template<size_t N>
size_t CubbyFlow::GridSystemData< N >::NumberOfAdvectableScalarData ( ) const

Returns the number of advectable scalar data.

◆ NumberOfAdvectableVectorData()

template<size_t N>
size_t CubbyFlow::GridSystemData< N >::NumberOfAdvectableVectorData ( ) const

Returns the number of advectable vector data.

◆ NumberOfScalarData()

template<size_t N>
size_t CubbyFlow::GridSystemData< N >::NumberOfScalarData ( ) const

Returns the number of non-advectable scalar data.

◆ NumberOfVectorData()

template<size_t N>
size_t CubbyFlow::GridSystemData< N >::NumberOfVectorData ( ) const

Returns the number of non-advectable vector data.

◆ operator=() [1/2]

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

Copy assignment operator.

◆ operator=() [2/2]

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

Move assignment operator.

◆ Origin()

template<size_t N>
Vector<double, N> CubbyFlow::GridSystemData< N >::Origin ( ) const

Returns the origin of the grid.

◆ Resize()

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

Resizes the whole system with given resolution, grid spacing, and origin.

This function resizes the entire grid layers within the system. Note, the resolution is the grid resolution, not the data size of each grid. Depending on the layout of the grid, the data point may lie on different part of the grid (vertex, cell-center, or face-center), thus can have different array size internally. The resolution of the grid means the grid cell resolution.

Parameters
[in]resolutionThe resolution.
[in]gridSpacingThe grid spacing.
[in]originThe origin.

◆ Resolution()

template<size_t N>
Vector<size_t, N> CubbyFlow::GridSystemData< N >::Resolution ( ) const

Returns the resolution of the grid.

This function resizes the entire grid layers within the system. Note, the resolution is the grid resolution, not the data size of each grid. Depending on the layout of the grid, the data point may lie on different part of the grid (vertex, cell-center, or face-center), thus can have different array size internally. The resolution of the grid means the grid cell resolution.

Returns
Grid cell resolution.

◆ ScalarDataAt()

template<size_t N>
const std::shared_ptr<ScalarGrid<N> >& CubbyFlow::GridSystemData< N >::ScalarDataAt ( size_t  idx) const

Returns the non-advectable scalar data at given index.

◆ Serialize()

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

Serialize the data to the given buffer.

Implements CubbyFlow::Serializable.

◆ VectorDataAt()

template<size_t N>
const std::shared_ptr<VectorGrid<N> >& CubbyFlow::GridSystemData< N >::VectorDataAt ( size_t  idx) const

Returns the non-advectable vector data at given index.

◆ Velocity()

template<size_t N>
const std::shared_ptr<FaceCenteredGrid<N> >& CubbyFlow::GridSystemData< N >::Velocity ( ) const

Returns the velocity field.

This class has velocity field by default, and it is part of the advectable vector data list.

Returns
Pointer to the velocity field.

◆ VelocityIndex()

template<size_t N>
size_t CubbyFlow::GridSystemData< N >::VelocityIndex ( ) const

Returns the index of the velocity field.

This class has velocity field by default, and it is part of the advectable vector data list. This function returns the index of the velocity field from the list.

Returns
Index of the velocity field.

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