User: szilagyi Date: 2014/01/07 04:35 PM
Modified: /PITTNullCode/SphericalHarmonicReconGen/ param.ccl, schedule.ccl /PITTNullCode/SphericalHarmonicReconGen/src/ read.cc
Log: work on the time-step adjuster algorithm
File Changes:
Directory: /PITTNullCode/SphericalHarmonicReconGen/ ===================================================
File [modified]: param.ccl Delta lines: +8 -8 =================================================================== --- PITTNullCode/SphericalHarmonicReconGen/param.ccl 2014-01-07 05:53:08 UTC (rev 110) +++ PITTNullCode/SphericalHarmonicReconGen/param.ccl 2014-01-07 22:35:23 UTC (rev 111) @@ -16,27 +16,27 @@ { } no
-BOOLEAN adjust_timestep "Should the time-step be adjusted?" +BOOLEAN adjust_timestep "Should the time-step be adjusted? Ignored if time_interpolate==false." { } 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." +CCTK_INT adjust_timestep__target_steps_per_time_level \ +"Target number of time-steps between two time-values in the datafile." { 1:* :: "at least one" } 1
CCTK_REAL adjust_timestep__maximum_time_step \ -"Maximum allowed time-step. Ignored if time_interpolate==false." +"Maximum allowed time-step." { (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." +CCTK_REAL adjust_timestep__rate_of_change \ +"Rate of change of the time-step." { - (0:1] :: "The smaller the value the more gradual the change in cctk_delta_time." -} 0.1 + (0:* :: "The smaller the value the more gradual the change in cctk_delta_time." +} 0.001
CCTK_INT sphere_number "the sphere number (if multiple spheres are present in one file) that corresponds to the worldtube radius NullSHRExtract::cr" {
File [modified]: schedule.ccl Delta lines: +2 -3 =================================================================== --- PITTNullCode/SphericalHarmonicReconGen/schedule.ccl 2014-01-07 05:53:08 UTC (rev 110) +++ PITTNullCode/SphericalHarmonicReconGen/schedule.ccl 2014-01-07 22:35:23 UTC (rev 111) @@ -21,9 +21,8 @@ #} "Schedule group for reconstructing world-tube data"
if(adjust_timestep) { - SCHEDULE SphericalHarmonicReconGeneric_SetTimeStep at CCTK_PRESTEP \ - before NullNews_InterpCycleTimelevels \ - before NullGrid_CopyTime + SCHEDULE SphericalHarmonicReconGeneric_SetTimeStep at CCTK_EVOL \ + after NullEvol_Step after NullNews_ScriVals { LANG: C OPTIONS: global
Directory: /PITTNullCode/SphericalHarmonicReconGen/src/ =======================================================
File [modified]: read.cc Delta lines: +20 -27 =================================================================== --- PITTNullCode/SphericalHarmonicReconGen/src/read.cc 2014-01-07 05:53:08 UTC (rev 110) +++ PITTNullCode/SphericalHarmonicReconGen/src/read.cc 2014-01-07 22:35:23 UTC (rev 111) @@ -101,33 +101,24 @@ if (! SHR::initialized) { CCTK_WARN(CCTK_WARN_ABORT, "Schedule mismatch. \n" - " SphericalHarmonicReconGeneric_SetTimeStep must be called after\n" - " SphericalHarmonicReconGeneric_Startup"); + " SphericalHarmonicReconGeneric_SetTimeStep must be called after\n" + " 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); + if(not time_interpolate) + CCTK_WARN(1, "cannot adjust time-step when time_interpolate==false"); return; } SHR::SPH_database& db=*(SHR::db[0]); - const double dt_old = dt; + double current_time_gap_in_file = -1; 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(time>eps+db.time(db.n_timesteps()-1)) { - CCTK_VInfo(CCTK_THORNSTRING, "Time-step has been left at %g",(double)dt); - return; // no adjustment - } + if(db.n_timesteps()<2) return; // no adjustment + if(time<db.time(0)-eps) return; // no adjustment + if(time>eps+db.time(db.n_timesteps()-1)) return; // no adjustment
// locate by bisection the interval containing time for(int l0=0,l1=db.n_timesteps()-1,c=0;;++c) { @@ -135,21 +126,23 @@ if(time<db.time(lh)-eps) l1=lh; else l0=lh; if(l1==l0+1) { - dt = db.time(l1)-db.time(l0); + current_time_gap_in_file = 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; - // 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); + if(current_time_gap_in_file<0) + CCTK_WARN(0, "cannot identify time gap in data file"); + + double target_dt = current_time_gap_in_file/ + adjust_timestep__target_steps_per_time_level; + // change the time-step gradually + target_dt = std::min(target_dt,adjust_timestep__maximum_time_step); + dt += adjust_timestep__rate_of_change*(target_dt-dt); + + if(verbose) CCTK_VInfo(CCTK_THORNSTRING, + "Time-step has been set to %g",(double)dt); }
void SphericalHarmonicReconGeneric_ReadData(CCTK_ARGUMENTS)
commits@lists.einsteintoolkit.org