16 #ifndef __H2D_RUNGE_KUTTA_H
17 #define __H2D_RUNGE_KUTTA_H
20 #include "weakform/weakform.h"
21 #include "function/filter.h"
22 #include "exceptions.h"
72 template<
typename Scalar>
73 class HERMES_API RungeKutta :
74 public Hermes::Mixins::Loggable,
75 public Hermes::Mixins::TimeMeasurable,
76 public Hermes::Mixins::IntegrableWithGlobalOrder,
77 public Hermes::Mixins::SettableComputationTime,
79 public Hermes::Algebra::Mixins::MatrixRhsOutput < Scalar >
85 RungeKutta(WeakFormSharedPtr<Scalar> wf, std::vector<SpaceSharedPtr<Scalar> > spaces, ButcherTable* bt);
88 RungeKutta(WeakFormSharedPtr<Scalar> wf, SpaceSharedPtr<Scalar> space, ButcherTable* bt);
90 void set_start_from_zero_K_vector();
91 void set_residual_as_solutions();
92 void set_block_diagonal_jacobian();
108 void rk_time_step_newton(std::vector<MeshFunctionSharedPtr<Scalar> > slns_time_prev, std::vector<MeshFunctionSharedPtr<Scalar> > slns_time_new, std::vector<MeshFunctionSharedPtr<Scalar> > error_fns);
109 void rk_time_step_newton(MeshFunctionSharedPtr<Scalar> slns_time_prev, MeshFunctionSharedPtr<Scalar> slns_time_new, MeshFunctionSharedPtr<Scalar> error_fn);
113 void rk_time_step_newton(std::vector<MeshFunctionSharedPtr<Scalar> > slns_time_prev, std::vector<MeshFunctionSharedPtr<Scalar> > slns_time_new);
114 void rk_time_step_newton(MeshFunctionSharedPtr<Scalar> sln_time_prev, MeshFunctionSharedPtr<Scalar> sln_time_new);
116 void set_freeze_jacobian();
117 void set_tolerance(
double newton_tol);
118 void set_max_allowed_iterations(
int newton_max_iter);
119 void set_newton_damping_coeff(
double newton_damping_coeff);
120 void set_newton_max_allowed_residual_norm(
double newton_max_allowed_residual_norm);
122 virtual void set_spaces(std::vector<SpaceSharedPtr<Scalar> > spaces);
123 virtual void set_space(SpaceSharedPtr<Scalar> space);
124 virtual std::vector<SpaceSharedPtr<Scalar> > get_spaces();
137 void set_filters_to_reinit(std::vector<Filter<Scalar>*> filters_to_reinit);
149 void multiply_as_diagonal_block_matrix(SparseMatrix<Scalar>* matrix_left,
int num_stages,
150 Scalar* stage_coeff_vec, Scalar* vector_left);
157 void create_stage_wf(
unsigned int size,
bool block_diagonal_jacobian);
160 void update_stage_wf(std::vector<MeshFunctionSharedPtr<Scalar> > slns_time_prev);
163 void prepare_u_ext_vec();
166 Hermes::Algebra::SparseMatrix<Scalar>* matrix_left;
169 Hermes::Algebra::SparseMatrix<Scalar>* matrix_right;
170 Hermes::Algebra::Vector<Scalar>* vector_right;
173 Hermes::Solvers::LinearMatrixSolver<Scalar>* solver;
176 const WeakFormSharedPtr<Scalar> wf;
179 std::vector<SpaceSharedPtr<Scalar> > spaces;
180 std::vector<unsigned int> spaces_seqs;
186 unsigned int num_stages;
191 WeakFormSharedPtr<Scalar> stage_wf_right;
192 DiscreteProblem<Scalar>* stage_dp_right;
195 WeakFormSharedPtr<Scalar> stage_wf_left;
196 DiscreteProblem<Scalar>* stage_dp_left;
198 bool start_from_zero_K_vector;
199 bool block_diagonal_jacobian;
200 bool residual_as_vector;
203 unsigned int iteration;
205 bool freeze_jacobian;
208 double newton_damping_coeff;
209 double newton_max_allowed_residual_norm;
211 std::vector<MeshFunctionSharedPtr<Scalar> > residuals_vector;
224 std::vector<Filter<Scalar>*> filters_to_reinit;
Common definitions for Hermes2D.