CubbyFlow::ParticleSystemData2 Class Reference

2-D particle system data. More...

#include <Core/Particle/ParticleSystemData2.h>

Inheritance diagram for CubbyFlow::ParticleSystemData2:
CubbyFlow::Serializable CubbyFlow::SPHSystemData2

Public Types

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

Public Member Functions

 ParticleSystemData2 ()
 Default constructor. More...
 
 ParticleSystemData2 (size_t numberOfParticles)
 Constructs particle system data with given number of particles. More...
 
 ParticleSystemData2 (const ParticleSystemData2 &other)
 Copy constructor. More...
 
virtual ~ParticleSystemData2 ()
 Destructor. More...
 
void Resize (size_t newNumberOfParticles)
 Resizes the number of particles of the container. More...
 
size_t GetNumberOfParticles () 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 Vector2D &initialVal=Vector2D())
 Adds a vector data layer and returns its index. More...
 
double GetRadius () const
 Returns the radius of the particles. More...
 
virtual void SetRadius (double newRadius)
 Sets the radius of the particles. More...
 
double GetMass () const
 Returns the mass of the particles. More...
 
virtual void SetMass (double newMass)
 Sets the mass of the particles. More...
 
ConstArrayAccessor1< Vector2DGetPositions () const
 Returns the position array (immutable). More...
 
ArrayAccessor1< Vector2DGetPositions ()
 Returns the position array (mutable). More...
 
ConstArrayAccessor1< Vector2DGetVelocities () const
 Returns the velocity array (immutable). More...
 
ArrayAccessor1< Vector2DGetVelocities ()
 Returns the velocity array (mutable). More...
 
ConstArrayAccessor1< Vector2DGetForces () const
 Returns the force array (immutable). More...
 
ArrayAccessor1< Vector2DGetForces ()
 Returns the force array (mutable). More...
 
ConstArrayAccessor1< double > ScalarDataAt (size_t idx) const
 Returns custom scalar data layer at given index (immutable). More...
 
ArrayAccessor1< double > ScalarDataAt (size_t idx)
 Returns custom scalar data layer at given index (mutable). More...
 
ConstArrayAccessor1< Vector2DVectorDataAt (size_t idx) const
 Returns custom vector data layer at given index (immutable). More...
 
ArrayAccessor1< Vector2DVectorDataAt (size_t idx)
 Returns custom vector data layer at given index (mutable). More...
 
void AddParticle (const Vector2D &newPosition, const Vector2D &newVelocity=Vector2D(), const Vector2D &newForce=Vector2D())
 Adds a particle to the data structure. More...
 
void AddParticles (const ConstArrayAccessor1< Vector2D > &newPositions, const ConstArrayAccessor1< Vector2D > &newVelocities=ConstArrayAccessor1< Vector2D >(), const ConstArrayAccessor1< Vector2D > &newForces=ConstArrayAccessor1< Vector2D >())
 Adds particles to the data structure. More...
 
const PointNeighborSearcher2PtrGetNeighborSearcher () const
 Returns neighbor searcher. More...
 
void SetNeighborSearcher (const PointNeighborSearcher2Ptr &newNeighborSearcher)
 Sets neighbor searcher. More...
 
const std::vector< std::vector< size_t > > & GetNeighborLists () 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 ParticleSystemData2 &other)
 Copies from other particle system data. More...
 
ParticleSystemData2operator= (const ParticleSystemData2 &other)
 Copies from other particle system data. More...
 

Protected Member Functions

void SerializeParticleSystemData (flatbuffers::FlatBufferBuilder *builder, flatbuffers::Offset< fbs::ParticleSystemData2 > *fbsParticleSystemData) const
 
void DeserializeParticleSystemData (const fbs::ParticleSystemData2 *fbsParticleSystemData)
 

Detailed Description

2-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

Scalar data chunk.

◆ VectorData

Constructor & Destructor Documentation

◆ ParticleSystemData2() [1/3]

CubbyFlow::ParticleSystemData2::ParticleSystemData2 ( )

Default constructor.

◆ ParticleSystemData2() [2/3]

CubbyFlow::ParticleSystemData2::ParticleSystemData2 ( size_t  numberOfParticles)
explicit

Constructs particle system data with given number of particles.

◆ ParticleSystemData2() [3/3]

CubbyFlow::ParticleSystemData2::ParticleSystemData2 ( const ParticleSystemData2 other)

Copy constructor.

◆ ~ParticleSystemData2()

virtual CubbyFlow::ParticleSystemData2::~ParticleSystemData2 ( )
virtual

Destructor.

Member Function Documentation

◆ AddParticle()

void CubbyFlow::ParticleSystemData2::AddParticle ( const Vector2D newPosition,
const Vector2D newVelocity = Vector2D(),
const Vector2D newForce = Vector2D() 
)

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 ParticleSystemData2::BuildNeighborSearcher and ParticleSystemData2::BuildNeighborLists to refresh those data.

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

◆ AddParticles()

void CubbyFlow::ParticleSystemData2::AddParticles ( const ConstArrayAccessor1< Vector2D > &  newPositions,
const ConstArrayAccessor1< Vector2D > &  newVelocities = ConstArrayAccessor1Vector2D >(),
const ConstArrayAccessor1< Vector2D > &  newForces = ConstArrayAccessor1Vector2D >() 
)

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 ParticleSystemData2::BuildNeighborSearcher and ParticleSystemData2::BuildNeighborLists to refresh those data.

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

