Peter Gottschling committed Feb 15, 2008 1 2 3 4 5 6 // ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // ============================================================================ // == ==  Thomas Witkowski committed Sep 28, 2009 7 // == TU Dresden ==  Peter Gottschling committed Feb 15, 2008 8 // == ==  Thomas Witkowski committed Sep 28, 2009 9 10 11 // == Institut für Wissenschaftliches Rechnen == // == Zellescher Weg 12-14 == // == 01069 Dresden ==  Peter Gottschling committed Feb 15, 2008 12 13 14 15 // == germany == // == == // ============================================================================ // == ==  Thomas Witkowski committed Sep 28, 2009 16 // == https://gforge.zih.tu-dresden.de/projects/amdis/ ==  Peter Gottschling committed Feb 15, 2008 17 18 19 20 21 22 23 24 25 26 27 28 29 30 // == == // ============================================================================ /** \file AdaptInstationary.h */ #ifndef AMDIS_ADAPTINSTATIONARY_H #define AMDIS_ADAPTINSTATIONARY_H #include #include #include #include "Flag.h" #include "AdaptInfo.h" #include "AdaptBase.h"  Thomas Witkowski committed May 07, 2009 31 #include "AMDiS_fwd.h"  Peter Gottschling committed Feb 15, 2008 32 33 34 35 36 37 38 39 40 41 42 43 44 45  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  Thomas Witkowski committed Nov 11, 2009 46  * dependent problem problemInstat. TODO: Make obsolete!  Peter Gottschling committed Feb 15, 2008 47  */  Thomas Witkowski committed Apr 16, 2009 48  AdaptInstationary(std::string name,  Peter Gottschling committed Feb 15, 2008 49  ProblemIterationInterface *problemStat,  Thomas Witkowski committed Aug 13, 2008 50 51 52  AdaptInfo *info, ProblemTimeInterface *problemInstat, AdaptInfo *initialInfo,  Backofen, Rainer committed Jun 14, 2010 53  time_t initialTimestampSet = 0);  Peter Gottschling committed Feb 15, 2008 54   Thomas Witkowski committed Nov 11, 2009 55 56 57 58 59 60 61 62 63  /** \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,  Backofen, Rainer committed Jun 14, 2010 64  time_t initialTimestampSet = 0);  Thomas Witkowski committed Nov 11, 2009 65 66 67 68 69 70 71 72 73 74  /** \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,  Backofen, Rainer committed Jun 14, 2010 75  time_t initialTimestampSet);  Thomas Witkowski committed Nov 11, 2009 76   Thomas Witkowski committed Apr 16, 2009 77  /// Destructor  Peter Gottschling committed Feb 15, 2008 78 79  virtual ~AdaptInstationary();  Thomas Witkowski committed Apr 16, 2009 80  /// Sets \ref strategy to aStrategy  Thomas Witkowski committed Jun 10, 2009 81 82  inline void setStrategy(int aStrategy) {  Peter Gottschling committed Feb 15, 2008 83  strategy = aStrategy;  Thomas Witkowski committed Dec 03, 2008 84  }  Peter Gottschling committed Feb 15, 2008 85   Thomas Witkowski committed Apr 16, 2009 86  /// Returns \ref strategy  Thomas Witkowski committed Jun 10, 2009 87 88  const int getStrategy() const {  Peter Gottschling committed Feb 15, 2008 89  return strategy;  Thomas Witkowski committed Dec 09, 2008 90  }  Thomas Witkowski committed Apr 16, 2009 91  /// Implementation of AdaptBase::adapt()  Peter Gottschling committed Feb 15, 2008 92 93  virtual int adapt();  Thomas Witkowski committed Apr 16, 2009 94  /// Serialization  Thomas Witkowski committed Aug 29, 2008 95  virtual void serialize(std::ostream &out);  Peter Gottschling committed Feb 15, 2008 96   Thomas Witkowski committed Apr 16, 2009 97  /// deserialization  Thomas Witkowski committed Aug 29, 2008 98  virtual void deserialize(std::istream &in);  Peter Gottschling committed Feb 15, 2008 99 100 101 102 103 104 105 106 107 108 109 110 111 112  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();  Thomas Witkowski committed Apr 16, 2009 113  /// Initialisation of this AdaptInstationary object  Thomas Witkowski committed Jul 20, 2009 114  void initialize(std::string aName);  Peter Gottschling committed Feb 15, 2008 115   Thomas Witkowski committed Apr 16, 2009 116  /// Implements the explit time strategy. Used by \ref oneTimestep().  Peter Gottschling committed Feb 15, 2008 117 118  virtual void explicitTimeStrategy();  Thomas Witkowski committed Apr 16, 2009 119  /// Implements the implicit time strategy. Used by \ref oneTimestep().  Peter Gottschling committed Feb 15, 2008 120 121  virtual void implicitTimeStrategy();  Thomas Witkowski committed Apr 15, 2010 122 123 124 125 126 127 128  /** \brief * This iteration strategy allows the timestep and the mesh to be adapted * after each timestep solution. There are no inner loops for mesh adaption and * no refused timesteps. */ void simpleAdaptiveTimeStrategy();  Peter Gottschling committed Feb 15, 2008 129 130 131 132 133 134 135 136 137 138 139  /** \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:  Thomas Witkowski committed Apr 16, 2009 140  /// Strategy for choosing one timestep  Peter Gottschling committed Feb 15, 2008 141 142  int strategy;  Thomas Witkowski committed Apr 16, 2009 143  /// Parameter \f$\delta_1 \f$ used in time step reduction  Thomas Witkowski committed Apr 15, 2010 144  double timeDelta1;  Peter Gottschling committed Feb 15, 2008 145   Thomas Witkowski committed Apr 16, 2009 146  /// Parameter \f$\delta_2 \f$ used in time step enlargement  Thomas Witkowski committed Apr 15, 2010 147  double timeDelta2;  Peter Gottschling committed Feb 15, 2008 148 149 150 151 152 153  /** \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;  Thomas Witkowski committed Apr 16, 2009 154  ///  Thomas Witkowski committed Apr 15, 2010 155  bool fixedTimestep;  Peter Gottschling committed Feb 15, 2008 156 157 158 159 160  /** \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. */  Thomas Witkowski committed Apr 15, 2010 161  int queueRuntime;  Peter Gottschling committed Feb 15, 2008 162   Thomas Witkowski committed Apr 16, 2009 163  /// Name of the file used to automatically serialize the problem.  Thomas Witkowski committed Apr 15, 2010 164  std::string queueSerializationFilename;  Peter Gottschling committed Feb 15, 2008 165 166  /** \brief  Thomas Witkowski committed Apr 16, 2009 167 168  * Timestamp at the beginning of all calculations. It is used to calculate the * overall runtime of the problem.  Peter Gottschling committed Feb 15, 2008 169  */  Thomas Witkowski committed Apr 15, 2010 170  time_t initialTimestamp;  Peter Gottschling committed Feb 15, 2008 171 172  /** \brief  Thomas Witkowski committed Apr 16, 2009 173 174  * Timestamp at the beginning of the last timestep iteration. Is is used to * calculate the runtime of the last timestep.  Peter Gottschling committed Feb 15, 2008 175  */  Thomas Witkowski committed Apr 15, 2010 176  time_t iterationTimestamp;  Peter Gottschling committed Feb 15, 2008 177   Thomas Witkowski committed Apr 16, 2009 178  /// Stores the runtime (in seconds) of some last timestep iterations.  Thomas Witkowski committed Apr 15, 2010 179  std::queue lastIterationsDuration;  Thomas Witkowski committed Dec 03, 2008 180 181  /** \brief  Thomas Witkowski committed Apr 16, 2009 182 183  * In debug mode, the adapt loop will print information about timestep decreasing * and increasing.  Thomas Witkowski committed Dec 03, 2008 184 185  */ bool dbgMode;  Peter Gottschling committed Feb 15, 2008 186 187 188 189 190  }; } #endif // AMDIS_ADAPTINSTATIONARY_H