18 #include <deal.II/algorithms/newton.h> 20 #include <deal.II/base/parameter_handler.h> 21 #include <deal.II/base/logstream.h> 22 #include <deal.II/lac/vector_memory.h> 31 template <
class VECTOR>
34 residual(&residual), inverse_derivative(&inverse_derivative),
36 n_stepsize_iterations(21),
37 assemble_threshold(0.),
43 template <
class VECTOR>
56 template <
class VECTOR>
68 template <
class VECTOR>
75 template <
class VECTOR>
84 template <
class VECTOR>
89 deallog.
push (
"Newton");
94 deallog <<
"u: " << u.l2_norm() << std::endl;
104 src1.
add(p,
"Newton iterate");
107 src2.
add(p,
"Newton residual");
110 out1.
add(p,
"Residual");
113 out2.
add(p,
"Update");
115 unsigned int step = 0;
117 (*residual)(out1, src1);
118 double resnorm = res->l2_norm();
130 (*inverse_derivative)(out2, src2);
134 deallog <<
"Inner iteration failed after " 135 << e.
last_step <<
" steps with residual " 143 out.
add(p,
"solution");
145 out.
add(p,
"update");
147 out.
add(p,
"residual");
153 old_residual = resnorm;
154 (*residual)(out1, src1);
155 resnorm = res->l2_norm();
158 unsigned int step_size = 0;
159 while (resnorm >= old_residual)
164 deallog <<
"No smaller stepsize allowed!";
168 deallog <<
"Trying step size: 1/" << (1<<step_size)
169 <<
" since residual was " << resnorm << std::endl;
170 u.add(1./(1<<step_size), *Du);
171 (*residual)(out1, src1);
172 resnorm = res->l2_norm();
186 DEAL_II_NAMESPACE_CLOSE
const double last_residual
static void declare_parameters(ParameterHandler ¶m)
void add(DATA &v, const std::string &name)
void initialize(ParameterHandler ¶m)
void parse_parameters(ParameterHandler ¶m)
unsigned int n_stepsize_iterations
#define AssertThrow(cond, exc)
virtual void operator()(NamedData< VECTOR * > &out, const NamedData< VECTOR * > &in)
void enter_subsection(const std::string &subsection)
SmartPointer< OutputOperator< VECTOR >, Newton< VECTOR > > data_out
Newton(Operator< VECTOR > &residual, Operator< VECTOR > &inverse_derivative)
double last_value() const
const unsigned int last_step
Stop iteration, goal reached.
#define Assert(cond, exc)
const Event bad_derivative
unsigned int size() const
Number of stored data objects.
unsigned int last_step() const
void declare_parameters(ParameterHandler ¶m)
void merge(NamedData< DATA2 > &)
bool get_bool(const std::string &entry_name) const
SmartPointer< Operator< VECTOR >, Newton< VECTOR > > residual
void push(const std::string &text)
virtual void notify(const Event &)
void log_history(const bool)
double get_double(const std::string &entry_name) const
void declare_entry(const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation=std::string())
::ExceptionBase & ExcNotImplemented()
double assemble_threshold
virtual State check(const unsigned int step, const double check_value)
SmartPointer< Operator< VECTOR >, Newton< VECTOR > > inverse_derivative
long int get_integer(const std::string &entry_string) const