Jet  v1.3.3
fdm_iccg_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_FDM_ICCG_SOLVER2_H_
8 #define INCLUDE_JET_FDM_ICCG_SOLVER2_H_
9 
10 #include <jet/fdm_cg_solver2.h>
11 
12 namespace jet {
13 
18 class FdmIccgSolver2 final : public FdmLinearSystemSolver2 {
19  public:
22 
24  bool solve(FdmLinearSystem2* system) override;
25 
28 
30  unsigned int maxNumberOfIterations() const;
31 
33  unsigned int lastNumberOfIterations() const;
34 
36  double tolerance() const;
37 
39  double lastResidual() const;
40 
41  private:
42  struct Preconditioner final {
44  FdmVector2 d;
45  FdmVector2 y;
46 
47  void build(const FdmMatrix2& matrix);
48 
49  void solve(const FdmVector2& b, FdmVector2* x);
50  };
51 
52  struct PreconditionerCompressed final {
53  const MatrixCsrD* A;
54  VectorND d;
55  VectorND y;
56 
57  void build(const MatrixCsrD& matrix);
58 
59  void solve(const VectorND& b, VectorND* x);
60  };
61 
62  unsigned int _maxNumberOfIterations;
63  unsigned int _lastNumberOfIterations;
64  double _tolerance;
65  double _lastResidualNorm;
66 
67  // Uncompressed vectors and preconditioner
68  FdmVector2 _r;
69  FdmVector2 _d;
70  FdmVector2 _q;
71  FdmVector2 _s;
72  Preconditioner _precond;
73 
74  // Compressed vectors and preconditioner
75  VectorND _rComp;
76  VectorND _dComp;
77  VectorND _qComp;
78  VectorND _sComp;
79  PreconditionerCompressed _precondComp;
80 
81  void clearUncompressedVectors();
82  void clearCompressedVectors();
83 };
84 
86 typedef std::shared_ptr<FdmIccgSolver2> FdmIccgSolver2Ptr;
87 
88 } // namespace jet
89 
90 #endif // INCLUDE_JET_FDM_ICCG_SOLVER2_H_
jet::VectorN< double >
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::FdmIccgSolver2::tolerance
double tolerance() const
Returns the max residual tolerance for the Jacobi method.
jet::FdmIccgSolver2
2-D finite difference-type linear system solver using incomplete Cholesky conjugate gradient (ICCG).
Definition: fdm_iccg_solver2.h:18
jet::FdmIccgSolver2::maxNumberOfIterations
unsigned int maxNumberOfIterations() const
Returns the max number of Jacobi iterations.
jet::MatrixCsr< double >
jet::Array< T, 2 >
2-D array class.
Definition: array2.h:42
jet
Definition: advection_solver2.h:18
jet::ConstArrayAccessor< T, 2 >
2-D read-only array accessor class.
Definition: array_accessor2.h:261
jet::FdmIccgSolver2::solveCompressed
bool solveCompressed(FdmCompressedLinearSystem2 *system) override
Solves the given compressed linear system.
jet::FdmIccgSolver2::FdmIccgSolver2
FdmIccgSolver2(unsigned int maxNumberOfIterations, double tolerance)
Constructs the solver with given parameters.
jet::FdmIccgSolver2Ptr
std::shared_ptr< FdmIccgSolver2 > FdmIccgSolver2Ptr
Shared pointer type for the FdmIccgSolver2.
Definition: fdm_iccg_solver2.h:86
jet::FdmIccgSolver2::solve
bool solve(FdmLinearSystem2 *system) override
Solves the given linear system.
jet::FdmIccgSolver2::lastNumberOfIterations
unsigned int lastNumberOfIterations() const
Returns the last number of Jacobi iterations the solver made.
jet::FdmLinearSystemSolver2
Abstract base class for 2-D finite difference-type linear system solver.
Definition: fdm_linear_system_solver2.h:17
jet::FdmIccgSolver2::lastResidual
double lastResidual() const
Returns the last residual after the Jacobi iterations.
jet::VectorND
VectorN< double > VectorND
Double-type N-D vector.
Definition: vector_n.h:404
fdm_cg_solver2.h
jet::FdmVector2
Array2< double > FdmVector2
Vector type for 2-D finite differencing.
Definition: fdm_linear_system2.h:30