33 #ifndef __H__UG__LIB_DISC__OPERATOR__LINEAR_SOLVER__CG__
34 #define __H__UG__LIB_DISC__OPERATOR__LINEAR_SOLVER__CG__
64 template <
typename TVector>
92 virtual const char*
name()
const {
return "CG";}
110 "Inadequate storage format of Vectors.");
133 UG_LOG(
"ERROR in 'CG::apply_return_defect': "
134 "Cannot apply preconditioner. Aborting.\n");
145 UG_THROW(
"CG::apply_return_defect: "
146 "Cannot convert z to consistent vector.");
176 UG_LOG(
"ERROR in 'CG::apply_return_defect': lambda=" <<
177 lambda<<
" is not admitted. Aborting solver.\n");
208 UG_LOG(
"ERROR in 'CG::apply_return_defect': "
209 "Cannot apply preconditioner. Aborting.\n");
220 UG_THROW(
"CG::apply_return_defect': "
221 "Cannot convert z to consistent vector.");
231 const number beta = rho/rhoOld;
269 s =
" (No Preconditioner) ";
277 char ext[20]; snprintf(ext, 20,
"_iter%03d", loopCnt);
278 write_debug(r, std::string(
"CG_Residual") + ext +
".vec");
279 write_debug(x, std::string(
"CG_Solution") + ext +
".vec");
286 char ext[20]; snprintf(ext, 20,
"_iter%03d", loopCnt);
Definition: smart_pointer.h:108
the CG method as a solver for linear operators
Definition: cg.h:67
virtual const char * name() const
name of solver
Definition: cg.h:92
CG(SmartPtr< ILinearIterator< vector_type, vector_type > > spPrecond)
Definition: cg.h:85
void write_debugXR(vector_type &x, vector_type &r, int loopCnt)
debugger output: solution and residual
Definition: cg.h:274
void enter_precond_debug_section(int loopCnt)
debugger section for the preconditioner
Definition: cg.h:283
IPreconditionedLinearOperatorInverse< vector_type > base_type
Base type.
Definition: cg.h:73
void remove_postprocess_corr(SmartPtr< IPProcessVector< vector_type > > p)
removes a post-process for the iterates
Definition: cg.h:251
TVector vector_type
Vector type.
Definition: cg.h:70
CG(SmartPtr< ILinearIterator< vector_type, vector_type > > spPrecond, SmartPtr< IConvergenceCheck< vector_type > > spConvCheck)
Definition: cg.h:88
virtual bool apply_return_defect(vector_type &x, vector_type &b)
Solve J(u)*x = b, such that x = J(u)^{-1} b.
Definition: cg.h:103
void add_postprocess_corr(SmartPtr< IPProcessVector< vector_type > > p)
adds a post-process for the iterates
Definition: cg.h:245
PProcessChain< vector_type > m_corr_post_process
postprocessor for the correction in the iterations
Definition: cg.h:303
SmartPtr< ILinearIterator< X, X > > preconditioner()
Definition: preconditioned_linear_operator_inverse.h:118
void prepare_conv_check()
adjust output of convergence check
Definition: cg.h:258
virtual bool supports_parallel() const
returns if parallel solving is supported
Definition: cg.h:95
CG()
constructors
Definition: cg.h:83
number VecProd(vector_type &a, vector_type &b)
Definition: cg.h:291
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
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_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 PROFILE_BEGIN_GROUP(name, groups)
Definition: profiler.h:255