G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsBiCgStab.h
Go to the documentation of this file.
1
14#pragma once
15
17
18namespace gismo
19{
20
24template<class T = real_t>
26{
27public:
29
30 typedef gsMatrix<T> VectorType;
31
32 typedef typename Base::LinOpPtr LinOpPtr;
33
34 typedef memory::shared_ptr<gsBiCgStab> Ptr;
35 typedef memory::unique_ptr<gsBiCgStab> uPtr;
36
41 template< typename OperatorType >
42 explicit gsBiCgStab( const OperatorType& mat, const LinOpPtr& precond = LinOpPtr() )
43 : Base(mat, precond), m_restartThereshold(1e-32) {}
44
49 template< typename OperatorType >
50 static uPtr make( const OperatorType& mat, const LinOpPtr& precond = LinOpPtr() )
51 { return uPtr( new gsBiCgStab(mat, precond) ); }
52
55 {
57 opt.addReal("RestartThereshold", "Thereshold for restarting gsBiCgStab solver.", 1e-32 );
58 return opt;
59 }
60
63 {
65 m_restartThereshold = opt.askReal("RestartThereshold", m_restartThereshold);
66 return *this;
67 }
68
69 bool initIteration( const VectorType& rhs, VectorType& x );
70 bool step( VectorType& x );
71
73 std::ostream &print(std::ostream &os) const
74 {
75 os << "gsBiCgStab\n";
76 return os;
77 }
78
79private:
80 using Base::m_mat;
81 using Base::m_precond;
83 using Base::m_tol;
84 using Base::m_num_iter;
85 using Base::m_rhs_norm;
86 using Base::m_error;
87
88 VectorType m_res;
89 VectorType m_r0;
90 VectorType m_tmp;
91 VectorType m_v;
92 VectorType m_p;
93 VectorType m_y;
94 VectorType m_s;
95 VectorType m_z;
96 VectorType m_t;
97
98 T m_alpha;
99 T m_rho;
100 T m_w;
101
102 T m_restartThereshold;
103};
104
105} // namespace gismo
106
107#ifndef GISMO_BUILD_LIB
108#include GISMO_HPP_HEADER(gsBiCgStab.hpp)
109#endif
Biconjugate gradient stabilized solver.
Definition gsBiCgStab.h:26
bool step(VectorType &x)
Perform one step, requires initIteration.
Definition gsBiCgStab.hpp:44
gsBiCgStab & setOptions(const gsOptionList &opt)
Set the options based on a gsOptionList.
Definition gsBiCgStab.h:62
bool initIteration(const VectorType &rhs, VectorType &x)
Init the iteration.
Definition gsBiCgStab.hpp:18
static uPtr make(const OperatorType &mat, const LinOpPtr &precond=LinOpPtr())
Make function using a matrix (operator) and optionally a preconditionner.
Definition gsBiCgStab.h:50
gsBiCgStab(const OperatorType &mat, const LinOpPtr &precond=LinOpPtr())
Constructor using a matrix (operator) and optionally a preconditionner.
Definition gsBiCgStab.h:42
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsBiCgStab.h:73
static gsOptionList defaultOptions()
Returns a list of default options.
Definition gsBiCgStab.h:54
Abstract class for iterative solvers.
Definition gsIterativeSolver.h:27
virtual gsIterativeSolver & setOptions(const gsOptionList &opt)
Set the options based on a gsOptionList.
Definition gsIterativeSolver.h:102
T m_rhs_norm
The norm of the right-hand-side.
Definition gsIterativeSolver.h:257
T m_error
The relative error as absolute_error/m_rhs_norm.
Definition gsIterativeSolver.h:258
LinOpPtr m_precond
The preconditioner.
Definition gsIterativeSolver.h:253
static gsOptionList defaultOptions()
Returns a list of default options.
Definition gsIterativeSolver.h:92
gsOptionList::Real m_tol
The tolerance for m_error to be reached.
Definition gsIterativeSolver.h:255
index_t m_num_iter
The number of iterations performed.
Definition gsIterativeSolver.h:256
index_t m_max_iters
The upper bound for the number of iterations.
Definition gsIterativeSolver.h:254
const LinOpPtr m_mat
The matrix/operator to be solved for.
Definition gsIterativeSolver.h:252
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Class which holds a list of parameters/options, and provides easy access to them.
Definition gsOptionList.h:33
Real askReal(const std::string &label, const Real &value=0) const
Reads value for option label from options.
Definition gsOptionList.cpp:139
void addReal(const std::string &label, const std::string &desc, const Real &value)
Adds a option named label, with description desc and value value.
Definition gsOptionList.cpp:211
Abstract class for iterative solvers.
The G+Smo namespace, containing all definitions for the library.