From 69d85e287d7cd42b998fda5d51af78d0d5b1a2f0 Mon Sep 17 00:00:00 2001 From: allen Date: Sun, 31 Oct 1999 13:26:59 +0000 Subject: Improved implementation of dynamic courant condition git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Time/trunk@13 5633253d-7678-4964-a54d-f87795f8ee59 --- doc/documention.tex | 2 +- interface.ccl | 3 ++- schedule.ccl | 5 +++++ 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; } } -- cgit v1.2.3