From 7a4d027bf05e9c29ae5f654ab47e6283c6385984 Mon Sep 17 00:00:00 2001 From: allen Date: Sun, 22 Dec 2002 22:13:28 +0000 Subject: Patch for halting at cctk_final_time when using Courant timestep from Ian Hawke Fixes CactusBase/1345 git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Time/trunk@53 5633253d-7678-4964-a54d-f87795f8ee59 --- param.ccl | 5 +++++ schedule.ccl | 7 ++++++- src/Courant.c | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/param.ccl b/param.ccl index 58ac84c..2f9e89f 100644 --- a/param.ccl +++ b/param.ccl @@ -1,6 +1,11 @@ # Parameter definitions for thorn Time # $Header$ +shares: cactus + +USES REAL cctk_final_time +USES KEYWORD terminate + restricted: KEYWORD timestep_method "Method for calculating timestep" diff --git a/schedule.ccl b/schedule.ccl index 65f8b4f..927b5a1 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -23,7 +23,12 @@ else if (CCTK_Equals (timestep_method, "courant_speed") || LANG: C } "Set timestep based on Courant condition" - schedule Time_Courant at CCTK_PRESTEP + schedule Time_Courant at CCTK_POSTINITIAL + { + LANG: C + } "Reset timestep each iteration" + + schedule Time_Courant at CCTK_POSTSTEP { LANG: C } "Reset timestep each iteration" diff --git a/src/Courant.c b/src/Courant.c index ade4e53..3d7451e 100644 --- a/src/Courant.c +++ b/src/Courant.c @@ -59,6 +59,14 @@ void Time_Courant(CCTK_ARGUMENTS) (*courant_wave_speed)/sqrt((double) cctk_dim); } + if (CCTK_Equals(terminate, "time")||CCTK_Equals(terminate, "both")) + { + if (cctkGH->cctk_time + *courant_dt > cctk_final_time) + { + *courant_dt = (1 + 1.e-10) * (cctk_final_time - cctkGH->cctk_time); + } + } + /* Set the Cactus timestep */ if (!timestep_outonly) -- cgit v1.2.3