CubbyFlow::SPHSystemData2 Class Reference

2-D SPH particle system data. More...

#include <Core/SPH/SPHSystemData2.h>

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

Public Member Functions

 SPHSystemData2 ()
 Constructs empty SPH system. More...
 
 SPHSystemData2 (size_t numberOfParticles)
 Constructs SPH system data with given number of particles. More...
 
 SPHSystemData2 (const SPHSystemData2 &other)
 Copy constructor. More...
 
virtual ~SPHSystemData2 ()
 Destructor. More...
 
void SetRadius (double newRadius) override
 Sets the radius. More...
 
void SetMass (double newMass) override
 Sets the mass of a particle. More...
 
ConstArrayAccessor1< double > GetDensities () const
 Returns the density array accessor (immutable). More...
 
ArrayAccessor1< double > GetDensities ()
 Returns the density array accessor (mutable). More...
 
ConstArrayAccessor1< double > GetPressures () const
 Returns the pressure array accessor (immutable). More...
 
ArrayAccessor1< double > GetPressures ()
 Returns the pressure array accessor (mutable). More...
 
void UpdateDensities ()
 Updates the density array with the latest particle positions. More...
 
void SetTargetDensity (double targetDensity)
 Sets the target density of this particle system. More...
 
double GetTargetDensity () const
 Returns the target density of this particle system. More...
 
void SetTargetSpacing (double spacing)
 Sets the target particle spacing in meters. More...
 
double GetTargetSpacing () const
 Returns the target particle spacing in meters. More...
 
void SetRelativeKernelRadius (double relativeRadius)
 Sets the relative kernel radius. More...
 
double GetRelativeKernelRadius () const
 Returns the relative kernel radius. More...
 
void SetKernelRadius (double kernelRadius)
 Sets the absolute kernel radius. More...
 
double GetKernelRadius () const
 Returns the kernel radius in meters unit. More...
 
double SumOfKernelNearby (const Vector2D &position) const
 Returns sum of kernel function evaluation for each nearby particle. More...
 
double Interpolate (const Vector2D &origin, const ConstArrayAccessor1< double > &values) const
 Returns interpolated value at given origin point. More...
 
Vector2D Interpolate (const Vector2D &origin, const ConstArrayAccessor1< Vector2D > &values) const
 Returns interpolated vector value at given origin point. More...
 
Vector2D GradientAt (size_t i, const ConstArrayAccessor1< double > &values) const
 
double LaplacianAt (size_t i, const ConstArrayAccessor1< double > &values) const
 
Vector2D LaplacianAt (size_t i, const ConstArrayAccessor1< Vector2D > &values) const
 
void BuildNeighborSearcher ()
 Builds neighbor searcher with kernel radius. More...
 
void BuildNeighborLists ()
 Builds neighbor lists with kernel radius. More...
 
void Serialize (std::vector< uint8_t > *buffer) const override
 Serializes this SPH system data to the buffer. More...
 
void Deserialize (const std::vector< uint8_t > &buffer) override
 Deserializes this SPH system data from the buffer. More...
 
void Set (const SPHSystemData2 &other)
 Copies from other SPH system data. More...
 
SPHSystemData2operator= (const SPHSystemData2 &other)
 Copies from other SPH system data. More...
 
- Public Member Functions inherited from CubbyFlow::ParticleSystemData2
 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...
 
double GetMass () const
 Returns 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 Set (const ParticleSystemData2 &other)
 Copies from other particle system data. More...
 
ParticleSystemData2operator= (const ParticleSystemData2 &other)
 Copies from other particle system data. More...
 

Additional Inherited Members

- Public Types inherited from CubbyFlow::ParticleSystemData2
using ScalarData = Array1< double >
 Scalar data chunk. More...
 
using VectorData = Array1< Vector2D >
 Vector data chunk. More...
 
- Protected Member Functions inherited from CubbyFlow::ParticleSystemData2
void SerializeParticleSystemData (flatbuffers::FlatBufferBuilder *builder, flatbuffers::Offset< fbs::ParticleSystemData2 > *fbsParticleSystemData) const
 
void DeserializeParticleSystemData (const fbs::ParticleSystemData2 *fbsParticleSystemData)
 

Detailed Description

2-D SPH particle system data.

This class extends ParticleSystemData2 to specialize the data model for SPH. It includes density and pressure array as a default particle attribute, and it also contains SPH utilities such as interpolation operator.

Constructor & Destructor Documentation

◆ SPHSystemData2() [1/3]

CubbyFlow::SPHSystemData2::SPHSystemData2 ( )

Constructs empty SPH system.

◆ SPHSystemData2() [2/3]

CubbyFlow::SPHSystemData2::SPHSystemData2 ( size_t  numberOfParticles)
explicit

Constructs SPH system data with given number of particles.

◆ SPHSystemData2() [3/3]

CubbyFlow::SPHSystemData2::SPHSystemData2 ( const SPHSystemData2 other)

Copy constructor.

◆ ~SPHSystemData2()

virtual CubbyFlow::SPHSystemData2::~SPHSystemData2 ( )
virtual

Destructor.

Member Function Documentation

◆ BuildNeighborLists()

void CubbyFlow::SPHSystemData2::BuildNeighborLists ( )

Builds neighbor lists with kernel radius.

◆ BuildNeighborSearcher()

void CubbyFlow::SPHSystemData2::BuildNeighborSearcher ( )

Builds neighbor searcher with kernel radius.

◆ Deserialize()

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

Deserializes this SPH system data from the buffer.

Reimplemented from CubbyFlow::ParticleSystemData2.

◆ GetDensities() [1/2]

ConstArrayAccessor1<double> CubbyFlow::SPHSystemData2::GetDensities ( ) const

