Loading...
Searching...
No Matches
FDMJacobiSolver2.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_FDM_JACOBI_SOLVER2_HPP
12#define CUBBYFLOW_FDM_JACOBI_SOLVER2_HPP
13
15
16namespace CubbyFlow
17{
20{
21 public:
24 unsigned int residualCheckInterval, double tolerance);
25
27 bool Solve(FDMLinearSystem2* system) override;
28
31
33 [[nodiscard]] unsigned int GetMaxNumberOfIterations() const;
34
36 [[nodiscard]] unsigned int GetLastNumberOfIterations() const;
37
39 [[nodiscard]] double GetTolerance() const;
40
42 [[nodiscard]] double GetLastResidual() const;
43
45 static void Relax(const FDMMatrix2& A, const FDMVector2& b, FDMVector2* x,
47
49 static void Relax(const MatrixCSRD& A, const VectorND& b, VectorND* x,
51
52 private:
53 void ClearUncompressedVectors();
54 void ClearCompressedVectors();
55
56 // Uncompressed vectors
57 FDMVector2 m_xTemp;
58 FDMVector2 m_residual;
59
60 // Compressed vectors
61 VectorND m_xTempComp;
62 VectorND m_residualComp;
63
64 unsigned int m_maxNumberOfIterations;
65 unsigned int m_lastNumberOfIterations;
66 unsigned int m_residualCheckInterval;
67 double m_tolerance;
68 double m_lastResidual;
69};
70
72using FDMJacobiSolver2Ptr = std::shared_ptr<FDMJacobiSolver2>;
73} // namespace CubbyFlow
74
75#endif
2-D finite difference-type linear system solver using Jacobi method.
Definition FDMJacobiSolver2.hpp:20
unsigned int GetLastNumberOfIterations() const
Returns the last number of Jacobi iterations the solver made.
bool SolveCompressed(FDMCompressedLinearSystem2 *system) override
Solves the given compressed linear system.
static void Relax(const FDMMatrix2 &A, const FDMVector2 &b, FDMVector2 *x, FDMVector2 *xTemp)
Performs single Jacobi relaxation step.
double GetLastResidual() const
Returns the last residual after the Jacobi iterations.
FDMJacobiSolver2(unsigned int maxNumberOfIterations, unsigned int residualCheckInterval, double tolerance)
Constructs the solver with given parameters.
double GetTolerance() const
Returns the max residual tolerance for the Jacobi method.
static void Relax(const MatrixCSRD &A, const VectorND &b, VectorND *x, VectorND *xTemp)
Performs single Jacobi relaxation step for compressed sys.
bool Solve(FDMLinearSystem2 *system) override
Solves the given linear system.
unsigned int GetMaxNumberOfIterations() const
Returns the max number of Jacobi iterations.
Abstract base class for 2-D finite difference-type linear system solver.
Definition FDMLinearSystemSolver2.hpp:20
Definition Matrix.hpp:30
Definition pybind11Utils.hpp:21
std::shared_ptr< FDMJacobiSolver2 > FDMJacobiSolver2Ptr
Shared pointer type for the FDMJacobiSolver2.
Definition FDMJacobiSolver2.hpp:72
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
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