SPHSystemData3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: SPHSystemData3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D SPH particle system data.
6 > Created Time: 2017/05/31
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_SPH_SYSTEM_DATA3_H
10 #define CUBBYFLOW_SPH_SYSTEM_DATA3_H
11 
13 
14 namespace CubbyFlow
15 {
24  {
25  public:
28 
30  explicit SPHSystemData3(size_t numberOfParticles);
31 
33  SPHSystemData3(const SPHSystemData3& other);
34 
36  virtual ~SPHSystemData3();
37 
44  void SetRadius(double newRadius) override;
45 
53  void SetMass(double newMass) override;
54 
57 
60 
63 
66 
68  void UpdateDensities();
69 
71  void SetTargetDensity(double targetDensity);
72 
74  double GetTargetDensity() const;
75 
82  void SetTargetSpacing(double spacing);
83 
85  double GetTargetSpacing() const;
86 
95  void SetRelativeKernelRadius(double relativeRadius);
96 
103  double GetRelativeKernelRadius() const;
104 
113  void SetKernelRadius(double kernelRadius);
114 
116  double GetKernelRadius() const;
117 
119  double SumOfKernelNearby(const Vector3D& position) const;
120 
129  double Interpolate(const Vector3D& origin, const ConstArrayAccessor1<double>& values) const;
130 
139  Vector3D Interpolate(const Vector3D& origin, const ConstArrayAccessor1<Vector3D>& values) const;
140 
142  Vector3D GradientAt(size_t i, const ConstArrayAccessor1<double>& values) const;
143 
145  double LaplacianAt(size_t i, const ConstArrayAccessor1<double>& values) const;
146 
148  Vector3D LaplacianAt(size_t i, const ConstArrayAccessor1<Vector3D>& values) const;
149 
151  void BuildNeighborSearcher();
152 
154  void BuildNeighborLists();
155 
157  void Serialize(std::vector<uint8_t>* buffer) const override;
158 
160  void Deserialize(const std::vector<uint8_t>& buffer) override;
161 
163  void Set(const SPHSystemData3& other);
164 
166  SPHSystemData3& operator=(const SPHSystemData3& other);
167 
168  private:
170  double m_targetDensity = WATER_DENSITY;
171 
173  double m_targetSpacing = 0.1;
174 
177  double m_kernelRadiusOverTargetSpacing = 1.8;
178 
180  double m_kernelRadius;
181 
182  size_t m_pressureIdx;
183 
184  size_t m_densityIdx;
185 
187  void ComputeMass();
188  };
189 
191  using SPHSystemData3Ptr = std::shared_ptr<SPHSystemData3>;
192 }
193 
194 #endif
3-D vector class.
Definition: Vector3.h:26
constexpr double WATER_DENSITY
Water density.
Definition: Constants.h:159
void BuildNeighborLists()
Builds neighbor lists with kernel radius.
double Interpolate(const Vector3D &origin, const ConstArrayAccessor1< double > &values) const
Returns interpolated value at given origin point.
void Serialize(std::vector< uint8_t > *buffer) const override
Serializes this SPH system data to the buffer.
void SetMass(double newMass) override
Sets the mass of a particle.
void SetTargetDensity(double targetDensity)
Sets the target density of this particle system.
double SumOfKernelNearby(const Vector3D &position) const
Returns sum of kernel function evaluation for each nearby particle.
ConstArrayAccessor1< double > GetPressures() const
Returns the pressure array accessor (immutable).
SPHSystemData3 & operator=(const SPHSystemData3 &other)
Copies from other SPH system data.
void BuildNeighborSearcher()
Builds neighbor searcher with kernel radius.
double GetKernelRadius() const
Returns the kernel radius in meters unit.
void SetRelativeKernelRadius(double relativeRadius)
Sets the relative kernel radius.
virtual ~SPHSystemData3()
Destructor.
double GetTargetSpacing() const
Returns the target particle spacing in meters.
1-D read-only array accessor class.
Definition: ArrayAccessor1.h:185
Definition: pybind11Utils.h:24
double GetTargetDensity() const
Returns the target density of this particle system.
double LaplacianAt(size_t i, const ConstArrayAccessor1< double > &values) const
Returns the Laplacian of the given values at i-th particle.
void Deserialize(const std::vector< uint8_t > &buffer) override
Deserializes this SPH system data from the buffer.
ConstArrayAccessor1< double > GetDensities() const
Returns the density array accessor (immutable).
void UpdateDensities()
Updates the density array with the latest particle positions.
void SetTargetSpacing(double spacing)
Sets the target particle spacing in meters.
1-D array accessor class.
Definition: ArrayAccessor1.h:28
double GetRelativeKernelRadius() const
Returns the relative kernel radius.
Vector3D GradientAt(size_t i, const ConstArrayAccessor1< double > &values) const
Returns the gradient of the given values at i-th particle.
3-D particle system data.
Definition: ParticleSystemData3.h:47
void Set(const SPHSystemData3 &other)
Copies from other SPH system data.
void SetRadius(double newRadius) override
Sets the radius.
SPHSystemData3()
Constructs empty SPH system.
std::shared_ptr< SPHSystemData3 > SPHSystemData3Ptr
Shared pointer for the SPHSystemData3 type.
Definition: SPHSystemData3.h:191
void SetKernelRadius(double kernelRadius)
Sets the absolute kernel radius.
3-D SPH particle system data.
Definition: SPHSystemData3.h:23