Jet  v1.3.3
sph_system_data2.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_SPH_SYSTEM_DATA2_H_
8 #define INCLUDE_JET_SPH_SYSTEM_DATA2_H_
9 
10 #include <jet/constants.h>
12 #include <vector>
13 
14 namespace jet {
15 
24  public:
27 
30 
33 
35  virtual ~SphSystemData2();
36 
43  void setRadius(double newRadius) override;
44 
52  void setMass(double newMass) override;
53 
56 
59 
62 
65 
76 
79 
81  double targetDensity() const;
82 
89  void setTargetSpacing(double spacing);
90 
92  double targetSpacing() const;
93 
102  void setRelativeKernelRadius(double relativeRadius);
103 
110  double relativeKernelRadius() const;
111 
121 
123  double kernelRadius() const;
124 
126  double sumOfKernelNearby(const Vector2D& position) const;
127 
139  double interpolate(const Vector2D& origin,
140  const ConstArrayAccessor1<double>& values) const;
141 
154  const ConstArrayAccessor1<Vector2D>& values) const;
155 
163  const ConstArrayAccessor1<double>& values) const;
164 
171  double laplacianAt(size_t i,
172  const ConstArrayAccessor1<double>& values) const;
173 
181  const ConstArrayAccessor1<Vector2D>& values) const;
182 
185 
188 
190  void serialize(std::vector<uint8_t>* buffer) const override;
191 
193  void deserialize(const std::vector<uint8_t>& buffer) override;
194 
196  void set(const SphSystemData2& other);
197 
200 
201  private:
203  double _targetDensity = kWaterDensity;
204 
206  double _targetSpacing = 0.1;
207 
210  double _kernelRadiusOverTargetSpacing = 1.8;
211 
213  double _kernelRadius;
214 
215  size_t _pressureIdx;
216 
217  size_t _densityIdx;
218 
220  void computeMass();
221 };
222 
224 typedef std::shared_ptr<SphSystemData2> SphSystemData2Ptr;
225 
226 } // namespace jet
227 
228 #endif // INCLUDE_JET_SPH_SYSTEM_DATA2_H_
jet::SphSystemData2::interpolate
Vector2D interpolate(const Vector2D &origin, const ConstArrayAccessor1< Vector2D > &values) const
Returns interpolated vector value at given origin point.
jet::SphSystemData2::targetDensity
double targetDensity() const
Returns the target density of this particle system.
jet::ConstArrayAccessor< T, 1 >
1-D read-only array accessor class.
Definition: array_accessor1.h:184
jet::SphSystemData2::pressures
ConstArrayAccessor1< double > pressures() const
Returns the pressure array accessor (immutable).
jet::SphSystemData2::setRadius
void setRadius(double newRadius) override
Sets the radius.
jet::SphSystemData2::serialize
void serialize(std::vector< uint8_t > *buffer) const override
Serializes this SPH system data to the buffer.
jet::SphSystemData2::kernelRadius
double kernelRadius() const
Returns the kernel radius in meters unit.
jet::SphSystemData2::interpolate
double interpolate(const Vector2D &origin, const ConstArrayAccessor1< double > &values) const
Returns interpolated value at given origin point.
jet::SphSystemData2::buildNeighborLists
void buildNeighborLists()
Builds neighbor lists with kernel radius.
jet::SphSystemData2::~SphSystemData2
virtual ~SphSystemData2()
Destructor.
jet::SphSystemData2::deserialize
void deserialize(const std::vector< uint8_t > &buffer) override
Deserializes this SPH system data from the buffer.
jet::SphSystemData2::laplacianAt
double laplacianAt(size_t i, const ConstArrayAccessor1< double > &values) const
jet::SphSystemData2
2-D SPH particle system data.
Definition: sph_system_data2.h:23
jet::SphSystemData2::densities
ConstArrayAccessor1< double > densities() const
Returns the density array accessor (immutable).
jet::SphSystemData2::pressures
ArrayAccessor1< double > pressures()
Returns the pressure array accessor (mutable).
jet::SphSystemData2::updateDensities
void updateDensities()
Updates the density array with the latest particle positions.
jet
Definition: advection_solver2.h:18
jet::SphSystemData2::setTargetSpacing
void setTargetSpacing(double spacing)
Sets the target particle spacing in meters.
jet::SphSystemData2::densities
ArrayAccessor1< double > densities()
Returns the density array accessor (mutable).
jet::ParticleSystemData2::numberOfParticles
size_t numberOfParticles() const
Returns the number of particles.
jet::SphSystemData2::SphSystemData2
SphSystemData2(size_t numberOfParticles)
Constructs SPH system data with given number of particles.
jet::Vector< T, 2 >
2-D vector class.
Definition: vector2.h:24
jet::SphSystemData2::gradientAt
Vector2D gradientAt(size_t i, const ConstArrayAccessor1< double > &values) const
jet::SphSystemData2::setRelativeKernelRadius
void setRelativeKernelRadius(double relativeRadius)
Sets the relative kernel radius.
jet::SphSystemData2::set
void set(const SphSystemData2 &other)
Copies from other SPH system data.
particle_system_data2.h
jet::SphSystemData2::SphSystemData2
SphSystemData2(const SphSystemData2 &other)
Copy constructor.
jet::SphSystemData2Ptr
std::shared_ptr< SphSystemData2 > SphSystemData2Ptr
Shared pointer for the SphSystemData2 type.
Definition: sph_system_data2.h:224
jet::SphSystemData2::setKernelRadius
void setKernelRadius(double kernelRadius)
Sets the absolute kernel radius.
constants.h
jet::SphSystemData2::relativeKernelRadius
double relativeKernelRadius() const
Returns the relative kernel radius.
jet::SphSystemData2::targetSpacing
double targetSpacing() const
Returns the target particle spacing in meters.
jet::SphSystemData2::setTargetDensity
void setTargetDensity(double targetDensity)
Sets the target density of this particle system.
jet::kWaterDensity
constexpr double kWaterDensity
Water density.
Definition: constants.h:304
jet::SphSystemData2::sumOfKernelNearby
double sumOfKernelNearby(const Vector2D &position) const
Returns sum of kernel function evaluation for each nearby particle.
jet::SphSystemData2::setMass
void setMass(double newMass) override
Sets the mass of a particle.
jet::SphSystemData2::operator=
SphSystemData2 & operator=(const SphSystemData2 &other)
Copies from other SPH system data.
jet::SphSystemData2::laplacianAt
Vector2D laplacianAt(size_t i, const ConstArrayAccessor1< Vector2D > &values) const
jet::SphSystemData2::SphSystemData2
SphSystemData2()
Constructs empty SPH system.
jet::ArrayAccessor< T, 1 >
1-D array accessor class.
Definition: array_accessor1.h:27
jet::SphSystemData2::buildNeighborSearcher
void buildNeighborSearcher()
Builds neighbor searcher with kernel radius.
jet::ParticleSystemData2
2-D particle system data.
Definition: particle_system_data2.h:45