Loading...
Searching...
No Matches
GridFractionalSinglePhasePressureSolver2.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_SOLVER2_HPP
12#define CUBBYFLOW_FRACTIONAL_SINGLE_PHASE_PRESSURE_SOLVER2_HPP
13
18
19namespace CubbyFlow
20{
47 : public GridPressureSolver2
48{
49 public:
52
56
60
63
67
71
95 void Solve(
96 const FaceCenteredGrid2& input, double timeIntervalInSeconds,
99 ConstantScalarField2{ std::numeric_limits<double>::max() },
101 const ScalarField2& fluidSDF =
102 ConstantScalarField2{ -std::numeric_limits<double>::max() },
103 bool useCompressed = false) override;
104
116
119 const;
120
123
125 [[nodiscard]] const FDMVector2& GetPressure() const;
126
127 private:
128 void BuildWeights(const FaceCenteredGrid2& input,
131 const ScalarField2& fluidSDF);
132
133 void DecompressSolution();
134
135 void BuildSystem(const FaceCenteredGrid2& input, bool useCompressed);
136
137 void ApplyPressureGradient(const FaceCenteredGrid2& input,
139
140 FDMLinearSystem2 m_system;
141 FDMCompressedLinearSystem2 m_compSystem;
142 FDMLinearSystemSolver2Ptr m_systemSolver;
143
144 FDMMGLinearSystem2 m_mgSystem;
145 FDMMGSolver2Ptr m_mgSystemSolver;
146
147 std::vector<Array2<double>> m_uWeights;
148 std::vector<Array2<double>> m_vWeights;
149 std::vector<Array2<double>> m_fluidSDF;
150
151 std::function<Vector2D(const Vector2D&)> m_boundaryVel;
152};
153
156 std::shared_ptr<GridFractionalSinglePhasePressureSolver2>;
157} // namespace CubbyFlow
158
159#endif
N-D constant scalar field.
Definition ConstantScalarField.hpp:21
N-D constant vector field.
Definition ConstantVectorField.hpp:21
N-D face-centered (a.k.a MAC or staggered) grid.
Definition FaceCenteredGrid.hpp:32
2-D fractional single-phase pressure solver.
Definition GridFractionalSinglePhasePressureSolver2.hpp:48
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.
void SetLinearSystemSolver(const FDMLinearSystemSolver2Ptr &solver)
Sets the linear system solver.
GridFractionalSinglePhasePressureSolver2()
Default constructor.
GridBoundaryConditionSolver2Ptr SuggestedBoundaryConditionSolver() const override
Returns the best boundary condition solver for this solver.
const FDMVector2 & GetPressure() const
Returns the pressure field.
const FDMLinearSystemSolver2Ptr & GetLinearSystemSolver() const
Returns the linear system solver.
GridFractionalSinglePhasePressureSolver2(const GridFractionalSinglePhasePressureSolver2 &)=delete
Deleted copy constructor.
GridFractionalSinglePhasePressureSolver2(GridFractionalSinglePhasePressureSolver2 &&) noexcept=delete
Deleted move constructor.
Abstract base class for 2-D grid-based pressure solver.
Definition GridPressureSolver2.hpp:30
Definition Matrix.hpp:30
Abstract base class for N-D scalar field.
Definition ScalarField.hpp:25
Abstract base class for N-D vector field.
Definition VectorField.hpp:43
Definition pybind11Utils.hpp:21
ScalarField< 2 > ScalarField2
2-D ScalarField type.
Definition ScalarField.hpp:61
Vector2< double > Vector2D
Definition Matrix.hpp:774
std::shared_ptr< FDMMGSolver2 > FDMMGSolver2Ptr
Shared pointer type for the FDMMGSolver2.
Definition FDMMGSolver2.hpp:55
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
ConstantScalarField< 2 > ConstantScalarField2
2-D ConstantScalarField type.
Definition ConstantScalarField.hpp:43
std::shared_ptr< GridFractionalSinglePhasePressureSolver2 > GridFractionalSinglePhasePressureSolver2Ptr
Shared pointer type for the GridFractionalSinglePhasePressureSolver2.
Definition GridFractionalSinglePhasePressureSolver2.hpp:156
std::shared_ptr< GridBoundaryConditionSolver2 > GridBoundaryConditionSolver2Ptr
Shared pointer type for the GridBoundaryConditionSolver2.
Definition GridBoundaryConditionSolver2.hpp:117
std::shared_ptr< FDMLinearSystemSolver2 > FDMLinearSystemSolver2Ptr
Shared pointer type for the FDMLinearSystemSolver2.
Definition FDMLinearSystemSolver2.hpp:52
Compressed linear system (Ax=b) for 2-D finite differencing.
Definition FDMLinearSystem2.hpp:60
Linear system (Ax=b) for 2-D finite differencing.
Definition FDMLinearSystem2.hpp:41
Multigrid-syle 2-D linear system.
Definition FDMMGLinearSystem2.hpp:27