FDMCGSolver3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: FDMCGSolver3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D finite difference-type linear system solver using conjugate gradient.
6 > Created Time: 2017/08/16
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_FDM_CG_SOLVER3_H
10 #define CUBBYFLOW_FDM_CG_SOLVER3_H
11 
13 
14 namespace CubbyFlow
15 {
17  class FDMCGSolver3 final : public FDMLinearSystemSolver3
18  {
19  public:
21  FDMCGSolver3(unsigned int maxNumberOfIterations, double tolerance);
22 
24  bool Solve(FDMLinearSystem3* system) override;
25 
27  bool SolveCompressed(FDMCompressedLinearSystem3* system) override;
28 
30  unsigned int GetMaxNumberOfIterations() const;
31 
33  unsigned int GetLastNumberOfIterations() const;
34 
36  double GetTolerance() const;
37 
39  double GetLastResidual() const;
40 
41  private:
42  unsigned int m_maxNumberOfIterations;
43  unsigned int m_lastNumberOfIterations;
44  double m_tolerance;
45  double m_lastResidual;
46 
47  // Uncompressed vectors
48  FDMVector3 m_r;
49  FDMVector3 m_d;
50  FDMVector3 m_q;
51  FDMVector3 m_s;
52 
53  // Compressed vectors
54  VectorND m_rComp;
55  VectorND m_dComp;
56  VectorND m_qComp;
57  VectorND m_sComp;
58 
59  void ClearUncompressedVectors();
60  void ClearCompressedVectors();
61  };
62 
64  using FDMCGSolver3Ptr = std::shared_ptr<FDMCGSolver3>;
65 }
66 
67 #endif
bool Solve(FDMLinearSystem3 *system) override
Solves the given linear system.
Abstract base class for 3-D finite difference-type linear system solver.
Definition: FDMLinearSystemSolver3.h:17
unsigned int GetLastNumberOfIterations() const
Returns the last number of Jacobi iterations the solver made.
double GetTolerance() const
Returns the max residual tolerance for the Jacobi method.
unsigned int GetMaxNumberOfIterations() const
Returns the max number of Jacobi iterations.
std::shared_ptr< FDMCGSolver3 > FDMCGSolver3Ptr
Shared pointer type for the FDMCGSolver3.
Definition: FDMCGSolver3.h:64
Definition: pybind11Utils.h:24
FDMCGSolver3(unsigned int maxNumberOfIterations, double tolerance)
Constructs the solver with given parameters.
double GetLastResidual() const
Returns the last residual after the Jacobi iterations.
3-D array class.
Definition: Array3.h:45
bool SolveCompressed(FDMCompressedLinearSystem3 *system) override
Solves the given compressed linear system.
Compressed linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.h:61
3-D finite difference-type linear system solver using conjugate gradient.
Definition: FDMCGSolver3.h:17
Linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.h:42