GridFractionalSinglePhasePressureSolver3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: GridFractionalSinglePhasePressureSolver3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D fractional single-phase pressure solver.
6 > Created Time: 2017/08/14
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_FRACTIONAL_SINGLE_PHASE_PRESSURE_SOLVER3_H
10 #define CUBBYFLOW_FRACTIONAL_SINGLE_PHASE_PRESSURE_SOLVER3_H
11 
16 
17 namespace CubbyFlow
18 {
44  {
45  public:
47 
49 
72  void Solve(
73  const FaceCenteredGrid3& input,
74  double timeIntervalInSeconds,
75  FaceCenteredGrid3* output,
76  const ScalarField3& boundarySDF = ConstantScalarField3(std::numeric_limits<double>::max()),
77  const VectorField3& boundaryVelocity = ConstantVectorField3({ 0, 0, 0 }),
78  const ScalarField3& fluidSDF = ConstantScalarField3(-std::numeric_limits<double>::max()),
79  bool useCompressed = false) override;
80 
91 
94 
97 
99  const FDMVector3& GetPressure() const;
100 
101  private:
102  FDMLinearSystem3 m_system;
103  FDMCompressedLinearSystem3 m_compSystem;
104  FDMLinearSystemSolver3Ptr m_systemSolver;
105 
106  FDMMGLinearSystem3 m_mgSystem;
107  FDMMGSolver3Ptr m_mgSystemSolver;
108 
109  std::vector<Array3<float>> m_uWeights;
110  std::vector<Array3<float>> m_vWeights;
111  std::vector<Array3<float>> m_wWeights;
112  std::vector<Array3<float>> m_fluidSDF;
113 
114  std::function<Vector3D(const Vector3D&)> m_boundaryVel;
115 
116  void BuildWeights(
117  const FaceCenteredGrid3& input,
118  const ScalarField3& boundarySDF,
119  const VectorField3& boundaryVelocity,
120  const ScalarField3& fluidSDF);
121 
122  void DecompressSolution();
123 
124  virtual void BuildSystem(const FaceCenteredGrid3& input, bool useCompressed);
125 
126  virtual void ApplyPressureGradient(const FaceCenteredGrid3& input, FaceCenteredGrid3* output);
127  };
128 
130  using GridFractionalSinglePhasePressureSolver3Ptr = std::shared_ptr<GridFractionalSinglePhasePressureSolver3>;
131 }
132 
133 #endif
3-D constant vector field.
Definition: ConstantVectorField3.h:17
std::shared_ptr< GridFractionalSinglePhasePressureSolver3 > GridFractionalSinglePhasePressureSolver3Ptr
Shared pointer type for the GridFractionalSinglePhasePressureSolver3.
Definition: GridFractionalSinglePhasePressureSolver3.h:130
std::shared_ptr< FDMLinearSystemSolver3 > FDMLinearSystemSolver3Ptr
Shared pointer type for the FDMLinearSystemSolver3.
Definition: FDMLinearSystemSolver3.h:33
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.
std::shared_ptr< GridBoundaryConditionSolver3 > GridBoundaryConditionSolver3Ptr
Shared pointer type for the GridBoundaryConditionSolver3.
Definition: GridBoundaryConditionSolver3.h:104
const FDMVector3 & GetPressure() const
Returns the pressure field.
3-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid3.h:25
std::shared_ptr< FDMMGSolver3 > FDMMGSolver3Ptr
Shared pointer type for the FDMMGSolver3.
Definition: FDMMGSolver3.h:55
void SetLinearSystemSolver(const FDMLinearSystemSolver3Ptr &solver)
Sets the linear system solver.
Definition: pybind11Utils.h:24
const FDMLinearSystemSolver3Ptr & GetLinearSystemSolver() const
Returns the linear system solver.
3-D fractional single-phase pressure solver.
Definition: GridFractionalSinglePhasePressureSolver3.h:43
3-D constant scalar field.
Definition: ConstantScalarField3.h:17
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
GridBoundaryConditionSolver3Ptr SuggestedBoundaryConditionSolver() const override
Returns the best boundary condition solver for this solver.
Multigrid-syle 3-D linear system.
Definition: FDMMGLinearSystem3.h:24
Linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.h:42