PCISPHSolver3.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_PCISPH_SOLVER3_HPP
12 #define CUBBYFLOW_PCISPH_SOLVER3_HPP
13 
15 
16 namespace CubbyFlow
17 {
27 class PCISPHSolver3 : public SPHSolver3
28 {
29  public:
30  class Builder;
31 
33  PCISPHSolver3();
34 
37  PCISPHSolver3(double targetDensity, double targetSpacing,
38  double relativeKernelRadius);
39 
41  PCISPHSolver3(const PCISPHSolver3&) = delete;
42 
44  PCISPHSolver3(PCISPHSolver3&&) noexcept = delete;
45 
47  ~PCISPHSolver3() override = default;
48 
50  PCISPHSolver3& operator=(const PCISPHSolver3&) = delete;
51 
53  PCISPHSolver3& operator=(PCISPHSolver3&&) noexcept = delete;
54 
56  [[nodiscard]] double GetMaxDensityErrorRatio() const;
57 
64  void SetMaxDensityErrorRatio(double ratio);
65 
67  [[nodiscard]] unsigned int GetMaxNumberOfIterations() const;
68 
74  void SetMaxNumberOfIterations(unsigned int n);
75 
77  [[nodiscard]] static Builder GetBuilder();
78 
79  protected:
82  void AccumulatePressureForce(double timeIntervalInSeconds) override;
83 
85  void OnBeginAdvanceTimeStep(double timeStepInSeconds) override;
86 
87  private:
88  [[nodiscard]] double ComputeDelta(double timeStepInSeconds) const;
89  [[nodiscard]] double ComputeBeta(double timeStepInSeconds) const;
90 
91  double m_maxDensityErrorRatio = 0.01;
92  unsigned int m_maxNumberOfIterations = 5;
93 
94  ParticleSystemData3::VectorData m_tempPositions;
95  ParticleSystemData3::VectorData m_tempVelocities;
96  ParticleSystemData3::VectorData m_pressureForces;
97  ParticleSystemData3::ScalarData m_densityErrors;
98 };
99 
101 using PCISPHSolver3Ptr = std::shared_ptr<PCISPHSolver3>;
102 
106 class PCISPHSolver3::Builder final : public SPHSolverBuilderBase3<Builder>
107 {
108  public:
110  [[nodiscard]] PCISPHSolver3 Build() const;
111 
113  [[nodiscard]] PCISPHSolver3Ptr MakeShared() const;
114 };
115 } // namespace CubbyFlow
116 
117 #endif
unsigned int GetMaxNumberOfIterations() const
Returns max number of iterations.
static Builder GetBuilder()
Returns builder fox PCISPHSolver3.
~PCISPHSolver3() override=default
Default virtual destructor.
PCISPHSolver3 & operator=(const PCISPHSolver3 &)=delete
Deleted copy assignment operator.
PCISPHSolver3()
Constructs a solver with empty particle set.
3-D SPH solver.
Definition: SPHSolver3.hpp:32
void AccumulatePressureForce(double timeIntervalInSeconds) override
std::shared_ptr< PCISPHSolver3 > PCISPHSolver3Ptr
Shared pointer type for the PCISPHSolver3.
Definition: PCISPHSolver3.hpp:101
void SetMaxDensityErrorRatio(double ratio)
Sets max allowed density error ratio.
Definition: pybind11Utils.hpp:20
Definition: Array-Impl.hpp:19
double GetMaxDensityErrorRatio() const
Returns max allowed density error ratio.
Front-end to create PCISPHSolver3 objects step by step.
Definition: PCISPHSolver3.hpp:106
Base class for SPH-based fluid solver builder.
Definition: SPHSolver3.hpp:208
void SetMaxNumberOfIterations(unsigned int n)
Sets max number of PCISPH iterations.
void OnBeginAdvanceTimeStep(double timeStepInSeconds) override
Performs pre-processing step before the simulation.
3-D PCISPH solver.
Definition: PCISPHSolver3.hpp:27