Flow123d  JS_before_hm-1710-g489f4168f
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/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(FMT_UNUSED 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_
LinearODESolver::system_matrix_changed_
bool system_matrix_changed_
Indicates that the system_matrix_ was recently updated.
Definition: linear_ode_solver.hh:64
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:62
LinearODESolver::evaluate_time_constraint
virtual bool evaluate_time_constraint(FMT_UNUSED double &time_constraint)
Estimate upper bound for time step. Return true if constraint was set.
Definition: linear_ode_solver.hh:56
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:59
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:38
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:61
LinearODESolver::~LinearODESolver
~LinearODESolver()
Definition: linear_ode_solver.cc:32
exc_common.hh
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:63
LinearODESolver::solution_matrix_
arma::mat solution_matrix_
the square solution matrix (exponential of system matrix)
Definition: linear_ode_solver.hh:60
LinearODESolver::LinearODESolver
LinearODESolver()
Definition: linear_ode_solver.cc:26
FMT_UNUSED
#define FMT_UNUSED
Definition: posix.h:75