45 #define NEWTON_PROFILE_FUNC() PROFILE_FUNC_GROUP("Newton")
46 #define NEWTON_PROFILE_BEGIN(name) PROFILE_BEGIN_GROUP(name, "Newton")
47 #define NEWTON_PROFILE_END() PROFILE_END()
49 #define NEWTON_PROFILE_FUNC()
50 #define NEWTON_PROFILE_BEGIN(name)
51 #define NEWTON_PROFILE_END()
57template <
typename TAlgebra>
60: m_spLinearSolver(NULL),
69template <
typename TAlgebra>
72: m_spLinearSolver(NULL),
83template <
typename TAlgebra>
86: m_spLinearSolver(NULL),
95template <
typename TAlgebra>
99 m_N = N.template cast_dynamic<AssembledOperator<TAlgebra> >();
101 UG_THROW(
"NewtonLimexSolver: currently only works for AssembledDiscreteOperator.");
103 m_spAss = m_N->discretization();
108template <
typename TAlgebra>
115template <
typename TAlgebra>
120 if (m_spLinearSolver.invalid())
121 UG_THROW(
"NewtonLimexSolver::apply: Linear solver not set.");
124 if (m_J.invalid() || m_J->discretization() != m_spAss)
127 m_J->set_level(m_N->level());
134 try {m_N->prepare(u);}
135 UG_CATCH_THROW(
"NewtonLimexSolver::prepare: Operator preparation failed.");
144 UG_CATCH_THROW(
"NewtonLimexSolver::apply: Defect computation failed.");
147 const int stdLinOffset = m_spLinearSolver->standard_offset();
148 m_spLinearSolver->convergence_check()->set_offset(stdLinOffset + 3);
163 UG_CATCH_THROW(
"NewtonLimexSolver::apply: Jacobian initialization failed.");
169 if (!m_spLinearSolver->init(m_J, u))
171 UG_LOGN(
"ERROR in 'NewtonLimexSolver::apply': Cannot init inverse linear "
172 "operator for Jacobi operator.");
177 UG_CATCH_THROW(
"NewtonLimexSolver::apply: Initialization of Linear Solver failed.");
183 if (!m_spLinearSolver->apply(*spC, *spD))
185 UG_LOGN(
"ERROR in 'NewtonLimexSolver::apply': Cannot apply inverse linear "
186 "operator for Jacobi operator.");
191 UG_CATCH_THROW(
"NewtonLimexSolver::apply: Application of Linear Solver failed.");
194 m_linSolverSteps = m_spLinearSolver->step();
195 m_linSolverRate = m_spLinearSolver->convergence_check()->avg_rate();
204 m_spLinearSolver->convergence_check()->set_offset(stdLinOffset);
210template <
typename TAlgebra>
213 return m_linSolverRate;
216template <
typename TAlgebra>
219 return m_linSolverSteps;
222template <
typename TAlgebra>
225 std::stringstream ss;
226 ss <<
"NewtonLimexSolver\n";
228 ss <<
" LinearSolver: ";
229 if (m_spLinearSolver.valid()) ss <<
ConfigShift(m_spLinearSolver->config_string()) <<
"\n";
230 else ss <<
" NOT SET!\n";
TAlgebra::vector_type vector_type
vector type
Definition newton_limex.h:61
LimexNewtonSolver()
default constructor
Definition newton_limex_impl.h:59
virtual bool prepare(vector_type &u)
prepare operator
Definition newton_limex_impl.h:109
number linear_solver_rate() const
prints average linear solver convergence
Definition newton_limex_impl.h:211
virtual bool init(SmartPtr< IOperator< vector_type > > N)
This operator inverts the operator N: Y -> X.
Definition newton_limex_impl.h:96
virtual std::string config_string() const
Returns information about configuration parameters. This should return necessary information about pa...
Definition newton_limex_impl.h:223
virtual bool apply(vector_type &u)
apply operator, i.e. N^{-1}(0) = u
Definition newton_limex_impl.h:116
int linear_solver_steps() const
information on linear solver convergence
Definition newton_limex_impl.h:217
#define UG_CATCH_THROW(msg)
UG_API std::string ConfigShift(std::string s)
#define NEWTON_PROFILE_END()
Definition newton_limex_impl.h:47
#define NEWTON_PROFILE_BEGIN(name)
Definition newton_limex_impl.h:46
SmartPtr< T, FreePolicy > make_sp(T *inst)
function ProblemDisc new(problemDesc, dom)