Jet  v1.3.3
fdm_gauss_seidel_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_GAUSS_SEIDEL_SOLVER3_H_
8 #define INCLUDE_JET_FDM_GAUSS_SEIDEL_SOLVER3_H_
9 
11 
12 namespace jet {
13 
17  public:
20  unsigned int residualCheckInterval, double tolerance,
21  double sorFactor = 1.0,
22  bool useRedBlackOrdering = false);
23 
25  bool solve(FdmLinearSystem3* system) override;
26 
29 
31  unsigned int maxNumberOfIterations() const;
32 
34  unsigned int lastNumberOfIterations() const;
35 
37  double tolerance() const;
38 
40  double lastResidual() const;
41 
43  double sorFactor() const;
44 
46  bool useRedBlackOrdering() const;
47 
49  static void relax(const FdmMatrix3& A, const FdmVector3& b,
50  double sorFactor, FdmVector3* x);
51 
54  static void relax(const MatrixCsrD& A, const VectorND& b, double sorFactor,
55  VectorND* x);
56 
58  static void relaxRedBlack(const FdmMatrix3& A, const FdmVector3& b,
59  double sorFactor, FdmVector3* x);
60 
61  private:
62  unsigned int _maxNumberOfIterations;
63  unsigned int _lastNumberOfIterations;
64  unsigned int _residualCheckInterval;
65  double _tolerance;
66  double _lastResidual;
67  double _sorFactor;
68  bool _useRedBlackOrdering;
69 
70  // Uncompressed vectors
71  FdmVector3 _residual;
72 
73  // Compressed vectors
74  VectorND _residualComp;
75 
76  void clearUncompressedVectors();
77  void clearCompressedVectors();
78 };
79 
81 typedef std::shared_ptr<FdmGaussSeidelSolver3> FdmGaussSeidelSolver3Ptr;
82 
83 } // namespace jet
84 
85 #endif // INCLUDE_JET_FDM_GAUSS_SEIDEL_SOLVER3_H_
jet::VectorN< double >
jet::FdmGaussSeidelSolver3::sorFactor
double sorFactor() const
Returns the SOR (Successive Over Relaxation) factor.
jet::FdmGaussSeidelSolver3Ptr
std::shared_ptr< FdmGaussSeidelSolver3 > FdmGaussSeidelSolver3Ptr
Shared pointer type for the FdmGaussSeidelSolver3.
Definition: fdm_gauss_seidel_solver3.h:81
jet::FdmGaussSeidelSolver3::lastResidual
double lastResidual() const
Returns the last residual after the Gauss-Seidel iterations.
jet::FdmGaussSeidelSolver3::FdmGaussSeidelSolver3
FdmGaussSeidelSolver3(unsigned int maxNumberOfIterations, unsigned int residualCheckInterval, double tolerance, double sorFactor=1.0, bool useRedBlackOrdering=false)
Constructs the solver with given parameters.
jet::FdmGaussSeidelSolver3::solve
bool solve(FdmLinearSystem3 *system) override
Solves the given linear system.
jet::FdmGaussSeidelSolver3::tolerance
double tolerance() const
Returns the max residual tolerance for the Gauss-Seidel method.
jet::FdmGaussSeidelSolver3::relaxRedBlack
static void relaxRedBlack(const FdmMatrix3 &A, const FdmVector3 &b, double sorFactor, FdmVector3 *x)
Performs single Red-Black Gauss-Seidel relaxation step.
jet::MatrixCsr< double >
jet
Definition: advection_solver2.h:18
jet::FdmGaussSeidelSolver3::useRedBlackOrdering
bool useRedBlackOrdering() const
Returns true if red-black ordering is enabled.
jet::FdmGaussSeidelSolver3::solveCompressed
bool solveCompressed(FdmCompressedLinearSystem3 *system) override
Solves the given compressed linear system.
jet::FdmLinearSystemSolver3
Abstract base class for 3-D finite difference-type linear system solver.
Definition: fdm_linear_system_solver3.h:17
jet::FdmGaussSeidelSolver3::maxNumberOfIterations
unsigned int maxNumberOfIterations() const
Returns the max number of Gauss-Seidel iterations.
jet::FdmCompressedLinearSystem3
Compressed linear system (Ax=b) for 3-D finite differencing.
Definition: fdm_linear_system3.h:57
jet::FdmGaussSeidelSolver3::relax
static void relax(const FdmMatrix3 &A, const FdmVector3 &b, double sorFactor, FdmVector3 *x)
Performs single natural Gauss-Seidel relaxation step.
jet::FdmLinearSystem3
Linear system (Ax=b) for 3-D finite differencing.
Definition: fdm_linear_system3.h:39
jet::FdmGaussSeidelSolver3::lastNumberOfIterations
unsigned int lastNumberOfIterations() const
Returns the last number of Gauss-Seidel iterations the solver made.
jet::FdmGaussSeidelSolver3
3-D finite difference-type linear system solver using Gauss-Seidel method.
Definition: fdm_gauss_seidel_solver3.h:16
fdm_linear_system_solver3.h
jet::FdmGaussSeidelSolver3::relax
static void relax(const MatrixCsrD &A, const VectorND &b, double sorFactor, VectorND *x)
Performs single natural Gauss-Seidel relaxation step for compressed sys.
jet::Array< T, 3 >
3-D array class.
Definition: array3.h:43