GridSinglePhasePressureSolver3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: GridSinglePhasePressureSolver3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D single-phase pressure solver.
6 > Created Time: 2017/08/14
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_SINGLE_PHASE_PRESSURE_SOLVER3_H
10 #define CUBBYFLOW_SINGLE_PHASE_PRESSURE_SOLVER3_H
11 
16 
17 namespace CubbyFlow
18 {
34  {
35  public:
38 
41 
64  void Solve(
65  const FaceCenteredGrid3& input,
66  double timeIntervalInSeconds,
67  FaceCenteredGrid3* output,
68  const ScalarField3& boundarySDF = ConstantScalarField3(std::numeric_limits<double>::max()),
69  const VectorField3& boundaryVelocity = ConstantVectorField3({ 0, 0, 0 }),
70  const ScalarField3& fluidSDF = ConstantScalarField3(-std::numeric_limits<double>::max()),
71  bool useCompressed = false) override;
72 
84 
87 
90 
92  const FDMVector3& GetPressure() const;
93 
94  private:
95  FDMLinearSystem3 m_system;
96  FDMCompressedLinearSystem3 m_compSystem;
97  FDMLinearSystemSolver3Ptr m_systemSolver;
98 
99  FDMMGLinearSystem3 m_mgSystem;
100  FDMMGSolver3Ptr m_mgSystemSolver;
101 
102  std::vector<Array3<char>> m_markers;
103 
104  void BuildMarkers(
105  const Size3& size,
106  const std::function<Vector3D(size_t, size_t, size_t)>& pos,
107  const ScalarField3& boundarySDF,
108  const ScalarField3& fluidSDF);
109 
110  void DecompressSolution();
111 
112  virtual void BuildSystem(const FaceCenteredGrid3& input, bool useCompressed);
113 
114  virtual void ApplyPressureGradient(const FaceCenteredGrid3& input, FaceCenteredGrid3* output);
115  };
116 
118  using GridSinglePhasePressureSolver3Ptr = std::shared_ptr<GridSinglePhasePressureSolver3>;
119 }
120 
121 #endif
3-D constant vector field.
Definition: ConstantVectorField3.h:17
std::shared_ptr< FDMLinearSystemSolver3 > FDMLinearSystemSolver3Ptr
Shared pointer type for the FDMLinearSystemSolver3.
Definition: FDMLinearSystemSolver3.h:33
std::shared_ptr< GridBoundaryConditionSolver3 > GridBoundaryConditionSolver3Ptr
Shared pointer type for the GridBoundaryConditionSolver3.
Definition: GridBoundaryConditionSolver3.h:104
3-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid3.h:25
std::shared_ptr< GridSinglePhasePressureSolver3 > GridSinglePhasePressureSolver3Ptr
Shared pointer type for the GridSinglePhasePressureSolver3.
Definition: GridSinglePhasePressureSolver3.h:118
3-D point class.
Definition: Point3.h:26
void SetLinearSystemSolver(const FDMLinearSystemSolver3Ptr &solver)
Sets the linear system solver.
3-D single-phase pressure solver.
Definition: GridSinglePhasePressureSolver3.h:33
std::shared_ptr< FDMMGSolver3 > FDMMGSolver3Ptr
Shared pointer type for the FDMMGSolver3.
Definition: FDMMGSolver3.h:55
void Solve(const FaceCenteredGrid3 &input, double timeIntervalInSeconds, FaceCenteredGrid3 *output, const ScalarField3 &boundarySDF=ConstantScalarField3(std::numeric_limits< double >::max()), const VectorField3 &boundaryVelocity=ConstantVectorField3({ 0, 0, 0 }), const ScalarField3 &fluidSDF=ConstantScalarField3(-std::numeric_limits< double >::max()), bool useCompressed=false) override
Solves the pressure term and apply it to the velocity field.
const FDMVector3 & GetPressure() const
Returns the pressure field.
GridSinglePhasePressureSolver3()
Default constructor.
Definition: pybind11Utils.h:24
const FDMLinearSystemSolver3Ptr & GetLinearSystemSolver() const
Returns the linear system solver.
3-D constant scalar field.
Definition: ConstantScalarField3.h:17
virtual ~GridSinglePhasePressureSolver3()
Default destructor.
Abstract base class for 3-D vector field.
Definition: VectorField3.h:21
Abstract base class for 3-D scalar field.
Definition: ScalarField3.h:21
3-D array class.
Definition: Array3.h:45
Abstract base class for 2-D grid-based pressure solver.
Definition: GridPressureSolver3.h:27
Compressed linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.h:61
Multigrid-syle 3-D linear system.
Definition: FDMMGLinearSystem3.h:24
GridBoundaryConditionSolver3Ptr SuggestedBoundaryConditionSolver() const override
Returns the best boundary condition solver for this solver.
Linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.h:42
Vector3< double > Vector3D
Double-type 3D vector.
Definition: Vector3.h:353