41 #define PROFILE_NEWTON
43 #define NEWTON_PROFILE_FUNC() PROFILE_FUNC_GROUP("Newton")
44 #define NEWTON_PROFILE_BEGIN(name) PROFILE_BEGIN_GROUP(name, "Newton")
45 #define NEWTON_PROFILE_END() PROFILE_END()
47 #define NEWTON_PROFILE_FUNC()
48 #define NEWTON_PROFILE_BEGIN(name)
49 #define NEWTON_PROFILE_END()
55 template <
typename TAlgebra>
58 : m_spLinearSolver(NULL),
67 template <
typename TAlgebra>
70 : m_spLinearSolver(NULL),
81 template <
typename TAlgebra>
84 : m_spLinearSolver(NULL),
93 template <
typename TAlgebra>
97 m_N = N.template cast_dynamic<AssembledOperator<TAlgebra> >();
99 UG_THROW(
"NewtonLimexSolver: currently only works for AssembledDiscreteOperator.");
101 m_spAss = m_N->discretization();
106 template <
typename TAlgebra>
113 template <
typename TAlgebra>
118 if (m_spLinearSolver.invalid())
119 UG_THROW(
"NewtonLimexSolver::apply: Linear solver not set.");
122 if (m_J.invalid() || m_J->discretization() != m_spAss)
125 m_J->set_level(m_N->level());
132 try {m_N->prepare(u);}
133 UG_CATCH_THROW(
"NewtonLimexSolver::prepare: Operator preparation failed.");
142 UG_CATCH_THROW(
"NewtonLimexSolver::apply: Defect computation failed.");
145 const int stdLinOffset = m_spLinearSolver->standard_offset();
146 m_spLinearSolver->convergence_check()->set_offset(stdLinOffset + 3);
161 UG_CATCH_THROW(
"NewtonLimexSolver::apply: Jacobian initialization failed.");
167 if (!m_spLinearSolver->init(m_J, u))
169 UG_LOGN(
"ERROR in 'NewtonLimexSolver::apply': Cannot init inverse linear "
170 "operator for Jacobi operator.");
175 UG_CATCH_THROW(
"NewtonLimexSolver::apply: Initialization of Linear Solver failed.");
181 if (!m_spLinearSolver->apply(*spC, *spD))
183 UG_LOGN(
"ERROR in 'NewtonLimexSolver::apply': Cannot apply inverse linear "
184 "operator for Jacobi operator.");
189 UG_CATCH_THROW(
"NewtonLimexSolver::apply: Application of Linear Solver failed.");
192 m_linSolverSteps = m_spLinearSolver->step();
193 m_linSolverRate = m_spLinearSolver->convergence_check()->avg_rate();
202 m_spLinearSolver->convergence_check()->set_offset(stdLinOffset);
208 template <
typename TAlgebra>
211 return m_linSolverRate;
214 template <
typename TAlgebra>
217 return m_linSolverSteps;
220 template <
typename TAlgebra>
223 std::stringstream ss;
224 ss <<
"NewtonLimexSolver\n";
226 ss <<
" LinearSolver: ";
227 if (m_spLinearSolver.valid()) ss <<
ConfigShift(m_spLinearSolver->config_string()) <<
"\n";
228 else ss <<
" NOT SET!\n";
TAlgebra::vector_type vector_type
vector type
Definition: newton_limex.h:59
LimexNewtonSolver()
default constructor
Definition: newton_limex_impl.h:57
virtual bool prepare(vector_type &u)
prepare operator
Definition: newton_limex_impl.h:107
number linear_solver_rate() const
prints average linear solver convergence
Definition: newton_limex_impl.h:209
virtual bool init(SmartPtr< IOperator< vector_type > > N)
This operator inverts the operator N: Y -> X.
Definition: newton_limex_impl.h:94
virtual std::string config_string() const
Returns information about configuration parameters. This should return necessary information about pa...
Definition: newton_limex_impl.h:221
virtual bool apply(vector_type &u)
apply operator, i.e. N^{-1}(0) = u
Definition: newton_limex_impl.h:114
int linear_solver_steps() const
information on linear solver convergence
Definition: newton_limex_impl.h:215
#define UG_CATCH_THROW(msg)
UG_API std::string ConfigShift(std::string s)
#define NEWTON_PROFILE_END()
Definition: newton_limex_impl.h:45
#define NEWTON_PROFILE_BEGIN(name)
Definition: newton_limex_impl.h:44
SmartPtr< T, FreePolicy > make_sp(T *inst)
function ProblemDisc new(problemDesc, dom)