FDMJacobiSolver3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: FDMJacobiSolver3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D finite difference-type linear system solver using Jacobi method.
6 > Created Time: 2017/08/17
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_FDM_JACOBI_SOLVER3_H
10 #define CUBBYFLOW_FDM_JACOBI_SOLVER3_H
11 
13 
14 namespace CubbyFlow
15 {
18  {
19  public:
22  unsigned int maxNumberOfIterations,
23  unsigned int residualCheckInterval,
24  double tolerance);
25 
27  bool Solve(FDMLinearSystem3* system) override;
28 
30  bool SolveCompressed(FDMCompressedLinearSystem3* system) override;
31 
33  unsigned int GetMaxNumberOfIterations() const;
34 
36  unsigned int GetLastNumberOfIterations() const;
37 
39  double GetTolerance() const;
40 
42  double GetLastResidual() const;
43 
45  static void Relax(const FDMMatrix3& A, const FDMVector3& b, FDMVector3* x, FDMVector3* xTemp);
46 
48  static void Relax(const MatrixCSRD& A, const VectorND& b, VectorND* x, VectorND* xTemp);
49 
50  private:
51  unsigned int m_maxNumberOfIterations;
52  unsigned int m_lastNumberOfIterations;
53  unsigned int m_residualCheckInterval;
54  double m_tolerance;
55  double m_lastResidual;
56 
57  // Uncompressed vectors
58  FDMVector3 m_xTemp;
59  FDMVector3 m_residual;
60 
61  // Compressed vectors
62  VectorND m_xTempComp;
63  VectorND m_residualComp;
64 
65  void ClearUncompressedVectors();
66  void ClearCompressedVectors();
67  };
68 
70  using FDMJacobiSolver3Ptr = std::shared_ptr<FDMJacobiSolver3>;
71 }
72 
73 #endif
Abstract base class for 3-D finite difference-type linear system solver.
Definition: FDMLinearSystemSolver3.h:17
double GetTolerance() const
Returns the max residual tolerance for the Jacobi method.
unsigned int GetLastNumberOfIterations() const
Returns the last number of Jacobi iterations the solver made.
static void Relax(const FDMMatrix3 &A, const FDMVector3 &b, FDMVector3 *x, FDMVector3 *xTemp)
Performs single Jacobi relaxation step.
FDMJacobiSolver3(unsigned int maxNumberOfIterations, unsigned int residualCheckInterval, double tolerance)
Constructs the solver with given parameters.
Definition: pybind11Utils.h:24
bool SolveCompressed(FDMCompressedLinearSystem3 *system) override
Solves the given compressed linear system.
std::shared_ptr< FDMJacobiSolver3 > FDMJacobiSolver3Ptr
Shared pointer type for the FDMJacobiSolver3.
Definition: FDMJacobiSolver3.h:70
double GetLastResidual() const
Returns the last residual after the Jacobi iterations.
3-D array class.
Definition: Array3.h:45
unsigned int GetMaxNumberOfIterations() const
Returns the max number of Jacobi iterations.
bool Solve(FDMLinearSystem3 *system) override
Solves the given linear system.
3-D finite difference-type linear system solver using Jacobi method.
Definition: FDMJacobiSolver3.h:17
Compressed linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.h:61
Linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.h:42