Flow123d
release_3.0.0-973-g92f55e826
flow123d
src
reaction
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
18
#include "
reaction/linear_ode_solver.hh
"
19
20
#include "armadillo"
21
#include "
input/accessors.hh
"
22
23
using namespace
Input::Type
;
24
25
26
LinearODESolver::LinearODESolver
()
27
: step_(0), step_changed_(true),
28
system_matrix_changed_(false)
29
{
30
}
31
32
LinearODESolver::~LinearODESolver
()
33
{
34
}
35
36
void
LinearODESolver::set_system_matrix
(
const
arma::mat& matrix)
37
{
38
system_matrix_
= matrix;
39
system_matrix_changed_
=
true
;
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
{
50
if
(
step_changed_
||
system_matrix_changed_
)
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:64
LinearODESolver::step_
double step_
the step of the numerical method
Definition:
linear_ode_solver.hh:62
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:59
LinearODESolver::set_system_matrix
void set_system_matrix(const arma::mat &matrix)
Sets the matrix of ODE system.
Definition:
linear_ode_solver.cc:36
accessors.hh
LinearODESolver::~LinearODESolver
~LinearODESolver()
Definition:
linear_ode_solver.cc:32
Input::Type
Definition:
balance.hh:38
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: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
Generated by
1.8.17