Flow123d  master-f44eb46
linear_ode_solver.cc
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.cc
15  * @brief
16  */
17 
19 
20 #include "armadillo"
21 #include "input/accessors.hh"
22 
23 using namespace Input::Type;
24 
25 
27 : step_(0), step_changed_(true),
28  system_matrix_changed_(false)
29 {
30 }
31 
33 {
34 }
35 
37 {
38  system_matrix_ = matrix;
40 }
41 
42 void LinearODESolver::set_step(double step)
43 {
44  step_ = step;
45  step_changed_ = true;
46 }
47 
48 void LinearODESolver::update_solution(arma::vec& init_vector, arma::vec& output_vec)
49 {
51  {
52  solution_matrix_ = arma::expmat(system_matrix_*step_); //coefficients multiplied by time
53  step_changed_ = false;
54  system_matrix_changed_ = false;
55  }
56 
57  output_vec = solution_matrix_ * init_vector;
58 }
59 
60 
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
bool step_changed_
flag is true if the step has been changed
ArmaMat< double, N, M > mat
Definition: armor.hh:888
ArmaVec< double, N > vec
Definition: armor.hh:885