Flow123d  3.9.0-9663d1cde
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 
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
linear_ode_solver.hh
LinearODESolver::set_step
void set_step(double step)
Sets the step of the numerical method.
Definition: linear_ode_solver.cc:42
LinearODESolver::system_matrix_
arma::mat system_matrix_
the square matrix of ODE system
Definition: linear_ode_solver.hh:55
LinearODESolver::set_system_matrix
void set_system_matrix(const arma::mat &matrix)
Sets the matrix of ODE system.
Definition: linear_ode_solver.cc:36
Armor::mat
ArmaMat< double, N, M > mat
Definition: armor.hh:888
accessors.hh
LinearODESolver::~LinearODESolver
~LinearODESolver()
Definition: linear_ode_solver.cc:32
Input::Type
Definition: balance.hh:41
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
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