accelerInt  v0.1
rk78_init.cpp
Go to the documentation of this file.
1 
10 //wrapper code
11 #include "rk78_typedefs.hpp"
12 
13 #ifdef GENERATE_DOCS
14 namespace rk78 {
15 #endif
16 
18 std::vector<state_type*> state_vectors;
20 std::vector<rhs_eval*> evaluators;
22 std::vector<stepper*> steppers;
24 std::vector<controller> controllers;
25 #ifdef STIFFNESS_MEASURE
26 std::vector<double> max_stepsize;
27 #include <stdio.h>
28 FILE* stepsizes;
29 #endif
30 
31 extern "C" void initialize_solver(int);
32 extern "C" void cleanup_solver(int);
33 extern "C" const char* solver_name();
34 extern "C" void init_solver_log();
35 extern "C" void solver_log();
36 
41 void initialize_solver(int num_threads) {
42  //create the necessary state vectors and evaluators
43  for (int i = 0; i < num_threads; ++i)
44  {
45  state_vectors.push_back(new state_type(NSP, 0.0));
46  evaluators.push_back(new rhs_eval());
47  steppers.push_back(new stepper());
48  controllers.push_back(make_controlled<stepper>(ATOL, RTOL, *steppers[i]));
49  }
50 }
51 
58 void cleanup_solver(int num_threads) {
59  for (int i = 0; i < state_vectors.size(); ++i)
60  {
61  delete state_vectors[i];
62  delete evaluators[i];
63  delete steppers[i];
64  controllers.pop_back();
65  }
66 #ifdef STIFFNESS_MEASURE
67  fclose(stepsizes);
68 #endif
69 }
70 
75 const char* solver_name() {
76  const char* name = "rk78-int";
77  return name;
78 }
79 
87 #ifdef STIFFNESS_MEASURE
88  stepsizes = fopen("stepsize_log.txt", "w");
89 #endif
90 }
91 
96 void solver_log() {
97 #ifdef STIFFNESS_MEASURE
98  for (int i = 0; i < max_stepsize.size(); ++i){
99  fprintf(stepsizes, "%d\t%.16e\n", i, max_stepsize[i]);
100  }
101 #endif
102 }
103 
104 #ifdef GENERATE_DOCS
105 }
106 #endif
A wrapper class to evaluate the rhs function y&#39; = f(y) stores the state variable, and provides to dyd...
std::vector< controller > controllers
ODE controllers.
Definition: rk78_init.cpp:24
std::vector< state_type * > state_vectors
State vector containers for boost.
Definition: rk78_init.cpp:18
std::vector< rhs_eval * > evaluators
RHS wrappers for boost.
Definition: rk78_init.cpp:20
const char * solver_name()
Returns a descriptive solver name.
Definition: rk78_init.cpp:75
void solver_log()
Executes solver specific logging tasks.
Definition: rk78_init.cpp:96
#define NSP
The IVP system size.
Definition: header.cuh:20
void init_solver_log()
Initializes solver specific items for logging.
Definition: rk78_init.cpp:86
std::vector< double > state_type
state vector
runge_kutta_fehlberg78< state_type, double > stepper
solver type
#define RTOL
#define ATOL
void initialize_solver(int)
Initializes the solver.
Definition: rk78_init.cpp:41
std::vector< stepper * > steppers
Addaptive timesteppers.
Definition: rk78_init.cpp:22
void cleanup_solver(int)
Cleans up the created solvers.
Definition: rk78_init.cpp:58
Defines an interface for boost&#39;s runge_kutta_fehlberg78 solver.