N-D SPH particle system data. More...
#include <Core/Particle/SPHSystemData.hpp>
Public Types | |
using | Base = ParticleSystemData< N > |
Public Types inherited from CubbyFlow::ParticleSystemData< N > | |
using | ScalarData = Array1< double > |
Scalar data chunk. More... | |
using | VectorData = Array1< Vector< double, N > > |
Vector data chunk. More... | |
Public Member Functions | |
SPHSystemData () | |
Constructs empty SPH system. More... | |
SPHSystemData (size_t numberOfParticles) | |
Constructs SPH system data with given number of particles. More... | |
~SPHSystemData () override=default | |
Default virtual destructor. More... | |
SPHSystemData (const SPHSystemData &other) | |
Copy constructor. More... | |
SPHSystemData (SPHSystemData &&other) noexcept | |
Move constructor. More... | |
SPHSystemData & | operator= (const SPHSystemData &other) |
Copy assignment operator. More... | |
SPHSystemData & | operator= (SPHSystemData &&other) noexcept |
Move assignment operator. More... | |
void | SetRadius (double newRadius) override |
Sets the radius. More... | |
void | SetMass (double newMass) override |
Sets the mass of a particle. More... | |
ConstArrayView1< double > | Densities () const |
Returns the density array view (immutable). More... | |
ArrayView1< double > | Densities () |
Returns the density array view (mutable). More... | |
ConstArrayView1< double > | Pressures () const |
Returns the pressure array view (immutable). More... | |
ArrayView1< double > | Pressures () |
Returns the pressure array view (mutable). More... | |
void | UpdateDensities () |
Updates the density array with the latest particle positions. More... | |
double | TargetDensity () const |
Returns the target density of this particle system. More... | |
void | SetTargetDensity (double targetDensity) |
Sets the target density of this particle system. More... | |
double | TargetSpacing () const |
Returns the target particle spacing in meters. More... | |
void | SetTargetSpacing (double spacing) |
Sets the target particle spacing in meters. More... | |
double | RelativeKernelRadius () const |
Returns the relative kernel radius. More... | |
void | SetRelativeKernelRadius (double relativeRadius) |
Sets the relative kernel radius. More... | |
double | KernelRadius () const |
Returns the kernel radius in meters unit. More... | |
void | SetKernelRadius (double kernelRadius) |
Sets the absolute kernel radius. More... | |
double | SumOfKernelNearby (const Vector< double, N > &position) const |
Returns sum of kernel function evaluation for each nearby particle. More... | |
double | Interpolate (const Vector< double, N > &origin, const ConstArrayView1< double > &values) const |
Returns interpolated value at given origin point. More... | |
Vector< double, N > | Interpolate (const Vector< double, N > &origin, const ConstArrayView1< Vector< double, N >> &values) const |
Returns interpolated vector value at given origin point. More... | |
Vector< double, N > | GradientAt (size_t i, const ConstArrayView1< double > &values) const |
double | LaplacianAt (size_t i, const ConstArrayView1< double > &values) const |
Vector< double, N > | LaplacianAt (size_t i, const ConstArrayView1< Vector< double, N >> &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 SPHSystemData &other) |
Copies from other SPH system data. More... | |
Public Member Functions inherited from CubbyFlow::ParticleSystemData< N > | |
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... | |
ParticleSystemData & | operator= (const ParticleSystemData &other) |
Copy assignment operator. More... | |
ParticleSystemData & | operator= (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... | |
double | Mass () const |
Returns 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 | 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... | |
Serializable & | operator= (const Serializable &)=default |
Default copy assignment operator. More... | |
Serializable & | operator= (Serializable &&) noexcept=default |
Default move assignment operator. More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from CubbyFlow::ParticleSystemData< N > | |
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::SPHSystemData< N >
N-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.
Member Typedef Documentation
◆ Base
using CubbyFlow::SPHSystemData< N >::Base = ParticleSystemData<N> |
Constructor & Destructor Documentation
◆ SPHSystemData() [1/4]
CubbyFlow::SPHSystemData< N >::SPHSystemData | ( | ) |
Constructs empty SPH system.
◆ SPHSystemData() [2/4]
|
explicit |
Constructs SPH system data with given number of particles.
◆ ~SPHSystemData()
|
overridedefault |
Default virtual destructor.
◆ SPHSystemData() [3/4]
CubbyFlow::SPHSystemData< N >::SPHSystemData | ( | const SPHSystemData< N > & | other | ) |
Copy constructor.
◆ SPHSystemData() [4/4]
|
noexcept |
Move constructor.
Member Function Documentation
◆ BuildNeighborLists()
void CubbyFlow::SPHSystemData< N >::BuildNeighborLists | ( | ) |
Builds neighbor lists with kernel radius.
◆ BuildNeighborSearcher()
void CubbyFlow::SPHSystemData< N >::BuildNeighborSearcher | ( | ) |
Builds neighbor searcher with kernel radius.
◆ Densities() [1/2]
ConstArrayView1<double> CubbyFlow::SPHSystemData< N >::Densities | ( | ) | const |
Returns the density array view (immutable).
◆ Densities() [2/2]
ArrayView1<double> CubbyFlow::SPHSystemData< N >::Densities | ( | ) |
Returns the density array view (mutable).
◆ Deserialize()
|
overridevirtual |
Deserializes this SPH system data from the buffer.
Reimplemented from CubbyFlow::ParticleSystemData< N >.
◆ GradientAt()
Vector<double, N> CubbyFlow::SPHSystemData< N >::GradientAt | ( | size_t | i, |
const ConstArrayView1< double > & | values | ||
) | const |
Returns the gradient of the given values at i-th particle.
- Warning
- You must update the neighbor lists (SPHSystemData::BuildNeighborLists) before calling this function.
◆ Interpolate() [1/2]
double CubbyFlow::SPHSystemData< N >::Interpolate | ( | const Vector< double, N > & | origin, |
const ConstArrayView1< 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 (SPHSystemData::BuildNeighborSearcher) before calling this function.
◆ Interpolate() [2/2]
Vector<double, N> CubbyFlow::SPHSystemData< N >::Interpolate | ( | const Vector< double, N > & | origin, |
const ConstArrayView1< Vector< double, N >> & | 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 (SPHSystemData::BuildNeighborSearcher) before calling this function.
◆ KernelRadius()
double CubbyFlow::SPHSystemData< N >::KernelRadius | ( | ) | const |
Returns the kernel radius in meters unit.
◆ LaplacianAt() [1/2]
double CubbyFlow::SPHSystemData< N >::LaplacianAt | ( | size_t | i, |
const ConstArrayView1< double > & | values | ||
) | const |
Returns the laplacian of the given values at i-th particle.
- Warning
- You must update the neighbor lists (SPHSystemData::BuildNeighborLists) before calling this function.
◆ LaplacianAt() [2/2]
Vector<double, N> CubbyFlow::SPHSystemData< N >::LaplacianAt | ( | size_t | i, |
const ConstArrayView1< Vector< double, N >> & | values | ||
) | const |
Returns the laplacian of the given values at i-th particle.
- Warning
- You must update the neighbor lists (SPHSystemData::BuildNeighborLists) before calling this function.
◆ operator=() [1/2]
SPHSystemData& CubbyFlow::SPHSystemData< N >::operator= | ( | const SPHSystemData< N > & | other | ) |
Copy assignment operator.
◆ operator=() [2/2]
|
noexcept |
Move assignment operator.
◆ Pressures() [1/2]
ConstArrayView1<double> CubbyFlow::SPHSystemData< N >::Pressures | ( | ) | const |
Returns the pressure array view (immutable).
◆ Pressures() [2/2]
ArrayView1<double> CubbyFlow::SPHSystemData< N >::Pressures | ( | ) |
Returns the pressure array view (mutable).
◆ RelativeKernelRadius()
double CubbyFlow::SPHSystemData< N >::RelativeKernelRadius | ( | ) | const |
Returns the relative kernel radius.
Returns the relative kernel radius compared to the target particle spacing (i.e. kernel radius / target spacing).
◆ Serialize()
|
overridevirtual |
Serializes this SPH system data to the buffer.
Reimplemented from CubbyFlow::ParticleSystemData< N >.
◆ Set()
void CubbyFlow::SPHSystemData< N >::Set | ( | const SPHSystemData< N > & | other | ) |
Copies from other SPH system data.
◆ SetKernelRadius()
void CubbyFlow::SPHSystemData< N >::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()
|
overridevirtual |
Sets the mass of a particle.
Setting the mass of a particle will change the target density.
- Parameters
-
[in] newMass The new mass.
Reimplemented from CubbyFlow::ParticleSystemData< N >.
◆ SetRadius()
|
overridevirtual |
Sets the radius.
Sets the radius of the particle system. The radius will be interpreted as target spacing.
Reimplemented from CubbyFlow::ParticleSystemData< N >.
◆ SetRelativeKernelRadius()
void CubbyFlow::SPHSystemData< N >::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::SPHSystemData< N >::SetTargetDensity | ( | double | targetDensity | ) |
Sets the target density of this particle system.
◆ SetTargetSpacing()
void CubbyFlow::SPHSystemData< N >::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::SPHSystemData< N >::SumOfKernelNearby | ( | const Vector< double, N > & | position | ) | const |
Returns sum of kernel function evaluation for each nearby particle.
◆ TargetDensity()
double CubbyFlow::SPHSystemData< N >::TargetDensity | ( | ) | const |
Returns the target density of this particle system.
◆ TargetSpacing()
double CubbyFlow::SPHSystemData< N >::TargetSpacing | ( | ) | const |
Returns the target particle spacing in meters.
◆ UpdateDensities()
void CubbyFlow::SPHSystemData< N >::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 (SPHSystemData::BuildNeighborSearcher) before calling this function.
The documentation for this class was generated from the following file:
- Core/Particle/SPHSystemData.hpp