aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--param.ccl2
-rw-r--r--src/Evolve.c86
2 files changed, 82 insertions, 6 deletions
diff --git a/param.ccl b/param.ccl
index 225352e..3053504 100644
--- a/param.ccl
+++ b/param.ccl
@@ -3,6 +3,8 @@
shares: cactus
+USES KEYWORD terminate
+
USES REAL cctk_initial_time
USES REAL cctk_final_time
diff --git a/src/Evolve.c b/src/Evolve.c
index ced449c..a55a0a7 100644
--- a/src/Evolve.c
+++ b/src/Evolve.c
@@ -149,19 +149,93 @@ int PUGH_Evolve(tFleshConfig *config)
Check the termination conditions for the evolution loop
@enddesc
@calls
- @calledby
+
+ @var GH
+ @vdesc GH data
+ @vtype cGH *
+ @vio in
+ @endvar
+ @var time
+ @vdesc coordinate time
+ @vtype CCTK_REAL
+ @vio in
+ @endvar
+ @var iteration
+ @vdesc iteration number
+ @vtype int
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ 1 - condition for evolution loop termination is true
+ 0 - condition for evolution loop termination is false
+ @endreturndesc
+
@history
@endhistory
@@*/
-static int DoneMainLoop (cGH *GH, CCTK_REAL cctk_time, int iteration)
+static int DoneMainLoop (cGH *GH, CCTK_REAL time, int iteration)
{
+ int retval;
+ int con;
DECLARE_CCTK_PARAMETERS
- 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;
}