From c514d77b6f47359f89e8825b7f454b7c23b34a70 Mon Sep 17 00:00:00 2001 From: Rainer Backofen <rainer.backofen@tu-dresden.de> Date: Mon, 6 Jun 2011 12:30:18 +0000 Subject: [PATCH] extended interface for Rosenbrock analog to standard AdaptInstat --- AMDiS/src/ElInfo2d.cc | 73 ++++++++++--------- AMDiS/src/time/RosenbrockAdaptInstationary.cc | 39 ++++++++-- AMDiS/src/time/RosenbrockAdaptInstationary.h | 24 ++++++ 3 files changed, 92 insertions(+), 44 deletions(-) diff --git a/AMDiS/src/ElInfo2d.cc b/AMDiS/src/ElInfo2d.cc index 1d6aa035..1988a540 100644 --- a/AMDiS/src/ElInfo2d.cc +++ b/AMDiS/src/ElInfo2d.cc @@ -163,44 +163,45 @@ namespace AMDiS { if (nb->getFirstChild() && edgeNo != 2) { - - // Search for the next neighbour. In many cases, the neighbour element - // may be refinemed in a way, such that there is no new vertex on the - // common edge. This situation is shown in the following picture: - // - // /|\ - // / | \ - // / | \ - // /\ | \ - // / \ | \ - // / \| \ - // ------------- - // - // nb el - // - // Note that we know (because of the last if statement), that the - // neighbour element has children and the common edge is not the - // refinement edge, which has always the number 2, of our element. - + /* + * Search for the next neighbour. In many cases, the neighbour element + * may be refinemed in a way, such that there is no new vertex on the + * common edge. This situation is shown in the following picture: + * + * /|\ + * / | \ + * / | \ + * /\ | \ + * / \ | \ + * / \| \ + * ------------- + * + * nb el + * + * Note that we know (because of the last if statement), that the + * neighbour element has children and the common edge is not the + * refinement edge, which has always the number 2, of our element. + */ if (edgeNo == 0) { - // The situation is as follows: - // - // ------- - // \ /|\ - // \ / | \ - // \/ | \ - // \ | \ - // \ | \ - // \| \ - // ------- - // - // nb el - // - // That means, the edge 0 of the same level neighbour is the common - // edge, i.e., the direct neighbour is the second child of the same - // level neighbour. - + /* + * The situation is as follows: + * + * ------- + * \ /|\ + * \ / | \ + * \/ | \ + * \ | \ + * \ | \ + * \| \ + * ------- + * + * nb el + * + * That means, the edge 0 of the same level neighbour is the common + * edge, i.e., the direct neighbour is the second child of the same + * level neighbour. + */ nb = neighbour[i] = nb->getSecondChild(); } else { // The situation is as shown in the picture above. So the next diff --git a/AMDiS/src/time/RosenbrockAdaptInstationary.cc b/AMDiS/src/time/RosenbrockAdaptInstationary.cc index 97ffa941..2b1477b0 100644 --- a/AMDiS/src/time/RosenbrockAdaptInstationary.cc +++ b/AMDiS/src/time/RosenbrockAdaptInstationary.cc @@ -32,27 +32,50 @@ namespace AMDiS { tauGamma(1.0) { FUNCNAME("RosenbrockAdaptInstationary::RosenbrockAdaptInstationary()"); + initConstructor(problemStat); + } + RosenbrockAdaptInstationary::RosenbrockAdaptInstationary(std::string name, + RosenbrockStationary &problemStat, + AdaptInfo &info, + ProblemTimeInterface &problemInstat, + AdaptInfo &initialInfo, + time_t initialTimestamp) + : AdaptInstationary(name, problemStat, info, problemInstat, initialInfo, initialTimestamp), + rosenbrockStat(&problemStat), + firstTimestep(true), + lastTimestepRejected(false), + succRejection(false), + fixFirstTimesteps(0), + tau(1.0), + tauGamma(1.0) + { + FUNCNAME("RosenbrockAdaptInstationary::RosenbrockAdaptInstationary()"); + initConstructor(&problemStat); + } + void RosenbrockAdaptInstationary::initConstructor( + RosenbrockStationary *problemStat) + { std::string str; Parameters::get(name + "->rosenbrock method", str); RosenbrockMethodCreator *creator = - dynamic_cast<RosenbrockMethodCreator*>(CreatorMap<RosenbrockMethod>::getCreator(str)); + dynamic_cast<RosenbrockMethodCreator*>(CreatorMap<RosenbrockMethod>::getCreator(str)); rosenbrockMethod = creator->create(); - + TEST_EXIT_DBG(rosenbrockMethod)("This should not happen!\n"); - + Parameters::get(name + "->fix first timesteps", fixFirstTimesteps); problemStat->setRosenbrockMethod(rosenbrockMethod); - + adaptInfo->setRosenbrockMode(true); - + problemStat->setTauGamma(&tauGamma); problemStat->setTau(&tau); - } + } - void RosenbrockAdaptInstationary::oneTimestep() - { + void RosenbrockAdaptInstationary::oneTimestep() + { FUNCNAME("RosenbrockAdaptInstationary::oneTimestep()"); // estimate before first adaption diff --git a/AMDiS/src/time/RosenbrockAdaptInstationary.h b/AMDiS/src/time/RosenbrockAdaptInstationary.h index 97b5b683..e9fc31a9 100644 --- a/AMDiS/src/time/RosenbrockAdaptInstationary.h +++ b/AMDiS/src/time/RosenbrockAdaptInstationary.h @@ -34,6 +34,11 @@ namespace AMDiS { class RosenbrockAdaptInstationary : public AdaptInstationary { public: +/** \brief + * Creates a AdaptInstationary object for Rosenbrock method + * with the given name for the time + * dependent problem problemInstat. TODO: Make obsolete! + */ RosenbrockAdaptInstationary(std::string name, RosenbrockStationary *problemStat, AdaptInfo *info, @@ -41,8 +46,27 @@ namespace AMDiS { AdaptInfo *initialInfo, time_t initialTimestamp = 0); +/** \brief + * Creates a AdaptInstationary object for Rosenbrock method + * with the given name for the time + * dependent problem problemInstat. + */ + RosenbrockAdaptInstationary(std::string name, + RosenbrockStationary &problemStat, + AdaptInfo &info, + ProblemTimeInterface &problemInstat, + AdaptInfo &initialInfo, + time_t initialTimestamp = 0); + /// Runs the Rosenbrock loop until one timestep is accepted. void oneTimestep(); +/** \brief + * This funciton is used only to avoid double code in both constructors. If the + * obsolte constructure, which uses pointers instead of references, will be + * removed, remove also this function. + * TODO: Remove if obsolete constructor will be removed. + */ + void initConstructor(RosenbrockStationary *problemStat); protected: /// Pointer to the Rosenbrock method that should be used. -- GitLab