Flow123d  release_3.0.0-966-gb002c76
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 #include <boost/exception/detail/error_info_impl.hpp> // for error_info
22 #include <boost/exception/info.hpp> // for operator<<
23 #include <iosfwd> // for stringstream
24 #include <string> // for string, basic_...
25 #include <vector> // for vector
26 #include "armadillo"
27 #include "system/exc_common.hh" // for ExcAssertMsg
28 #include "system/exceptions.hh" // for ExcAssertMsg::...
29 #include "system/global_defs.h" // for msg, rank, OLD...
30 #include "system/asserts.hh"
31 
32 
33 /// @brief Class for linear ODE solver.
34 /** This class represents the solver of a system of linear ordinary differential
35  * equations with constant coefficients which uses matrix exponential to compute
36  * the solution at given times.
37  */
39 {
40 public:
41 
44 
45  void set_system_matrix(const arma::mat &matrix); ///< Sets the matrix of ODE system.
46  void set_step(double step); ///< Sets the step of the numerical method.
47 
48  /// Updates solution of the ODEs system.
49  /**
50  * @param init_vec is the column initial vector
51  * @param output_vec is the column output vector containing the result
52  */
53  void update_solution(arma::vec &init_vec, arma::vec &output_vec);
54 
55  /// Estimate upper bound for time step. Return true if constraint was set.
56  virtual bool evaluate_time_constraint(double &time_constraint) { return false; }
57 
58 protected:
59  arma::mat system_matrix_; ///< the square matrix of ODE system
60  arma::mat solution_matrix_; ///< the square solution matrix (exponential of system matrix)
61  arma::vec rhs_; ///< the column vector of RHS values (not used currently)
62  double step_; ///< the step of the numerical method
63  bool step_changed_; ///< flag is true if the step has been changed
64  bool system_matrix_changed_; ///< Indicates that the system_matrix_ was recently updated.
65 };
66 
67 
68 
69 #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 system_matrix_
the square matrix of ODE system
bool system_matrix_changed_
Indicates that the system_matrix_ was recently updated.
Global macros to enhance readability and debugging, general constants.
arma::mat solution_matrix_
the square solution matrix (exponential of system matrix)
arma::vec rhs_
the column vector of RHS values (not used currently)
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.
virtual bool evaluate_time_constraint(double &time_constraint)
Estimate upper bound for time step. Return true if constraint was set.
double step_
the step of the numerical method
bool step_changed_
flag is true if the step has been changed