From a3998fdebaee6957083566f552f792b678dfd8b3 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Wed, 11 Nov 2009 16:54:45 +0000 Subject: [PATCH] Start to change pointer usage to reference usage in AMDiS interface. --- AMDiS/src/AdaptInstationary.cc | 33 +++++++++++++++++++++++++++++---- AMDiS/src/AdaptInstationary.h | 24 +++++++++++++++++++++++- AMDiS/src/AdaptStationary.cc | 13 +++++++++++++ AMDiS/src/AdaptStationary.h | 7 ++++++- AMDiS/src/ProblemInstat.cc | 14 ++++++++++++++ AMDiS/src/ProblemInstat.h | 4 ++++ AMDiS/src/ProblemScal.cc | 5 +++++ AMDiS/src/ProblemScal.h | 5 ++++- AMDiS/src/ProblemVec.cc | 5 +++++ AMDiS/src/ProblemVec.h | 5 ++++- 10 files changed, 107 insertions(+), 8 deletions(-) diff --git a/AMDiS/src/AdaptInstationary.cc b/AMDiS/src/AdaptInstationary.cc index 9200429d..e34123e0 100644 --- a/AMDiS/src/AdaptInstationary.cc +++ b/AMDiS/src/AdaptInstationary.cc @@ -20,16 +20,41 @@ namespace AMDiS { { FUNCNAME("AdaptInstationary::AdaptInstationary()"); +// MSG("You make use of the obsolete constructor AdaptInstationary::AdaptInstationary(...)!\n"); +// MSG("Please use the constructor that uses references instead of pointers!\n"); + + initConstructor(problemStat, info, initialInfo, initialTimestamp); + } + + AdaptInstationary::AdaptInstationary(std::string name, + ProblemIterationInterface &problemStat, + AdaptInfo &info, + ProblemTimeInterface &problemInstat, + AdaptInfo &initialInfo, + time_t initialTimestamp) + : AdaptBase(name, &problemStat, &info, &problemInstat, &initialInfo), + breakWhenStable(0), + dbgMode(false) + { + FUNCNAME("AdaptInstationary::AdaptInstationary()"); + + initConstructor(&problemStat, &info, &initialInfo, initialTimestamp); + } + + void AdaptInstationary::initConstructor(ProblemIterationInterface *problemStat, + AdaptInfo *info, + AdaptInfo *initialInfo, + time_t initialTimestamp) + { initialize(name); fixedTimestep_ = (info->getMinTimestep() == info->getMaxTimestep()); - if (initialTimestamp == 0) { + if (initialTimestamp == 0) initialTimestamp_ = time(NULL); - } else { + else initialTimestamp_ = initialTimestamp; - } - + // Check if the problem should be deserialized because of the -rs parameter. std::string serializationFilename = ""; GET_PARAMETER(0, "argv->rs", &serializationFilename); diff --git a/AMDiS/src/AdaptInstationary.h b/AMDiS/src/AdaptInstationary.h index 7adf1660..56faf49b 100644 --- a/AMDiS/src/AdaptInstationary.h +++ b/AMDiS/src/AdaptInstationary.h @@ -43,7 +43,7 @@ namespace AMDiS { public: /** \brief * Creates a AdaptInstationary object with the given name for the time - * dependent problem problemInstat. + * dependent problem problemInstat. TODO: Make obsolete! */ AdaptInstationary(std::string name, ProblemIterationInterface *problemStat, @@ -52,6 +52,28 @@ namespace AMDiS { AdaptInfo *initialInfo, time_t initialTimestamp = 0); + /** \brief + * Creates a AdaptInstationary object with the given name for the time + * dependent problem problemInstat. + */ + AdaptInstationary(std::string name, + ProblemIterationInterface &problemStat, + AdaptInfo &info, + ProblemTimeInterface &problemInstat, + AdaptInfo &initialInfo, + time_t initialTimestamp = 0); + + /** \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(ProblemIterationInterface *problemStat, + AdaptInfo *info, + AdaptInfo *initialInfo, + time_t initialTimestamp); + /// Destructor virtual ~AdaptInstationary(); diff --git a/AMDiS/src/AdaptStationary.cc b/AMDiS/src/AdaptStationary.cc index b45bdc0a..cb291601 100644 --- a/AMDiS/src/AdaptStationary.cc +++ b/AMDiS/src/AdaptStationary.cc @@ -11,6 +11,19 @@ namespace AMDiS { ProblemIterationInterface *prob, AdaptInfo *info) : AdaptBase(name, prob, info) + { + FUNCNAME("AdaptStationary::AdaptStationary()"); + +// MSG("You make use of the obsolete constructor AdaptStationary::AdaptStationary(...)!\n"); +// MSG("Please use the constructor that uses references instead of pointers!\n"); + + initialize(); + } + + AdaptStationary::AdaptStationary(std::string name, + ProblemIterationInterface& prob, + AdaptInfo& info) + : AdaptBase(name, &prob, &info) { initialize(); } diff --git a/AMDiS/src/AdaptStationary.h b/AMDiS/src/AdaptStationary.h index 77b897f7..32afc62d 100644 --- a/AMDiS/src/AdaptStationary.h +++ b/AMDiS/src/AdaptStationary.h @@ -45,11 +45,16 @@ namespace AMDiS { class AdaptStationary : public AdaptBase { public: - /// Creates a AdaptStationary object with given name. + /// Creates a AdaptStationary object with given name. TODO: Make obsolete! AdaptStationary(std::string name, ProblemIterationInterface *prob, AdaptInfo *info); + /// Creates a AdaptStationary object with given name. + AdaptStationary(std::string name, + ProblemIterationInterface &prob, + AdaptInfo &info); + /// Destructor virtual ~AdaptStationary() {} diff --git a/AMDiS/src/ProblemInstat.cc b/AMDiS/src/ProblemInstat.cc index ebbb84bc..dbfa5e01 100644 --- a/AMDiS/src/ProblemInstat.cc +++ b/AMDiS/src/ProblemInstat.cc @@ -50,6 +50,20 @@ namespace AMDiS { oldSolution(NULL) {} + ProblemInstatScal::ProblemInstatScal(std::string name_, + ProblemScal& prob) + : ProblemInstat(name_, NULL), + problemStat(&prob), + oldSolution(NULL) + {} + + ProblemInstatScal::ProblemInstatScal(std::string name_, + ProblemScal& prob, + ProblemStatBase& initialProb) + : ProblemInstat(name_, &initialProb), + problemStat(&prob), + oldSolution(NULL) + {} ProblemInstatScal::~ProblemInstatScal() { diff --git a/AMDiS/src/ProblemInstat.h b/AMDiS/src/ProblemInstat.h index e4c40bd1..94badcf2 100644 --- a/AMDiS/src/ProblemInstat.h +++ b/AMDiS/src/ProblemInstat.h @@ -119,6 +119,10 @@ namespace AMDiS { ProblemScal *prob, ProblemStatBase *initialProb = NULL); + ProblemInstatScal(std::string name, ProblemScal& prob); + + ProblemInstatScal(std::string name, ProblemScal& prob, ProblemStatBase& initialProb); + /// Destructor. virtual ~ProblemInstatScal(); diff --git a/AMDiS/src/ProblemScal.cc b/AMDiS/src/ProblemScal.cc index 74d510eb..baa6a63e 100644 --- a/AMDiS/src/ProblemScal.cc +++ b/AMDiS/src/ProblemScal.cc @@ -58,6 +58,11 @@ namespace AMDiS { fileWriters[i]->writeFiles(adaptInfo, force); } + void ProblemScal::writeFiles(AdaptInfo &adaptInfo, bool force) + { + writeFiles(&adaptInfo, force); + } + void ProblemScal::interpolInitialSolution(AbstractFunction<double, WorldVector<double> > *fct) { solution->interpol(fct); diff --git a/AMDiS/src/ProblemScal.h b/AMDiS/src/ProblemScal.h index c4f28da7..4b5c9154 100644 --- a/AMDiS/src/ProblemScal.h +++ b/AMDiS/src/ProblemScal.h @@ -157,9 +157,12 @@ namespace AMDiS { return this; } - /// Writes output files. + /// Writes output files. TODO: Make obsolete. void writeFiles(AdaptInfo *adaptInfo, bool force); + /// Writes output files. + void writeFiles(AdaptInfo &adaptInfo, bool force); + /// Interpolates fct to \ref solution. void interpolInitialSolution(AbstractFunction<double, WorldVector<double> > *fct); diff --git a/AMDiS/src/ProblemVec.cc b/AMDiS/src/ProblemVec.cc index c97f69ba..a5244b25 100644 --- a/AMDiS/src/ProblemVec.cc +++ b/AMDiS/src/ProblemVec.cc @@ -842,6 +842,11 @@ namespace AMDiS { #endif } + void ProblemVec::writeFiles(AdaptInfo &adaptInfo, bool force) + { + writeFiles(&adaptInfo, force); + } + void ProblemVec::interpolInitialSolution(std::vector<AbstractFunction<double, WorldVector<double> >*> *fct) { FUNCNAME("ProblemVec::interpolInitialSolution()"); diff --git a/AMDiS/src/ProblemVec.h b/AMDiS/src/ProblemVec.h index fd53b085..4f6266e4 100644 --- a/AMDiS/src/ProblemVec.h +++ b/AMDiS/src/ProblemVec.h @@ -202,9 +202,12 @@ namespace AMDiS { return this; } - /// Writes output files. + /// Writes output files. TODO: Make obsolete. void writeFiles(AdaptInfo *adaptInfo, bool force); + /// Writes output files. + void writeFiles(AdaptInfo &adaptInfo, bool force); + /// Interpolates fct to \ref solution. void interpolInitialSolution(std::vector<AbstractFunction<double, WorldVector<double> >*> *fct); -- GitLab