// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // ============================================================================ // == == // == crystal growth group == // == == // == Stiftung caesar == // == Ludwig-Erhard-Allee 2 == // == 53175 Bonn == // == germany == // == == // ============================================================================ // == == // == http://www.caesar.de/cg/AMDiS == // == == // ============================================================================ /** \file AdaptInstationary.h */ #ifndef AMDIS_ADAPTINSTATIONARY_H #define AMDIS_ADAPTINSTATIONARY_H #include #include #include #include "Flag.h" #include "AdaptInfo.h" #include "AdaptBase.h" #include "AMDiS_fwd.h" namespace AMDiS { /** \ingroup Adaption * \brief * AdaptInstationary implements the adaptive procdure for time dependent * problems (see ProblemInstat). It contains a pointer to a ProblemInstat * object. */ class AdaptInstationary : public AdaptBase { public: /** \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); /// Destructor virtual ~AdaptInstationary(); /// Sets \ref strategy to aStrategy inline void setStrategy(int aStrategy) { strategy = aStrategy; } /// Returns \ref strategy const int getStrategy() const { return strategy; } /// Implementation of AdaptBase::adapt() virtual int adapt(); /// Serialization virtual void serialize(std::ostream &out); /// deserialization virtual void deserialize(std::istream &in); protected: /** \brief * Implements one (maybe adaptive) timestep. Both the explicit and the * implicit time strategy are implemented. The semi-implicit strategy * is only a special case of the implicit strategy with a limited number of * iterations (exactly one). * The routine uses the parameter \ref strategy to select the strategy: * strategy 0: Explicit strategy, * strategy 1: Implicit strategy. */ virtual void oneTimestep(); /// Initialisation of this AdaptInstationary object void initialize(std::string aName); /// Implements the explit time strategy. Used by \ref oneTimestep(). virtual void explicitTimeStrategy(); /// Implements the implicit time strategy. Used by \ref oneTimestep(). virtual void implicitTimeStrategy(); /** \brief * Checks whether the runtime of the queue (of the servers batch system) requires * to stop the calculation and to reschedule the problem to the batch system. * * The function return true, if there will be a timeout in the near future, and * therefore the problem should be rescheduled. Otherwise, the return value is * false. */ bool checkQueueRuntime(); protected: /// Strategy for choosing one timestep int strategy; /// Parameter \f$ \delta_1 \f$ used in time step reduction double time_delta_1; /// Parameter \f$ \delta_2 \f$ used in time step enlargement double time_delta_2; /** \brief * If this parameter is 1 and the instationary problem is stable, hence the number * of solver iterations to solve the problem is zero, the adaption loop will stop. */ int breakWhenStable; /// bool fixedTimestep_; /** \brief * Runtime of the queue (of the servers batch system) in seconds. If the problem * runs on a computer/server without a time limited queue, the value is -1. */ int queueRuntime_; /// Name of the file used to automatically serialize the problem. std::string queueSerializationFilename_; /** \brief * Timestamp at the beginning of all calculations. It is used to calculate the * overall runtime of the problem. */ time_t initialTimestamp_; /** \brief * Timestamp at the beginning of the last timestep iteration. Is is used to * calculate the runtime of the last timestep. */ time_t iterationTimestamp_; /// Stores the runtime (in seconds) of some last timestep iterations. std::queue lastIterationsDuration_; /** \brief * In debug mode, the adapt loop will print information about timestep decreasing * and increasing. */ bool dbgMode; }; } #endif // AMDIS_ADAPTINSTATIONARY_H