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

added posibility to use est_t_max for time adaptivity. The time error may now...

added posibility to use est_t_max for time adaptivity. The time error may now be defined as est_t_combined =sum_fac*est_t_sum + max_fac*est_t_max. Default is sum_fac=1 and max_fac=0. Thus, by default adaption is working as before. 
parent 8ee949af
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,8 @@ namespace AMDiS {
SerUtil::serialize(out, scalContents[i]->est_t_sum);
SerUtil::serialize(out, scalContents[i]->est_max);
SerUtil::serialize(out, scalContents[i]->est_t_max);
SerUtil::serialize(out, scalContents[i]->fac_max);
SerUtil::serialize(out, scalContents[i]->fac_sum);
SerUtil::serialize(out, scalContents[i]->spaceTolerance);
SerUtil::serialize(out, scalContents[i]->timeTolerance);
SerUtil::serialize(out, scalContents[i]->timeErrLow);
......@@ -93,6 +95,8 @@ namespace AMDiS {
SerUtil::deserialize(in, scalContents[i]->est_t_sum);
SerUtil::deserialize(in, scalContents[i]->est_max);
SerUtil::deserialize(in, scalContents[i]->est_t_max);
SerUtil::deserialize(in, scalContents[i]->fac_max);
SerUtil::deserialize(in, scalContents[i]->fac_sum);
SerUtil::deserialize(in, scalContents[i]->spaceTolerance);
SerUtil::deserialize(in, scalContents[i]->timeTolerance);
SerUtil::deserialize(in, scalContents[i]->timeErrLow);
......
......@@ -47,16 +47,19 @@ namespace AMDiS {
/// Constructor.
ScalContent(std::string prefix)
: est_sum(0.0),
est_t_sum(0.0),
est_max(0.0),
est_t_max(0.0),
spaceTolerance(1.0),
timeTolerance(1.0),
timeErrLow(1.0),
coarsenAllowed(0),
refinementAllowed(1),
refineBisections(1),
coarseBisections(1)
est_t_sum(0.0),
est_max(0.0),
est_t_max(0.0),
fac_max(0.0),
fac_sum(1.0),
spaceTolerance(1.0),
timeTolerance(1.0),
timeErrLow(1.0),
coarsenAllowed(0),
refinementAllowed(1),
refineBisections(1),
coarseBisections(1)
{
double totalTol = 1.0;
double relSpaceErr = 1.0;
......@@ -73,6 +76,8 @@ namespace AMDiS {
GET_PARAMETER(0, prefix + "->refinement allowed", "%d", &refinementAllowed);
GET_PARAMETER(0, prefix + "->refine bisections", "%d", &refineBisections);
GET_PARAMETER(0, prefix + "->coarsen bisections", "%d", &coarseBisections);
GET_PARAMETER(0, prefix + "->sum factor", "%f", &fac_sum);
GET_PARAMETER(0, prefix + "->max factor", "%f", &fac_max);
spaceTolerance = totalTol * relSpaceErr;
timeTolerance = totalTol * relTimeErr * timeTheta1;
......@@ -90,6 +95,9 @@ namespace AMDiS {
/// Maximum of all time error estimates
double est_t_max;
/// factors to combine max and integral time estimate
double fac_max, fac_sum;
/// Tolerance for the (absolute or relative) error
double spaceTolerance;
......@@ -220,7 +228,7 @@ namespace AMDiS {
virtual bool timeToleranceReached()
{
for (unsigned int i = 0; i < scalContents.size(); i++)
if (!(scalContents[i]->est_t_sum < scalContents[i]->timeTolerance))
if (!(getTimeEstCombined(i) < scalContents[i]->timeTolerance))
return false;
return true;
......@@ -229,7 +237,7 @@ namespace AMDiS {
/// Returns whether time tolerance of component i is reached.
virtual bool timeToleranceReached(int i)
{
if (!(scalContents[i]->est_t_sum < scalContents[i]->timeTolerance))
if (!(getTimeEstCombined(i) < scalContents[i]->timeTolerance))
return false;
else
return true;
......@@ -239,19 +247,30 @@ namespace AMDiS {
virtual bool timeErrorLow()
{
for (unsigned int i = 0; i < scalContents.size(); i++)
if (!(scalContents[i]->est_t_sum < scalContents[i]->timeErrLow))
if (!(getTimeEstCombined(i) < scalContents[i]->timeErrLow))
return false;
return true;
}
/// Returns the time estimation as a combination
/// of maximal and integral time error
double getTimeEstCombined(unsigned i) const
{
return scalContents[i]->est_t_max*scalContents[i]->fac_max
+scalContents[i]->est_t_sum*scalContents[i]->fac_sum;
}
/// Print debug information about time error and its bound.
void printTimeErrorLowInfo()
{
for (unsigned int i = 0; i < scalContents.size(); i++)
std::cout << " Time error estimate = " << scalContents[i]->est_t_sum
for (unsigned int i = 0; i < scalContents.size(); i++){
std::cout << " Time error estimate = " << getTimeEstCombined(i)
<< " Time error estimate sum = " << scalContents[i]->est_t_sum
<< " Time error estimate max = " << scalContents[i]->est_t_max
<< " Time error low bound = " << scalContents[i]->timeErrLow
<< " Time error high bound = " << scalContents[i]->timeTolerance << "\n";
}
}
/// Returns \ref spaceIteration.
......
......@@ -138,16 +138,18 @@ namespace AMDiS {
problemIteration_->oneIteration(adaptInfo, NO_ADAPTION);
adaptInfo->incTimestepIteration();
if (!fixedTimestep_ &&
!adaptInfo->timeToleranceReached() &&
adaptInfo->getTimestepIteration() <= adaptInfo->getMaxTimestepIteration() &&
!(adaptInfo->getTimestep() <= adaptInfo->getMinTimestep())) {
adaptInfo->setTime(adaptInfo->getTime() - adaptInfo->getTimestep());
adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1);
continue;
adaptInfo->setTime(adaptInfo->getTime() - adaptInfo->getTimestep());
adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1);
continue;
}
adaptInfo->setSpaceIteration(0);
......@@ -185,6 +187,7 @@ namespace AMDiS {
} while(!adaptInfo->timeToleranceReached() &&
!(adaptInfo->getTimestep() <= adaptInfo->getMinTimestep()) &&
adaptInfo->getTimestepIteration() <= adaptInfo->getMaxTimestepIteration());
adaptInfo->setLastProcessedTimestep(adaptInfo->getTimestep());
// After successful iteration/timestep the timestep will be changed according
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment