Newer
Older
// ============================================================================
// == ==
// == AMDiS - Adaptive multidimensional simulations ==
// == ==

Thomas Witkowski
committed
// == http://www.amdis-fem.org ==
// == ==
// ============================================================================

Thomas Witkowski
committed
//
// 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.
/** \file AdaptInstationary.h */
#ifndef AMDIS_ADAPTINSTATIONARY_H
#define AMDIS_ADAPTINSTATIONARY_H
#include <string>
#include <ctime>
#include <queue>
#include "Flag.h"
#include "AdaptInfo.h"
#include "AdaptBase.h"
#include "AMDiS_fwd.h"
using namespace std;
/** \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. TODO: Make obsolete!
AdaptInstationary(string name,
ProblemIterationInterface *problemStat,
AdaptInfo *info,
ProblemTimeInterface *problemInstat,
AdaptInfo *initialInfo,
time_t initialTimestampSet = 0);
/** \brief
* Creates a AdaptInstationary object with the given name for the time
* dependent problem problemInstat.
*/
AdaptInstationary(string name,
ProblemIterationInterface &problemStat,
AdaptInfo &info,
ProblemTimeInterface &problemInstat,
AdaptInfo &initialInfo,
time_t initialTimestampSet = 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 initialTimestampSet);
virtual ~AdaptInstationary() {}
virtual void serialize(ostream &out);
virtual void deserialize(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();
void initialize(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
* 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();
/** \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:
/// Parameter \f$ \delta_1 \f$ used in time step reduction
/// Parameter \f$ \delta_2 \f$ used in time step enlargement
/** \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;
/** \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.
*/
/// Name of the file used to automatically serialize the problem.
string queueSerializationFilename;
* Timestamp at the beginning of all calculations. It is used to calculate the
* overall runtime of the problem.
* Timestamp at the beginning of the last timestep iteration. Is is used to
* calculate the runtime of the last timestep.
/// Stores the runtime (in seconds) of some last timestep iterations.
queue<int> lastIterationsDuration;
* In debug mode, the adapt loop will print information about timestep decreasing
* and increasing.
*/
bool dbgMode;
};
}
#endif // AMDIS_ADAPTINSTATIONARY_H