From c9a56148003bc0e695d152bae08a767caed47943 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Fri, 21 May 2010 08:49:13 +0000 Subject: [PATCH] First working Rosenbrock method implementation finished, part 2. --- AMDiS/src/time/RosenbrockMethod.cc | 165 +++++++++++++++++++++++++ AMDiS/src/time/RosenbrockMethod.h | 188 +++++++++++++++++++++++++++++ 2 files changed, 353 insertions(+) create mode 100644 AMDiS/src/time/RosenbrockMethod.cc create mode 100644 AMDiS/src/time/RosenbrockMethod.h diff --git a/AMDiS/src/time/RosenbrockMethod.cc b/AMDiS/src/time/RosenbrockMethod.cc new file mode 100644 index 00000000..2efed80e --- /dev/null +++ b/AMDiS/src/time/RosenbrockMethod.cc @@ -0,0 +1,165 @@ +#include "time/RosenbrockMethod.h" + +namespace AMDiS { + + void RosenbrockMethod::createData() + { + a.resize(stages); + for (int i = 0; i < stages; i++) { + a[i].resize(stages); + for (int j = 0; j < stages; j++) + a[i][j] = 0.0; + } + + c.resize(stages); + for (int i = 0; i < stages; i++) { + c[i].resize(stages); + for (int j = 0; j < stages; j++) + c[i][j] = 0.0; + } + + m1.resize(stages); + m2.resize(stages); + for (int i = 0; i < stages; i++) { + m1[i] = 0.0; + m2[i] = 0.0; + } + } + + + Ros2::Ros2() + { + order = 2; + stages = 2; + gamma = 1.707106781186547; + + createData(); + + a[1][0] = 5.857864376269050e-01; + + c[0][0] = 5.857864376269050e-01; + c[1][0] = 1.171572875253810e+00; + c[1][1] = 5.857864376269050e-01; + + m1[0] = 8.786796564403575e-01; + m1[1] = 2.928932188134525e-01; + + m2[0] = 5.857864376269050e-01; + } + + + Rowda3::Rowda3() + { + order = 3; + stages = 3; + gamma = 4.358665215084590e-01; + + createData(); + + a[1][0] = 1.605996252195329e+00; + a[2][0] = 1.605996252195329e+00; + + c[0][0] = 2.294280360279042e+00; + c[1][0] = -8.874044410657833e-01; + c[1][1] = 2.294280360279042e+00; + c[2][0] = -2.398747971635036e+01; + c[2][1] = -5.263722371562129e+00; + c[2][2] = 2.294280360279042e+00; + + m1[0] = 2.236727045296590e+00; + m1[1] = 2.250067730969644e+00; + m1[2] = -2.092514044390320e-01; + + m2[0] = 2.059356167645940e+00; + m2[1] = 1.694014319346528e-01; + } + + + Ros3p::Ros3p() + { + order = 3; + stages = 3; + gamma = 7.886751345948129e-01; + + createData(); + + a[1][0] = 1.267949192431123e+00; + a[2][0] = 1.267949192431123e+00; + + c[0][0] = 1.267949192431123e+00; + c[1][0] = 1.607695154586739e+00; + c[1][1] = 1.267949192431123e+00; + c[2][0] = 3.462101615137755e+00; + c[2][1] = 1.732050807568877e+00; + c[2][2] = 1.267949192431123e+00; + + m1[0] = 2.0; + m1[1] = 5.773502691896258e-01; + m1[2] = 4.226497308103742e-01; + + m2[0] = 2.113248654051871e+00; + m2[1] = 1.0; + m2[2] = 4.226497308103742e-01; + } + + + Rodasp::Rodasp() + { + order = 4; + stages = 6; + gamma = 2.5e-01; + + createData(); + + a[1][0] = 3.0; + a[2][0] = 1.831036793486759e+00; + a[2][1] = 4.955183967433795e-01; + a[3][0] = 2.304376582692669e+00; + a[3][1] = -5.249275245743001e-02; + a[3][2] = -1.176798761832782e+00; + a[4][0] = -7.170454962423025e+00; + a[4][1] = -4.741636671481786e+00; + a[4][2] = -1.631002631330971e+01; + a[4][3] = -1.062004044111401e+00; + a[5][0] = -7.170454962423025e+00; + a[5][1] = -4.741636671481785e+00; + a[5][2] = -1.631002631330971e+01; + a[5][3] = -1.062004044111401e+00; + a[5][4] = 1.0; + + c[0][0] = 4.0; + c[1][0] = 1.200000000000000e+01; + c[1][1] = 4.0; + c[2][0] = 8.791795173947035e+00; + c[2][1] = 2.207865586973518e+00; + c[2][2] = 4.0; + c[3][0] = -1.081793056857153e+01; + c[3][1] = -6.780270611428266e+00; + c[3][2] = -1.953485944642410e+01; + c[3][3] = 4.0; + c[4][0] = -3.419095006749677e+01; + c[4][1] = -1.549671153725963e+01; + c[4][2] = -5.474760875964130e+01; + c[4][3] = -1.416005392148534e+01; + c[4][4] = 4.0; + c[5][0] = -3.462605830930533e+01; + c[5][1] = -1.530084976114473e+01; + c[5][2] = -5.699955578662667e+01; + c[5][3] = -1.840807009793095e+01; + c[5][4] = 5.714285714285717e+00; + c[5][5] = 4.0; + + m1[0] = -7.170454962423026e+00; + m1[1] = -4.741636671481786e+00; + m1[2] = -1.631002631330971e+01; + m1[3] = -1.062004044111401e+00; + m1[4] = 1.0; + m1[5] = 1.0; + + m2[0] = -7.170454962423026e+00; + m2[1] = -4.741636671481786e+00; + m2[2] = -1.631002631330971e+01; + m2[3] = -1.062004044111401e+00; + m2[4] = 1.0; + } +} diff --git a/AMDiS/src/time/RosenbrockMethod.h b/AMDiS/src/time/RosenbrockMethod.h new file mode 100644 index 00000000..777b0295 --- /dev/null +++ b/AMDiS/src/time/RosenbrockMethod.h @@ -0,0 +1,188 @@ +// ============================================================================ +// == == +// == AMDiS - Adaptive multidimensional simulations == +// == == +// ============================================================================ +// == == +// == TU Dresden == +// == == +// == Institut für Wissenschaftliches Rechnen == +// == Zellescher Weg 12-14 == +// == 01069 Dresden == +// == germany == +// == == +// ============================================================================ +// == == +// == https://gforge.zih.tu-dresden.de/projects/amdis/ == +// == == +// ============================================================================ + +/** \file RosenbrochMethod.h */ + +#ifndef AMDIS_ROSENBROCKMETHOD_H +#define AMDIS_ROSENBROCKMETHOD_H + +#include "AMDiS_fwd.h" +#include "CreatorInterface.h" + +namespace AMDiS { + + class RosenbrockMethod + { + public: + RosenbrockMethod() {} + + virtual ~RosenbrockMethod() {} + + inline int getOrder() + { + return order; + } + + inline int getStages() + { + return stages; + } + + inline double getGamma() + { + return gamma; + } + + inline double getA(int i, int j) + { + return a[i][j]; + } + + inline double getC(int i, int j) + { + return c[i][j]; + } + + inline double getM1(int i) + { + return m1[i]; + } + + inline double getM2(int i) + { + return m2[i]; + } + + protected: + void createData(); + + protected: + int order; + + int stages; + + double gamma; + + std::vector<std::vector<double> > a; + + std::vector<std::vector<double> > c; + + std::vector<double> m1; + + std::vector<double> m2; + }; + + class RosenbrockMethodCreator : public CreatorInterface<RosenbrockMethod> + { + public: + RosenbrockMethodCreator() + {} + }; + + + class Ros2 : public RosenbrockMethod + { + public: + class Creator : public RosenbrockMethodCreator + { + public: + Creator() : RosenbrockMethodCreator() {} + + ~Creator() {} + + RosenbrockMethod* create() + { + return new Ros2(); + } + }; + + Ros2(); + + ~Ros2() {} + }; + + + class Rowda3 : public RosenbrockMethod + { + public: + class Creator : public RosenbrockMethodCreator + { + public: + Creator() : RosenbrockMethodCreator() {} + + ~Creator() {} + + RosenbrockMethod* create() + { + return new Rowda3(); + } + }; + + Rowda3(); + + ~Rowda3() {} + }; + + + class Ros3p : public RosenbrockMethod + { + public: + class Creator : public RosenbrockMethodCreator + { + public: + Creator() : RosenbrockMethodCreator() {} + + ~Creator() {} + + RosenbrockMethod* create() + { + return new Ros3p(); + } + }; + + Ros3p(); + + ~Ros3p() {} + }; + + + class Rodasp : public RosenbrockMethod + { + public: + class Creator : public RosenbrockMethodCreator + { + public: + Creator() : RosenbrockMethodCreator() {} + + ~Creator() {} + + RosenbrockMethod* create() + { + return new Rodasp(); + } + }; + + Rodasp(); + + ~Rodasp() {} + }; + +} + +#endif // AMDIS_ROSENBROCKMETHOD_H -- GitLab