diff --git a/AMDiS/src/AdaptInfo.cc b/AMDiS/src/AdaptInfo.cc index 3275be8642e9f35aaf586a287b07b43920b7cce9..3d517c93529a873d45f47821233f70d036595155 100644 --- a/AMDiS/src/AdaptInfo.cc +++ b/AMDiS/src/AdaptInfo.cc @@ -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); diff --git a/AMDiS/src/AdaptInfo.h b/AMDiS/src/AdaptInfo.h index e46d8e1cd94111b8b36de3480b5a6eaf816669ed..2ff0d4ec9a850895071ba96d17e01197b3b286a3 100644 --- a/AMDiS/src/AdaptInfo.h +++ b/AMDiS/src/AdaptInfo.h @@ -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. diff --git a/AMDiS/src/AdaptInstationary.cc b/AMDiS/src/AdaptInstationary.cc index 64fa550cdc5cbeb124e0fb0eec06ee1e9b43fb45..2d9144fd76b1eddf1baca4b2dadda6cc6859b729 100644 --- a/AMDiS/src/AdaptInstationary.cc +++ b/AMDiS/src/AdaptInstationary.cc @@ -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