Loading...
Searching...
No Matches
GridSinglePhasePressureSolver2.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_SINGLE_PHASE_PRESSURE_SOLVER2_HPP
12#define CUBBYFLOW_SINGLE_PHASE_PRESSURE_SOLVER2_HPP
13
18
19namespace CubbyFlow
20{
36{
37 public:
40
43 delete;
44
47 delete;
48
51
55
59
83 void Solve(
84 const FaceCenteredGrid2& input, double timeIntervalInSeconds,
87 ConstantScalarField2{ std::numeric_limits<double>::max() },
89 const ScalarField2& fluidSDF =
90 ConstantScalarField2{ -std::numeric_limits<double>::max() },
91 bool useCompressed = false) override;
92
105
108 const;
109
112
114 [[nodiscard]] const FDMVector2& GetPressure() const;
115
116 private:
117 void BuildMarkers(const Vector2UZ& size,
118 const std::function<Vector2D(size_t, size_t)>& pos,
120 const ScalarField2& fluidSDF);
121
122 void DecompressSolution();
123
124 virtual void BuildSystem(const FaceCenteredGrid2& input,
125 bool useCompressed);
126
127 virtual void ApplyPressureGradient(const FaceCenteredGrid2& input,
129
130 FDMLinearSystem2 m_system;
131 FDMCompressedLinearSystem2 m_compSystem;
132 FDMLinearSystemSolver2Ptr m_systemSolver;
133
134 FDMMGLinearSystem2 m_mgSystem;
135 FDMMGSolver2Ptr m_mgSystemSolver;
136
137 std::vector<Array2<char>> m_markers;
138};
139
142 std::shared_ptr<GridSinglePhasePressureSolver2>;
143} // namespace CubbyFlow
144
145#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
Abstract base class for 2-D grid-based pressure solver.
Definition GridPressureSolver2.hpp:30
2-D single-phase pressure solver.
Definition GridSinglePhasePressureSolver2.hpp:36
const FDMVector2 & GetPressure() const
Returns the pressure field.
void SetLinearSystemSolver(const FDMLinearSystemSolver2Ptr &solver)
Sets the linear system solver.
GridSinglePhasePressureSolver2(const GridSinglePhasePressureSolver2 &)=delete
Deleted copy constructor.
GridBoundaryConditionSolver2Ptr SuggestedBoundaryConditionSolver() const override
Returns the best boundary condition solver for this solver.
GridSinglePhasePressureSolver2(GridSinglePhasePressureSolver2 &&) noexcept=delete
Deleted move constructor.
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.
GridSinglePhasePressureSolver2()
Default constructor.
const FDMLinearSystemSolver2Ptr & GetLinearSystemSolver() const
Returns the linear system solver.
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< GridSinglePhasePressureSolver2 > GridSinglePhasePressureSolver2Ptr
Shared pointer type for the GridSinglePhasePressureSolver2.
Definition GridSinglePhasePressureSolver2.hpp:142
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