Jet  v1.3.3
fdm_jacobi_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_JACOBI_SOLVER2_H_
8 #define INCLUDE_JET_FDM_JACOBI_SOLVER2_H_
9 
11 
12 namespace jet {
13 
16  public:
19  unsigned int residualCheckInterval, double tolerance);
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 
40  static void relax(const FdmMatrix2& A, const FdmVector2& b, FdmVector2* x,
41  FdmVector2* xTemp);
42 
44  static void relax(const MatrixCsrD& A, const VectorND& b, VectorND* x,
45  VectorND* xTemp);
46 
47  private:
48  unsigned int _maxNumberOfIterations;
49  unsigned int _lastNumberOfIterations;
50  unsigned int _residualCheckInterval;
51  double _tolerance;
52  double _lastResidual;
53 
54  // Uncompressed vectors
55  FdmVector2 _xTemp;
56  FdmVector2 _residual;
57 
58  // Compressed vectors
59  VectorND _xTempComp;
60  VectorND _residualComp;
61 
62  void clearUncompressedVectors();
63  void clearCompressedVectors();
64 };
65 
67 typedef std::shared_ptr<FdmJacobiSolver2> FdmJacobiSolver2Ptr;
68 
69 } // namespace jet
70 
71 #endif // INCLUDE_JET_FDM_JACOBI_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::FdmJacobiSolver2::relax
static void relax(const MatrixCsrD &A, const VectorND &b, VectorND *x, VectorND *xTemp)
Performs single Jacobi relaxation step for compressed sys.
jet::FdmJacobiSolver2::maxNumberOfIterations
unsigned int maxNumberOfIterations() const
Returns the max number of Jacobi iterations.
jet::FdmJacobiSolver2::lastNumberOfIterations
unsigned int lastNumberOfIterations() const
Returns the last number of Jacobi iterations the solver made.
jet::FdmJacobiSolver2::relax
static void relax(const FdmMatrix2 &A, const FdmVector2 &b, FdmVector2 *x, FdmVector2 *xTemp)
Performs single Jacobi relaxation step.
jet::FdmJacobiSolver2::tolerance
double tolerance() const
Returns the max residual tolerance for the Jacobi method.
jet::MatrixCsr< double >
jet::Array< T, 2 >
2-D array class.
Definition: array2.h:42
jet
Definition: advection_solver2.h:18
jet::FdmJacobiSolver2::FdmJacobiSolver2
FdmJacobiSolver2(unsigned int maxNumberOfIterations, unsigned int residualCheckInterval, double tolerance)
Constructs the solver with given parameters.
jet::FdmJacobiSolver2
2-D finite difference-type linear system solver using Jacobi method.
Definition: fdm_jacobi_solver2.h:15
jet::FdmJacobiSolver2::lastResidual
double lastResidual() const
Returns the last residual after the Jacobi iterations.
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::FdmJacobiSolver2::solveCompressed
bool solveCompressed(FdmCompressedLinearSystem2 *system) override
Solves the given compressed linear system.
jet::FdmJacobiSolver2Ptr
std::shared_ptr< FdmJacobiSolver2 > FdmJacobiSolver2Ptr
Shared pointer type for the FdmJacobiSolver2.
Definition: fdm_jacobi_solver2.h:67
jet::FdmJacobiSolver2::solve
bool solve(FdmLinearSystem2 *system) override
Solves the given linear system.