1 #ifndef _pf_solve_nonlinear_problem_h_
2 #define _pf_solve_nonlinear_problem_h_
7 void Phaseflow<dim>::step_newton()
9 this->old_newton_solution = this->newton_solution;
11 this->assemble_system();
13 this->apply_boundary_values_and_constraints();
15 this->solve_linear_system();
17 this->newton_solution -= this->newton_residual;
22 bool Phaseflow<dim>::solve_nonlinear_problem()
24 this->newton_solution = this->solution;
26 bool converged =
false;
30 double old_norm_residual = 1.e32;
32 for (i = 0; i < this->params.nonlinear_solver.max_iterations; ++i)
37 "newton_residual.vtk",
39 this->newton_residual);
42 "newton_solution.vtk",
44 this->newton_solution);
46 double norm_residual = this->newton_residual.l2_norm()/this->newton_solution.l2_norm();
48 std::cout <<
"Newton iteration: L2 norm of relative residual, || w_w || / || w_k || = " << norm_residual << std::endl;
50 if (norm_residual > old_norm_residual)
54 std::cout <<
"Newton iteration diverged." << std::endl;
57 "diverged_newton_solution.vtk",
59 this->newton_solution);
61 if (this->time_step_size == this->params.time.min_step_size)
69 old_norm_residual = norm_residual;
71 if (norm_residual < this->params.nonlinear_solver.tolerance)
79 if ((this->time_step_size > this->params.time.min_step_size) & !converged)
86 std::cout <<
"Newton method converged after " << i + 1 <<
" iterations." << std::endl;
88 this->solution = this->newton_solution;
void write_solution_to_vtk(const std::string filename, DoFHandler< dim > &dof_handler, Vector< double > &solution)
Definition: output.h:16