Flow123d  jenkins-Flow123d-linux-release-multijob-282
linear_ode_analytic.cc
Go to the documentation of this file.
1 
3 #include "input/accessors.hh"
4 #include "system/sys_profiler.hh"
5 
6 using namespace Input::Type;
7 
9  = Record("LinearODEAnalytic", "Evaluate analytic solution of the system of ODEs.")
11 
13 {
14 }
15 
17 {
18 }
19 
20 void LinearODEAnalytic::update_solution(arma::vec& init_vector, arma::vec& output_vec)
21 {
22  if(step_changed_)
23  {
24  compute_matrix();
25  step_changed_ = false;
26  }
27 
28  output_vec = solution_matrix_ * init_vector;
29 }
30 
32 {
33  START_TIMER("ODEAnalytic::compute_matrix");
34 
35  ASSERT(system_matrix_.n_cols == system_matrix_.n_rows, "Matrix is not square.");
36  solution_matrix_.copy_size(system_matrix_);
37 
38  double exponential, temp;
39  for(unsigned int i = 0; i < solution_matrix_.n_rows; i++)
40  {
41  exponential = std::exp(system_matrix_(i,i) * step_);
42  for(unsigned int j = 0; j < solution_matrix_.n_cols; j++)
43  {
44  temp = 1.0;
45  if( (i != j) && (system_matrix_(i,i) != 0.0) )
46  temp = -system_matrix_(j,i)/system_matrix_(i,i);
47 
48  solution_matrix_(j,i) = (1-exponential)*temp;
49  }
50  solution_matrix_(i,i) = exponential;
51  }
52 }
static Input::Type::AbstractRecord input_type
Record & derive_from(AbstractRecord &parent)
Definition: type_record.cc:197
#define ASSERT(...)
Definition: global_defs.h:121
void update_solution(arma::vec &init_vector, arma::vec &output_vec) override
Updates solution of the ODEs system.
Accessor to the data with type Type::Record.
Definition: accessors.hh:327
#define START_TIMER(tag)
Starts a timer with specified tag.
~LinearODEAnalytic(void)
Destructor.
LinearODEAnalytic()
Default constructor is possible because the input record is not needed.
static Input::Type::Record input_type
Record type proxy class.
Definition: type_record.hh:169