libode
Easy to compile, fast ODE integrators as C++ classes
Loading...
Searching...
No Matches
ode_adaptive.h
Go to the documentation of this file.
1#ifndef ODE_ADAPTIVE_H_
2#define ODE_ADAPTIVE_H_
3
5
6#include <cstdio>
7#include <cmath>
8#include <vector>
9#include <cstring>
10#include <string>
11
12#include "ode_io.h"
13#include "ode_util.h"
14#include "ode_base.h"
15
16namespace ode {
17
19
30class OdeAdaptive : public OdeBase {
31
32 public:
34
38 OdeAdaptive (unsigned long neq, bool need_jac);
40 virtual ~OdeAdaptive ();
41
42 //-------------------
43 //getters and setters
44
46 long unsigned get_nrej () { return(nrej_); }
48 double get_abstol () { return(abstol_); }
50 double get_reltol () { return(reltol_); }
52 double get_dtmax () { return(dtmax_); }
53
55 void set_abstol (double tol) { abstol_ = tol; };
57 void set_reltol (double tol) { reltol_ = tol; };
59 void set_tol (double tol) { abstol_ = tol; reltol_ = tol; };
61 void set_dtmax (double dtmax) { dtmax_ = dtmax; }
62
63 //---------------------------------------
64 //integration with adaptive time stepping
65
67
72 void solve_adaptive (double tint, double dt0, bool extras=true);
73
75
81 void solve_adaptive (double tint, double dt0, const char *dirout, int inter);
82
84
90 void solve_adaptive (double tint, double dt0, unsigned long nsnap, const char *dirout);
91
93
99 void solve_adaptive (double dt0, double *tsnap, unsigned long nsnap, const char *dirout);
100
101 protected:
102
104
109 void solve_adaptive_ (double tint, double dt0, bool extra=true);
110
111 //------------------------
112 //basic adaptive variables
113
115 long unsigned nrej_;
117 double abstol_;
119 double reltol_;
121 double dtmax_;
122
124 virtual void adapt (double abstol, double reltol);
126 virtual bool is_rejected ();
128 virtual double dt_adapt ();
129
131 bool solve_done_adaptive (double tend);
132
133 //wrappers
135 bool step_adaptive_ (double dt, bool extra=true);
137 double dt_adapt_ (double tend);
138
139 private:
141 double *solprev_;
142};
143
144} // namespace ode
145
146#endif
Base class implementing solver functions with adaptive time steps.
long unsigned get_nrej()
gets the count of rejected steps
void set_reltol(double tol)
sets the relative error tolerance
void set_tol(double tol)
sets the absolute and relative error tolerance to the same value
double reltol_
absolute error tolerance
double dt_adapt_(double tend)
wrapper around dt_adapt() to perform additional checks
long unsigned nrej_
counter for rejected steps
double dtmax_
maximum allowable time step
void solve_adaptive_(double tint, double dt0, bool extra=true)
integrates without output or any counters, trackers, extra functions...
double get_dtmax()
gets the maximum allowable time step
virtual ~OdeAdaptive()
destructs
double get_reltol()
gets the relative error tolerance
bool solve_done_adaptive(double tend)
determines whether an adaptive solve is finished
bool step_adaptive_(double dt, bool extra=true)
executes a single time and calls all necessary adapting functions
void set_abstol(double tol)
sets the absolute error tolerance
double abstol_
absolute error tolerance
void solve_adaptive(double tint, double dt0, bool extras=true)
integrates for a specified duration of independent variable without output
double get_abstol()
gets the absolute error tolerance
virtual bool is_rejected()
retreives a bool determining whether a step is accepted/rejected, false by default
OdeAdaptive(unsigned long neq, bool need_jac)
constructs
virtual double dt_adapt()
retrieves the best time step for the next step
void set_dtmax(double dtmax)
sets the maximum allowable time step
virtual void adapt(double abstol, double reltol)
executes whatever calculations need to be performed for adapting, including a determination of whethe...
Lowest base class for all solvers.
Definition ode_base.h:184