Jet  v1.3.3
fdm_cg_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_CG_SOLVER2_H_
8 #define INCLUDE_JET_FDM_CG_SOLVER2_H_
9 
11 
12 namespace jet {
13 
16 class FdmCgSolver2 final : public FdmLinearSystemSolver2 {
17  public:
20 
22  bool solve(FdmLinearSystem2* system) override;
23 
26 
28  unsigned int maxNumberOfIterations() const;
29 
31  unsigned int lastNumberOfIterations() const;
32 
34  double tolerance() const;
35 
37  double lastResidual() const;
38 
39  private:
40  unsigned int _maxNumberOfIterations;
41  unsigned int _lastNumberOfIterations;
42  double _tolerance;
43  double _lastResidual;
44 
45  // Uncompressed vectors
46  FdmVector2 _r;
47  FdmVector2 _d;
48  FdmVector2 _q;
49  FdmVector2 _s;
50 
51  // Compressed vectors
52  VectorND _rComp;
53  VectorND _dComp;
54  VectorND _qComp;
55  VectorND _sComp;
56 
57  void clearUncompressedVectors();
58  void clearCompressedVectors();
59 };
60 
62 typedef std::shared_ptr<FdmCgSolver2> FdmCgSolver2Ptr;
63 
64 } // namespace jet
65 
66 #endif // INCLUDE_JET_FDM_CG_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::FdmCgSolver2::FdmCgSolver2
FdmCgSolver2(unsigned int maxNumberOfIterations, double tolerance)
Constructs the solver with given parameters.
jet::FdmCgSolver2::lastNumberOfIterations
unsigned int lastNumberOfIterations() const
Returns the last number of CG iterations the solver made.
jet::FdmCgSolver2::maxNumberOfIterations
unsigned int maxNumberOfIterations() const
Returns the max number of CG iterations.
jet::Array< T, 2 >
2-D array class.
Definition: array2.h:42
jet
Definition: advection_solver2.h:18
jet::FdmCgSolver2Ptr
std::shared_ptr< FdmCgSolver2 > FdmCgSolver2Ptr
Shared pointer type for the FdmCgSolver2.
Definition: fdm_cg_solver2.h:62
jet::FdmCgSolver2::solveCompressed
bool solveCompressed(FdmCompressedLinearSystem2 *system) override
Solves the given compressed linear system.
jet::FdmCgSolver2::solve
bool solve(FdmLinearSystem2 *system) override
Solves the given linear system.
jet::FdmCgSolver2::lastResidual
double lastResidual() const
Returns the last residual after the CG iterations.
jet::FdmCgSolver2
2-D finite difference-type linear system solver using conjugate gradient.
Definition: fdm_cg_solver2.h:16
jet::FdmLinearSystemSolver2
Abstract base class for 2-D finite difference-type linear system solver.
Definition: fdm_linear_system_solver2.h:17
fdm_linear_system_solver2.h
jet::FdmCgSolver2::tolerance
double tolerance() const
Returns the max residual tolerance for the CG method.