Jet  v1.3.3
fdm_iccg_solver3.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_SOLVER3_H_
8 #define INCLUDE_JET_FDM_ICCG_SOLVER3_H_
9 
10 #include <jet/fdm_cg_solver3.h>
11 
12 namespace jet {
13 
18 class FdmIccgSolver3 final : public FdmLinearSystemSolver3 {
19  public:
22 
24  bool solve(FdmLinearSystem3* 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  FdmVector3 d;
45  FdmVector3 y;
46 
47  void build(const FdmMatrix3& matrix);
48 
49  void solve(const FdmVector3& b, FdmVector3* 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  FdmVector3 _r;
69  FdmVector3 _d;
70  FdmVector3 _q;
71  FdmVector3 _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<FdmIccgSolver3> FdmIccgSolver3Ptr;
87 
88 } // namespace jet
89 
90 #endif // INCLUDE_JET_FDM_ICCG_SOLVER3_H_
jet::ConstArrayAccessor< T, 3 >
3-D read-only array accessor class.
Definition: array_accessor3.h:270
jet::FdmIccgSolver3::tolerance
double tolerance() const
Returns the max residual tolerance for the ICCG method.
jet::VectorN< double >
jet::FdmIccgSolver3::lastResidual
double lastResidual() const
Returns the last residual after the ICCG iterations.
jet::FdmIccgSolver3::maxNumberOfIterations
unsigned int maxNumberOfIterations() const
Returns the max number of ICCG iterations.
jet::FdmIccgSolver3::lastNumberOfIterations
unsigned int lastNumberOfIterations() const
Returns the last number of ICCG iterations the solver made.
fdm_cg_solver3.h
jet::MatrixCsr< double >
jet::FdmIccgSolver3
3-D finite difference-type linear system solver using incomplete Cholesky conjugate gradient (ICCG).
Definition: fdm_iccg_solver3.h:18
jet
Definition: advection_solver2.h:18
jet::FdmLinearSystemSolver3
Abstract base class for 3-D finite difference-type linear system solver.
Definition: fdm_linear_system_solver3.h:17
jet::FdmCompressedLinearSystem3
Compressed linear system (Ax=b) for 3-D finite differencing.
Definition: fdm_linear_system3.h:57
jet::FdmIccgSolver3::FdmIccgSolver3
FdmIccgSolver3(unsigned int maxNumberOfIterations, double tolerance)
Constructs the solver with given parameters.
jet::FdmLinearSystem3
Linear system (Ax=b) for 3-D finite differencing.
Definition: fdm_linear_system3.h:39
jet::FdmIccgSolver3Ptr
std::shared_ptr< FdmIccgSolver3 > FdmIccgSolver3Ptr
Shared pointer type for the FdmIccgSolver3.
Definition: fdm_iccg_solver3.h:86
jet::VectorND
VectorN< double > VectorND
Double-type N-D vector.
Definition: vector_n.h:404
jet::FdmVector3
Array3< double > FdmVector3
Vector type for 3-D finite differencing.
Definition: fdm_linear_system3.h:33
jet::FdmIccgSolver3::solve
bool solve(FdmLinearSystem3 *system) override
Solves the given linear system.
jet::Array< T, 3 >
3-D array class.
Definition: array3.h:43
jet::FdmIccgSolver3::solveCompressed
bool solveCompressed(FdmCompressedLinearSystem3 *system) override
Solves the given compressed linear system.