33 #ifndef __H__UG__LIB_DISC__OPERATOR__AUTO_LINEAR_OPERATOR__LINEAR_SOLVER__
34 #define __H__UG__LIB_DISC__OPERATOR__AUTO_LINEAR_OPERATOR__LINEAR_SOLVER__
62 template <
typename TVector>
81 (
double desiredDefect,
double desiredReduction)
139 virtual const char*
name()
const {
return "Auto Iterative Linear Solver";}
186 if(uo.
valid()) uo->calculate_matrix();
187 if(
m_u.size() != 0.0)
208 UG_LOG(
"ERROR in 'LinearSolver::apply': Iterator "
209 "Operator applied incorrectly. Aborting.\n");
234 UG_THROW(
"LinearSolver::apply: Inadequate storage format of Vectors.");
257 char ext[20]; snprintf(ext, 20,
"_iter%03d", loopCnt);
258 std::string
name(
"LS_Defect_");
name.append(ext).append(
".vec");
260 name = std::string(
"LS_Solution_");
name.append(ext).append(
".vec");
285 double spentTime =
get_clock_s() - tStartIterationTime;
287 double tComputeTime = spentTime/steps;
293 double approxRemainingTimeForSolution = approxSteps*tComputeTime;
307 UG_LOG(
"AutoLinearSolver: REINIT because reduction rate >= 1.")
316 if(approxResolveTime < approxRemainingTimeForSolution)
320 UG_LOG(
" approximated remaining Time for Solution with old preconditioner = " << approxRemainingTimeForSolution <<
" s\n");
321 UG_LOG(
" > approximated Time for Reinit preconditioner and solve = " << approxResolveTime <<
" s\n");
322 UG_LOG(
" with old preconditioner:\n");
325 UG_LOG(
" spentTime = " << spentTime <<
", time per Step = " << tComputeTime <<
"\n");
326 UG_LOG(
" approximation of solution with old:\n")
328 UG_LOG(
" approxSteps with last reduction rate = " << approxSteps <<
"\n");
343 double spentTime =
get_clock_s() - tStartIterationTime;
345 UG_LOG(
"AutoLinearSolver solved with old preconditioner [")
388 UG_LOG(
"ERROR in 'LinearSolver::apply': post-convergence-check "
389 "signaled failure. Aborting.\n");
402 UG_LOG(
"AutoLinearSolver:\n");
424 s =
" (No Preconditioner) ";
Definition: smart_pointer.h:108
bool valid() const
returns true if the pointer is valid, false if not.
Definition: smart_pointer.h:206
linear solver using abstract preconditioner interface
Definition: auto_linear_solver.h:65
int m_bInited
Definition: auto_linear_solver.h:113
void set_reinit_when_worse_then_average(double d)
Definition: auto_linear_solver.h:133
void prepare_conv_check()
prepares the convergence check output
Definition: auto_linear_solver.h:414
double m_savedTime
Definition: auto_linear_solver.h:124
AutoLinearSolver()
Definition: auto_linear_solver.h:92
vector_type m_u
Definition: auto_linear_solver.h:116
virtual bool apply(vector_type &x, const vector_type &b)
compute new correction c = B*d
Definition: auto_linear_solver.h:219
bool init_op(SmartPtr< ILinearOperator< vector_type, vector_type > > J)
Definition: auto_linear_solver.h:153
void set_reduction_always_accept(double d)
Definition: auto_linear_solver.h:128
double m_reductionPerTime
Definition: auto_linear_solver.h:122
size_t m_initCalled
Definition: auto_linear_solver.h:119
double m_lastCallTime
Definition: auto_linear_solver.h:122
bool reinit()
Definition: auto_linear_solver.h:177
SmartPtr< ILinearOperator< vector_type, vector_type > > pJ
Definition: auto_linear_solver.h:115
IPreconditionedLinearOperatorInverse< vector_type > base_type
Base type.
Definition: auto_linear_solver.h:71
double m_reductionAlwaysAccept
Definition: auto_linear_solver.h:111
bool compute_correction(vector_type &c, vector_type &d)
Definition: auto_linear_solver.h:199
virtual const char * name() const
returns the name of the solver
Definition: auto_linear_solver.h:139
double m_worseThenAverage
Definition: auto_linear_solver.h:112
double m_desiredReduction
Definition: auto_linear_solver.h:123
virtual bool apply_return_defect(vector_type &x, vector_type &b)
solves the system and returns the last defect
Definition: auto_linear_solver.h:227
SmartPtr< ILinearIterator< X, X > > preconditioner()
Definition: preconditioned_linear_operator_inverse.h:118
double m_avgReduction
Definition: auto_linear_solver.h:117
TVector vector_type
Vector type.
Definition: auto_linear_solver.h:68
double m_lastCallReduction
Definition: auto_linear_solver.h:122
size_t m_initsDone
Definition: auto_linear_solver.h:118
virtual bool supports_parallel() const
returns if parallel solving is supported
Definition: auto_linear_solver.h:103
virtual bool init(SmartPtr< ILinearOperator< vector_type, vector_type > > J)
initializes the solver for an operator
Definition: auto_linear_solver.h:147
double m_desiredDefect
Definition: auto_linear_solver.h:123
double m_lastInitTime
Definition: auto_linear_solver.h:121
virtual bool init(SmartPtr< ILinearOperator< vector_type, vector_type > > J, const vector_type &u)
initializes the solver for an operator
Definition: auto_linear_solver.h:142
void print_information()
Definition: auto_linear_solver.h:400
describes a linear mapping X->Y
Definition: linear_operator.h:80
ConstSmartPtr< IConvergenceCheck< X > > convergence_check() const
returns the convergence check
Definition: linear_operator_inverse.h:202
number reduction() const
returns the current relative reduction
Definition: linear_operator_inverse.h:214
number defect() const
returns the current defect
Definition: linear_operator_inverse.h:208
SmartPtr< ILinearOperator< Y, X > > linear_operator()
returns the current Operator this Inverse Operator is initialized for
Definition: linear_operator_inverse.h:227
virtual bool init(SmartPtr< ILinearOperator< Y, X > > L)
initializes for the inverse for a linear operator
Definition: linear_operator_inverse.h:135
describes an inverse linear mapping X->X
Definition: preconditioned_linear_operator_inverse.h:63
virtual bool init(SmartPtr< ILinearOperator< X, X > > J, const X &u)
initializes the solver for an operator
Definition: preconditioned_linear_operator_inverse.h:123
SmartPtr< ILinearIterator< X, X > > preconditioner()
Definition: preconditioned_linear_operator_inverse.h:118
Definition: auto_linear_solver.h:49
virtual void calculate_matrix()=0
virtual ~UpdateableMatrixOperator()
Definition: auto_linear_solver.h:51
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
static std::ios_base & reset_floats(std::ios_base &o)
used to unset flags set by std::scientific or std::fixed.
Definition: ostream_util.h:52
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
#define LS_PROFILE_BEGIN(name)
Definition: linear_solver_profiling.h:40
#define LS_PROFILE_END(name)
Definition: linear_solver_profiling.h:41
double get_clock_s()
Definition: stopwatch.h:103