◆ AddScalarData()

size_t CubbyFlow::ParticleSystemData2::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()

size_t CubbyFlow::ParticleSystemData2::AddVectorData ( const Vector2D initialVal = Vector2D())

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()

void CubbyFlow::ParticleSystemData2::BuildNeighborLists ( double  maxSearchRadius)

Builds neighbor lists with given search radius.

◆ BuildNeighborSearcher()

void CubbyFlow::ParticleSystemData2::BuildNeighborSearcher ( double  maxSearchRadius)

Builds neighbor searcher with given search radius.

◆ Deserialize()

void CubbyFlow::ParticleSystemData2::Deserialize ( const std::vector< uint8_t > &  buffer)
overridevirtual

Deserializes this particle system data from the buffer.

Implements CubbyFlow::Serializable.

Reimplemented in CubbyFlow::SPHSystemData2.

◆ DeserializeParticleSystemData()

void CubbyFlow::ParticleSystemData2::DeserializeParticleSystemData ( const fbs::ParticleSystemData2 *  fbsParticleSystemData)
protected

◆ GetForces() [1/2]

ConstArrayAccessor1<Vector2D> CubbyFlow::ParticleSystemData2::GetForces ( ) const

Returns the force array (immutable).

◆ GetForces() [2/2]

ArrayAccessor1<Vector2D> CubbyFlow::ParticleSystemData2::GetForces ( )

Returns the force array (mutable).

◆ GetMass()

double CubbyFlow::ParticleSystemData2::GetMass ( ) const

Returns the mass of the particles.

◆ GetNeighborLists()

const std::vector<std::vector<size_t> >& CubbyFlow::ParticleSystemData2::GetNeighborLists ( ) 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.

◆ GetNeighborSearcher()

const PointNeighborSearcher2Ptr& CubbyFlow::ParticleSystemData2::GetNeighborSearcher ( ) const

Returns neighbor searcher.

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

Returns
Current neighbor searcher.

◆ GetNumberOfParticles()

size_t CubbyFlow::ParticleSystemData2::GetNumberOfParticles ( ) const

Returns the number of particles.

◆ GetPositions() [1/2]

ConstArrayAccessor1<Vector2D> CubbyFlow::ParticleSystemData2::GetPositions ( ) const

Returns the position array (immutable).

◆ GetPositions() [2/2]

ArrayAccessor1<Vector2D> CubbyFlow::ParticleSystemData2::GetPositions ( )

Returns the position array (mutable).

◆ GetRadius()

double CubbyFlow::ParticleSystemData2::GetRadius ( ) const

Returns the radius of the particles.

◆ GetVelocities() [1/2]

ConstArrayAccessor1<Vector2D> CubbyFlow::ParticleSystemData2::GetVelocities ( ) const

Returns the velocity array (immutable).

◆ GetVelocities() [2/2]

ArrayAccessor1<Vector2D> CubbyFlow::ParticleSystemData2::GetVelocities ( )

Returns the velocity array (mutable).

◆ operator=()

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

Copies from other particle system data.

◆ Resize()

void CubbyFlow::ParticleSystemData2::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 ParticleSystemData2::BuildNeighborSearcher and ParticleSystemData2::BuildNeighborLists to refresh those data.

Parameters
[in]newNumberOfParticlesNew number of particles.

◆ ScalarDataAt() [1/2]

ConstArrayAccessor1<double> CubbyFlow::ParticleSystemData2::ScalarDataAt ( size_t  idx) const

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

◆ ScalarDataAt() [2/2]

ArrayAccessor1<double> CubbyFlow::ParticleSystemData2::ScalarDataAt ( size_t  idx)

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

◆ Serialize()

void CubbyFlow::ParticleSystemData2::Serialize ( std::vector< uint8_t > *  buffer) const
overridevirtual

Serializes this particle system data to the buffer.

Implements CubbyFlow::Serializable.

Reimplemented in CubbyFlow::SPHSystemData2.

◆ SerializeParticleSystemData()

void CubbyFlow::ParticleSystemData2::SerializeParticleSystemData ( flatbuffers::FlatBufferBuilder *  builder,
flatbuffers::Offset< fbs::ParticleSystemData2 > *  fbsParticleSystemData 
) const
protected

◆ Set()

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

Copies from other particle system data.

◆ SetMass()

virtual void CubbyFlow::ParticleSystemData2::SetMass ( double  newMass)
virtual

Sets the mass of the particles.

Reimplemented in CubbyFlow::SPHSystemData2.

◆ SetNeighborSearcher()

void CubbyFlow::ParticleSystemData2::SetNeighborSearcher ( const PointNeighborSearcher2Ptr newNeighborSearcher)

Sets neighbor searcher.

◆ SetRadius()

virtual void CubbyFlow::ParticleSystemData2::SetRadius ( double  newRadius)
virtual

Sets the radius of the particles.

Reimplemented in CubbyFlow::SPHSystemData2.

◆ VectorDataAt() [1/2]

ConstArrayAccessor1<Vector2D> CubbyFlow::ParticleSystemData2::VectorDataAt ( size_t  idx) const

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

◆ VectorDataAt() [2/2]

ArrayAccessor1<Vector2D> CubbyFlow::ParticleSystemData2::VectorDataAt ( size_t  idx)

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


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