CubbyFlow::ParticleSystemData< N > Class Template Reference

N-D particle system data. More...

#include <Core/Particle/ParticleSystemData.hpp>

Inheritance diagram for CubbyFlow::ParticleSystemData< N >:
CubbyFlow::Serializable CubbyFlow::SPHSystemData< N >

Public Types

using ScalarData = Array1< double >
 Scalar data chunk. More...
 
using VectorData = Array1< Vector< double, N > >
 Vector data chunk. More...
 

Public Member Functions

 ParticleSystemData ()
 Default constructor. More...
 
 ParticleSystemData (size_t numberOfParticles)
 Constructs particle system data with given number of particles. More...
 
 ~ParticleSystemData () override=default
 Default virtual destructor. More...
 
 ParticleSystemData (const ParticleSystemData &other)
 Copy constructor. More...
 
 ParticleSystemData (ParticleSystemData &&other) noexcept
 Move constructor. More...
 
ParticleSystemDataoperator= (const ParticleSystemData &other)
 Copy assignment operator. More...
 
ParticleSystemDataoperator= (ParticleSystemData &&other) noexcept
 Move assignment operator. More...
 
void Resize (size_t newNumberOfParticles)
 Resizes the number of particles of the container. More...
 
size_t NumberOfParticles () const
 Returns the number of particles. More...
 
size_t AddScalarData (double initialVal=0.0)
 Adds a scalar data layer and returns its index. More...
 
size_t AddVectorData (const Vector< double, N > &initialVal=Vector< double, N >{})
 Adds a vector data layer and returns its index. More...
 
double Radius () const
 Returns the radius of the particles. More...
 
virtual void SetRadius (double newRadius)
 Sets the radius of the particles. More...
 
double Mass () const
 Returns the mass of the particles. More...
 
virtual void SetMass (double newMass)
 Sets the mass of the particles. More...
 
ConstArrayView1< Vector< double, N > > Positions () const
 Returns the position array (immutable). More...
 
ArrayView1< Vector< double, N > > Positions ()
 Returns the position array (mutable). More...
 
ConstArrayView1< Vector< double, N > > Velocities () const
 Returns the velocity array (immutable). More...
 
ArrayView1< Vector< double, N > > Velocities ()
 Returns the velocity array (mutable). More...
 
ConstArrayView1< Vector< double, N > > Forces () const
 Returns the force array (immutable). More...
 
ArrayView1< Vector< double, N > > Forces ()
 Returns the force array (mutable). More...
 
ConstArrayView1< double > ScalarDataAt (size_t idx) const
 Returns custom scalar data layer at given index (immutable). More...
 
ArrayView1< double > ScalarDataAt (size_t idx)
 Returns custom scalar data layer at given index (mutable). More...
 
ConstArrayView1< Vector< double, N > > VectorDataAt (size_t idx) const
 Returns custom vector data layer at given index (immutable). More...
 
ArrayView1< Vector< double, N > > VectorDataAt (size_t idx)
 Returns custom vector data layer at given index (mutable). More...
 
void AddParticle (const Vector< double, N > &newPosition, const Vector< double, N > &newVelocity=Vector< double, N >(), const Vector< double, N > &newForce=Vector< double, N >())
 Adds a particle to the data structure. More...
 
void AddParticles (const ConstArrayView1< Vector< double, N >> &newPositions, const ConstArrayView1< Vector< double, N >> &newVelocities=ConstArrayView1< Vector< double, N >>(), const ConstArrayView1< Vector< double, N >> &newForces=ConstArrayView1< Vector< double, N >>())
 Adds particles to the data structure. More...
 
const std::shared_ptr< PointNeighborSearcher< N > > & NeighborSearcher () const
 Returns neighbor searcher. More...
 
void SetNeighborSearcher (const std::shared_ptr< PointNeighborSearcher< N >> &newNeighborSearcher)
 Sets neighbor searcher. More...
 
const Array1< Array1< size_t > > & NeighborLists () const
 Returns neighbor lists. More...
 
void BuildNeighborSearcher (double maxSearchRadius)
 Builds neighbor searcher with given search radius. More...
 
void BuildNeighborLists (double maxSearchRadius)
 Builds neighbor lists with given search radius. More...
 
void Serialize (std::vector< uint8_t > *buffer) const override
 Serializes this particle system data to the buffer. More...
 
void Deserialize (const std::vector< uint8_t > &buffer) override
 Deserializes this particle system data from the buffer. More...
 
void Set (const ParticleSystemData &other)
 Copies from other particle system data. 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...
 

Static Protected Member Functions

template<size_t M = N>
static std::enable_if_t< M==2, void > Serialize (const ParticleSystemData< 2 > &particles, flatbuffers::FlatBufferBuilder *builder, flatbuffers::Offset< fbs::ParticleSystemData2 > *fbsParticleSystemData)
 
template<size_t M = N>
static std::enable_if_t< M==3, void > Serialize (const ParticleSystemData< 3 > &particles, flatbuffers::FlatBufferBuilder *builder, flatbuffers::Offset< fbs::ParticleSystemData3 > *fbsParticleSystemData)
 
template<size_t M = N>
static std::enable_if_t< M==2, void > Deserialize (const fbs::ParticleSystemData2 *fbsParticleSystemData, ParticleSystemData< 2 > &particles)
 
template<size_t M = N>
static std::enable_if_t< M==3, void > Deserialize (const fbs::ParticleSystemData3 *fbsParticleSystemData, ParticleSystemData< 3 > &particles)
 

Detailed Description

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

N-D particle system data.

This class is the key data structure for storing particle system data. A single particle has position, velocity, and force attributes by default. But it can also have additional custom scalar or vector attributes.

Member Typedef Documentation

◆ ScalarData

template<size_t N>
using CubbyFlow::ParticleSystemData< N >::ScalarData = Array1<double>

Scalar data chunk.

◆ VectorData

template<size_t N>
using CubbyFlow::ParticleSystemData< N >::VectorData = Array1<Vector<double, N> >

Vector data chunk.

Constructor & Destructor Documentation

◆ ParticleSystemData() [1/4]

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

Default constructor.

◆ ParticleSystemData() [2/4]

template<size_t N>
CubbyFlow::ParticleSystemData< N >::ParticleSystemData ( size_t  numberOfParticles)
explicit

Constructs particle system data with given number of particles.

◆ ~ParticleSystemData()

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

Default virtual destructor.

◆ ParticleSystemData() [3/4]

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

Copy constructor.

◆ ParticleSystemData() [4/4]

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

Move constructor.

Member Function Documentation

◆ AddParticle()

template<size_t N>
void CubbyFlow::ParticleSystemData< N >::AddParticle ( const Vector< double, N > &  newPosition,
const Vector< double, N > &  newVelocity = Vector< double, N >(),
const Vector< double, N > &  newForce = Vector< double, N >() 
)

Adds a particle to the data structure.

This function will add a single particle to the data structure. For custom data layers, zeros will be assigned for new particles. However, this will invalidate neighbor searcher and neighbor lists. It is users responsibility to call ParticleSystemData::BuildNeighborSearcher and ParticleSystemData::BuildNeighborLists to refresh those data.

Parameters
[in]newPositionThe new position.
[in]newVelocityThe new velocity.
[in]newForceThe new force.

◆ AddParticles()

template<size_t N>
void CubbyFlow::ParticleSystemData< N >::AddParticles ( const ConstArrayView1< Vector< double, N >> &  newPositions,
const ConstArrayView1< Vector< double, N >> &  newVelocities = ConstArrayView1Vector< double, N >>(),
const ConstArrayView1< Vector< double, N >> &  newForces = ConstArrayView1Vector< double, N >>() 
)

Adds particles to the data structure.

This function will add particles to the data structure. For custom data layers, zeros will be assigned for new particles. However, this will invalidate neighbor searcher and neighbor lists. It is users responsibility to call ParticleSystemData::BuildNeighborSearcher and ParticleSystemData::BuildNeighborLists to refresh those data.

