19 #include "solver/picard_solver.h"
20 #include "projections/ogprojection.h"
21 #include "exact_solution.h"
30 template<
typename Scalar>
31 PicardSolver<Scalar>::PicardSolver() : Solver<Scalar>(false), PicardMatrixSolver<Scalar>()
33 this->dp =
new DiscreteProblem<Scalar>(
false,
false);
37 template<
typename Scalar>
38 PicardSolver<Scalar>::PicardSolver(DiscreteProblem<Scalar>* dp) : Solver<Scalar>(dp), PicardMatrixSolver<Scalar>()
42 template<
typename Scalar>
43 PicardSolver<Scalar>::PicardSolver(WeakFormSharedPtr<Scalar> wf, SpaceSharedPtr<Scalar> space) : Solver<Scalar>(false), PicardMatrixSolver<Scalar>()
45 this->dp =
new DiscreteProblem<Scalar>(wf, space,
false,
false);
49 template<
typename Scalar>
50 PicardSolver<Scalar>::PicardSolver(WeakFormSharedPtr<Scalar> wf, std::vector<SpaceSharedPtr<Scalar> > spaces) : Solver<Scalar>(false), PicardMatrixSolver<Scalar>()
52 this->dp =
new DiscreteProblem<Scalar>(wf, spaces,
false,
false);
56 template<
typename Scalar>
57 PicardSolver<Scalar>::~PicardSolver()
61 template<
typename Scalar>
64 PicardMatrixSolver<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 bool use_Anderson = this->anderson_is_on && (this->vec_in_memory >= this->num_last_vectors_used);
84 this->dp->assemble(use_Anderson ? this->previous_Anderson_sln_vector : this->sln_vector, this->get_residual());
85 this->process_vector_output(this->get_residual(), this->get_current_iteration_number());
88 template<
typename Scalar>
89 bool PicardSolver<Scalar>::assemble_jacobian(
bool store_previous_jacobian)
91 if (store_previous_jacobian)
93 if (this->previous_jacobian)
94 delete this->previous_jacobian;
95 if (this->get_current_iteration_number() > 1)
96 this->previous_jacobian = this->get_jacobian()->duplicate();
99 bool use_Anderson = this->anderson_is_on && (this->vec_in_memory >= this->num_last_vectors_used);
100 bool result = this->dp->assemble(use_Anderson ? this->previous_Anderson_sln_vector : this->sln_vector, this->get_jacobian());
101 this->process_matrix_output(this->get_jacobian(), this->get_current_iteration_number());
105 template<
typename Scalar>
106 bool PicardSolver<Scalar>::assemble(
bool store_previous_jacobian,
bool store_previous_residual)
108 if (store_previous_jacobian)
110 if (this->previous_jacobian)
111 delete this->previous_jacobian;
112 if (this->get_current_iteration_number() > 1)
113 this->previous_jacobian = this->get_jacobian()->duplicate();
116 bool use_Anderson = this->anderson_is_on && (this->vec_in_memory >= this->num_last_vectors_used);
117 bool result = this->dp->assemble(use_Anderson ? this->previous_Anderson_sln_vector : this->sln_vector, this->get_jacobian(), this->get_residual());
118 this->process_vector_output(this->get_residual(), this->get_current_iteration_number());
119 this->process_matrix_output(this->get_jacobian(), this->get_current_iteration_number());
123 template<
typename Scalar>
129 template<
typename Scalar>
133 this->jacobian_reusable =
false;
136 template<
typename Scalar>
140 PicardMatrixSolver<Scalar>::init_solving(coeff_vec);
143 template<
typename Scalar>
147 this->jacobian_reusable =
false;
virtual void set_weak_formulation(WeakFormSharedPtr< Scalar > wf)
DiscreteProblemWeakForm helper.
virtual void init_solving(Scalar *coeff_vec)
Initialization - called at the beginning of solving.
virtual void set_verbose_output(bool to_set)
See Hermes::Mixins::Loggable.
Scalar * get_sln_vector()
Get sln vector.
Used to pass the instances of Space around.
virtual void set_spaces(std::vector< SpaceSharedPtr< Scalar > > spaces)
SettableSpaces helper.
virtual void set_weak_formulation(WeakFormSharedPtr< Scalar > wf)
DiscreteProblemWeakForm helper.
virtual void set_spaces(std::vector< SpaceSharedPtr< Scalar > > spaces)
DiscreteProblemWeakForm helper.
virtual int assign_dofs(int first_dof=0)
Builds basis functions and assigns DOF numbers to them.
virtual void solve()
Basic solve method.
virtual bool isOkay() const
State querying helpers.