Advanced Multi-Physics (AMP)
On-Line Documentation
Relaxation.h
Go to the documentation of this file.
1#ifndef included_AMP_AMG_Relaxation
2#define included_AMP_AMG_Relaxation
3
4#include "AMP/operators/LinearOperator.h"
5#include "AMP/operators/Operator.h"
6#include "AMP/solvers/SolverFactory.h"
7#include "AMP/solvers/SolverStrategy.h"
8#include "AMP/solvers/SolverStrategyParameters.h"
9
10#include "AMP/matrices/CSRMatrix.h"
11#include "AMP/matrices/Matrix.h"
12
13#include <cstddef>
14
15namespace AMP::Solver::AMG {
16
18 explicit RelaxationParameters( std::shared_ptr<AMP::Database> db )
20 {
21 }
22
23 std::shared_ptr<AMP::LinearAlgebra::Matrix> d_matrix;
24};
25
27public:
28 enum class Sweep { forward, backward, symmetric };
29 enum class Direction { forward, backward };
30 explicit Relaxation( std::shared_ptr<const SolverStrategyParameters> params,
31 const std::string &name_,
32 const std::string &short_name_ );
33
34 virtual std::string type() const override { return "Relaxation"; }
35
36 void getFromInput( std::shared_ptr<AMP::Database> );
37
38 void apply( std::shared_ptr<const LinearAlgebra::Vector> b,
39 std::shared_ptr<LinearAlgebra::Vector> x ) override;
40
41 void setLevel( size_t lvl ) { d_caller_lvl = lvl; }
42
43protected:
44 virtual void relax_visit( std::shared_ptr<const LinearAlgebra::Vector> b,
45 std::shared_ptr<LinearAlgebra::Vector> x ) = 0;
46
47 const std::string name, short_name;
51 std::shared_ptr<AMP::LinearAlgebra::Matrix> d_matrix;
52
54};
55
57 explicit HybridGS( std::shared_ptr<const SolverStrategyParameters> params );
58
60
61 static std::unique_ptr<SolverStrategy>
62 createSolver( std::shared_ptr<SolverStrategyParameters> params )
63 {
64 return std::make_unique<HybridGS>( params );
65 }
66
67 std::string type() const override { return "Hybrid Gauss-Seidel"; }
68
69 void registerOperator( std::shared_ptr<AMP::Operator::Operator> ) override;
70
71protected:
72 std::byte *d_ghost_vals;
75
77
78 void relax_visit( std::shared_ptr<const LinearAlgebra::Vector> b,
79 std::shared_ptr<LinearAlgebra::Vector> x ) override;
80
81 template<typename Config>
82 void relax( std::shared_ptr<LinearAlgebra::CSRMatrix<Config>> A,
83 std::shared_ptr<const LinearAlgebra::Vector> b,
84 std::shared_ptr<LinearAlgebra::Vector> x );
85
86 template<typename Config>
91};
92
94 explicit JacobiL1( std::shared_ptr<const SolverStrategyParameters> params );
95
96 static std::unique_ptr<SolverStrategy>
97 createSolver( std::shared_ptr<SolverStrategyParameters> params )
98 {
99 return std::make_unique<JacobiL1>( params );
100 }
101
102 std::string type() const override { return "Jacobi L1"; }
103
104 void registerOperator( std::shared_ptr<AMP::Operator::Operator> ) override;
105
106protected:
107 void relax_visit( std::shared_ptr<const LinearAlgebra::Vector> b,
108 std::shared_ptr<LinearAlgebra::Vector> x ) override;
109
111 std::shared_ptr<LinearAlgebra::Vector> d_dinv;
112 std::shared_ptr<LinearAlgebra::Vector> d_r;
113 std::shared_ptr<LinearAlgebra::Vector> d_z;
114 template<typename Config>
115 void relax( std::shared_ptr<LinearAlgebra::CSRMatrix<Config>> A,
116 std::shared_ptr<const LinearAlgebra::Vector> b,
117 std::shared_ptr<LinearAlgebra::Vector> x );
118};
119
120} // namespace AMP::Solver::AMG
121#endif
An concrete class for dealing with dense serial matrices.
Definition CSRMatrix.h:26
Abstraction of a discrete Vector in a linear simulation.
Definition Vector.h:54
std::shared_ptr< ParameterBase > shared_ptr
std::shared_ptr< AMP::Solver::SolverStrategy > shared_ptr
std::string type() const override
Return the name of the solver.
Definition Relaxation.h:67
HybridGS(std::shared_ptr< const SolverStrategyParameters > params)
static std::unique_ptr< SolverStrategy > createSolver(std::shared_ptr< SolverStrategyParameters > params)
Definition Relaxation.h:62
void registerOperator(std::shared_ptr< AMP::Operator::Operator >) override
void sweep(const Relaxation::Direction relax_dir, LinearAlgebra::CSRMatrix< Config > &A, const LinearAlgebra::Vector &bvec, LinearAlgebra::Vector &xvec)
void relax_visit(std::shared_ptr< const LinearAlgebra::Vector > b, std::shared_ptr< LinearAlgebra::Vector > x) override
void relax(std::shared_ptr< LinearAlgebra::CSRMatrix< Config > > A, std::shared_ptr< const LinearAlgebra::Vector > b, std::shared_ptr< LinearAlgebra::Vector > x)
std::shared_ptr< LinearAlgebra::Vector > d_z
Definition Relaxation.h:113
void relax(std::shared_ptr< LinearAlgebra::CSRMatrix< Config > > A, std::shared_ptr< const LinearAlgebra::Vector > b, std::shared_ptr< LinearAlgebra::Vector > x)
static std::unique_ptr< SolverStrategy > createSolver(std::shared_ptr< SolverStrategyParameters > params)
Definition Relaxation.h:97
std::string type() const override
Return the name of the solver.
Definition Relaxation.h:102
void registerOperator(std::shared_ptr< AMP::Operator::Operator >) override
void relax_visit(std::shared_ptr< const LinearAlgebra::Vector > b, std::shared_ptr< LinearAlgebra::Vector > x) override
std::shared_ptr< LinearAlgebra::Vector > d_r
Definition Relaxation.h:112
std::shared_ptr< LinearAlgebra::Vector > d_dinv
Definition Relaxation.h:111
JacobiL1(std::shared_ptr< const SolverStrategyParameters > params)
RelaxationParameters(std::shared_ptr< AMP::Database > db)
Definition Relaxation.h:18
std::shared_ptr< AMP::LinearAlgebra::Matrix > d_matrix
Definition Relaxation.h:23
const std::string name
Definition Relaxation.h:47
const std::string short_name
Definition Relaxation.h:47
void setLevel(size_t lvl)
Definition Relaxation.h:41
virtual std::string type() const override
Return the name of the solver.
Definition Relaxation.h:34
void getFromInput(std::shared_ptr< AMP::Database >)
std::shared_ptr< AMP::LinearAlgebra::Matrix > d_matrix
Definition Relaxation.h:51
void apply(std::shared_ptr< const LinearAlgebra::Vector > b, std::shared_ptr< LinearAlgebra::Vector > x) override
Relaxation(std::shared_ptr< const SolverStrategyParameters > params, const std::string &name_, const std::string &short_name_)
virtual void relax_visit(std::shared_ptr< const LinearAlgebra::Vector > b, std::shared_ptr< LinearAlgebra::Vector > x)=0



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:41.
Comments on this page