4 #ifndef CPPQEDCORE_UTILS_EVOLVED_H_INCLUDED
5 #define CPPQEDCORE_UTILS_EVOLVED_H_INCLUDED
7 #include "EvolvedFwd.h"
9 #include "core_config.h"
11 #include <boost/shared_ptr.hpp>
12 #include <boost/function.hpp>
13 #include <boost/utility.hpp>
15 #ifndef DO_NOT_USE_BOOST_SERIALIZATION
16 #include <boost/serialization/base_object.hpp>
17 #include <boost/serialization/split_member.hpp>
18 #endif // DO_NOT_USE_BOOST_SERIALIZATION
57 double getTime( )
const {
return t_;}
58 void setTime(
double t) {t_=t;}
78 void update(
double t,
double dtTry);
90 #ifndef DO_NOT_USE_BOOST_SERIALIZATION
91 friend class boost::serialization::access;
92 template<
class Archive>
93 void serialize(Archive& ar,
const unsigned int) {ar & t_ & dtDid_ & dtTry_;}
94 #endif // DO_NOT_USE_BOOST_SERIALIZATION
96 double t_, dtTry_, dtDid_;
98 const double epsRel_, epsAbs_;
116 typedef boost::shared_ptr<EvolvedIO> Ptr;
117 typedef boost::shared_ptr<const EvolvedIO> ConstPtr;
120 EvolvedIO(A&,
double dtInit,
double epsRel,
double epsAbs);
122 using TimeStepBookkeeper::operator=;
124 A & getA() {
return this->a_;}
125 A
const& getA()
const {
return this->a_;}
131 #ifndef DO_NOT_USE_BOOST_SERIALIZATION
136 template<
class Archive>
137 void save(Archive& ar,
const unsigned int)
const
138 {A temp(a_); ar & temp & boost::serialization::base_object<TimeStepBookkeeper>(*this);}
140 template<
class Archive>
141 void load(Archive& ar,
const unsigned int)
142 {A temp; ar & temp & boost::serialization::base_object<TimeStepBookkeeper>(*this); a_.reference(temp);}
144 BOOST_SERIALIZATION_SPLIT_MEMBER()
146 #endif // DO_NOT_USE_BOOST_SERIALIZATION
173 typedef boost::function<void(double, const A&, A&)>
Derivs;
175 typedef boost::shared_ptr< Evolved> Ptr;
176 typedef boost::shared_ptr<const Evolved> ConstPtr;
179 Evolved(A&, Derivs,
double dtInit,
double epsRel,
double epsAbs);
181 using TimeStepBookkeeper::operator=;
187 void step(
double deltaT
194 const Derivs getDerivs()
const {
return derivs_;}
200 virtual void step_v(
double deltaT) = 0;
201 virtual std::ostream& displayParameters_v(std::ostream&)
const = 0;
202 virtual size_t nFailedSteps_v()
const = 0;
215 void evolve(E&,
double deltaT);
234 typedef typename Evolved<A>::Ptr Ptr;
238 const Ptr
operator()(A& array, Derivs derivs,
double dtInit,
double epsRel,
double epsAbs,
240 )
const {
return make(array,derivs,dtInit,epsRel,epsAbs,scaleAbs);}
245 virtual const Ptr make(A&, Derivs,
double dtInit,
double epsRel,
double epsAbs,
const A& scaleAbs)
const = 0;
254 #endif // CPPQEDCORE_UTILS_EVOLVED_H_INCLUDED
EvolvedIO(A &, double dtInit, double epsRel, double epsAbs)
straightforward constructor
void evolveTo(E &e, double t)
evolves up to exactly time t
Factory class for Evolved types.
void evolve(E &, double deltaT)
evolves for exactly time deltaT
A common interface for (adaptive stepsize) ODE drivers.
size_t nFailedSteps() const
number of failed steps in the last timestep (delegates to pure virtual)
SteppingFunction
Enumeration for different stepping-function types, for i/o operations.
const Ptr operator()(A &array, Derivs derivs, double dtInit, double epsRel, double epsAbs, const A &scaleAbs) const
The factory member function expecting the most generic set of parameters.
TimeStepBookkeeper(double dtInit, double epsRel, double epsAbs)
straightforward constructor
void setDtTry(double dtTry)
Sets the timestep to try in the next step.
Evolved(A &, Derivs, double dtInit, double epsRel, double epsAbs)
straightforward constructor
void step(double deltaT)
takes a single adaptive step
Class for serialization of Evolved states.
std::ostream & displayParameters(std::ostream &os) const
delegates to private virtual
Bookkeeps the timestep-data of Evolved.
friend class boost::serialization::access
The serialization of A by reference leads to memory leak (for not completely understood reasons)...
double getEpsAbs() const
absolute precision
boost::function< void(double, const A &, A &)> Derivs
the strategy functor to calculate time derivative at a given time (3rd argument for output) ...
double getDtDid() const
returns the last performed timestep
double getEpsRel() const
relative precision
TimeStepBookkeeper & operator=(const TimeStepBookkeeper &)
straightforward assignment operator that avoids self-assignment
double getDtTry() const
returns the timestep to try in the next step
virtual ~EvolvedIO()
necessary in order that EvolvedIO be polymorphic
Comprises utilities related to ODE adaptive evolution.