Jet  v1.3.3
fdm_cg_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_CG_SOLVER3_H_
8 #define INCLUDE_JET_FDM_CG_SOLVER3_H_
9 
11 
12 namespace jet {
13 
16 class FdmCgSolver3 final : public FdmLinearSystemSolver3 {
17  public:
20 
22  bool solve(FdmLinearSystem3* 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  FdmVector3 _r;
47  FdmVector3 _d;
48  FdmVector3 _q;
49  FdmVector3 _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<FdmCgSolver3> FdmCgSolver3Ptr;
63 
64 } // namespace jet
65 
66 #endif // INCLUDE_JET_FDM_CG_SOLVER3_H_
jet::VectorN< double >
jet::FdmCgSolver3Ptr
std::shared_ptr< FdmCgSolver3 > FdmCgSolver3Ptr
Shared pointer type for the FdmCgSolver3.
Definition: fdm_cg_solver3.h:62
jet::FdmCgSolver3::lastResidual
double lastResidual() const
Returns the last residual after the CG iterations.
jet::FdmCgSolver3::solveCompressed
bool solveCompressed(FdmCompressedLinearSystem3 *system) override
Solves the given compressed linear system.
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::FdmCgSolver3::solve
bool solve(FdmLinearSystem3 *system) override
Solves the given linear system.
jet::FdmCompressedLinearSystem3
Compressed linear system (Ax=b) for 3-D finite differencing.
Definition: fdm_linear_system3.h:57
jet::FdmCgSolver3
3-D finite difference-type linear system solver using conjugate gradient.
Definition: fdm_cg_solver3.h:16
jet::FdmCgSolver3::tolerance
double tolerance() const
Returns the max residual tolerance for the CG method.
jet::FdmCgSolver3::FdmCgSolver3
FdmCgSolver3(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::FdmCgSolver3::lastNumberOfIterations
unsigned int lastNumberOfIterations() const
Returns the last number of CG iterations the solver made.
fdm_linear_system_solver3.h
jet::Array< T, 3 >
3-D array class.
Definition: array3.h:43
jet::FdmCgSolver3::maxNumberOfIterations
unsigned int maxNumberOfIterations() const
Returns the max number of CG iterations.