AdaptInstationary.h 5.78 KB
Newer Older
 Peter Gottschling committed Feb 15, 2008 1 2 3 4 // ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == Thomas Witkowski committed Dec 16, 2010 5 // == http://www.amdis-fem.org == Peter Gottschling committed Feb 15, 2008 6 7 // == == // ============================================================================ Thomas Witkowski committed Dec 16, 2010 8 9 10 11 12 13 14 15 16 17 18 19 // // Software License for AMDiS // // Copyright (c) 2010 Dresden University of Technology // All rights reserved. // Authors: Simon Vey, Thomas Witkowski et al. // // This file is part of AMDiS // // See also license.opensource.txt in the distribution. Peter Gottschling committed Feb 15, 2008 20 21 22 23 24 25 26 27 28 29 30 31 /** \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 32 #include "AMDiS_fwd.h" Peter Gottschling committed Feb 15, 2008 33 34 35 namespace AMDiS { Thomas Witkowski committed Apr 18, 2011 36 37 using namespace std; Peter Gottschling committed Feb 15, 2008 38 39 40 41 42 43 44 45 46 /** \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: Thomas Witkowski committed Aug 06, 2012 47 48 /// Creates a AdaptInstationary object with the given name for the time /// dependent problem problemInstat. TODO: Make obsolete! Thomas Witkowski committed Apr 18, 2011 49 AdaptInstationary(string name, Peter Gottschling committed Feb 15, 2008 50 ProblemIterationInterface *problemStat, Thomas Witkowski committed Aug 13, 2008 51 52 53 AdaptInfo *info, ProblemTimeInterface *problemInstat, AdaptInfo *initialInfo, Backofen, Rainer committed Jun 14, 2010 54 time_t initialTimestampSet = 0); Peter Gottschling committed Feb 15, 2008 55 Thomas Witkowski committed Aug 06, 2012 56 57 /// Creates a AdaptInstationary object with the given name for the time /// dependent problem problemInstat. Thomas Witkowski committed Apr 18, 2011 58 AdaptInstationary(string name, Thomas Witkowski committed Nov 11, 2009 59 60 61 62 ProblemIterationInterface &problemStat, AdaptInfo &info, ProblemTimeInterface &problemInstat, AdaptInfo &initialInfo, Backofen, Rainer committed Jun 14, 2010 63 time_t initialTimestampSet = 0); Thomas Witkowski committed Nov 11, 2009 64 65 66 67 68 69 70 71 72 73 /** \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 74 time_t initialTimestampSet); Thomas Witkowski committed Nov 11, 2009 75 Thomas Witkowski committed Apr 16, 2009 76 /// Destructor Thomas Witkowski committed Apr 18, 2011 77 virtual ~AdaptInstationary() {} Peter Gottschling committed Feb 15, 2008 78 Thomas Witkowski committed Apr 16, 2009 79 /// Sets \ref strategy to aStrategy Thomas Witkowski committed Jun 10, 2009 80 81 inline void setStrategy(int aStrategy) { Peter Gottschling committed Feb 15, 2008 82 strategy = aStrategy; Thomas Witkowski committed Dec 03, 2008 83 } Peter Gottschling committed Feb 15, 2008 84 Thomas Witkowski committed Apr 16, 2009 85 /// Returns \ref strategy Thomas Witkowski committed Jun 10, 2009 86 87 const int getStrategy() const { Peter Gottschling committed Feb 15, 2008 88 return strategy; Thomas Witkowski committed Dec 09, 2008 89 } Thomas Witkowski committed Aug 06, 2012 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 Apr 18, 2011 95 virtual void serialize(ostream &out); Peter Gottschling committed Feb 15, 2008 96 Thomas Witkowski committed Apr 16, 2009 97 /// deserialization Thomas Witkowski committed Apr 18, 2011 98 virtual void deserialize(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 Apr 18, 2011 114 void initialize(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 Thomas Witkowski committed Aug 06, 2012 149 150 /// 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. Peter Gottschling committed Feb 15, 2008 151 int breakWhenStable; Thomas Witkowski committed Aug 06, 2012 152 Thomas Witkowski committed Apr 16, 2009 153 /// Thomas Witkowski committed Apr 15, 2010 154 bool fixedTimestep; Peter Gottschling committed Feb 15, 2008 155 Thomas Witkowski committed Aug 06, 2012 156 157 /// 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 158 int queueRuntime; Peter Gottschling committed Feb 15, 2008 159 Thomas Witkowski committed Apr 16, 2009 160 /// Name of the file used to automatically serialize the problem. Thomas Witkowski committed Apr 18, 2011 161 string queueSerializationFilename; Peter Gottschling committed Feb 15, 2008 162 Thomas Witkowski committed Aug 06, 2012 163 164 /// Timestamp at the beginning of all calculations. It is used to calculate the /// overall runtime of the problem. Thomas Witkowski committed Apr 15, 2010 165 time_t initialTimestamp; Peter Gottschling committed Feb 15, 2008 166 Thomas Witkowski committed Aug 06, 2012 167 168 /// Timestamp at the beginning of the last timestep iteration. Is is used to /// calculate the runtime of the last timestep. Thomas Witkowski committed Apr 15, 2010 169 time_t iterationTimestamp; Peter Gottschling committed Feb 15, 2008 170 Thomas Witkowski committed Apr 16, 2009 171 /// Stores the runtime (in seconds) of some last timestep iterations. Thomas Witkowski committed Apr 18, 2011 172 queue lastIterationsDuration; Thomas Witkowski committed Dec 03, 2008 173 Thomas Witkowski committed Aug 06, 2012 174 175 /// In debug mode, the adapt loop will print information about timestep decreasing /// and increasing. Thomas Witkowski committed Dec 03, 2008 176 bool dbgMode; Peter Gottschling committed Feb 15, 2008 177 178 179 180 181 }; } #endif // AMDIS_ADAPTINSTATIONARY_H