From 9c9766cc5ed93eb540f111afe9c2fb89fd82689a Mon Sep 17 00:00:00 2001
From: Rainer Backofen <rainer.backofen@tu-dresden.de>
Date: Tue, 6 Apr 2010 08:54:39 +0000
Subject: [PATCH] adaption loop symmetrized w.r.t. increase and decrease of
 timestep

---
 AMDiS/src/AdaptInfo.h          |  3 ++-
 AMDiS/src/AdaptInstationary.cc | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/AMDiS/src/AdaptInfo.h b/AMDiS/src/AdaptInfo.h
index b4878c78..e46d8e1c 100644
--- a/AMDiS/src/AdaptInfo.h
+++ b/AMDiS/src/AdaptInfo.h
@@ -250,7 +250,8 @@ namespace AMDiS {
     {
       for (unsigned int i = 0; i < scalContents.size(); i++)
 	std::cout << "    Time error estimate = " << scalContents[i]->est_t_sum 
-		  << "    Time error bound = " << scalContents[i]->timeErrLow << "\n";
+		  << "    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 6c68c285..64fa550c 100644
--- a/AMDiS/src/AdaptInstationary.cc
+++ b/AMDiS/src/AdaptInstationary.cc
@@ -186,6 +186,10 @@ namespace AMDiS {
 	    !(adaptInfo->getTimestep() <= adaptInfo->getMinTimestep()) && 
 	    adaptInfo->getTimestepIteration() <= adaptInfo->getMaxTimestepIteration());  
     adaptInfo->setLastProcessedTimestep(adaptInfo->getTimestep()); 
+
+    // After successful iteration/timestep the timestep will be changed according 
+    // adaption rules for next timestep. 
+    // First, check for increase of timestep
     if (!fixedTimestep_ && adaptInfo->timeErrorLow()) {
       adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_2);
       if (dbgMode) {
@@ -201,6 +205,12 @@ namespace AMDiS {
 	  adaptInfo->printTimeErrorLowInfo();
       }
     }
+    // Second, check for decrease of timestep
+    if (!fixedTimestep_ &&
+	!adaptInfo->timeToleranceReached() &&
+	!(adaptInfo->getTimestep() <= adaptInfo->getMinTimestep())) {
+	adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1);
+    }
   }
 
   void AdaptInstationary::oneTimestep()
-- 
GitLab