diff options
-rw-r--r-- | doc/documention.tex | 2 | ||||
-rw-r--r-- | interface.ccl | 3 | ||||
-rw-r--r-- | schedule.ccl | 5 | ||||
-rw-r--r-- | src/Courant.c | 18 |
4 files changed, 17 insertions, 11 deletions
diff --git a/doc/documention.tex b/doc/documention.tex index 316d514..5629beb 100644 --- a/doc/documention.tex +++ b/doc/documention.tex @@ -55,7 +55,7 @@ $$ If a dynamic {\tt courant} condition is selected, a thorn must set the protected variable {\tt courant\_wave\_speed} for the maximum wave speed before Time sets the timestep. -If a dynamic {\tt courant_time} condition is selected, a thorn must set the protected variable +If a dynamic {\tt courant\_time} condition is selected, a thorn must set the protected variable {\tt courant\_time} for the minimum time for a wave to cross a zone before Time sets the timestep. diff --git a/interface.ccl b/interface.ccl index aea0edc..db7f042 100644 --- a/interface.ccl +++ b/interface.ccl @@ -7,7 +7,8 @@ protected: REAL speedvars type=SCALAR { - wave_speed + courant_wave_speed + courant_time } "Speed to use for Courant condition" private: diff --git a/schedule.ccl b/schedule.ccl index 33a3133..9919078 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -11,6 +11,11 @@ if (CCTK_Equals(courant_method,"standard")) if (CCTK_Equals(courant_method,"courant") || CCTK_Equals(courant_method,"courant_time")) { + schedule Time_Simple at CCTK_BASEGRID after CartGrid3D + { + LANG: C + } "Set timestep based on Courant condition" + schedule Time_Courant at CCTK_PRESTEP { LANG: C diff --git a/src/Courant.c b/src/Courant.c index d0c36ef..71b62b2 100644 --- a/src/Courant.c +++ b/src/Courant.c @@ -50,14 +50,13 @@ void Time_Courant(CCTK_CARGUMENTS) } /* Calculate the courant timestep */ - courant_speed = *wave_speed; - *courant_dt = courant_fac/courant_speed/sqrt((CCTK_REAL )cctk_dim); - - /* Output timestep if required */ - - if (outcourant_every > 0 && cctk_iteration%outcourant_every == 0) - { - CCTK_OutputVarAsByMethod(cctkGH,"time::courant_dt","Scalar","courant"); + if (CCTK_Equals(courant_method,"courant_time")) + { + *courant_dt = courant_fac*(*courant_time)/sqrt((CCTK_REAL )cctk_dim); + } + else if (CCTK_Equals(courant_method,"courant")) + { + *courant_dt = courant_fac/(*courant_wave_speed)/sqrt((CCTK_REAL )cctk_dim); } /* Set the Cactus timestep */ @@ -70,10 +69,11 @@ void Time_Courant(CCTK_CARGUMENTS) sprintf(message,"Time step set to %f",cctkGH->cctk_delta_time); CCTK_INFO(message); free(message); + } else { - cctkGH->cctk_delta_time = dtfac*min_spacing; + cctkGH->cctk_delta_time = dtfac*min_spacing; } } |