Skip to content
Snippets Groups Projects
Commit 960408e0 authored by Backofen, Rainer's avatar Backofen, Rainer
Browse files

fixed bug in runtime calculation, initialTimestamp was not set correctly

parent 8daad3cb
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ namespace AMDiS {
AdaptInfo *info,
ProblemTimeInterface *problemInstat,
AdaptInfo *initialInfo,
time_t initialTimestamp)
time_t initialTimestampSet)
: AdaptBase(name, problemStat, info, problemInstat, initialInfo),
breakWhenStable(0),
dbgMode(false)
......@@ -23,8 +23,9 @@ namespace AMDiS {
// 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);
}
initConstructor(problemStat, info, initialInfo, initialTimestampSet);
}
AdaptInstationary::AdaptInstationary(std::string name,
......@@ -32,31 +33,32 @@ namespace AMDiS {
AdaptInfo &info,
ProblemTimeInterface &problemInstat,
AdaptInfo &initialInfo,
time_t initialTimestamp)
time_t initialTimestampSet)
: AdaptBase(name, &problemStat, &info, &problemInstat, &initialInfo),
breakWhenStable(0),
dbgMode(false)
{
FUNCNAME("AdaptInstationary::AdaptInstationary()");
initConstructor(&problemStat, &info, &initialInfo, initialTimestamp);
initConstructor(&problemStat, &info, &initialInfo, initialTimestampSet);
}
void AdaptInstationary::initConstructor(ProblemIterationInterface *problemStat,
AdaptInfo *info,
AdaptInfo *initialInfo,
time_t initialTimestamp)
time_t initialTimestampSet)
{
initialize(name);
fixedTimestep = (info->getMinTimestep() == info->getMaxTimestep());
if (initialTimestamp == 0)
if (initialTimestampSet == 0)
initialTimestamp = time(NULL);
else
initialTimestamp = initialTimestamp;
initialTimestamp = initialTimestampSet;
// Check if the problem should be deserialized because of the -rs parameter.
std::string serializationFilename = "";
GET_PARAMETER(0, "argv->rs", &serializationFilename);
......@@ -279,7 +281,6 @@ namespace AMDiS {
int AdaptInstationary::adapt()
{
FUNCNAME("AdaptInstationary::adapt()");
int errorCode = 0;
TEST_EXIT(adaptInfo->getTimestep() >= adaptInfo->getMinTimestep())
......@@ -308,10 +309,12 @@ namespace AMDiS {
oneTimestep();
problemTime->closeTimestep(adaptInfo);
if (breakWhenStable && (adaptInfo->getSolverIterations() == 0)) {
if (breakWhenStable && (adaptInfo->getSolverIterations() == 0))
break;
}
/*
if (adaptInfo->forceBreak)
break;
*/
// Check if there is a runtime limitation. If there is a runtime limitation
// and there is no more time for a next adaption loop, than return the error
// code for rescheduling the problem and break the adaption loop.
......@@ -374,7 +377,6 @@ namespace AMDiS {
if (queueRuntime == -1) {
return false;
}
// Get the current time.
time_t currentTimestamp = time(NULL);
......@@ -388,11 +390,11 @@ namespace AMDiS {
std::queue<int> tmpQueue = lastIterationsDuration;
int avrgLastIterations = 0;
while (!tmpQueue.empty()) {
avrgLastIterations += tmpQueue.front();
tmpQueue.pop();
avrgLastIterations += tmpQueue.front();
tmpQueue.pop();
}
avrgLastIterations /= lastIterationsDuration.size();
// Check if there is enough time for a further iteration.
if (initialTimestamp + queueRuntime - currentTimestamp < avrgLastIterations * 2) {
std::ofstream out(queueSerializationFilename.c_str());
......
......@@ -50,7 +50,7 @@ namespace AMDiS {
AdaptInfo *info,
ProblemTimeInterface *problemInstat,
AdaptInfo *initialInfo,
time_t initialTimestamp = 0);
time_t initialTimestampSet = 0);
/** \brief
* Creates a AdaptInstationary object with the given name for the time
......@@ -61,7 +61,7 @@ namespace AMDiS {
AdaptInfo &info,
ProblemTimeInterface &problemInstat,
AdaptInfo &initialInfo,
time_t initialTimestamp = 0);
time_t initialTimestampSet = 0);
/** \brief
* This funciton is used only to avoid double code in both constructors. If the
......@@ -72,7 +72,7 @@ namespace AMDiS {
void initConstructor(ProblemIterationInterface *problemStat,
AdaptInfo *info,
AdaptInfo *initialInfo,
time_t initialTimestamp);
time_t initialTimestampSet);
/// Destructor
virtual ~AdaptInstationary();
......@@ -88,7 +88,6 @@ namespace AMDiS {
{
return strategy;
}
/// Implementation of AdaptBase::adapt()
virtual int adapt();
......@@ -152,7 +151,6 @@ namespace AMDiS {
* of solver iterations to solve the problem is zero, the adaption loop will stop.
*/
int breakWhenStable;
///
bool fixedTimestep;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment