23 #ifndef STEPCORE_GSLSOLVER_H
24 #define STEPCORE_GSLSOLVER_H
27 #if defined(STEPCORE_WITH_GSL) || defined(Q_MOC_RUN)
32 #include <gsl/gsl_odeiv.h>
44 class GslGenericSolver:
public Solver
50 GslGenericSolver(
double stepSize,
bool adaptive, const gsl_odeiv_step_type* gslStepType)
51 : Solver(stepSize), _adaptive(adaptive), _gslStepType(gslStepType) { init(); }
53 GslGenericSolver(
int dimension, Function
function,
void* params,
double stepSize,
54 bool adaptive,
const gsl_odeiv_step_type* gslStepType)
55 : Solver(dimension, function, params, stepSize),
56 _adaptive(adaptive), _gslStepType(gslStepType) { init(); }
58 GslGenericSolver(
const GslGenericSolver& gslSolver)
59 : Solver(gslSolver), _adaptive(gslSolver._adaptive),
60 _gslStepType(gslSolver._gslStepType) { init(); }
62 ~GslGenericSolver() { fini(); }
64 void setDimension(
int dimension) { fini(); _dimension = dimension; init(); }
65 void setToleranceAbs(
double toleranceAbs) { fini(); _toleranceAbs = toleranceAbs; init(); }
66 void setToleranceRel(
double toleranceRel) { fini(); _toleranceRel = toleranceRel; init(); }
73 static int gslFunction(
double t,
const double* y,
double* f,
void* params);
87 const gsl_odeiv_step_type* _gslStepType;
88 gsl_odeiv_system _gslSystem;
89 gsl_odeiv_step* _gslStep;
90 gsl_odeiv_control* _gslControl;
91 gsl_odeiv_evolve* _gslEvolve;
97 class GslSolver:
public GslGenericSolver
101 GslSolver(
double stepSize, const gsl_odeiv_step_type* gslStepType):
102 GslGenericSolver(stepSize, false, gslStepType) {}
103 GslSolver(
int dimension, Function
function,
void* params,
double stepSize,
104 const gsl_odeiv_step_type* gslStepType)
105 : GslGenericSolver(dimension, function, params, stepSize, false, gslStepType) {}
106 GslSolver(
const GslSolver& gslSolver): GslGenericSolver(gslSolver) {}
112 class GslAdaptiveSolver:
public GslGenericSolver
116 GslAdaptiveSolver(const gsl_odeiv_step_type* gslStepType):
117 GslGenericSolver(1, true, gslStepType) {}
118 GslAdaptiveSolver(
int dimension, Function
function,
void* params,
119 const gsl_odeiv_step_type* gslStepType)
120 : GslGenericSolver(dimension, function, params, 1, true, gslStepType) {}
121 GslAdaptiveSolver(
const GslAdaptiveSolver& gslSolver): GslGenericSolver(gslSolver) {}
124 #define STEPCORE_DECLARE_GSLSOLVER(Class, type) \
125 class Gsl##Class##Solver: public GslSolver { \
126 STEPCORE_OBJECT(Gsl##Class##Solver) \
128 Gsl##Class##Solver(double stepSize = 0.01): GslSolver(stepSize, gsl_odeiv_step_##type) {} \
129 Gsl##Class##Solver(int dimension, Function function, void* params, double stepSize) \
130 : GslSolver(dimension, function, params, stepSize, gsl_odeiv_step_##type) {} \
131 Gsl##Class##Solver(const Gsl##Class##Solver& gslSolver): GslSolver(gslSolver) {} \
134 #define STEPCORE_DECLARE_GSLASOLVER(Class, type) \
135 class GslAdaptive##Class##Solver: public GslAdaptiveSolver { \
136 STEPCORE_OBJECT(GslAdaptive##Class##Solver) \
138 GslAdaptive##Class##Solver(): GslAdaptiveSolver(gsl_odeiv_step_##type) {} \
139 GslAdaptive##Class##Solver(int dimension, Function function, void* params) \
140 : GslAdaptiveSolver(dimension, function, params, gsl_odeiv_step_##type) {} \
141 GslAdaptive##Class##Solver(const GslAdaptive##Class##Solver& gslSolver): GslAdaptiveSolver(gslSolver) {} \
148 STEPCORE_DECLARE_GSLSOLVER(RK2, rk2)
154 STEPCORE_DECLARE_GSLASOLVER(RK2, rk2)
160 STEPCORE_DECLARE_GSLSOLVER(RK4, rk4)
166 STEPCORE_DECLARE_GSLASOLVER(RK4, rk4)
172 STEPCORE_DECLARE_GSLSOLVER(RKF45, rkf45)
178 STEPCORE_DECLARE_GSLASOLVER(RKF45, rkf45)
184 STEPCORE_DECLARE_GSLSOLVER(RKCK, rkck)
190 STEPCORE_DECLARE_GSLASOLVER(RKCK, rkck)
196 STEPCORE_DECLARE_GSLSOLVER(RK8PD, rk8pd)
202 STEPCORE_DECLARE_GSLASOLVER(RK8PD, rk8pd)
208 STEPCORE_DECLARE_GSLSOLVER(RK2IMP, rk2imp)
214 STEPCORE_DECLARE_GSLASOLVER(RK2IMP, rk2imp)
220 STEPCORE_DECLARE_GSLSOLVER(RK4IMP, rk4imp)
226 STEPCORE_DECLARE_GSLASOLVER(RK4IMP, rk4imp)
230 #endif // defined(STEPCORE_WITH_GSL) || defined(Q_MOC_RUN)
232 #endif // STEPCORE_GSLSOLVER_H
Object, MetaObject and MetaProperty classes.
#define STEPCORE_OBJECT(_className)