PCISPHSolver2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: PCISPHSolver2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 2-D PCISPH solver.
6 > Created Time: 2017/06/09
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_PCISPH_SOLVER2_H
10 #define CUBBYFLOW_PCISPH_SOLVER2_H
11 
13 
14 namespace CubbyFlow
15 {
25  class PCISPHSolver2 : public SPHSolver2
26  {
27  public:
28  class Builder;
29 
31  PCISPHSolver2();
32 
34  PCISPHSolver2(double targetDensity, double targetSpacing, double relativeKernelRadius);
35 
36  virtual ~PCISPHSolver2();
37 
39  double GetMaxDensityErrorRatio() const;
40 
47  void SetMaxDensityErrorRatio(double ratio);
48 
50  unsigned int GetMaxNumberOfIterations() const;
51 
57  void SetMaxNumberOfIterations(unsigned int n);
58 
60  static Builder GetBuilder();
61 
62  protected:
64  void AccumulatePressureForce(double timeIntervalInSeconds) override;
65 
67  void OnBeginAdvanceTimeStep(double timeStepInSeconds) override;
68 
69  private:
70  double m_maxDensityErrorRatio = 0.01;
71  unsigned int m_maxNumberOfIterations = 5;
72 
73  ParticleSystemData2::VectorData m_tempPositions;
74  ParticleSystemData2::VectorData m_tempVelocities;
75  ParticleSystemData2::VectorData m_pressureForces;
76  ParticleSystemData2::ScalarData m_densityErrors;
77 
78  double ComputeDelta(double timeStepInSeconds) const;
79  double ComputeBeta(double timeStepInSeconds) const;
80  };
81 
83  using PCISPHSolver2Ptr = std::shared_ptr<PCISPHSolver2>;
84 
88  class PCISPHSolver2::Builder final : public SPHSolverBuilderBase2<PCISPHSolver2::Builder>
89  {
90  public:
92  PCISPHSolver2 Build() const;
93 
96  };
97 }
98 
99 #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.h:192
unsigned int GetMaxNumberOfIterations() const
Returns max number of iterations.
Front-end to create PCISPHSolver2 objects step by step.
Definition: PCISPHSolver2.h:88
PCISPHSolver2Ptr MakeShared() const
Builds shared pointer of PCISPHSolver2 instance.
std::shared_ptr< PCISPHSolver2 > PCISPHSolver2Ptr
Shared pointer type for the PCISPHSolver2.
Definition: PCISPHSolver2.h:83
void AccumulatePressureForce(double timeIntervalInSeconds) override
Accumulates the pressure force to the forces array in the particle system.
1-D array class.
Definition: Array1.h:29
Definition: pybind11Utils.h:24
double GetMaxDensityErrorRatio() const
Returns max allowed density error ratio.
PCISPHSolver2 Build() const
Builds PCISPHSolver2.
2-D PCISPH solver.
Definition: PCISPHSolver2.h:25
PCISPHSolver2()
Constructs a solver with empty particle set.
static Builder GetBuilder()
Returns builder fox PCISPHSolver2.
2-D SPH solver.
Definition: SPHSolver2.h:30
void OnBeginAdvanceTimeStep(double timeStepInSeconds) override
Performs pre-processing step before the simulation.