GridFractionalSinglePhasePressureSolver3.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_FRACTIONAL_SINGLE_PHASE_PRESSURE_SOLVER3_HPP
12 #define CUBBYFLOW_FRACTIONAL_SINGLE_PHASE_PRESSURE_SOLVER3_HPP
13 
18 
19 namespace CubbyFlow
20 {
47 {
48  public:
51 
55 
58  GridFractionalSinglePhasePressureSolver3&&) noexcept = delete;
59 
61  ~GridFractionalSinglePhasePressureSolver3() override = default;
62 
66 
69  GridFractionalSinglePhasePressureSolver3&&) noexcept = delete;
70 
94  void Solve(const FaceCenteredGrid3& input, double timeIntervalInSeconds,
95  FaceCenteredGrid3* output,
96  const ScalarField3& boundarySDF =
97  ConstantScalarField3{ std::numeric_limits<double>::max() },
98  const VectorField3& boundaryVelocity =
99  ConstantVectorField3{ { 0, 0, 0 } },
100  const ScalarField3& fluidSDF =
101  ConstantScalarField3{ -std::numeric_limits<double>::max() },
102  bool useCompressed = false) override;
103 
113  [[nodiscard]] GridBoundaryConditionSolver3Ptr
114  SuggestedBoundaryConditionSolver() const override;
115 
117  [[nodiscard]] const FDMLinearSystemSolver3Ptr& GetLinearSystemSolver()
118  const;
119 
122 
124  [[nodiscard]] const FDMVector3& GetPressure() const;
125 
126  private:
127  void BuildWeights(const FaceCenteredGrid3& input,
128  const ScalarField3& boundarySDF,
129  const VectorField3& boundaryVelocity,
130  const ScalarField3& fluidSDF);
131 
132  void DecompressSolution();
133 
134  virtual void BuildSystem(const FaceCenteredGrid3& input,
135  bool useCompressed);
136 
137  virtual void ApplyPressureGradient(const FaceCenteredGrid3& input,
138  FaceCenteredGrid3* output);
139 
140  FDMLinearSystem3 m_system;
141  FDMCompressedLinearSystem3 m_compSystem;
142  FDMLinearSystemSolver3Ptr m_systemSolver;
143 
144  FDMMGLinearSystem3 m_mgSystem;
145  FDMMGSolver3Ptr m_mgSystemSolver;
146 
147  std::vector<Array3<double>> m_uWeights;
148  std::vector<Array3<double>> m_vWeights;
149  std::vector<Array3<double>> m_wWeights;
150  std::vector<Array3<double>> m_fluidSDF;
151 
152  std::function<Vector3D(const Vector3D&)> m_boundaryVel;
153 };
154 
157  std::shared_ptr<GridFractionalSinglePhasePressureSolver3>;
158 } // namespace CubbyFlow
159 
160 #endif
N-D constant vector field.
Definition: ConstantVectorField.hpp:20
std::shared_ptr< GridFractionalSinglePhasePressureSolver3 > GridFractionalSinglePhasePressureSolver3Ptr
Shared pointer type for the GridFractionalSinglePhasePressureSolver3.
Definition: GridFractionalSinglePhasePressureSolver3.hpp:157
std::shared_ptr< FDMLinearSystemSolver3 > FDMLinearSystemSolver3Ptr
Shared pointer type for the FDMLinearSystemSolver3.
Definition: FDMLinearSystemSolver3.hpp:52
std::shared_ptr< GridBoundaryConditionSolver3 > GridBoundaryConditionSolver3Ptr
Shared pointer type for the GridBoundaryConditionSolver3.
Definition: GridBoundaryConditionSolver3.hpp:117
const FDMVector3 & GetPressure() const
Returns the pressure field.
Abstract base class for N-D scalar field.
Definition: ScalarField.hpp:24
std::shared_ptr< FDMMGSolver3 > FDMMGSolver3Ptr
Shared pointer type for the FDMMGSolver3.
Definition: FDMMGSolver3.hpp:55
~GridFractionalSinglePhasePressureSolver3() override=default
Default virtual destructor.
void SetLinearSystemSolver(const FDMLinearSystemSolver3Ptr &solver)
Sets the linear system solver.
Definition: pybind11Utils.hpp:20
const FDMLinearSystemSolver3Ptr & GetLinearSystemSolver() const
Returns the linear system solver.
GridFractionalSinglePhasePressureSolver3 & operator=(const GridFractionalSinglePhasePressureSolver3 &)=delete
Deleted copy assignment operator.
Definition: Array-Impl.hpp:19
3-D fractional single-phase pressure solver.
Definition: GridFractionalSinglePhasePressureSolver3.hpp:46
GridFractionalSinglePhasePressureSolver3()
Default constructor.
N-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid.hpp:31
Abstract base class for N-D vector field.
Definition: VectorField.hpp:42
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.
Abstract base class for 2-D grid-based pressure solver.
Definition: GridPressureSolver3.hpp:29
N-D constant scalar field.
Definition: ConstantScalarField.hpp:20
Compressed linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.hpp:62
GridBoundaryConditionSolver3Ptr SuggestedBoundaryConditionSolver() const override
Returns the best boundary condition solver for this solver.
Multigrid-syle 3-D linear system.
Definition: FDMMGLinearSystem3.hpp:26
Linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.hpp:43