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

bela at caltech.edu bela at caltech.edu
Fri Jan 3 03:40:13 CST 2014


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

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

Log:
 work on adaptive time-stepping

File Changes:

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

File [modified]: param.ccl
Delta lines: +16 -0
===================================================================
--- PITTNullCode/SphericalHarmonicReconGen/param.ccl	2013-12-27 22:16:05 UTC (rev 106)
+++ PITTNullCode/SphericalHarmonicReconGen/param.ccl	2014-01-03 09:40:13 UTC (rev 107)
@@ -16,6 +16,22 @@
 {
 } no
 
+BOOLEAN adjust_timestep "Should the time-step be adjusted?"
+{
+} no
+
+CCTK_INT adjust_timestep__steps_per_time_level \
+"Number of time-steps between two time-values in the datafile. Ignored if time_interpolate==false."
+{
+ 1:* :: "at least one"
+} 1
+
+CCTK_REAL adjust_timestep__maximum_time_step \
+"Maximum allowed time-step. Ignored if time_interpolate==false."
+{
+ (0:* :: "larger than zero"
+} 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: +6 -0
===================================================================
--- PITTNullCode/SphericalHarmonicReconGen/schedule.ccl	2013-12-27 22:16:05 UTC (rev 106)
+++ PITTNullCode/SphericalHarmonicReconGen/schedule.ccl	2014-01-03 09:40:13 UTC (rev 107)
@@ -20,6 +20,12 @@
 #{
 #} "Schedule group for reconstructing world-tube data"
 
+if(adjust_timestep) {
+  SCHEDULE SphericalHarmonicReconGeneric_SetTimeStep IN PreStep
+  {
+    LANG: C
+  } "Set the time-step"
+}
 SCHEDULE SphericalHarmonicReconGeneric_ReadData IN SphericalHarmonicReconRead
 {
   LANG: C

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

File [modified]: read.cc
Delta lines: +43 -0
===================================================================
--- PITTNullCode/SphericalHarmonicReconGen/src/read.cc	2013-12-27 22:16:05 UTC (rev 106)
+++ PITTNullCode/SphericalHarmonicReconGen/src/read.cc	2014-01-03 09:40:13 UTC (rev 107)
@@ -93,6 +93,49 @@
   }
 
 
+  void SphericalHarmonicReconGeneric_SetTimeStep(CCTK_ARGUMENTS)
+  {
+    DECLARE_CCTK_ARGUMENTS;
+    DECLARE_CCTK_PARAMETERS;
+
+    if (! SHR::initialized)
+    {
+      CCTK_WARN(CCTK_WARN_ABORT, "Schedule mismatch. \n"
+         "      SphericalHarmonicReconGeneric_SetTimeStep must be called after\n"
+         "      SphericalHarmonicReconGeneric_Startup");
+    }
+
+    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)) {
+      dt = db.time(1)-db.time(0);
+      return;
+    }
+    if(cctk_time>=db.time(db.n_timesteps()-1)) return; // no adjustment
+
+    // locate by bisection the interval containing cctk_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;
+      else l0=lh;
+      if(l1==l0+1) {
+        dt = db.time(l1)-db.time(l0);
+        break;
+      }
+      if(c>2+db.n_timesteps()) CCTK_WARN(0, "run-away bisection algorithm");
+    }
+
+    //if (CCTK_MyProc(cctkGH) == 0)
+    if (time_interpolate)
+    {
+      dt /= adjust_timestep__steps_per_time_level;
+      dt = std::min(dt,adjust_timestep__maximum_time_step);
+    }
+    if(verbose) CCTK_VInfo(CCTK_THORNSTRING, "Time-step has been set to %g",(double)dt);
+  }
+  
   void SphericalHarmonicReconGeneric_ReadData(CCTK_ARGUMENTS)
   {
     DECLARE_CCTK_ARGUMENTS;



More information about the Commits mailing list