Liebe Gitlab-Nutzerin, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

Commit 52d5144a authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Bla

parent 9df9d4af
......@@ -45,20 +45,20 @@ namespace AMDiS {
*/
AdaptBase(const std::string& name,
ProblemIterationInterface *problemIteration,
AdaptInfo *adaptInfo,
AdaptInfo *adapt,
ProblemTimeInterface *problemTime = NULL,
AdaptInfo *initialAdaptInfo = NULL)
: name_(name),
problemIteration_(problemIteration),
adaptInfo_(adaptInfo),
adaptInfo(adapt),
problemTime_(problemTime),
initialAdaptInfo_(initialAdaptInfo)
{};
{}
/** \brief
* Destructor
*/
virtual ~AdaptBase() {};
virtual ~AdaptBase() {}
/** \brief
* Pure virtual method. Must be overloaded by sub classes to perform
......@@ -71,32 +71,32 @@ namespace AMDiS {
*/
inline const std::string& getName() const {
return name_;
};
}
/** \brief
* Returns \ref problemIteration_
*/
inline ProblemIterationInterface *getProblemIteration() {
return problemIteration_;
};
}
inline void setProblemIteration(ProblemIterationInterface *pii) {
problemIteration_ = pii;
};
}
/** \brief
* Returns \ref adaptInfo_
* Returns \ref adaptInfo
*/
inline AdaptInfo *getAdaptInfo() {
return adaptInfo_;
};
return adaptInfo;
}
/** \brief
* Returns \ref problemTime_
*/
inline ProblemTimeInterface *getProblemTime() {
return problemTime_;
};
}
inline void setProblemTime(ProblemTimeInterface *pti) {
problemTime_ = pti;
......@@ -107,7 +107,7 @@ namespace AMDiS {
*/
inline AdaptInfo *getInitialAdaptInfo() {
return initialAdaptInfo_;
};
}
protected:
/** \brief
......@@ -123,7 +123,7 @@ namespace AMDiS {
/** \brief
* Main adapt info
*/
AdaptInfo *adaptInfo_;
AdaptInfo *adaptInfo;
/** \brief
* problem time interface
......
......@@ -31,6 +31,7 @@ namespace AMDiS {
out.write(reinterpret_cast<const char*>(&minTimestep), sizeof(double));
out.write(reinterpret_cast<const char*>(&maxTimestep), sizeof(double));
out.write(reinterpret_cast<const char*>(&timestepNumber), sizeof(int));
out.write(reinterpret_cast<const char*>(&nTimesteps), sizeof(int));
out.write(reinterpret_cast<const char*>(&solverIterations), sizeof(int));
out.write(reinterpret_cast<const char*>(&maxSolverIterations), sizeof(int));
out.write(reinterpret_cast<const char*>(&solverTolerance), sizeof(double));
......@@ -80,6 +81,7 @@ namespace AMDiS {
in.read(reinterpret_cast<char*>(&minTimestep), sizeof(double));
in.read(reinterpret_cast<char*>(&maxTimestep), sizeof(double));
in.read(reinterpret_cast<char*>(&timestepNumber), sizeof(int));
in.read(reinterpret_cast<char*>(&nTimesteps), sizeof(int));
in.read(reinterpret_cast<char*>(&solverIterations), sizeof(int));
in.read(reinterpret_cast<char*>(&maxSolverIterations), sizeof(int));
in.read(reinterpret_cast<char*>(&solverTolerance), sizeof(double));
......
......@@ -165,6 +165,7 @@ namespace AMDiS {
minTimestep(0.0),
maxTimestep(1.0),
timestepNumber(0),
nTimesteps(0),
solverIterations(0),
maxSolverIterations(0),
solverTolerance(1e-8),
......@@ -183,6 +184,8 @@ namespace AMDiS {
GET_PARAMETER(0, name_ + "->min timestep", "%f", &minTimestep);
GET_PARAMETER(0, name_ + "->max timestep", "%f", &maxTimestep);
GET_PARAMETER(0, name_ + "->number of timesteps", "%d", &nTimesteps);
if (size == 1) {
scalContents[0] = new ScalContent(name);
} else {
......@@ -400,6 +403,11 @@ namespace AMDiS {
return timestepNumber;
}
/// Returns \ref nTimesteps.
inline int getNumberOfTimesteps() {
return nTimesteps;
}
/** \brief
* Increments \ref timestepNumber by 1;
*/
......@@ -536,6 +544,15 @@ namespace AMDiS {
return timestep;
}
/** \brief
* Returns true, if the end time is reached and no more timestep
* computations must be done.
*/
inline bool reachedEndTime() {
return !(time < endTime - DBL_TOL ||
(nTimesteps > 0 && timestepNumber < nTimesteps));
}
/** \brief
* Gets \ref timestep
*/
......@@ -798,6 +815,13 @@ namespace AMDiS {
* Number of current time step
*/
int timestepNumber;
/** \brief
* Per default this value is 0 and not used. If it is set to a non-zero value,
* the computation of the stationary problem is done nTimesteps times with a
* fixed timestep.
*/
int nTimesteps;
/** \brief
* number of iterations needed of linear or nonlinear solver
......
......@@ -78,24 +78,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()
......@@ -103,66 +103,66 @@ 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 only space iterations only if the maximum is higher than 0. === */
if (adaptInfo_->getMaxSpaceIteration() > 0) {
if (adaptInfo->getMaxSpaceIteration() > 0) {
/* === Space iterations === */
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->spaceToleranceReached() &&
adaptInfo->getSpaceIteration() <= adaptInfo->getMaxSpaceIteration());
} else {
problemIteration_->endIteration(adaptInfo_);
problemIteration_->endIteration(adaptInfo);
}
} while(!adaptInfo_->timeToleranceReached() &&
!adaptInfo_->getTimestep() <= adaptInfo_->getMinTimestep() &&
adaptInfo_->getTimestepIteration() <= adaptInfo_->getMaxTimestepIteration());
} 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);
if (dbgMode) {
// print information about timestep increase
}
......@@ -173,8 +173,8 @@ namespace AMDiS {
if (fixedTimestep_) {
std::cout << " fixedTimestep = true\n";
}
if (!adaptInfo_->timeErrorLow()) {
adaptInfo_->printTimeErrorLowInfo();
if (!adaptInfo->timeErrorLow()) {
adaptInfo->printTimeErrorLowInfo();
}
}
}
......@@ -184,7 +184,7 @@ namespace AMDiS {
{
FUNCNAME("AdaptInstationary::oneTimestep()");
adaptInfo_->setTimestepIteration(0);
adaptInfo->setTimestepIteration(0);
switch (strategy) {
case 0:
......@@ -198,7 +198,7 @@ namespace AMDiS {
explicitTimeStrategy();
}
adaptInfo_->incTimestepNumber();
adaptInfo->incTimestepNumber();
}
int AdaptInstationary::adapt()
......@@ -207,35 +207,33 @@ 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->reachedEndTime()) {
iterationTimestamp_ = time(NULL);
problemTime_->initTimestep(adaptInfo_);
problemTime_->initTimestep(adaptInfo);
oneTimestep();
problemTime_->closeTimestep(adaptInfo);
problemTime_->closeTimestep(adaptInfo_);
if (breakWhenStable && (adaptInfo_->getSolverIterations() == 0)) {
if (breakWhenStable && (adaptInfo->getSolverIterations() == 0)) {
break;
}
......@@ -277,7 +275,7 @@ namespace AMDiS {
FUNCNAME("AdaptInstationary::serialize()");
problemIteration_->serialize(out);
adaptInfo_->serialize(out);
adaptInfo->serialize(out);
if (problemTime_) {
problemTime_->serialize(out);
}
......@@ -288,7 +286,7 @@ namespace AMDiS {
FUNCNAME("AdaptInstationary::deserialize()");
problemIteration_->deserialize(in);
adaptInfo_->deserialize(in);
adaptInfo->deserialize(in);
if (problemTime_) {
problemTime_->deserialize(in);
}
......
......@@ -78,7 +78,7 @@ namespace AMDiS {
*/
const int getStrategy() const {
return strategy;
};
}
/** \brief
* Implementation of AdaptBase::adapt()
......
......@@ -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;
......
......@@ -65,7 +65,7 @@ namespace AMDiS {
/** \brief
* Destructor
*/
virtual ~AdaptStationary() {};
virtual ~AdaptStationary() {}
/** \brief
* Implementation of AdaptBase::adapt()
......
......@@ -5,11 +5,11 @@ namespace AMDiS {
int AdaptParaReal::adapt()
{
// Compute number of coarse and fine time stages.
int coarseStages = static_cast<int>(round(adaptInfo_->getEndTime() / coarseTimestep));
int coarseStages = static_cast<int>(round(adaptInfo->getEndTime() / coarseTimestep));
int fineStages = static_cast<int>(round(coarseTimestep / fineTimestep));
// First, sequentially calculate first approximation on coarse time grid.
adaptInfo_->setTimestep(coarseTimestep);
adaptInfo->setTimestep(coarseTimestep);
pararealProb->setStoreSolutions(false, true);
pararealProb->setStoreInitSolution(true);
pararealProb->setInitSolutionVec(NULL);
......@@ -19,9 +19,9 @@ namespace AMDiS {
for (int k = 0; k < pararealIter; k++) {
// Compute solutions with fine timestep on the coarse grid slides.
for (int i = 0; i < coarseStages; i++) {
adaptInfo_->resetTimeValues(fineTimestep,
i * coarseTimestep,
(i + 1) *coarseTimestep);
adaptInfo->resetTimeValues(fineTimestep,
i * coarseTimestep,
(i + 1) *coarseTimestep);
pararealProb->setStoreSolutions(true, false);
pararealProb->setStoreInitSolution(false);
pararealProb->setInitSolutionVec((*pararealProb->getCoarseSolutions())[i]);
......@@ -38,7 +38,7 @@ namespace AMDiS {
// Again, compute solutions on coarse grid and calculate the corrected solutions.
for (int i = 1; i <= coarseStages; i++) {
adaptInfo_->resetTimeValues(coarseTimestep,
adaptInfo->resetTimeValues(coarseTimestep,
(i - 1) * coarseTimestep,
i * coarseTimestep);
pararealProb->setStoreSolutions(false, true);
......
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