PCISPHSolver3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: PCISPHSolver3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D PCISPH solver.
6 > Created Time: 2017/06/09
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_PCISPH_SOLVER3_H
10 #define CUBBYFLOW_PCISPH_SOLVER3_H
11 
13 
14 namespace CubbyFlow
15 {
25  class PCISPHSolver3 : public SPHSolver3
26  {
27  public:
28  class Builder;
29 
31  PCISPHSolver3();
32 
34  PCISPHSolver3(double targetDensity, double targetSpacing, double relativeKernelRadius);
35 
36  virtual ~PCISPHSolver3();
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  ParticleSystemData3::VectorData m_tempPositions;
74  ParticleSystemData3::VectorData m_tempVelocities;
75  ParticleSystemData3::VectorData m_pressureForces;
76  ParticleSystemData3::ScalarData m_densityErrors;
77 
78  double ComputeDelta(double timeStepInSeconds) const;
79  double ComputeBeta(double timeStepInSeconds) const;
80  };
81 
83  using PCISPHSolver3Ptr = std::shared_ptr<PCISPHSolver3>;
84 
88  class PCISPHSolver3::Builder final : public SPHSolverBuilderBase3<PCISPHSolver3::Builder>
89  {
90  public:
92  PCISPHSolver3 Build() const;
93 
96  };
97 }
98 
99 #endif
unsigned int GetMaxNumberOfIterations() const
Returns max number of iterations.
static Builder GetBuilder()
Returns builder fox PCISPHSolver3.
PCISPHSolver3()
Constructs a solver with empty particle set.
PCISPHSolver3 Build() const
Builds PCISPHSolver3.
PCISPHSolver3Ptr MakeShared() const
Builds shared pointer of PCISPHSolver3 instance.
3-D SPH solver.
Definition: SPHSolver3.h:30
void AccumulatePressureForce(double timeIntervalInSeconds) override
Accumulates the pressure force to the forces array in the particle system.
std::shared_ptr< PCISPHSolver3 > PCISPHSolver3Ptr
Shared pointer type for the PCISPHSolver3.
Definition: PCISPHSolver3.h:83
1-D array class.
Definition: Array1.h:29
void SetMaxDensityErrorRatio(double ratio)
Sets max allowed density error ratio.
Definition: pybind11Utils.h:24
double GetMaxDensityErrorRatio() const
Returns max allowed density error ratio.
Front-end to create PCISPHSolver3 objects step by step.
Definition: PCISPHSolver3.h:88
Base class for SPH-based fluid solver builder.
Definition: SPHSolver3.h:192
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.h:25