Parameters
[in]newPositionsThe new positions.
[in]newVelocitiesThe new velocities.
[in]newForcesThe new forces.

◆ AddScalarData()

template<size_t N>
size_t CubbyFlow::ParticleSystemData< N >::AddScalarData ( double  initialVal = 0.0)

Adds a scalar data layer and returns its index.

This function adds a new scalar data layer to the system. It can be used for adding a scalar attribute, such as temperature, to the particles.

Parameters
[in]initialValInitial value of the new scalar data.

◆ AddVectorData()

template<size_t N>
size_t CubbyFlow::ParticleSystemData< N >::AddVectorData ( const Vector< double, N > &  initialVal = Vector< double, N >{})

Adds a vector data layer and returns its index.

This function adds a new vector data layer to the system. It can be used for adding a vector attribute, such as vortex, to the particles.

Parameters
[in]initialValInitial value of the new vector data.

◆ BuildNeighborLists()

template<size_t N>
void CubbyFlow::ParticleSystemData< N >::BuildNeighborLists ( double  maxSearchRadius)

Builds neighbor lists with given search radius.

◆ BuildNeighborSearcher()

template<size_t N>
void CubbyFlow::ParticleSystemData< N >::BuildNeighborSearcher ( double  maxSearchRadius)

Builds neighbor searcher with given search radius.

◆ Deserialize() [1/3]

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

Deserializes this particle system data from the buffer.

Implements CubbyFlow::Serializable.

Reimplemented in CubbyFlow::SPHSystemData< N >.

◆ Deserialize() [2/3]

template<size_t N>
template<size_t M = N>
static std::enable_if_t<M == 2, void> CubbyFlow::ParticleSystemData< N >::Deserialize ( const fbs::ParticleSystemData2 *  fbsParticleSystemData,
ParticleSystemData< 2 > &  particles 
)
staticprotected

◆ Deserialize() [3/3]

template<size_t N>
template<size_t M = N>
static std::enable_if_t<M == 3, void> CubbyFlow::ParticleSystemData< N >::Deserialize ( const fbs::ParticleSystemData3 *  fbsParticleSystemData,
ParticleSystemData< 3 > &  particles 
)
staticprotected

◆ Forces() [1/2]

template<size_t N>
ConstArrayView1<Vector<double, N> > CubbyFlow::ParticleSystemData< N >::Forces ( ) const

Returns the force array (immutable).

◆ Forces() [2/2]

template<size_t N>
ArrayView1<Vector<double, N> > CubbyFlow::ParticleSystemData< N >::Forces ( )

Returns the force array (mutable).

◆ Mass()

template<size_t N>
double CubbyFlow::ParticleSystemData< N >::Mass ( ) const

Returns the mass of the particles.

◆ NeighborLists()

template<size_t N>
const Array1<Array1<size_t> >& CubbyFlow::ParticleSystemData< N >::NeighborLists ( ) const

Returns neighbor lists.

This function returns neighbor lists which is available after calling PointParallelHashGridSearcher2::BuildNeighborLists. Each list stores indices of the neighbors.

Returns
Neighbor lists.

◆ NeighborSearcher()

template<size_t N>
const std::shared_ptr<PointNeighborSearcher<N> >& CubbyFlow::ParticleSystemData< N >::NeighborSearcher ( ) const

Returns neighbor searcher.

This function returns currently set neighbor searcher object. By default, PointParallelHashGridSearcher2 is used.

Returns
Current neighbor searcher.

◆ NumberOfParticles()

template<size_t N>
size_t CubbyFlow::ParticleSystemData< N >::NumberOfParticles ( ) const

Returns the number of particles.

◆ operator=() [1/2]

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

Copy assignment operator.

◆ operator=() [2/2]

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

Move assignment operator.

◆ Positions() [1/2]

template<size_t N>
ConstArrayView1<Vector<double, N> > CubbyFlow::ParticleSystemData< N >::Positions ( ) const

Returns the position array (immutable).

◆ Positions() [2/2]

template<size_t N>
ArrayView1<Vector<double, N> > CubbyFlow::ParticleSystemData< N >::Positions ( )

