diff --git a/AMDiS/src/AdaptInstationary.cc b/AMDiS/src/AdaptInstationary.cc index 9200429d24ff3bef514f92e5574b9b6061d9552d..e34123e033b2cd5d6a22a30e2e54349cac1843ce 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 7adf1660716cefe778886bafc539f4f31ea3a588..56faf49b7a2d3cfdde971cbbee22a8882f9d6f29 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 b45bdc0afbc2d941521d6edd5f982187fa9fcb33..cb2916019ece396c581bc09989103bdaaea7679a 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 77b897f738f891b41bb214aac74684fd8cd20adb..32afc62d3dccffaeade9c4e08cc106f1d5b95fbd 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 ebbb84bc9264d24991c2a347846290e5f86f2c2f..dbfa5e0155ac48f159f07d9b629de63c6bfe238e 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 e4c40bd18420e7272b2e721a5b6c24053b02a37c..94badcf219fdee4e3058837251f4f1b582ad154e 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 74d510eb47b0aa0fd74f5aa66d4f095d15f7848e..baa6a63ee09ede90623c5b550659881b1d1d7814 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 c4f28da7947b6acb357e34f9af46478cbf8a6323..4b5c9154443a64f76da0b3eb2aabd22c56cd25d8 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 c97f69ba0f7e3bdbfc5dc8939f2a1bb09c1f21c2..a5244b25eeddde7ebb117efc06d677e69f8ef2c4 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 fd53b085f5acbf0fdb4dba92a7eba38a396361ea..4f6266e42c63b4f015f54a478efc595a4eac78ec 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);