ode-toolbox

ODE integration tools
git clone https://git.0xfab.ch/ode-toolbox.git
Log | Files | Refs | README | LICENSE

commit 34bdb09e38ca79d613ad830b9c926e09f9ccf232
parent 4f8402b4c5168751e5ad70f67d640581d1d2c0f0
Author: Fabian Wermelinger <fabianw@mavt.ethz.ch>
Date:   Mon, 26 Sep 2016 08:41:22 +0200

introduced default type argument for Trhs

Diffstat:
MTimeStepper/KernelBase.h | 2+-
MTimeStepper/StepperBase.h | 18+++++++++++-------
MTimeStepper/orderVerification/orderVerification.cpp | 24++++++++++++------------
3 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/TimeStepper/KernelBase.h b/TimeStepper/KernelBase.h @@ -14,7 +14,7 @@ using Real = float; using Real = double; #endif -template <typename Tinput, typename Trhs> +template <typename Tinput, typename Trhs=Tinput> class KernelBase { KernelBase(KernelBase const& c) = delete; diff --git a/TimeStepper/StepperBase.h b/TimeStepper/StepperBase.h @@ -9,18 +9,22 @@ #include "KernelBase.h" // forward declarations -template <typename Tinput, typename Trhs> +template <typename Tinput, typename Trhs=Tinput> class StepperBase; -template <typename Tinput, typename Trhs> +template <typename Tinput, typename Trhs=Tinput> class Euler; -template <typename Tinput, typename Trhs> +template <typename Tinput, typename Trhs=Tinput> class RK4; -template <typename Tinput, typename Trhs> +template <typename Tinput, typename Trhs=Tinput> class LSRK3; -template <typename Tinput, typename Trhs> +template <typename Tinput, typename Trhs=Tinput> class RKF45; -template <typename Tinput, typename Trhs> +template <typename Tinput, typename Trhs=Tinput> class RKV56; +#ifdef _USE_SUNDIALS_ +template <typename Tinput, typename Trhs=Tinput> +class BDF; +#endif /* _USE_SUNDIALS_ */ #ifdef _FLOAT_PRECISION_ using Real = float; @@ -85,7 +89,7 @@ struct StepperSettings printf("\tError PI control beta = %e\n", beta); } - template <typename Tinput, typename Trhs> + template <typename Tinput, typename Trhs=Tinput> StepperBase<Tinput,Trhs>* stepperFactory(ArgumentParser& p, Tinput& U, KernelBase<Tinput,Trhs> * const kern=nullptr) { assert(kern != nullptr); diff --git a/TimeStepper/orderVerification/orderVerification.cpp b/TimeStepper/orderVerification/orderVerification.cpp @@ -20,7 +20,7 @@ using namespace std; constexpr Real DECAY = -1.0; -template <typename Tinput, typename Trhs> +template <typename Tinput, typename Trhs=Tinput> class Dahlquist : public KernelBase<Tinput,Trhs> { GnuplotDump m_gp; @@ -43,7 +43,7 @@ public: } }; -template <typename Tinput, typename Trhs> +template <typename Tinput, typename Trhs=Tinput> class DahlquistLSRK3 : public Dahlquist<Tinput,Trhs> { using Dahlquist<Tinput, Trhs>::m_a; @@ -64,8 +64,8 @@ public: // types we use using vec_t = StateVector<State1>; -using baseKernel_t = KernelBase<vec_t,vec_t>*; -using baseStepper_t = StepperBase<vec_t,vec_t>*; +using baseKernel_t = KernelBase<vec_t>*; +using baseStepper_t = StepperBase<vec_t>*; inline Real exact(const Real t, const Real c) { return exp(c*t); } @@ -107,21 +107,21 @@ int main(int argc, const char** argv) vec_t U; // kernel instances - baseKernel_t dahlquist = new Dahlquist<vec_t,vec_t>(DECAY); - baseKernel_t dahlquistLSRK3 = new DahlquistLSRK3<vec_t,vec_t>(DECAY); + baseKernel_t dahlquist = new Dahlquist<vec_t>(DECAY); + baseKernel_t dahlquistLSRK3 = new DahlquistLSRK3<vec_t>(DECAY); // setup time steppers ArgumentParser parser(argc, argv); StepperSettings S(parser); vector<pair<pair<string,Real>, baseStepper_t> > timeStepperList; - timeStepperList.push_back(make_pair(make_pair("Euler",1.0), new Euler<vec_t, vec_t>(U, S, dahlquist))); - timeStepperList.push_back(make_pair(make_pair("RK4",4.0), new RK4<vec_t, vec_t>(U, S, dahlquist))); - timeStepperList.push_back(make_pair(make_pair("LSRK3",3.0), new LSRK3<vec_t, vec_t>(U, S, dahlquistLSRK3))); - // timeStepperList.push_back(make_pair(make_pair("RKF45",5.0), new RKF45<vec_t, vec_t>(U, S, dahlquist))); - // timeStepperList.push_back(make_pair(make_pair("RKV56",6.0), new RKV56<vec_t, vec_t>(U, S, dahlquist))); + timeStepperList.push_back(make_pair(make_pair("Euler",1.0), new Euler<vec_t>(U, S, dahlquist))); + timeStepperList.push_back(make_pair(make_pair("RK4",4.0), new RK4<vec_t>(U, S, dahlquist))); + timeStepperList.push_back(make_pair(make_pair("LSRK3",3.0), new LSRK3<vec_t>(U, S, dahlquistLSRK3))); + // timeStepperList.push_back(make_pair(make_pair("RKF45",5.0), new RKF45<vec_t>(U, S, dahlquist))); + // timeStepperList.push_back(make_pair(make_pair("RKV56",6.0), new RKV56<vec_t>(U, S, dahlquist))); #ifdef _USE_SUNDIALS_ - timeStepperList.push_back(make_pair(make_pair("BDF",5.0), new BDF<vec_t, vec_t>(U, S, dahlquist))); + timeStepperList.push_back(make_pair(make_pair("BDF",5.0), new BDF<vec_t>(U, S, dahlquist))); #endif /* _USE_SUNDIALS_ */ for (size_t i = 0; i < timeStepperList.size(); ++i)