AlgebraicMultigrid 0.1
C++ algebraic multigrid.
Loading...
Searching...
No Matches
AMG::SparseGaussSeidel< EleType > Class Template Reference

Symmetric Gauss-Seidel smoother for sparse systems. More...

#include <smoother.hpp>

Inheritance diagram for AMG::SparseGaussSeidel< EleType >:
AMG::SmootherBase< EleType >

Public Member Functions

 SparseGaussSeidel ()
 Construct a new Sparse Gauss Seidel object for pre/post smoother in AMG.
 
void smooth (const Eigen::SparseMatrix< EleType > &A, Eigen::Matrix< EleType, -1, 1 > &u, const Eigen::Matrix< EleType, -1, 1 > &b)
 Must implement function that smooths Au = b.
 
- Public Member Functions inherited from AMG::SmootherBase< EleType >
 SmootherBase ()
 
 SmootherBase (size_t n_iters_)
 
 SmootherBase (double tolerance_, size_t compute_error_every_n_iters_, size_t n_iters_)
 Construct a new Smoother Base object with iterative solver member data.
 

Private Member Functions

void matvecprod (int col, EleType &rsum, EleType &diag, const EleType &z, const Eigen::SparseMatrix< EleType > &A, const Eigen::Matrix< EleType, -1, 1 > &u)
 Modified sparse matvec product of Au for Gauss-Seidel sweeps.
 
void update (int col, const Eigen::SparseMatrix< EleType > &A, const Eigen::Matrix< EleType, -1, 1 > &b, Eigen::Matrix< EleType, -1, 1 > &u)
 Updates a single entry in u inplace using the definition of a Gauss-Seidel.
 
void forwardsweep (const Eigen::SparseMatrix< EleType > &A, const Eigen::Matrix< EleType, -1, 1 > &b, Eigen::Matrix< EleType, -1, 1 > &u, const int &ncols)
 Gauss-Seidel iteration starting from the first row.
 
void backwardsweep (const Eigen::SparseMatrix< EleType > &A, const Eigen::Matrix< EleType, -1, 1 > &b, Eigen::Matrix< EleType, -1, 1 > &u, const int &ncols)
 Gauss-Seidel iteration starting from the last row.
 

Additional Inherited Members

- Public Attributes inherited from AMG::SmootherBase< EleType >
EleType tolerance {1e-9}
 Tolerance below which a smoother is considered to have converged.
 
size_t compute_error_every_n_iters {100}
 Compute the error every n iterations during smoothing.
 
size_t n_iters {1}
 Maximum number of iterations before smoothing termination.
 

Detailed Description

template<class EleType>
class AMG::SparseGaussSeidel< EleType >

Symmetric Gauss-Seidel smoother for sparse systems.

The forward and backward sweep are not strictly both necessary, it seems like most numerical linear algebra books (E.g., Heath's "Scientific Computing") only propose one sweep as the algorithm. For completeness, however, Ref [2] does assert the justification of the so-called symmetric sweep.

References

[1] : smoother.jl in AlgebraicMultigrid.jl

[2] : Strang2006 MIT 18.086 Lecture: Iterative Methods

[3] : Julia Lang: Dot product as linear combination

Template Parameters
EleType

Constructor & Destructor Documentation

◆ SparseGaussSeidel()

template<class EleType >
AMG::SparseGaussSeidel< EleType >::SparseGaussSeidel ( )
inline

Construct a new Sparse Gauss Seidel object for pre/post smoother in AMG.

Member Function Documentation

◆ backwardsweep()

template<class EleType >
void AMG::SparseGaussSeidel< EleType >::backwardsweep ( const Eigen::SparseMatrix< EleType > & A,
const Eigen::Matrix< EleType, -1, 1 > & b,
Eigen::Matrix< EleType, -1, 1 > & u,
const int & ncols )
inlineprivate

Gauss-Seidel iteration starting from the last row.

Parameters
ACoefficients matrix for discretized governing equations.
bRight hand side of linear system Au = b.
uSolution to linear system of equations.
nrows

◆ forwardsweep()

template<class EleType >
void AMG::SparseGaussSeidel< EleType >::forwardsweep ( const Eigen::SparseMatrix< EleType > & A,
const Eigen::Matrix< EleType, -1, 1 > & b,
Eigen::Matrix< EleType, -1, 1 > & u,
const int & ncols )
inlineprivate

Gauss-Seidel iteration starting from the first row.

Parameters
ACoefficients matrix for discretized governing equations.
bRight hand side of linear system Au = b.
uSolution to linear system of equations.
nrows

◆ matvecprod()

template<class EleType >
void AMG::SparseGaussSeidel< EleType >::matvecprod ( int col,
EleType & rsum,
EleType & diag,
const EleType & z,
const Eigen::SparseMatrix< EleType > & A,
const Eigen::Matrix< EleType, -1, 1 > & u )
inlineprivate

Modified sparse matvec product of Au for Gauss-Seidel sweeps.

The results of this operation update rsum and diag inplace.

Parameters
colIndex of the column for which you desire sparse row indices and values.
rsumSum representing the matvec product.
diagValue of diagonal for particular column of CSC matrix.
zZero value
ACoefficients matrix for discretized governing equations.
uSolution to linear system of equations.

◆ smooth()

template<class EleType >
void AMG::SparseGaussSeidel< EleType >::smooth ( const Eigen::SparseMatrix< EleType > & A,
Eigen::Matrix< EleType, -1, 1 > & u,
const Eigen::Matrix< EleType, -1, 1 > & b )
inlinevirtual

Must implement function that smooths Au = b.

Parameters
ACoefficients matrix for discretized governing equations. Coeffcients matrix for linear system of equations.
uSolution to linear system of equations.
bRight hand side of linear system Au = b. Right hand side of linear system of equations.

Implements AMG::SmootherBase< EleType >.

◆ update()

template<class EleType >
void AMG::SparseGaussSeidel< EleType >::update ( int col,
const Eigen::SparseMatrix< EleType > & A,
const Eigen::Matrix< EleType, -1, 1 > & b,
Eigen::Matrix< EleType, -1, 1 > & u )
inlineprivate

Updates a single entry in u inplace using the definition of a Gauss-Seidel.

$ u_{i} = \frac{b_i - \sum_{j \neq i} a_{ij} u_j }{a_{ii}}. $

Parameters
col
ACoefficients matrix for discretized governing equations.
bRight hand side of linear system Au = b.
uSolution to linear system of equations.

The documentation for this class was generated from the following file: