GridSinglePhasePressureSolver2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: GridSinglePhasePressureSolver2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 2-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_SOLVER2_H
10 #define CUBBYFLOW_SINGLE_PHASE_PRESSURE_SOLVER2_H
11 
16 
17 namespace CubbyFlow
18 {
34  {
35  public:
38 
41 
64  void Solve(
65  const FaceCenteredGrid2& input,
66  double timeIntervalInSeconds,
67  FaceCenteredGrid2* output,
68  const ScalarField2& boundarySDF = ConstantScalarField2(std::numeric_limits<double>::max()),
69  const VectorField2& boundaryVelocity = ConstantVectorField2({ 0, 0 }),
70  const ScalarField2& fluidSDF = ConstantScalarField2(-std::numeric_limits<double>::max()),
71  bool useCompressed = false) override;
72 
84 
87 
90 
92  const FDMVector2& GetPressure() const;
93 
94  private:
95  FDMLinearSystem2 m_system;
96  FDMCompressedLinearSystem2 m_compSystem;
97  FDMLinearSystemSolver2Ptr m_systemSolver;
98 
99  FDMMGLinearSystem2 m_mgSystem;
100  FDMMGSolver2Ptr m_mgSystemSolver;
101 
102  std::vector<Array2<char>> m_markers;
103 
104  void BuildMarkers(
105  const Size2& size,
106  const std::function<Vector2D(size_t, size_t)>& pos,
107  const ScalarField2& boundarySDF,
108  const ScalarField2& fluidSDF);
109 
110  void DecompressSolution();
111 
112  virtual void BuildSystem(const FaceCenteredGrid2& input, bool useCompressed);
113 
114  virtual void ApplyPressureGradient(const FaceCenteredGrid2& input, FaceCenteredGrid2* output);
115  };
116 
118  using GridSinglePhasePressureSolver2Ptr = std::shared_ptr<GridSinglePhasePressureSolver2>;
119 }
120 
121 #endif
std::shared_ptr< FDMLinearSystemSolver2 > FDMLinearSystemSolver2Ptr
Shared pointer type for the FDMLinearSystemSolver2.
Definition: FDMLinearSystemSolver2.h:33
Linear system (Ax=b) for 2-D finite differencing.
Definition: FDMLinearSystem2.h:39
Abstract base class for 2-D scalar field.
Definition: ScalarField2.h:21
Abstract base class for 2-D grid-based pressure solver.
Definition: GridPressureSolver2.h:27
std::shared_ptr< GridSinglePhasePressureSolver2 > GridSinglePhasePressureSolver2Ptr
Shared pointer type for the GridSinglePhasePressureSolver2.
Definition: GridSinglePhasePressureSolver2.h:118
std::shared_ptr< GridBoundaryConditionSolver2 > GridBoundaryConditionSolver2Ptr
Shared pointer type for the GridBoundaryConditionSolver2.
Definition: GridBoundaryConditionSolver2.h:104
2-D point class.
Definition: Point2.h:25
GridSinglePhasePressureSolver2()
Default constructor.
2-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid2.h:25
Definition: pybind11Utils.h:24
std::shared_ptr< FDMMGSolver2 > FDMMGSolver2Ptr
Shared pointer type for the FDMMGSolver2.
Definition: FDMMGSolver2.h:55
Vector2< double > Vector2D
Double-type 2D vector.
Definition: Vector2.h:341
void SetLinearSystemSolver(const FDMLinearSystemSolver2Ptr &solver)
Sets the linear system solver.
2-D single-phase pressure solver.
Definition: GridSinglePhasePressureSolver2.h:33
const FDMLinearSystemSolver2Ptr & GetLinearSystemSolver() const
Returns the linear system solver.
Compressed linear system (Ax=b) for 2-D finite differencing.
Definition: FDMLinearSystem2.h:58
2-D constant vector field.
Definition: ConstantVectorField2.h:17
virtual ~GridSinglePhasePressureSolver2()
Default destructor.
void Solve(const FaceCenteredGrid2 &input, double timeIntervalInSeconds, FaceCenteredGrid2 *output, const ScalarField2 &boundarySDF=ConstantScalarField2(std::numeric_limits< double >::max()), const VectorField2 &boundaryVelocity=ConstantVectorField2({ 0, 0 }), const ScalarField2 &fluidSDF=ConstantScalarField2(-std::numeric_limits< double >::max()), bool useCompressed=false) override
Solves the pressure term and apply it to the velocity field.
2-D constant scalar field.
Definition: ConstantScalarField2.h:17
Abstract base class for 2-D vector field.
Definition: VectorField2.h:21
2-D array class.
Definition: Array2.h:42
const FDMVector2 & GetPressure() const
Returns the pressure field.
Multigrid-syle 2-D linear system.
Definition: FDMMGLinearSystem2.h:24
GridBoundaryConditionSolver2Ptr SuggestedBoundaryConditionSolver() const override
Returns the best boundary condition solver for this solver.