Jet  v1.3.3
grid_single_phase_pressure_solver2.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_GRID_SINGLE_PHASE_PRESSURE_SOLVER2_H_
8 #define INCLUDE_JET_GRID_SINGLE_PHASE_PRESSURE_SOLVER2_H_
9 
12 #include <jet/fdm_mg_solver2.h>
15 
16 #include <memory>
17 
18 namespace jet {
19 
35  public:
38 
41 
63  void solve(const FaceCenteredGrid2& input, double timeIntervalInSeconds,
64  FaceCenteredGrid2* output,
65  const ScalarField2& boundarySdf = ConstantScalarField2(kMaxD),
66  const VectorField2& boundaryVelocity = ConstantVectorField2({0,
67  0}),
68  const ScalarField2& fluidSdf = ConstantScalarField2(-kMaxD),
69  bool useCompressed = false) override;
70 
82  const override;
83 
86 
89 
91  const FdmVector2& pressure() const;
92 
93  private:
94  FdmLinearSystem2 _system;
95  FdmCompressedLinearSystem2 _compSystem;
96  FdmLinearSystemSolver2Ptr _systemSolver;
97 
98  FdmMgLinearSystem2 _mgSystem;
99  FdmMgSolver2Ptr _mgSystemSolver;
100 
101  std::vector<Array2<char>> _markers;
102 
103  void buildMarkers(const Size2& size,
104  const std::function<Vector2D(size_t, size_t)>& pos,
105  const ScalarField2& boundarySdf,
106  const ScalarField2& fluidSdf);
107 
108  void decompressSolution();
109 
110  virtual void buildSystem(const FaceCenteredGrid2& input,
111  bool useCompressed);
112 
113  virtual void applyPressureGradient(const FaceCenteredGrid2& input,
114  FaceCenteredGrid2* output);
115 };
116 
118 typedef std::shared_ptr<GridSinglePhasePressureSolver2>
120 
121 } // namespace jet
122 
123 #endif // INCLUDE_JET_GRID_SINGLE_PHASE_PRESSURE_SOLVER2_H_
grid_pressure_solver2.h
jet::FdmMgLinearSystem2
Multigrid-syle 2-D linear system.
Definition: fdm_mg_linear_system2.h:23
jet::FdmCompressedLinearSystem2
Compressed linear system (Ax=b) for 2-D finite differencing.
Definition: fdm_linear_system2.h:54
jet::FdmLinearSystem2
Linear system (Ax=b) for 2-D finite differencing.
Definition: fdm_linear_system2.h:36
jet::GridSinglePhasePressureSolver2::linearSystemSolver
const FdmLinearSystemSolver2Ptr & linearSystemSolver() const
Returns the linear system solver.
jet::FdmLinearSystemSolver2Ptr
std::shared_ptr< FdmLinearSystemSolver2 > FdmLinearSystemSolver2Ptr
Shared pointer type for the FdmLinearSystemSolver2.
Definition: fdm_linear_system_solver2.h:31
jet::Vector2D
Vector2< double > Vector2D
Double-type 2D vector.
Definition: vector2.h:340
fdm_mg_linear_system2.h
fdm_mg_solver2.h
jet::GridSinglePhasePressureSolver2
2-D single-phase pressure solver.
Definition: grid_single_phase_pressure_solver2.h:34
jet::ScalarField2
Abstract base class for 2-D scalar field.
Definition: scalar_field2.h:18
grid_boundary_condition_solver2.h
jet::FaceCenteredGrid2
2-D face-centered (a.k.a MAC or staggered) grid.
Definition: face_centered_grid2.h:26
jet::Array< T, 2 >
2-D array class.
Definition: array2.h:42
jet
Definition: advection_solver2.h:18
jet::GridSinglePhasePressureSolver2::~GridSinglePhasePressureSolver2
virtual ~GridSinglePhasePressureSolver2()
Default destructor.
jet::ConstantScalarField2
2-D constant scalar field.
Definition: constant_scalar_field2.h:15
jet::GridPressureSolver2
Abstract base class for 2-D grid-based pressure solver.
Definition: grid_pressure_solver2.h:29
jet::GridSinglePhasePressureSolver2::GridSinglePhasePressureSolver2
GridSinglePhasePressureSolver2()
Default constructor.
jet::kMaxD
constexpr double kMaxD
Max double.
Definition: constants.h:88
jet::GridSinglePhasePressureSolver2::pressure
const FdmVector2 & pressure() const
Returns the pressure field.
jet::Size2
2-D size class.
Definition: size2.h:19
jet::GridSinglePhasePressureSolver2Ptr
std::shared_ptr< GridSinglePhasePressureSolver2 > GridSinglePhasePressureSolver2Ptr
Shared pointer type for the GridSinglePhasePressureSolver2.
Definition: grid_single_phase_pressure_solver2.h:119
jet::GridSinglePhasePressureSolver2::solve
void solve(const FaceCenteredGrid2 &input, double timeIntervalInSeconds, FaceCenteredGrid2 *output, const ScalarField2 &boundarySdf=ConstantScalarField2(kMaxD), const VectorField2 &boundaryVelocity=ConstantVectorField2({0, 0}), const ScalarField2 &fluidSdf=ConstantScalarField2(-kMaxD), bool useCompressed=false) override
Solves the pressure term and apply it to the velocity field.
jet::GridBoundaryConditionSolver2Ptr
std::shared_ptr< GridBoundaryConditionSolver2 > GridBoundaryConditionSolver2Ptr
Shared pointer type for the GridBoundaryConditionSolver2.
Definition: grid_boundary_condition_solver2.h:104
jet::VectorField2
Abstract base class for 2-D vector field.
Definition: vector_field2.h:18
fdm_linear_system_solver2.h
jet::FdmMgSolver2Ptr
std::shared_ptr< FdmMgSolver2 > FdmMgSolver2Ptr
Shared pointer type for the FdmMgSolver2.
Definition: fdm_mg_solver2.h:54
jet::GridSinglePhasePressureSolver2::setLinearSystemSolver
void setLinearSystemSolver(const FdmLinearSystemSolver2Ptr &solver)
Sets the linear system solver.
jet::GridSinglePhasePressureSolver2::suggestedBoundaryConditionSolver
GridBoundaryConditionSolver2Ptr suggestedBoundaryConditionSolver() const override
Returns the best boundary condition solver for this solver.
jet::ConstantVectorField2
2-D constant vector field.
Definition: constant_vector_field2.h:16