PCISPHSolver2.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_SOLVER2_HPP
12 #define CUBBYFLOW_PCISPH_SOLVER2_HPP
13 
15 
16 namespace CubbyFlow
17 {
27 class PCISPHSolver2 : public SPHSolver2
28 {
29  public:
30  class Builder;
31 
33  PCISPHSolver2();
34 
37  PCISPHSolver2(double targetDensity, double targetSpacing,
38  double relativeKernelRadius);
39 
41  PCISPHSolver2(const PCISPHSolver2&) = delete;
42 
44  PCISPHSolver2(PCISPHSolver2&&) noexcept = delete;
45 
47  ~PCISPHSolver2() override = default;
48 
50  PCISPHSolver2& operator=(const PCISPHSolver2&) = delete;
51 
53  PCISPHSolver2& operator=(PCISPHSolver2&&) 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  ParticleSystemData2::VectorData m_tempPositions;
95  ParticleSystemData2::VectorData m_tempVelocities;
96  ParticleSystemData2::VectorData m_pressureForces;
97  ParticleSystemData2::ScalarData m_densityErrors;
98 };
99 
101 using PCISPHSolver2Ptr = std::shared_ptr<PCISPHSolver2>;
102 
106 class PCISPHSolver2::Builder final : public SPHSolverBuilderBase2<Builder>
107 {
108  public:
110  [[nodiscard]] PCISPHSolver2 Build() const;
111 
113  [[nodiscard]] PCISPHSolver2Ptr MakeShared() const;
114 };
115 } // namespace CubbyFlow
116 
117 #endif
void SetMaxDensityErrorRatio(double ratio)
Sets max allowed density error ratio.
void SetMaxNumberOfIterations(unsigned int n)
Sets max number of PCISPH iterations.
Base class for SPH-based fluid solver builder.
Definition: SPHSolver2.hpp:208
unsigned int GetMaxNumberOfIterations() const
Returns max number of iterations.
Front-end to create PCISPHSolver2 objects step by step.
Definition: PCISPHSolver2.hpp:106
std::shared_ptr< PCISPHSolver2 > PCISPHSolver2Ptr
Shared pointer type for the PCISPHSolver2.
Definition: PCISPHSolver2.hpp:101
void AccumulatePressureForce(double timeIntervalInSeconds) override
~PCISPHSolver2() override=default
Default virtual destructor.
Definition: pybind11Utils.hpp:20
Definition: Array-Impl.hpp:19
double GetMaxDensityErrorRatio() const
Returns max allowed density error ratio.
2-D PCISPH solver.
Definition: PCISPHSolver2.hpp:27
PCISPHSolver2()
Constructs a solver with empty particle set.
PCISPHSolver2 & operator=(const PCISPHSolver2 &)=delete
Deleted copy assignment operator.
static Builder GetBuilder()
Returns builder fox PCISPHSolver2.
2-D SPH solver.
Definition: SPHSolver2.hpp:32
void OnBeginAdvanceTimeStep(double timeStepInSeconds) override
Performs pre-processing step before the simulation.