Returns the density array accessor (immutable).

◆ GetDensities() [2/2]

ArrayAccessor1<double> CubbyFlow::SPHSystemData2::GetDensities ( )

Returns the density array accessor (mutable).

◆ GetKernelRadius()

double CubbyFlow::SPHSystemData2::GetKernelRadius ( ) const

Returns the kernel radius in meters unit.

◆ GetPressures() [1/2]

ConstArrayAccessor1<double> CubbyFlow::SPHSystemData2::GetPressures ( ) const

Returns the pressure array accessor (immutable).

◆ GetPressures() [2/2]

ArrayAccessor1<double> CubbyFlow::SPHSystemData2::GetPressures ( )

Returns the pressure array accessor (mutable).

◆ GetRelativeKernelRadius()

double CubbyFlow::SPHSystemData2::GetRelativeKernelRadius ( ) const

Returns the relative kernel radius.

Returns the relative kernel radius compared to the target particle spacing (i.e. kernel radius / target spacing).

◆ GetTargetDensity()

double CubbyFlow::SPHSystemData2::GetTargetDensity ( ) const

Returns the target density of this particle system.

◆ GetTargetSpacing()

double CubbyFlow::SPHSystemData2::GetTargetSpacing ( ) const

Returns the target particle spacing in meters.

◆ GradientAt()

Vector2D CubbyFlow::SPHSystemData2::GradientAt ( size_t  i,
const ConstArrayAccessor1< double > &  values 
) const

Returns the gradient of the given values at i-th particle.

Warning
You must update the neighbor lists (SPHSystemData2::BuildNeighborLists) before calling this function.

◆ Interpolate() [1/2]

double CubbyFlow::SPHSystemData2::Interpolate ( const Vector2D origin,
const ConstArrayAccessor1< double > &  values 
) const

Returns interpolated value at given origin point.

Returns interpolated scalar data from the given position using standard SPH weighted average. The data array should match the particle layout. For example, density or pressure arrays can be used.

Warning
You must update the neighbor searcher (SPHSystemData2::BuildNeighborSearcher) before calling this function.

◆ Interpolate() [2/2]

Vector2D CubbyFlow::SPHSystemData2::Interpolate ( const Vector2D origin,
const ConstArrayAccessor1< Vector2D > &  values 
) const

Returns interpolated vector value at given origin point.

Returns interpolated vector data from the given position using standard SPH weighted average. The data array should match the particle layout. For example, velocity or acceleration arrays can be used.

Warning
You must update the neighbor searcher (SPHSystemData2::BuildNeighborSearcher) before calling this function.

◆ LaplacianAt() [1/2]

double CubbyFlow::SPHSystemData2::LaplacianAt ( size_t  i,
const ConstArrayAccessor1< double > &  values 
) const

Returns the Laplacian of the given values at i-th particle.

Warning
You must update the neighbor lists (SPHSystemData2::BuildNeighborLists) before calling this function.

◆ LaplacianAt() [2/2]

Vector2D CubbyFlow::SPHSystemData2::LaplacianAt ( size_t  i,
const ConstArrayAccessor1< Vector2D > &  values 
) const

Returns the Laplacian of the given values at i-th particle.

Warning
You must update the neighbor lists (SPHSystemData2::BuildNeighborLists) before calling this function.

◆ operator=()

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

Copies from other SPH system data.

◆ Serialize()

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

Serializes this SPH system data to the buffer.

Reimplemented from CubbyFlow::ParticleSystemData2.

◆ Set()

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

Copies from other SPH system data.

◆ SetKernelRadius()

void CubbyFlow::SPHSystemData2::SetKernelRadius ( double  kernelRadius)

Sets the absolute kernel radius.

Sets the absolute kernel radius compared to the target particle spacing (i.e. relative kernel radius * target spacing). Once this function is called, hash grid and density should be updated using UpdateHashGrid() and UpdateDensities).

◆ SetMass()

void CubbyFlow::SPHSystemData2::SetMass ( double  newMass)
overridevirtual

Sets the mass of a particle.

Setting the mass of a particle will change the target density.

Parameters
[in]newMassThe new mass.

Reimplemented from CubbyFlow::ParticleSystemData2.

◆ SetRadius()

void CubbyFlow::SPHSystemData2::SetRadius ( double  newRadius)
overridevirtual

Sets the radius.

Sets the radius of the particle system. The radius will be interpreted as target spacing.

Reimplemented from CubbyFlow::ParticleSystemData2.

◆ SetRelativeKernelRadius()

void CubbyFlow::SPHSystemData2::SetRelativeKernelRadius ( double  relativeRadius)

Sets the relative kernel radius.

Sets the relative kernel radius compared to the target particle spacing (i.e. kernel radius / target spacing). Once this function is called, hash grid and density should be updated using UpdateHashGrid() and UpdateDensities).

◆ SetTargetDensity()

void CubbyFlow::SPHSystemData2::SetTargetDensity ( double  targetDensity)

Sets the target density of this particle system.

◆ SetTargetSpacing()

void CubbyFlow::SPHSystemData2::SetTargetSpacing ( double  spacing)

Sets the target particle spacing in meters.

Once this function is called, hash grid and density should be updated using UpdateHashGrid() and UpdateDensities).

◆ SumOfKernelNearby()

double CubbyFlow::SPHSystemData2::SumOfKernelNearby ( const Vector2D position) const

Returns sum of kernel function evaluation for each nearby particle.

◆ UpdateDensities()

void CubbyFlow::SPHSystemData2::UpdateDensities ( )

Updates the density array with the latest particle positions.

This function updates the density array by recalculating each particle's latest nearby particles' position.

Warning
You must update the neighbor searcher (SPHSystemData2::BuildNeighborSearcher) before calling this function.

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