aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorallen <allen@5633253d-7678-4964-a54d-f87795f8ee59>1999-10-19 16:41:35 +0000
committerallen <allen@5633253d-7678-4964-a54d-f87795f8ee59>1999-10-19 16:41:35 +0000
commit9ad75f1b1648057d41cb96409acd05c19bb01aa9 (patch)
tree2d661c56ed3bd8d4bf65f44641793e8a10722e71
parent28e9900807b4b66d58076f2360808e5add0a65e8 (diff)
Generic courant timestep ... not linked to anything yet
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Time/trunk@9 5633253d-7678-4964-a54d-f87795f8ee59
-rw-r--r--src/Courant.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/Courant.c b/src/Courant.c
new file mode 100644
index 0000000..82f3557
--- /dev/null
+++ b/src/Courant.c
@@ -0,0 +1,80 @@
+ /*@@
+ @file Courant.c
+ @date September 4 1999
+ @author Gabrielle Allen
+ @desc
+ Specification of timestep using Courant condition
+ @enddesc
+ @@*/
+
+#include <malloc.h>
+#include <math.h>
+
+#include "cctk.h"
+#include "cctk_arguments.h"
+#include "cctk_parameters.h"
+
+void Time_Courant(CCTK_CARGUMENTS)
+{
+ DECLARE_CCTK_PARAMETERS
+ DECLARE_CCTK_CARGUMENTS
+
+ CCTK_REAL min_spacing;
+ CCTK_REAL courant_speed;
+
+ char *message;
+
+ /* Calculate the minimum grid spacing */
+ if (cctk_dim>=1)
+ {
+ min_spacing = cctk_delta_space[0];
+ }
+
+ if (cctk_dim>=2)
+ {
+ min_spacing = (min_spacing<cctk_delta_space[1] ?
+ min_spacing : cctk_delta_space[1]);
+ }
+
+ if (cctk_dim>=3)
+ {
+ min_spacing = (min_spacing<cctk_delta_space[2] ?
+ min_spacing : cctk_delta_space[2]);
+ }
+
+ if (cctk_dim>=4)
+ {
+ CCTK_WARN(0,"Time Step not defined for greater than 4 dimensions");
+ }
+
+ /* 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");
+ }
+
+ /* Set the Cactus timestep */
+
+ if (! courant_outonly)
+ {
+ cctkGH->cctk_delta_time = *courant_dt;
+
+ message = (char *)malloc(1024*sizeof(char));
+ sprintf(message,"Time step set to %f",cctkGH->cctk_delta_time);
+ CCTK_INFO(message);
+ free(message);
+ }
+ else
+ {
+ cctkGH->cctk_delta_time = dtfac*min_spacing/courant_wave_speed;
+ }
+
+}
+
+
+