Flow123d  3.9.0-960b954f9
linear_ode_solver.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file linear_ode_solver.hh
15  * @brief
16  */
17 
18 #ifndef LINEAR_ODE_SOLVER_H_
19 #define LINEAR_ODE_SOLVER_H_
20 
21 
22 
23 #include <iosfwd> // for stringstream
24 #include <string> // for string, basic_...
25 #include <vector> // for vector
26 #include "armadillo"
27 #include "system/exceptions.hh" // for ExcAssertMsg::...
28 #include "system/global_defs.h" // for msg, rank, OLD...
29 #include "system/asserts.hh"
30 
31 
32 /// @brief Class for linear ODE solver.
33 /** This class represents the solver of a system of linear ordinary differential
34  * equations with constant coefficients which uses matrix exponential to compute
35  * the solution at given times.
36  */
38 {
39 public:
40 
43 
44  void set_system_matrix(const arma::mat &matrix); ///< Sets the matrix of ODE system.
45  void set_step(double step); ///< Sets the step of the numerical method.
46 
47  /// Updates solution of the ODEs system.
48  /**
49  * @param init_vec is the column initial vector
50  * @param output_vec is the column output vector containing the result
51  */
52  void update_solution(arma::vec &init_vec, arma::vec &output_vec);
53 
54 protected:
55  arma::mat system_matrix_; ///< the square matrix of ODE system
56  arma::mat solution_matrix_; ///< the square solution matrix (exponential of system matrix)
57  arma::vec rhs_; ///< the column vector of RHS values (not used currently)
58  double step_; ///< the step of the numerical method
59  bool step_changed_; ///< flag is true if the step has been changed
60  bool system_matrix_changed_; ///< Indicates that the system_matrix_ was recently updated.
61 };
62 
63 
64 
65 #endif // LINEAR_ODE_SOLVER_H_
LinearODESolver::system_matrix_changed_
bool system_matrix_changed_
Indicates that the system_matrix_ was recently updated.
Definition: linear_ode_solver.hh:60
Armor::vec
ArmaVec< double, N > vec
Definition: armor.hh:885
LinearODESolver::step_
double step_
the step of the numerical method
Definition: linear_ode_solver.hh:58
LinearODESolver::set_step
void set_step(double step)
Sets the step of the numerical method.
Definition: linear_ode_solver.cc:42
asserts.hh
Definitions of ASSERTS.
LinearODESolver::system_matrix_
arma::mat system_matrix_
the square matrix of ODE system
Definition: linear_ode_solver.hh:55
exceptions.hh
LinearODESolver::set_system_matrix
void set_system_matrix(const arma::mat &matrix)
Sets the matrix of ODE system.
Definition: linear_ode_solver.cc:36
LinearODESolver
Class for linear ODE solver.
Definition: linear_ode_solver.hh:37
Armor::mat
ArmaMat< double, N, M > mat
Definition: armor.hh:888
LinearODESolver::rhs_
arma::vec rhs_
the column vector of RHS values (not used currently)
Definition: linear_ode_solver.hh:57
LinearODESolver::~LinearODESolver
~LinearODESolver()
Definition: linear_ode_solver.cc:32
LinearODESolver::update_solution
void update_solution(arma::vec &init_vec, arma::vec &output_vec)
Updates solution of the ODEs system.
Definition: linear_ode_solver.cc:48
global_defs.h
Global macros to enhance readability and debugging, general constants.
LinearODESolver::step_changed_
bool step_changed_
flag is true if the step has been changed
Definition: linear_ode_solver.hh:59
LinearODESolver::solution_matrix_
arma::mat solution_matrix_
the square solution matrix (exponential of system matrix)
Definition: linear_ode_solver.hh:56
LinearODESolver::LinearODESolver
LinearODESolver()
Definition: linear_ode_solver.cc:26