Commit 83dd4be1 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Small bug fixes

parent 18c0eba3
...@@ -65,7 +65,7 @@ The runtime will increase by factor 5 to 6 without --enable-debug! ...@@ -65,7 +65,7 @@ The runtime will increase by factor 5 to 6 without --enable-debug!
5) Run the configure script: 5) Run the configure script:
./configure --prefix=`pwd` --with-mpi=/licsoft/libraries/openmpi/1.2.4/64bit --enable-parmetis ./configure --prefix=`pwd` --with-mpi=/licsoft/libraries/openmpi/1.2.6/64bit --enable-parmetis
You may also enable --enable-debug. You may also enable --enable-debug.
......
...@@ -43,14 +43,14 @@ namespace AMDiS { ...@@ -43,14 +43,14 @@ namespace AMDiS {
/** \brief /** \brief
* Constructor * Constructor
*/ */
AdaptBase(const ::std::string& name, AdaptBase(const ::std::string& name,
ProblemIterationInterface *problemIteration, ProblemIterationInterface *problemIteration,
AdaptInfo *adaptInfo, AdaptInfo *adaptInfo_,
ProblemTimeInterface *problemTime = NULL, ProblemTimeInterface *problemTime = NULL,
AdaptInfo *initialAdaptInfo = NULL) AdaptInfo *initialAdaptInfo = NULL)
: name_(name), : name_(name),
problemIteration_(problemIteration), problemIteration_(problemIteration),
adaptInfo_(adaptInfo), adaptInfo(adaptInfo_),
problemTime_(problemTime), problemTime_(problemTime),
initialAdaptInfo_(initialAdaptInfo) initialAdaptInfo_(initialAdaptInfo)
{}; {};
...@@ -85,10 +85,10 @@ namespace AMDiS { ...@@ -85,10 +85,10 @@ namespace AMDiS {
}; };
/** \brief /** \brief
* Returns \ref adaptInfo_ * Returns \ref adaptInfo
*/ */
inline AdaptInfo *getAdaptInfo() { inline AdaptInfo *getAdaptInfo() {
return adaptInfo_; return adaptInfo;
}; };
/** \brief /** \brief
...@@ -123,7 +123,7 @@ namespace AMDiS { ...@@ -123,7 +123,7 @@ namespace AMDiS {
/** \brief /** \brief
* Main adapt info * Main adapt info
*/ */
AdaptInfo *adaptInfo_; AdaptInfo *adaptInfo;
/** \brief /** \brief
* problem time interface * problem time interface
......
...@@ -77,24 +77,24 @@ namespace AMDiS { ...@@ -77,24 +77,24 @@ namespace AMDiS {
FUNCNAME("AdaptInstationary::explicitTimeStrategy()"); FUNCNAME("AdaptInstationary::explicitTimeStrategy()");
// estimate before first adaption // estimate before first adaption
if (adaptInfo_->getTime() <= adaptInfo_->getStartTime()) { if (adaptInfo->getTime() <= adaptInfo->getStartTime()) {
problemIteration_->oneIteration(adaptInfo_, ESTIMATE); problemIteration_->oneIteration(adaptInfo, ESTIMATE);
} }
// increment time // increment time
adaptInfo_->setTime(adaptInfo_->getTime() + adaptInfo_->getTimestep()); adaptInfo->setTime(adaptInfo->getTime() + adaptInfo->getTimestep());
problemTime_->setTime(adaptInfo_); problemTime_->setTime(adaptInfo);
INFO(info_,6)("time = %e, timestep = %e\n", INFO(info_,6)("time = %e, timestep = %e\n",
adaptInfo_->getTime(), adaptInfo_->getTimestep()); adaptInfo->getTime(), adaptInfo->getTimestep());
adaptInfo_->setSpaceIteration(0); adaptInfo->setSpaceIteration(0);
// do the iteration // do the iteration
problemIteration_->beginIteration(adaptInfo_); problemIteration_->beginIteration(adaptInfo);
problemIteration_->oneIteration(adaptInfo_, FULL_ITERATION); problemIteration_->oneIteration(adaptInfo, FULL_ITERATION);
problemIteration_->endIteration(adaptInfo_); problemIteration_->endIteration(adaptInfo);
} }
void AdaptInstationary::implicitTimeStrategy() void AdaptInstationary::implicitTimeStrategy()
...@@ -102,54 +102,54 @@ namespace AMDiS { ...@@ -102,54 +102,54 @@ namespace AMDiS {
FUNCNAME("AdaptInstationary::implicitTimeStrategy()"); FUNCNAME("AdaptInstationary::implicitTimeStrategy()");
do { do {
adaptInfo_->setTime(adaptInfo_->getTime() + adaptInfo_->getTimestep()); adaptInfo->setTime(adaptInfo->getTime() + adaptInfo->getTimestep());
problemTime_->setTime(adaptInfo_); problemTime_->setTime(adaptInfo);
INFO(info_,6)("time = %e, try timestep = %e\n", INFO(info_,6)("time = %e, try timestep = %e\n",
adaptInfo_->getTime(), adaptInfo_->getTimestep()); adaptInfo->getTime(), adaptInfo->getTimestep());
problemIteration_->oneIteration(adaptInfo_, NO_ADAPTION); problemIteration_->oneIteration(adaptInfo, NO_ADAPTION);
adaptInfo_->incTimestepIteration(); adaptInfo->incTimestepIteration();
if (!fixedTimestep_ && if (!fixedTimestep_ &&
!adaptInfo_->timeToleranceReached() && !adaptInfo->timeToleranceReached() &&
!adaptInfo_->getTimestep() <= adaptInfo_->getMinTimestep()) !adaptInfo->getTimestep() <= adaptInfo->getMinTimestep())
{ {
adaptInfo_->setTime(adaptInfo_->getTime() - adaptInfo_->getTimestep()); adaptInfo->setTime(adaptInfo->getTime() - adaptInfo->getTimestep());
adaptInfo_->setTimestep(adaptInfo_->getTimestep() * time_delta_1); adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1);
continue; continue;
} }
adaptInfo_->setSpaceIteration(0); adaptInfo->setSpaceIteration(0);
do { do {
problemIteration_->beginIteration(adaptInfo_); problemIteration_->beginIteration(adaptInfo);
if (problemIteration_->oneIteration(adaptInfo_, FULL_ITERATION)) { if (problemIteration_->oneIteration(adaptInfo, FULL_ITERATION)) {
if (!fixedTimestep_ && if (!fixedTimestep_ &&
!adaptInfo_->timeToleranceReached() && !adaptInfo->timeToleranceReached() &&
!adaptInfo_->getTimestep() <= adaptInfo_->getMinTimestep()) !adaptInfo->getTimestep() <= adaptInfo->getMinTimestep())
{ {
adaptInfo_->setTime(adaptInfo_->getTime() - adaptInfo_->getTimestep()); adaptInfo->setTime(adaptInfo->getTime() - adaptInfo->getTimestep());
adaptInfo_->setTimestep(adaptInfo_->getTimestep() * time_delta_1); adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1);
problemIteration_->endIteration(adaptInfo_); problemIteration_->endIteration(adaptInfo);
adaptInfo_->incSpaceIteration(); adaptInfo->incSpaceIteration();
break; break;
} }
} }
adaptInfo_->incSpaceIteration(); adaptInfo->incSpaceIteration();
problemIteration_->endIteration(adaptInfo_); problemIteration_->endIteration(adaptInfo);
} while(!adaptInfo_->spaceToleranceReached() && } while(!adaptInfo->spaceToleranceReached() &&
adaptInfo_->getSpaceIteration() <= adaptInfo_->getMaxSpaceIteration()); adaptInfo->getSpaceIteration() <= adaptInfo->getMaxSpaceIteration());
} while(!adaptInfo_->timeToleranceReached() && } while(!adaptInfo->timeToleranceReached() &&
!adaptInfo_->getTimestep() <= adaptInfo_->getMinTimestep() && !adaptInfo->getTimestep() <= adaptInfo->getMinTimestep() &&
adaptInfo_->getTimestepIteration() <= adaptInfo_->getMaxTimestepIteration()); adaptInfo->getTimestepIteration() <= adaptInfo->getMaxTimestepIteration());
if (!fixedTimestep_ && adaptInfo_->timeErrorLow()) { if (!fixedTimestep_ && adaptInfo->timeErrorLow()) {
adaptInfo_->setTimestep(adaptInfo_->getTimestep() *time_delta_2); adaptInfo->setTimestep(adaptInfo->getTimestep() *time_delta_2);
} }
} }
...@@ -157,7 +157,7 @@ namespace AMDiS { ...@@ -157,7 +157,7 @@ namespace AMDiS {
{ {
FUNCNAME("AdaptInstationary::oneTimestep"); FUNCNAME("AdaptInstationary::oneTimestep");
adaptInfo_->setTimestepIteration(0); adaptInfo->setTimestepIteration(0);
switch(strategy) switch(strategy)
{ {
...@@ -172,7 +172,7 @@ namespace AMDiS { ...@@ -172,7 +172,7 @@ namespace AMDiS {
explicitTimeStrategy(); explicitTimeStrategy();
} }
adaptInfo_->incTimestepNumber(); adaptInfo->incTimestepNumber();
} }
int AdaptInstationary::adapt() int AdaptInstationary::adapt()
...@@ -181,29 +181,36 @@ namespace AMDiS { ...@@ -181,29 +181,36 @@ namespace AMDiS {
int errorCode = 0; int errorCode = 0;
TEST_EXIT(adaptInfo_->getTimestep() >= adaptInfo_->getMinTimestep()) TEST_EXIT(adaptInfo->getTimestep() >= adaptInfo->getMinTimestep())
("timestep < min timestep\n"); ("timestep < min timestep\n");
TEST_EXIT(adaptInfo_->getTimestep() <= adaptInfo_->getMaxTimestep()) TEST_EXIT(adaptInfo->getTimestep() <= adaptInfo->getMaxTimestep())
("timestep > max timestep\n"); ("timestep > max timestep\n");
TEST_EXIT(adaptInfo_->getTimestep() > 0)("timestep <= 0!\n"); TEST_EXIT(adaptInfo->getTimestep() > 0)("timestep <= 0!\n");
if (adaptInfo_->getTimestepNumber() == 0) { if (adaptInfo->getTimestepNumber() == 0) {
adaptInfo_->setTime(adaptInfo_->getStartTime()); adaptInfo->setTime(adaptInfo->getStartTime());
initialAdaptInfo_->setStartTime(adaptInfo_->getStartTime()); initialAdaptInfo_->setStartTime(adaptInfo->getStartTime());
initialAdaptInfo_->setTime(adaptInfo_->getStartTime()); initialAdaptInfo_->setTime(adaptInfo->getStartTime());
problemTime_->setTime(adaptInfo_); problemTime_->setTime(adaptInfo);
// initial adaption // initial adaption
problemTime_->solveInitialProblem(initialAdaptInfo_); problemTime_->solveInitialProblem(initialAdaptInfo_);
problemTime_->transferInitialSolution(adaptInfo_); problemTime_->transferInitialSolution(adaptInfo);
} }
while (adaptInfo_->getTime() < adaptInfo_->getEndTime() - DBL_TOL) { // while (adaptInfo->getTime() < adaptInfo->getEndTime() - DBL_TOL) {
while (adaptInfo->getEndTime() - adaptInfo->getTime() > DBL_TOL) {
std::cout.precision(10);
std::cout << "TIME: " << adaptInfo->getTime() << std::endl;
std::cout << "END TIME: " << adaptInfo->getEndTime() << std::endl;
std::cout << "DIFF: " << adaptInfo->getEndTime() - adaptInfo->getTime() << std::endl;
std::cout << "TOL: " << DBL_TOL << std::endl;
iterationTimestamp_ = time(NULL); iterationTimestamp_ = time(NULL);
problemTime_->initTimestep(adaptInfo_); problemTime_->initTimestep(adaptInfo);
#ifdef _OPENMP #ifdef _OPENMP
if (problemTime_->existsDelayedCalculation()) { if (problemTime_->existsDelayedCalculation()) {
...@@ -223,9 +230,9 @@ namespace AMDiS { ...@@ -223,9 +230,9 @@ namespace AMDiS {
oneTimestep(); oneTimestep();
#endif #endif
problemTime_->closeTimestep(adaptInfo_); problemTime_->closeTimestep(adaptInfo);
if (breakWhenStable && (adaptInfo_->getSolverIterations() == 0)) { if (breakWhenStable && (adaptInfo->getSolverIterations() == 0)) {
break; break;
} }
...@@ -269,7 +276,7 @@ namespace AMDiS { ...@@ -269,7 +276,7 @@ namespace AMDiS {
FUNCNAME("AdaptInstationary::serialize()"); FUNCNAME("AdaptInstationary::serialize()");
problemIteration_->serialize(out); problemIteration_->serialize(out);
adaptInfo_->serialize(out); adaptInfo->serialize(out);
if (problemTime_) { if (problemTime_) {
problemTime_->serialize(out); problemTime_->serialize(out);
} }
...@@ -280,7 +287,7 @@ namespace AMDiS { ...@@ -280,7 +287,7 @@ namespace AMDiS {
FUNCNAME("AdaptInstationary::deserialize()"); FUNCNAME("AdaptInstationary::deserialize()");
problemIteration_->deserialize(in); problemIteration_->deserialize(in);
adaptInfo_->deserialize(in); adaptInfo->deserialize(in);
if (problemTime_) { if (problemTime_) {
problemTime_->deserialize(in); problemTime_->deserialize(in);
} }
...@@ -298,20 +305,20 @@ namespace AMDiS { ...@@ -298,20 +305,20 @@ namespace AMDiS {
time_t currentTimestamp = time(NULL); time_t currentTimestamp = time(NULL);
// Update list with the last iteration runtimes. // Update list with the last iteration runtimes.
lastIterationsDuration_.push(currentTimestamp - iterationTimestamp_); lastIterationsDuration.push(currentTimestamp - iterationTimestamp_);
// The list should not contain more than 5 elements. If so, delete the oldest one. // The list should not contain more than 5 elements. If so, delete the oldest one.
if (lastIterationsDuration_.size() > 5) { if (lastIterationsDuration.size() > 5) {
lastIterationsDuration_.pop(); lastIterationsDuration.pop();
} }
// Calculate the avarage of the last iterations. // Calculate the avarage of the last iterations.
::std::queue<int> tmpQueue = lastIterationsDuration_; ::std::queue<int> tmpQueue = lastIterationsDuration;
int avrgLastIterations = 0; int avrgLastIterations = 0;
while (!tmpQueue.empty()) { while (!tmpQueue.empty()) {
avrgLastIterations += tmpQueue.front(); avrgLastIterations += tmpQueue.front();
tmpQueue.pop(); tmpQueue.pop();
} }
avrgLastIterations /= lastIterationsDuration_.size(); avrgLastIterations /= lastIterationsDuration.size();
// Check if there is enough time for a further iteration. // Check if there is enough time for a further iteration.
if (initialTimestamp_ + queueRuntime_ - currentTimestamp < avrgLastIterations * 2) { if (initialTimestamp_ + queueRuntime_ - currentTimestamp < avrgLastIterations * 2) {
......
...@@ -186,7 +186,7 @@ namespace AMDiS { ...@@ -186,7 +186,7 @@ namespace AMDiS {
/** \brief /** \brief
* Stores the runtime (in seconds) of some last timestep iterations. * Stores the runtime (in seconds) of some last timestep iterations.
*/ */
::std::queue<int> lastIterationsDuration_; ::std::queue<int> lastIterationsDuration;
}; };
} }
......
...@@ -20,26 +20,26 @@ namespace AMDiS { ...@@ -20,26 +20,26 @@ namespace AMDiS {
FUNCNAME("AdaptStationary::adapt()"); FUNCNAME("AdaptStationary::adapt()");
// initial iteration // initial iteration
if (adaptInfo_->getSpaceIteration() == -1) { if (adaptInfo->getSpaceIteration() == -1) {
problemIteration_->beginIteration(adaptInfo_); problemIteration_->beginIteration(adaptInfo);
problemIteration_->oneIteration(adaptInfo_, NO_ADAPTION); problemIteration_->oneIteration(adaptInfo, NO_ADAPTION);
problemIteration_->endIteration(adaptInfo_); problemIteration_->endIteration(adaptInfo);
adaptInfo_->incSpaceIteration(); adaptInfo->incSpaceIteration();
} }
// adaption loop // adaption loop
while (!adaptInfo_->spaceToleranceReached() && while (!adaptInfo->spaceToleranceReached() &&
(adaptInfo_->getSpaceIteration() < adaptInfo_->getMaxSpaceIteration() || (adaptInfo->getSpaceIteration() < adaptInfo->getMaxSpaceIteration() ||
adaptInfo_->getMaxSpaceIteration() < 0) ) { adaptInfo->getMaxSpaceIteration() < 0) ) {
problemIteration_->beginIteration(adaptInfo_); problemIteration_->beginIteration(adaptInfo);
Flag adapted = problemIteration_->oneIteration(adaptInfo_, FULL_ITERATION); Flag adapted = problemIteration_->oneIteration(adaptInfo, FULL_ITERATION);
problemIteration_->endIteration(adaptInfo_); problemIteration_->endIteration(adaptInfo);
if (!adapted) if (!adapted)
break; break;
adaptInfo_->incSpaceIteration(); adaptInfo->incSpaceIteration();
} }
return 0; return 0;
......
...@@ -785,23 +785,24 @@ namespace AMDiS { ...@@ -785,23 +785,24 @@ namespace AMDiS {
} }
template<typename T> template<typename T>
DOFVector<T>& DOFVector<T>::operator=(const DOFVector<T>& rhs ) DOFVector<T>& DOFVector<T>::operator=(const DOFVector<T>& rhs)
{ {
feSpace=rhs.feSpace; feSpace = rhs.feSpace;
vec=rhs.vec; vec = rhs.vec;
this->elementVector=NULL; this->elementVector = NULL;
interFct=rhs.interFct; interFct = rhs.interFct;
refineInter=rhs.refineInter; refineInter = rhs.refineInter;
coarsenOperation=rhs.coarsenOperation; coarsenOperation = rhs.coarsenOperation;
this->operators=rhs.operators; this->operators = rhs.operators;
this->operatorFactor=rhs.operatorFactor; this->operatorFactor = rhs.operatorFactor;
if (rhs.boundaryManager) { if (rhs.boundaryManager) {
if(this->boundaryManager) delete this->boundaryManager; if (this->boundaryManager)
delete this->boundaryManager;
this->boundaryManager = new BoundaryManager(*rhs.boundaryManager); this->boundaryManager = new BoundaryManager(*rhs.boundaryManager);
// boundaryManager->setDOFVector(this); // boundaryManager->setDOFVector(this);
} else {
this->boundaryManager = NULL;
} }
else
this->boundaryManager=NULL;
return *this; return *this;
} }
......
...@@ -36,8 +36,10 @@ namespace AMDiS { ...@@ -36,8 +36,10 @@ namespace AMDiS {
GET_PARAMETER(0, name + "->output->append index", "%d", &appendIndex); GET_PARAMETER(0, name + "->output->append index", "%d", &appendIndex);
GET_PARAMETER(0, name + "->output->index length", "%d", &indexLength); GET_PARAMETER(0, name + "->output->index length", "%d", &indexLength);
GET_PARAMETER(0, name + "->output->index decimals", "%d", &indexDecimals); GET_PARAMETER(0, name + "->output->index decimals", "%d", &indexDecimals);
GET_PARAMETER(0, name + "->output->write every i-th timestep", "%d", GET_PARAMETER(0, name + "->output->write every i-th timestep", "%d", &tsModulo);
&tsModulo);
TEST_EXIT(tsModulo > 0)
("Init file option \"write every i-th timestep\" is smaller than 1!\n");
} }
void ElementFileWriter::writeFiles(AdaptInfo *adaptInfo, bool force, void ElementFileWriter::writeFiles(AdaptInfo *adaptInfo, bool force,
......
...@@ -155,6 +155,9 @@ namespace AMDiS { ...@@ -155,6 +155,9 @@ namespace AMDiS {
TEST_EXIT(!delayWriting_ || amdisHaveOpenMP) TEST_EXIT(!delayWriting_ || amdisHaveOpenMP)
("Delayed writing only possible with OpenMP support!\n"); ("Delayed writing only possible with OpenMP support!\n");
TEST_EXIT(tsModulo > 0)
("Init file option \"write every i-th timestep\" is smaller than 1!\n");
} }
void FileWriter::writeFiles(AdaptInfo *adaptInfo, void FileWriter::writeFiles(AdaptInfo *adaptInfo,
......
...@@ -84,7 +84,9 @@ namespace AMDiS { ...@@ -84,7 +84,9 @@ namespace AMDiS {
/** \brief /** \brief
* Returns the problem with the given name. * Returns the problem with the given name.
*/ */
virtual ProblemStatBase *getProblem(const ::std::string& name) { return NULL; }; virtual ProblemStatBase *getProblem(const ::std::string& name) {
return NULL;
};
/** \brief /** \brief
* Returns the name of the problem. * Returns the name of the problem.
......
...@@ -177,18 +177,24 @@ namespace AMDiS { ...@@ -177,18 +177,24 @@ namespace AMDiS {
/** \brief /** \brief
* Returns number of managed problems * Returns number of managed problems
*/ */
virtual int getNumProblems() { return 1; }; virtual int getNumProblems() {
return 1;
};
/** \brief /** \brief
* Implementation of ProblemStatBase::getNumComponents() * Implementation of ProblemStatBase::getNumComponents()
*/ */
virtual int getNumComponents() { return 1; }; virtual int getNumComponents() {
return 1;
};
/** \brief /** \brief
* Returns the problem with the given number. If only one problem * Returns the problem with the given number. If only one problem
* is managed by this master problem, the number hasn't to be given. * is managed by this master problem, the number hasn't to be given.
*/ */
virtual ProblemStatBase *getProblem(int number = 0) { return this; }; virtual ProblemStatBase *getProblem(int number = 0) {
return this;
};
/** \brief /** \brief
* Writes output files. * Writes output files.
......
...@@ -39,14 +39,18 @@ namespace AMDiS { ...@@ -39,14 +39,18 @@ namespace AMDiS {
Serializer(ProblemType *problem) Serializer(ProblemType *problem)
: name_(""), : name_(""),
problem_(problem), problem_(problem),
tsModulo_(1), tsModulo(1),
timestepNumber_(-1) timestepNumber_(-1)
{ {
GET_PARAMETER(0, problem_->getName() + "->output->serialization filename", GET_PARAMETER(0, problem_->getName() + "->output->serialization filename",
&name_); &name_);
GET_PARAMETER(0, problem_->getName() + "->output->write every i-th timestep", GET_PARAMETER(0, problem_->getName() + "->output->write every i-th timestep",
"%d", &tsModulo_); "%d", &tsModulo);
TEST_EXIT(name_ != "")("no filename\n"); TEST_EXIT(name_ != "")("no filename\n");
TEST_EXIT(tsModulo > 0)
("Init file option \"write every i-th timestep\" is smaller than 1!\n");
}; };
virtual ~Serializer() {};