Flow123d  master-ae9ffcc
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_
Definitions of ASSERTS.
Class for linear ODE solver.
void set_step(double step)
Sets the step of the numerical method.
arma::mat solution_matrix_
the square solution matrix (exponential of system matrix)
void set_system_matrix(const arma::mat &matrix)
Sets the matrix of ODE system.
void update_solution(arma::vec &init_vec, arma::vec &output_vec)
Updates solution of the ODEs system.
bool system_matrix_changed_
Indicates that the system_matrix_ was recently updated.
double step_
the step of the numerical method
arma::mat system_matrix_
the square matrix of ODE system
arma::vec rhs_
the column vector of RHS values (not used currently)
bool step_changed_
flag is true if the step has been changed
Global macros to enhance readability and debugging, general constants.
ArmaMat< double, N, M > mat
Definition: armor.hh:936
ArmaVec< double, N > vec
Definition: armor.hh:933