33 #ifndef __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__BICGSTAB__
34 #define __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__BICGSTAB__
66 template <
typename TVector>
101 virtual const char*
name()
const {
return "BiCGStab";}
121 UG_THROW(
"BiCGStab: Inadequate storage format of Vectors.");
146 UG_THROW(
"BiCGStab: Cannot convert b to a vector with the 'unique' parallel storage type.");
153 bool bRestart =
true;
164 std::stringstream ss; ss <<
179 UG_THROW(
"BiCGStab: Cannot convert r to unique vector.");
185 v = 0.0;
omega = 1.0;
198 const number rhoOld = rho;
208 if(fabs(rho)/(norm_r * norm_r0) <=
m_minOrtho)
210 std::stringstream ss; ss <<
211 "Restarting: Min Orthogonality "<<
m_minOrtho<<
" missed: "
212 <<
"(r,r0)="<<fabs(rho)<<
", ||r||="<<norm_r<<
", ||r0||= "
221 UG_LOG(
"BiCGStab: Method breakdown with rhoOld = "<<rhoOld<<
222 ". Aborting iteration.\n");
238 UG_LOG(
"BiCGStab: Cannot apply preconditioner. Aborting.\n");
252 UG_THROW(
"BiCGStab: Cannot convert q to consistent vector.");
265 UG_THROW(
"BiCGStab: Cannot convert v to unique vector.");
276 UG_LOG(
"BiCGStab: Method breakdown: alpha = "<<
alpha<<
277 " is an invalid value. Aborting iteration.\n");
307 UG_LOG(
"BiCGStab: Cannot apply preconditioner. Aborting.\n");
321 UG_THROW(
"BiCGStab: Cannot convert q to consistent vector.");
334 UG_THROW(
"BiCGStab: Cannot convert t to unique vector.");
353 UG_LOG(
"BiCGStab: Method breakdown tt = "<<tt<<
" is an "
354 "invalid value. Aborting iteration.\n");
375 UG_LOG(
"BiCGStab: Method breakdown with omega = "<<
omega<<
376 ". Aborting iteration.\n");
417 s =
" (No Preconditioner) ";
426 write_debug(r, std::string(
"BiCGStab_Residual") + ext +
".vec");
427 write_debug(x, std::string(
"BiCGStab_Solution") + ext +
".vec");
441 std::stringstream ss;
Definition: smart_pointer.h:108
the BiCGStab method as a solver for linear operators
Definition: bicgstab.h:69
void add_postprocess_corr(SmartPtr< IPProcessVector< vector_type > > p)
adds a post-process for the iterates
Definition: bicgstab.h:393
BiCGStab()
constructors
Definition: bicgstab.h:85
void write_debugXR(vector_type &x, vector_type &r, int loopCnt, char phase)
debugger output: solution and residual
Definition: bicgstab.h:422
void enter_precond_debug_section(int loopCnt, char phase)
debugger section for the preconditioner
Definition: bicgstab.h:431
BiCGStab(SmartPtr< ILinearIterator< vector_type, vector_type > > spPrecond)
Definition: bicgstab.h:89
TVector vector_type
Vector type.
Definition: bicgstab.h:72
void remove_postprocess_corr(SmartPtr< IPProcessVector< vector_type > > p)
removes a post-process for the iterates
Definition: bicgstab.h:399
void set_restart(int numRestarts)
sets to restart at given number of iteration steps
Definition: bicgstab.h:387
void set_min_orthogonality(number minOrtho)
sets to restart if given orthogonality missed
Definition: bicgstab.h:390
BiCGStab(SmartPtr< ILinearIterator< vector_type > > spPrecond, SmartPtr< IConvergenceCheck< vector_type > > spConvCheck)
Definition: bicgstab.h:94
virtual const char * name() const
name of solver
Definition: bicgstab.h:101
number m_minOrtho
minimal value in (0,1) accepted for Orthoginality before restart
Definition: bicgstab.h:451
SmartPtr< ILinearIterator< X, X > > preconditioner()
Definition: preconditioned_linear_operator_inverse.h:118
PProcessChain< vector_type > m_corr_post_process
postprocessor for the correction in the iterations
Definition: bicgstab.h:459
IPreconditionedLinearOperatorInverse< vector_type > base_type
Base type.
Definition: bicgstab.h:75
void prepare_conv_check()
prepares the output of the convergence check
Definition: bicgstab.h:406
virtual bool supports_parallel() const
returns if parallel solving is supported
Definition: bicgstab.h:104
virtual std::string config_string() const
returns information about configuration parameters
Definition: bicgstab.h:439
virtual bool apply_return_defect(vector_type &x, vector_type &b)
Definition: bicgstab.h:112
int m_numRestarts
restarts at every numRestarts steps (numRestarts <= 0 --> never)
Definition: bicgstab.h:448
Definition: convergence_check.h:72
describes a linear iterator
Definition: linear_iterator.h:81
ConstSmartPtr< IConvergenceCheck< X > > convergence_check() const
returns the convergence check
Definition: linear_operator_inverse.h:202
SmartPtr< ILinearOperator< Y, X > > linear_operator()
returns the current Operator this Inverse Operator is initialized for
Definition: linear_operator_inverse.h:227
int step() const
returns the current number of steps
Definition: linear_operator_inverse.h:211
interface for pre- and postprocess functions
Definition: pprocess.h:59
describes an inverse linear mapping X->X
Definition: preconditioned_linear_operator_inverse.h:63
virtual bool apply(TVector &x, const TVector &b)
Definition: preconditioned_linear_operator_inverse.h:152
SmartPtr< ILinearIterator< X, X > > preconditioner()
Definition: preconditioned_linear_operator_inverse.h:118
std::string config_string_preconditioner_convergence_check() const
returns config information of convergence check and preconditioner
Definition: preconditioned_linear_operator_inverse.h:200
void add(SmartPtr< p_process_type > p)
adds an operation at the end of the chain
Definition: pprocess.h:96
void apply(vector_type &v)
performs all the operations
Definition: pprocess.h:86
void remove(SmartPtr< p_process_type > p)
removes an operation from the chain
Definition: pprocess.h:108
bool vector_debug_writer_valid() const
returns true if the debug writer is set
Definition: debug_writer.h:290
void enter_vector_debug_writer_section(std::string secDir)
enters a debugging section
Definition: debug_writer.h:331
void leave_vector_debug_writer_section()
leaves a debugging section
Definition: debug_writer.h:342
void write_debug(const vector_type &vec, const char *filename)
writing debug output for a vector (if debug writer set)
Definition: debug_writer.h:293
TVector vector_type
type of vector
Definition: debug_writer.h:269
@ PST_CONSISTENT
Definition: parallel_storage_type.h:68
@ PST_UNIQUE
Definition: parallel_storage_type.h:70
@ PST_ADDITIVE
Definition: parallel_storage_type.h:69
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
double number
Definition: types.h:124
void VecScaleAdd(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1, typename vector_t::value_type s2, const vector_t &v2)
Scales two Vectors, adds them and returns the sum in a third vector.
Definition: math_vector_functions_common_impl.hpp:265
#define LS_PROFILE_BEGIN(name)
Definition: linear_solver_profiling.h:40
double VecProd(const double &a, const double &b)
returns scal<a, b>
Definition: operations_vec.h:84
std::string GetStringPrintf(const char *format, Args... args)
Definition: string_util.h:449