summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-07-10 10:33:24 +0000
committerallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-07-10 10:33:24 +0000
commitd6938dc131dbb2cecb17f810320d5f76873a5c75 (patch)
tree392aedb23a3e79df98c4c6e5e16438fa09224755
parentfcc44b6e9ac12bae2939da5dcf597c2fe148f8a1 (diff)
The condition for terminating the Cactus main evolution has changed
slightly, and will affect people using PUGH (or the default Cactus evolution routine) *and* terminating by setting the parameters cctk_initial_time and cctk_final_time There is now a keyword parameter, Cactus::terminate which can be set either to: iteration (the default): terminate when cctk_itlast is reached time: if cctk_initial_time < cctk_final_time terminate when time >= cctk_final_time if cctk_initial_time > cctk_final_time terminate when time <= cctk_final_time either: terminate when either of the above conditions are true both: terminate when both of the above conditions are true never: ignore iteration and time for termination The reason for making this change is to support a negative timestep. git-svn-id: http://svn.cactuscode.org/flesh/trunk@2273 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r--src/main/CactusDefaultEvolve.c66
-rw-r--r--src/param.ccl9
2 files changed, 70 insertions, 5 deletions
diff --git a/src/main/CactusDefaultEvolve.c b/src/main/CactusDefaultEvolve.c
index 72695c70..7634ae61 100644
--- a/src/main/CactusDefaultEvolve.c
+++ b/src/main/CactusDefaultEvolve.c
@@ -210,14 +210,19 @@ int CactusDefaultEvolve(tFleshConfig *config)
@endhistory
@@*/
-static int DoneMainLoop (cGH *GH, CCTK_REAL cctk_time, int iteration)
+static int DoneMainLoop (cGH *GH, CCTK_REAL time, int iteration)
{
int param_type;
CCTK_INT cctk_itlast;
CCTK_REAL cctk_initial_time;
CCTK_REAL cctk_final_time;
CCTK_INT terminate_next;
+ char *terminate;
+ int retval;
+ int con;
+ terminate = CCTK_ParameterGet("terminate",
+ "Cactus",&param_type);
cctk_initial_time = (*(CCTK_REAL *)CCTK_ParameterGet("cctk_initial_time",
"Cactus",&param_type));
cctk_final_time = (*(CCTK_REAL *)CCTK_ParameterGet("cctk_final_time",
@@ -227,10 +232,61 @@ static int DoneMainLoop (cGH *GH, CCTK_REAL cctk_time, int iteration)
terminate_next = (*(CCTK_INT *)CCTK_ParameterGet("terminate_next",
"Cactus",&param_type));
- return (terminate_next || CCTK_TerminationReached(GH) ||
- ! ( iteration < cctk_itlast ||
- (cctk_final_time > cctk_initial_time ?
- cctk_time < cctk_final_time : 0)));
+ if (terminate_next || CCTK_TerminationReached(GH))
+ {
+ retval = 1;
+ }
+ else
+ {
+ if (CCTK_Equals(terminate,"never"))
+ {
+ retval = 0;
+ }
+ else if (CCTK_Equals(terminate,"iteration"))
+ {
+ retval = iteration < cctk_itlast ? 0 : 1;
+ }
+ else if (CCTK_Equals(terminate,"time"))
+ {
+ if (cctk_initial_time < cctk_final_time)
+ {
+ retval = (time >= cctk_final_time) ? 1 : 0;
+ }
+ else
+ {
+ retval = (time <= cctk_final_time) ? 1 : 0;
+ }
+ }
+ else if (CCTK_Equals(terminate,"either"))
+ {
+ if (cctk_initial_time < cctk_final_time)
+ {
+ con = (time >= cctk_final_time) ? 1 : 0;
+ }
+ else
+ {
+ con = (time <= cctk_final_time) ? 1 : 0;
+ }
+
+ retval = (!con && iteration < cctk_itlast) ? 0 : 1;
+ }
+ else if (CCTK_Equals(terminate,"both"))
+ {
+ if (cctk_initial_time < cctk_final_time)
+ {
+ con = (time >= cctk_final_time) ? 1 : 0;
+ }
+ else
+ {
+ con = (time <= cctk_final_time) ? 1 : 0;
+ }
+
+ retval = (!con || iteration < cctk_itlast) ? 0 : 1;
+ }
+ }
+
+ return retval;
+
}
diff --git a/src/param.ccl b/src/param.ccl
index 610cbb21..a69099da 100644
--- a/src/param.ccl
+++ b/src/param.ccl
@@ -59,6 +59,15 @@ BOOLEAN terminate_next "Terminate on next iteration?" STEERABLE=ALWAYS
{
} "no"
+KEYWORD terminate "Condition on which to terminate evolution loop" STEERABLE=ALWAYS
+{
+ "never" :: "Never terminate"
+ "iteration" :: "Take termination condition from iteration number"
+ "time" :: "Take termination condition from coordinate time"
+ "either" :: "Take termination condition from either iteration number or coordinate time"
+ "both" :: "Take termination condition from both iteration number and coordinate time"
+} "iteration"
+
REAL cctk_initial_time "Initial time for evolution"
{
: :: "Anything"