Returns the position array (mutable).

◆ Radius()

template<size_t N>
double CubbyFlow::ParticleSystemData< N >::Radius ( ) const

Returns the radius of the particles.

◆ Resize()

template<size_t N>
void CubbyFlow::ParticleSystemData< N >::Resize ( size_t  newNumberOfParticles)

Resizes the number of particles of the container.

This function will resize internal containers to store newly given number of particles including custom data layers. However, this will invalidate neighbor searcher and neighbor lists. It is users responsibility to call ParticleSystemData::BuildNeighborSearcher and ParticleSystemData::BuildNeighborLists to refresh those data.

Parameters
[in]newNumberOfParticlesNew number of particles.

◆ ScalarDataAt() [1/2]

template<size_t N>
ConstArrayView1<double> CubbyFlow::ParticleSystemData< N >::ScalarDataAt ( size_t  idx) const

Returns custom scalar data layer at given index (immutable).

◆ ScalarDataAt() [2/2]

template<size_t N>
ArrayView1<double> CubbyFlow::ParticleSystemData< N >::ScalarDataAt ( size_t  idx)

Returns custom scalar data layer at given index (mutable).

◆ Serialize() [1/3]

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

Serializes this particle system data to the buffer.

Implements CubbyFlow::Serializable.

Reimplemented in CubbyFlow::SPHSystemData< N >.

◆ Serialize() [2/3]

template<size_t N>
template<size_t M = N>
static std::enable_if_t<M == 2, void> CubbyFlow::ParticleSystemData< N >::Serialize ( const ParticleSystemData< 2 > &  particles,
flatbuffers::FlatBufferBuilder *  builder,
flatbuffers::Offset< fbs::ParticleSystemData2 > *  fbsParticleSystemData 
)
staticprotected

◆ Serialize() [3/3]

template<size_t N>
template<size_t M = N>
static std::enable_if_t<M == 3, void> CubbyFlow::ParticleSystemData< N >::Serialize ( const ParticleSystemData< 3 > &  particles,
flatbuffers::FlatBufferBuilder *  builder,
flatbuffers::Offset< fbs::ParticleSystemData3 > *  fbsParticleSystemData 
)
staticprotected

◆ Set()

template<size_t N>
void CubbyFlow::ParticleSystemData< N >::Set ( const ParticleSystemData< N > &  other)

Copies from other particle system data.

◆ SetMass()

template<size_t N>
virtual void CubbyFlow::ParticleSystemData< N >::SetMass ( double  newMass)
virtual

Sets the mass of the particles.

Reimplemented in CubbyFlow::SPHSystemData< N >.

◆ SetNeighborSearcher()

template<size_t N>
void CubbyFlow::ParticleSystemData< N >::SetNeighborSearcher ( const std::shared_ptr< PointNeighborSearcher< N >> &  newNeighborSearcher)

Sets neighbor searcher.

◆ SetRadius()

template<size_t N>
virtual void CubbyFlow::ParticleSystemData< N >::SetRadius ( double  newRadius)
virtual

Sets the radius of the particles.

Reimplemented in CubbyFlow::SPHSystemData< N >.

◆ VectorDataAt() [1/2]

template<size_t N>
ConstArrayView1<Vector<double, N> > CubbyFlow::ParticleSystemData< N >::VectorDataAt ( size_t  idx) const

Returns custom vector data layer at given index (immutable).

◆ VectorDataAt() [2/2]

template<size_t N>
ArrayView1<Vector<double, N> > CubbyFlow::ParticleSystemData< N >::VectorDataAt ( size_t  idx)

Returns custom vector data layer at given index (mutable).

◆ Velocities() [1/2]

template<size_t N>
ConstArrayView1<Vector<double, N> > CubbyFlow::ParticleSystemData< N >::Velocities ( ) const

Returns the velocity array (immutable).

◆ Velocities() [2/2]

template<size_t N>
ArrayView1<Vector<double, N> > CubbyFlow::ParticleSystemData< N >::Velocities ( )

Returns the velocity array (mutable).


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