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

* Small bug fixes

parent 18c0eba3
......@@ -65,7 +65,7 @@ The runtime will increase by factor 5 to 6 without --enable-debug!
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.
......
......@@ -43,14 +43,14 @@ namespace AMDiS {
/** \brief
* Constructor
*/
AdaptBase(const ::std::string& name,
AdaptBase(const ::std::string& name,
ProblemIterationInterface *problemIteration,
AdaptInfo *adaptInfo,
ProblemTimeInterface *problemTime = NULL,
AdaptInfo *initialAdaptInfo = NULL)
AdaptInfo *adaptInfo_,
ProblemTimeInterface *problemTime = NULL,
AdaptInfo *initialAdaptInfo = NULL)
: name_(name),
problemIteration_(problemIteration),
adaptInfo_(adaptInfo),
adaptInfo(adaptInfo_),
problemTime_(problemTime),
initialAdaptInfo_(initialAdaptInfo)
{};
......@@ -85,10 +85,10 @@ namespace AMDiS {
};
/** \brief
* Returns \ref adaptInfo_
* Returns \ref adaptInfo
*/
inline AdaptInfo *getAdaptInfo() {
return adaptInfo_;
return adaptInfo;
};
/** \brief
......@@ -123,7 +123,7 @@ namespace AMDiS {
/** \brief
* Main adapt info
*/
AdaptInfo *adaptInfo_;
AdaptInfo *adaptInfo;
/** \brief
* problem time interface
......
......@@ -77,24 +77,24 @@ namespace AMDiS {
FUNCNAME("AdaptInstationary::explicitTimeStrategy()");
// estimate before first adaption
if (adaptInfo_->getTime() <= adaptInfo_->getStartTime()) {
problemIteration_->oneIteration(adaptInfo_, ESTIMATE);
if (adaptInfo->getTime() <= adaptInfo->getStartTime()) {
problemIteration_->oneIteration(adaptInfo, ESTIMATE);
}
// 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",
adaptInfo_->getTime(), adaptInfo_->getTimestep());
adaptInfo->getTime(), adaptInfo->getTimestep());
adaptInfo_->setSpaceIteration(0);
adaptInfo->setSpaceIteration(0);
// do the iteration
problemIteration_->beginIteration(adaptInfo_);
problemIteration_->oneIteration(adaptInfo_, FULL_ITERATION);
problemIteration_->endIteration(adaptInfo_);
problemIteration_->beginIteration(adaptInfo);
problemIteration_->oneIteration(adaptInfo, FULL_ITERATION);
problemIteration_->endIteration(adaptInfo);
}
void AdaptInstationary::implicitTimeStrategy()
......@@ -102,54 +102,54 @@ namespace AMDiS {
FUNCNAME("AdaptInstationary::implicitTimeStrategy()");
do {
adaptInfo_->setTime(adaptInfo_->getTime() + adaptInfo_->getTimestep());
problemTime_->setTime(adaptInfo_);
adaptInfo->setTime(adaptInfo->getTime() + adaptInfo->getTimestep());
problemTime_->setTime(adaptInfo);
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_ &&
!adaptInfo_->timeToleranceReached() &&
!adaptInfo_->getTimestep() <= adaptInfo_->getMinTimestep())
!adaptInfo->timeToleranceReached() &&
!adaptInfo->getTimestep() <= adaptInfo->getMinTimestep())
{
adaptInfo_->setTime(adaptInfo_->getTime() - adaptInfo_->getTimestep());
adaptInfo_->setTimestep(adaptInfo_->getTimestep() * time_delta_1);
adaptInfo->setTime(adaptInfo->getTime() - adaptInfo->getTimestep());
adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1);
continue;
}
adaptInfo_->setSpaceIteration(0);
adaptInfo->setSpaceIteration(0);
do {
problemIteration_->beginIteration(adaptInfo_);
problemIteration_->beginIteration(adaptInfo);
if (problemIteration_->oneIteration(adaptInfo_, FULL_ITERATION)) {
if (problemIteration_->oneIteration(adaptInfo, FULL_ITERATION)) {
if (!fixedTimestep_ &&
!adaptInfo_->timeToleranceReached() &&
!adaptInfo_->getTimestep() <= adaptInfo_->getMinTimestep())
!adaptInfo->timeToleranceReached() &&
!adaptInfo->getTimestep() <= adaptInfo->getMinTimestep())
{
adaptInfo_->setTime(adaptInfo_->getTime() - adaptInfo_->getTimestep());
adaptInfo_->setTimestep(adaptInfo_->getTimestep() * time_delta_1);
problemIteration_->endIteration(adaptInfo_);
adaptInfo_->incSpaceIteration();
adaptInfo->setTime(adaptInfo->getTime() - adaptInfo->getTimestep());
adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1);
problemIteration_->endIteration(adaptInfo);
adaptInfo->incSpaceIteration();
break;
}
}
adaptInfo_->incSpaceIteration();
problemIteration_->endIteration(adaptInfo_);
adaptInfo->incSpaceIteration();
problemIteration_->endIteration(adaptInfo);
} while(!adaptInfo_->spaceToleranceReached() &&
adaptInfo_->getSpaceIteration() <= adaptInfo_->getMaxSpaceIteration());
} while(!adaptInfo_->timeToleranceReached() &&
!adaptInfo_->getTimestep() <= adaptInfo_->getMinTimestep() &&
adaptInfo_->getTimestepIteration() <= adaptInfo_->getMaxTimestepIteration());
} while(!adaptInfo->spaceToleranceReached() &&
adaptInfo->getSpaceIteration() <= adaptInfo->getMaxSpaceIteration());
} while(!adaptInfo->timeToleranceReached() &&
!adaptInfo->getTimestep() <= adaptInfo->getMinTimestep() &&
adaptInfo->getTimestepIteration() <= adaptInfo->getMaxTimestepIteration());
if (!fixedTimestep_ && adaptInfo_->timeErrorLow()) {
adaptInfo_->setTimestep(adaptInfo_->getTimestep() *time_delta_2);
if (!fixedTimestep_ && adaptInfo->timeErrorLow()) {
adaptInfo->setTimestep(adaptInfo->getTimestep() *time_delta_2);
}
}
......@@ -157,7 +157,7 @@ namespace AMDiS {
{
FUNCNAME("AdaptInstationary::oneTimestep");
adaptInfo_->setTimestepIteration(0);
adaptInfo->setTimestepIteration(0);
switch(strategy)
{
......@@ -172,7 +172,7 @@ namespace AMDiS {
explicitTimeStrategy();
}
adaptInfo_->incTimestepNumber();
adaptInfo->incTimestepNumber();
}
int AdaptInstationary::adapt()
......@@ -181,29 +181,36 @@ namespace AMDiS {
int errorCode = 0;
TEST_EXIT(adaptInfo_->getTimestep() >= adaptInfo_->getMinTimestep())
TEST_EXIT(adaptInfo->getTimestep() >= adaptInfo->getMinTimestep())
("timestep < min timestep\n");
TEST_EXIT(adaptInfo_->getTimestep() <= adaptInfo_->getMaxTimestep())
TEST_EXIT(adaptInfo->getTimestep() <= adaptInfo->getMaxTimestep())
("timestep > max timestep\n");
TEST_EXIT(adaptInfo_->getTimestep() > 0)("timestep <= 0!\n");
TEST_EXIT(adaptInfo->getTimestep() > 0)("timestep <= 0!\n");
if (adaptInfo_->getTimestepNumber() == 0) {
adaptInfo_->setTime(adaptInfo_->getStartTime());
initialAdaptInfo_->setStartTime(adaptInfo_->getStartTime());
initialAdaptInfo_->setTime(adaptInfo_->getStartTime());
if (adaptInfo->getTimestepNumber() == 0) {
adaptInfo->setTime(adaptInfo->getStartTime());
initialAdaptInfo_->setStartTime(adaptInfo->getStartTime());
initialAdaptInfo_->setTime(adaptInfo->getStartTime());
problemTime_->setTime(adaptInfo_);
problemTime_->setTime(adaptInfo);
// initial adaption
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);
problemTime_->initTimestep(adaptInfo_);
problemTime_->initTimestep(adaptInfo);
#ifdef _OPENMP
if (problemTime_->existsDelayedCalculation()) {
......@@ -223,9 +230,9 @@ namespace AMDiS {
oneTimestep();
#endif
problemTime_->closeTimestep(adaptInfo_);
problemTime_->closeTimestep(adaptInfo);
if (breakWhenStable && (adaptInfo_->getSolverIterations() == 0)) {
if (breakWhenStable && (adaptInfo->getSolverIterations() == 0)) {
break;
}
......@@ -269,7 +276,7 @@ namespace AMDiS {
FUNCNAME("AdaptInstationary::serialize()");
problemIteration_->serialize(out);
adaptInfo_->serialize(out);
adaptInfo->serialize(out);
if (problemTime_) {
problemTime_->serialize(out);
}
......@@ -280,7 +287,7 @@ namespace AMDiS {
FUNCNAME("AdaptInstationary::deserialize()");
problemIteration_->deserialize(in);
adaptInfo_->deserialize(in);
adaptInfo->deserialize(in);
if (problemTime_) {
problemTime_->deserialize(in);
}
......@@ -298,20 +305,20 @@ namespace AMDiS {
time_t currentTimestamp = time(NULL);
// 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.
if (lastIterationsDuration_.size() > 5) {
lastIterationsDuration_.pop();
if (lastIterationsDuration.size() > 5) {
lastIterationsDuration.pop();
}
// Calculate the avarage of the last iterations.
::std::queue<int> tmpQueue = lastIterationsDuration_;
::std::queue<int> tmpQueue = lastIterationsDuration;
int avrgLastIterations = 0;
while (!tmpQueue.empty()) {
avrgLastIterations += tmpQueue.front();
tmpQueue.pop();
}
avrgLastIterations /= lastIterationsDuration_.size();
avrgLastIterations /= lastIterationsDuration.size();
// Check if there is enough time for a further iteration.
if (initialTimestamp_ + queueRuntime_ - currentTimestamp < avrgLastIterations * 2) {
......
......@@ -186,7 +186,7 @@ namespace AMDiS {
/** \brief
* Stores the runtime (in seconds) of some last timestep iterations.
*/
::std::queue<int> lastIterationsDuration_;
::std::queue<int> lastIterationsDuration;
};
}
......
......@@ -20,26 +20,26 @@ namespace AMDiS {
FUNCNAME("AdaptStationary::adapt()");
// initial iteration
if (adaptInfo_->getSpaceIteration() == -1) {
problemIteration_->beginIteration(adaptInfo_);
problemIteration_->oneIteration(adaptInfo_, NO_ADAPTION);
problemIteration_->endIteration(adaptInfo_);
adaptInfo_->incSpaceIteration();
if (adaptInfo->getSpaceIteration() == -1) {
problemIteration_->beginIteration(adaptInfo);
problemIteration_->oneIteration(adaptInfo, NO_ADAPTION);
problemIteration_->endIteration(adaptInfo);
adaptInfo->incSpaceIteration();
}
// adaption loop
while (!adaptInfo_->spaceToleranceReached() &&
(adaptInfo_->getSpaceIteration() < adaptInfo_->getMaxSpaceIteration() ||
adaptInfo_->getMaxSpaceIteration() < 0) ) {
while (!adaptInfo->spaceToleranceReached() &&
(adaptInfo->getSpaceIteration() < adaptInfo->getMaxSpaceIteration() ||
adaptInfo->getMaxSpaceIteration() < 0) ) {
problemIteration_->beginIteration(adaptInfo_);
Flag adapted = problemIteration_->oneIteration(adaptInfo_, FULL_ITERATION);
problemIteration_->endIteration(adaptInfo_);
problemIteration_->beginIteration(adaptInfo);
Flag adapted = problemIteration_->oneIteration(adaptInfo, FULL_ITERATION);
problemIteration_->endIteration(adaptInfo);
if (!adapted)
break;
adaptInfo_->incSpaceIteration();
adaptInfo->incSpaceIteration();
}
return 0;
......
......@@ -785,23 +785,24 @@ namespace AMDiS {
}
template<typename T>
DOFVector<T>& DOFVector<T>::operator=(const DOFVector<T>& rhs )
DOFVector<T>& DOFVector<T>::operator=(const DOFVector<T>& rhs)
{
feSpace=rhs.feSpace;
vec=rhs.vec;
this->elementVector=NULL;
interFct=rhs.interFct;
refineInter=rhs.refineInter;
coarsenOperation=rhs.coarsenOperation;
this->operators=rhs.operators;
this->operatorFactor=rhs.operatorFactor;
feSpace = rhs.feSpace;
vec = rhs.vec;
this->elementVector = NULL;
interFct = rhs.interFct;
refineInter = rhs.refineInter;
coarsenOperation = rhs.coarsenOperation;
this->operators = rhs.operators;
this->operatorFactor = rhs.operatorFactor;
if (rhs.boundaryManager) {
if(this->boundaryManager) delete this->boundaryManager;
if (this->boundaryManager)
delete this->boundaryManager;
this->boundaryManager = new BoundaryManager(*rhs.boundaryManager);
// boundaryManager->setDOFVector(this);
} else {
this->boundaryManager = NULL;
}
else
this->boundaryManager=NULL;
return *this;
}
......
......@@ -36,8 +36,10 @@ namespace AMDiS {
GET_PARAMETER(0, name + "->output->append index", "%d", &appendIndex);
GET_PARAMETER(0, name + "->output->index length", "%d", &indexLength);
GET_PARAMETER(0, name + "->output->index decimals", "%d", &indexDecimals);
GET_PARAMETER(0, name + "->output->write every i-th timestep", "%d",
&tsModulo);
GET_PARAMETER(0, name + "->output->write every i-th timestep", "%d", &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,
......
......@@ -155,6 +155,9 @@ namespace AMDiS {
TEST_EXIT(!delayWriting_ || amdisHaveOpenMP)
("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,
......
......@@ -84,7 +84,9 @@ namespace AMDiS {
/** \brief
* 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
* Returns the name of the problem.
......
......@@ -177,18 +177,24 @@ namespace AMDiS {
/** \brief
* Returns number of managed problems
*/
virtual int getNumProblems() { return 1; };
virtual int getNumProblems() {
return 1;
};
/** \brief
* Implementation of ProblemStatBase::getNumComponents()
*/
virtual int getNumComponents() { return 1; };
virtual int getNumComponents() {
return 1;
};
/** \brief
* Returns the problem with the given number. If only one problem
* 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
* Writes output files.
......
......@@ -39,14 +39,18 @@ namespace AMDiS {
Serializer(ProblemType *problem)
: name_(""),
problem_(problem),
tsModulo_(1),
tsModulo(1),
timestepNumber_(-1)
{
GET_PARAMETER(0, problem_->getName() + "->output->serialization filename",
&name_);
GET_PARAMETER(0, problem_->getName() + "->output->write every i-th timestep",
"%d", &tsModulo_);
"%d", &tsModulo);
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() {};
......@@ -60,7 +64,7 @@ namespace AMDiS {
FUNCNAME("Serializer::writeFiles()");
timestepNumber_++;
timestepNumber_ %= tsModulo_;
timestepNumber_ %= tsModulo;
if ((timestepNumber_ != 0) && !force) {
return;
}
......@@ -95,7 +99,7 @@ namespace AMDiS {
/** \brief
* The problem is serialized every tsModulo-th timestep.
*/
int tsModulo_;
int tsModulo;
/** \brief
* Current timestep number.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment