19 #include "solver/newton_solver.h"
20 #include "projections/ogprojection.h"
21 #include "hermes_common.h"
30 template<
typename Scalar>
31 NewtonSolver<Scalar>::NewtonSolver() : Solver<Scalar>(), NewtonMatrixSolver<Scalar>()
33 this->dp =
new DiscreteProblem<Scalar>(
false,
true);
37 template<
typename Scalar>
38 NewtonSolver<Scalar>::NewtonSolver(DiscreteProblem<Scalar>* dp) : Solver<Scalar>(dp), NewtonMatrixSolver<Scalar>()
42 template<
typename Scalar>
43 NewtonSolver<Scalar>::NewtonSolver(WeakFormSharedPtr<Scalar> wf, SpaceSharedPtr<Scalar> space) : Solver<Scalar>(wf, space), NewtonMatrixSolver<Scalar>()
45 this->dp =
new DiscreteProblem<Scalar>(wf, space,
false,
true);
49 template<
typename Scalar>
50 NewtonSolver<Scalar>::NewtonSolver(WeakFormSharedPtr<Scalar> wf, std::vector<SpaceSharedPtr<Scalar> > spaces) : Solver<Scalar>(wf, spaces), NewtonMatrixSolver<Scalar>()
52 this->dp =
new DiscreteProblem<Scalar>(wf, spaces,
false,
true);
56 template<
typename Scalar>
57 NewtonSolver<Scalar>::~NewtonSolver()
61 template<
typename Scalar>
64 NewtonMatrixSolver<Scalar>::solve(coeff_vec);
67 template<
typename Scalar>
70 return this->sln_vector;
73 template<
typename Scalar>
76 MatrixSolver<Scalar>::set_verbose_output(to_set);
77 this->dp->set_verbose_output(to_set);
80 template<
typename Scalar>
83 this->dp->
assemble(this->sln_vector, this->get_residual());
84 this->process_vector_output(this->get_residual(), this->get_current_iteration_number());
85 this->get_residual()->change_sign();
88 template<
typename Scalar>
91 bool result = this->dp->assemble(this->sln_vector, this->get_jacobian());
93 this->dp->set_reassembled_states_reuse_linear_system_fn(
nullptr);
95 this->process_matrix_output(this->get_jacobian(), this->get_current_iteration_number());
99 template<
typename Scalar>
102 bool result = this->dp->assemble(this->sln_vector, this->get_jacobian(), this->get_residual());
104 this->dp->set_reassembled_states_reuse_linear_system_fn(
nullptr);
105 this->get_residual()->change_sign();
106 this->process_vector_output(this->get_residual(), this->get_current_iteration_number());
107 this->process_matrix_output(this->get_jacobian(), this->get_current_iteration_number());
111 template<
typename Scalar>
117 template<
typename Scalar>
121 this->jacobian_reusable =
false;
124 template<
typename Scalar>
128 NewtonMatrixSolver<Scalar>::init_solving(coeff_vec);
131 template<
typename Scalar>
135 this->jacobian_reusable =
false;
virtual void set_weak_formulation(WeakFormSharedPtr< Scalar > wf)
DiscreteProblemWeakForm helper.
Scalar * get_sln_vector()
Get sln vector.
virtual void set_spaces(std::vector< SpaceSharedPtr< Scalar > > spaces)
DiscreteProblemWeakForm helper.
Used to pass the instances of Space around.
virtual void init_solving(Scalar *coeff_vec)
Initialization - called at the beginning of solving.
virtual bool assemble(bool store_previous_jacobian, bool store_previous_residual)
virtual void set_spaces(std::vector< SpaceSharedPtr< Scalar > > spaces)
SettableSpaces helper.
virtual bool assemble_jacobian(bool store_previous_jacobian)
virtual int assign_dofs(int first_dof=0)
Builds basis functions and assigns DOF numbers to them.
virtual void set_weak_formulation(WeakFormSharedPtr< Scalar > wf)
DiscreteProblemWeakForm helper.
virtual void solve()
Basic solve method.
virtual void set_verbose_output(bool to_set)
See Hermes::Mixins::Loggable.
virtual bool isOkay() const
State querying helpers.