[Commits] [svn:einsteintoolkit] incoming/PITTNullCode/SphericalHarmonicReconGen/ (Rev. 108)

bela at caltech.edu bela at caltech.edu
Fri Jan 3 05:01:22 CST 2014


User: szilagyi
Date: 2014/01/03 05:01 AM

Modified:
 /PITTNullCode/SphericalHarmonicReconGen/
  param.ccl, schedule.ccl
 /PITTNullCode/SphericalHarmonicReconGen/src/
  read.cc

Log:
 work on the adaptive timestep controller

File Changes:

Directory: /PITTNullCode/SphericalHarmonicReconGen/
===================================================

File [modified]: param.ccl
Delta lines: +6 -0
===================================================================
--- PITTNullCode/SphericalHarmonicReconGen/param.ccl	2014-01-03 09:40:13 UTC (rev 107)
+++ PITTNullCode/SphericalHarmonicReconGen/param.ccl	2014-01-03 11:01:21 UTC (rev 108)
@@ -32,6 +32,12 @@
  (0:* :: "larger than zero"
 } 0.1
 
+CCTK_REAL adjust_timestep__max_relative_change_per_step \
+"Maximum allowed relative change of the time-step during a single step.  Ignored if time_interpolate==false."
+{
+ (0:1] :: "The smaller the value the more gradual the change in cctk_delta_time."
+} 0.1
+
 CCTK_INT sphere_number "the sphere number (if multiple spheres are present in one file) that corresponds to the worldtube radius NullSHRExtract::cr"
 {
   0:* :: "positive"

File [modified]: schedule.ccl
Delta lines: +4 -1
===================================================================
--- PITTNullCode/SphericalHarmonicReconGen/schedule.ccl	2014-01-03 09:40:13 UTC (rev 107)
+++ PITTNullCode/SphericalHarmonicReconGen/schedule.ccl	2014-01-03 11:01:21 UTC (rev 108)
@@ -21,9 +21,12 @@
 #} "Schedule group for reconstructing world-tube data"
 
 if(adjust_timestep) {
-  SCHEDULE SphericalHarmonicReconGeneric_SetTimeStep IN PreStep
+  SCHEDULE SphericalHarmonicReconGeneric_SetTimeStep at CCTK_PRESTEP \
+  before NullNews_InterpCycleTimelevels \
+  before NullGrid_CopyTime
   {
     LANG: C
+    OPTIONS: global
   } "Set the time-step"
 }
 SCHEDULE SphericalHarmonicReconGeneric_ReadData IN SphericalHarmonicReconRead

Directory: /PITTNullCode/SphericalHarmonicReconGen/src/
=======================================================

File [modified]: read.cc
Delta lines: +23 -7
===================================================================
--- PITTNullCode/SphericalHarmonicReconGen/src/read.cc	2014-01-03 09:40:13 UTC (rev 107)
+++ PITTNullCode/SphericalHarmonicReconGen/src/read.cc	2014-01-03 11:01:21 UTC (rev 108)
@@ -105,20 +105,34 @@
          "      SphericalHarmonicReconGeneric_Startup");
     }
 
+    CCTK_REAL &dt = cctkGH->cctk_delta_time;
+    // no adaptivity for the 1st few time-steps
+    if(cctk_iteration<5) {
+      CCTK_VInfo(CCTK_THORNSTRING, "Time-step has been left at %g",(double)dt);
+      return;
+    }
     SHR::SPH_database& db=*(SHR::db[0]);
-    CCTK_REAL &dt = cctkGH->cctk_delta_time;
-    if(db.n_timesteps()<2) return; // no adjustment
-    if(cctk_time<=db.time(0)) {
+    const double dt_old = dt;
+    const double time=cctk_time + SHR::initial_time_in_file;
+    const double eps=1.e-10*(db.time(1)-db.time(0));
+    if(db.n_timesteps()<2) {
+      CCTK_VInfo(CCTK_THORNSTRING, "Time-step has been left at %g",(double)dt);
+      return; // no adjustment
+    }
+    if(time<db.time(0)-eps) {
       dt = db.time(1)-db.time(0);
+      CCTK_VInfo(CCTK_THORNSTRING, "Time-step has been left at %g",(double)dt);
       return;
     }
-    if(cctk_time>=db.time(db.n_timesteps()-1)) return; // no adjustment
+    if(time>eps+db.time(db.n_timesteps()-1)) {
+      CCTK_VInfo(CCTK_THORNSTRING, "Time-step has been left at %g",(double)dt);
+      return; // no adjustment
+    }
 
-    // locate by bisection the interval containing cctk_time
+    // locate by bisection the interval containing time
     for(int l0=0,l1=db.n_timesteps()-1,c=0;;++c) {
       const int lh=static_cast<int>(0.5*(l0+l1));
-      const double eps=1.e-10*(db.time(1)-db.time(0));
-      if(cctk_time<db.time(lh)-eps) l1=lh;
+      if(time<db.time(lh)-eps) l1=lh;
       else l0=lh;
       if(l1==l0+1) {
         dt = db.time(l1)-db.time(l0);
@@ -131,6 +145,8 @@
     if (time_interpolate)
     {
       dt /= adjust_timestep__steps_per_time_level;
+      // change the time-step gradually
+      dt = dt_old + (dt - dt_old) * adjust_timestep__max_relative_change_per_step;
       dt = std::min(dt,adjust_timestep__maximum_time_step);
     }
     if(verbose) CCTK_VInfo(CCTK_THORNSTRING, "Time-step has been set to %g",(double)dt);



More information about the Commits mailing list