aboutsummaryrefslogtreecommitdiff
path: root/src/SetTime.c
diff options
context:
space:
mode:
authorhawke <hawke@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b>2003-04-23 14:59:00 +0000
committerhawke <hawke@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b>2003-04-23 14:59:00 +0000
commitfd1b7d175f18cb5f1d168c8a9e95508b41ae39e9 (patch)
tree438f83a13ed6c0dcd80b495222d57b5ee59c898c /src/SetTime.c
parent1100eb9f3017973b6cfa5b6bff3306773ff3e532 (diff)
The Method of Lines thorn (version 2 - see below).
MoL provides generic integration methods for multiple thorns simultaneously. By providing a layer between the driver and evolution thorns, this should mean that some technical issues to do with mesh refinement can be ignored. It also allows you to choose different evolution methods (in time, at least). But the primary purpose is to unambiguously evolve models in different thorns at the same time. This is version 2 - the one that will work with mesh refinement. It's a straight copy of HawkeCVS/Public/CactusMoL2/MoL2 and I haven't checked that it will work "as is" with the new name (one of the reasons it goes into Alpha). At the moment the only evolution method guaranteed to work with mesh refinement is ICN, although RK2 should. The generic RK methods will do something that will be subtly wrong... Note that the "old" way of registering variables (through the functions declared in header files) is still there. As soon as function aliasing settles down, this will be removed. Also to be done: Better documentation Tidy up the code (especially the debugging statements) Optimize Add various useful time evolution methods. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/MoL/trunk@2 578cdeb0-5ea1-4b81-8215-5a3b8777ee0b
Diffstat (limited to 'src/SetTime.c')
-rw-r--r--src/SetTime.c231
1 files changed, 231 insertions, 0 deletions
diff --git a/src/SetTime.c b/src/SetTime.c
new file mode 100644
index 0000000..be06650
--- /dev/null
+++ b/src/SetTime.c
@@ -0,0 +1,231 @@
+ /*@@
+ @file SetTime.c
+ @date Mon May 20 09:45:45 2002
+ @author Ian Hawke
+ @desc
+ Sets the time and dt depending on the ODE method and
+ position in the loop.
+ @enddesc
+ @version $Header$
+ @@*/
+
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+
+static const char *rcsid = "$Header$";
+
+CCTK_FILEVERSION(CactusMoL2_MoL2_SetTime_c);
+
+/********************************************************************
+ ********************* Local Data Types ***********************
+ ********************************************************************/
+
+/********************************************************************
+ ********************* Local Routine Prototypes *********************
+ ********************************************************************/
+
+/********************************************************************
+ ***************** Scheduled Routine Prototypes *********************
+ ********************************************************************/
+
+int MoL_SetTime(CCTK_ARGUMENTS);
+
+int MoL_ResetTime(CCTK_ARGUMENTS);
+
+/********************************************************************
+ ********************* Other Routine Prototypes *********************
+ ********************************************************************/
+
+/********************************************************************
+ ********************* Local Data *****************************
+ ********************************************************************/
+
+/********************************************************************
+ ********************* External Routines **********************
+ ********************************************************************/
+
+ /*@@
+ @routine MoL_SetTime
+ @date Mon May 20 09:48:55 2002
+ @author Ian Hawke
+ @desc
+ Sets the time and timestep before the MoL evolution loop starts.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+int MoL_SetTime(CCTK_ARGUMENTS)
+{
+
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+ /*
+ CCTK_INT i,j,k;
+ CCTK_REAL *Var0,*Var1,*Var2;
+
+ Var0 = (CCTK_REAL*)CCTK_VarDataPtr(cctkGH, 0,
+ "wavetoymol::phi");
+ Var1 = (CCTK_REAL*)CCTK_VarDataPtr(cctkGH, 1,
+ "wavetoymol::phi");
+ Var2 = (CCTK_REAL*)CCTK_VarDataPtr(cctkGH, 2,
+ "wavetoymol::phi");
+ printf("Grid %d: Pointer to time levels %ld %ld %ld\n",
+ cctkGH->cctk_levfac[0], Var0,Var1,Var2);
+ printf("First point of first two levels is %g and %g.\n",
+ Var0[0],Var1[0]);*/
+ /*
+ for (k=0;k<cctk_lsh[2];k++)
+ {
+ for (j=0;j<cctk_lsh[1];j++)
+ {
+ for (i=0;i<cctk_lsh[0];i++)
+ {
+ printf("Set time: %d %d %d %d %g\n", cctk_levfac[0],
+ i, j, k,
+ Var1[CCTK_GFINDEX3D(cctkGH, i, j, k)]);
+ }
+ }
+ }*/
+
+
+ *Original_Time = cctkGH->cctk_time;
+ *Original_Delta_Time = cctkGH->CCTK_DELTA_TIME;
+ cctkGH->cctk_time -= cctkGH->CCTK_DELTA_TIME;
+ /*
+ CCTK_VInfo(CCTK_THORNSTRING,"Original time was %g. Reset to %g",
+ *Original_Time,cctkGH->cctk_time);
+ */
+ /* if ( (CCTK_EQUALS(MoL_ODE_Method,"ICN")) ||
+ ( (CCTK_EQUALS(MoL_ODE_Method,"Generic")) &&
+ ( (MoL_Intermediate_Steps == 4))
+ || CCTK_EQUALS(Generic_Type,"ICN") ) )*/
+ if ( (CCTK_EQUALS(MoL_ODE_Method,"ICN")) ||
+ ( (CCTK_EQUALS(MoL_ODE_Method,"Generic")) &&
+ CCTK_EQUALS(Generic_Type,"ICN") ) )
+ {
+ cctkGH->CCTK_DELTA_TIME = 0.5*(*Original_Delta_Time);
+ }
+
+ return 0;
+}
+
+ /*@@
+ @routine MoL_ResetTime
+ @date Mon May 20 09:49:41 2002
+ @author Ian Hawke
+ @desc
+ Sets the time and timestep during the MoL evolution loop.
+ At the last time all methods should end up with the original
+ values for time and timestep.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+int MoL_ResetTime(CCTK_ARGUMENTS)
+{
+
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+
+ if (*MoL_Intermediate_Step == 0)
+ {
+ cctkGH->cctk_time = (*Original_Time);
+ cctkGH->CCTK_DELTA_TIME = (*Original_Delta_Time);
+ }
+ else if (*MoL_Intermediate_Step == 1)
+ {
+ if ( (CCTK_EQUALS(MoL_ODE_Method,"Generic"))
+ &&(CCTK_EQUALS(Generic_Type,"RK")) )
+ {
+ if (MoL_Intermediate_Steps == 2)
+ {
+ cctkGH->cctk_time = (*Original_Time);
+ /* cctkGH->CCTK_DELTA_TIME = 0.5 * (*Original_Delta_Time);*/
+ }
+ /* else if (MoL_Intermediate_Steps == 3)
+ {
+ cctkGH->CCTK_DELTA_TIME = 2.0 / 3.0 * (*Original_Delta_Time);
+ cctkGH->cctk_time = (*Original_Time) - 0.5 * (*Original_Delta_Time);
+ }
+ else if (MoL_Intermediate_Steps == 4)
+ {
+ cctkGH->CCTK_DELTA_TIME = (*Original_Delta_Time) / 6.0;
+ cctkGH->cctk_time = (*Original_Time);
+ }*/
+ }
+ else if ( ((CCTK_EQUALS(MoL_ODE_Method,"Generic"))&&
+ (CCTK_EQUALS(Generic_Type,"ICN"))) ||
+ (CCTK_EQUALS(MoL_ODE_Method,"ICN")) )
+ {
+ cctkGH->CCTK_DELTA_TIME = *Original_Delta_Time;
+ cctkGH->cctk_time = (*Original_Time)-0.5*(*Original_Delta_Time);
+ }
+ else if ( CCTK_EQUALS(MoL_ODE_Method,"RK2") )
+ {
+ cctkGH->CCTK_DELTA_TIME = 0.5 * (*Original_Delta_Time);
+ cctkGH->cctk_time = (*Original_Time);
+ }
+ }
+ else if (*MoL_Intermediate_Step == 2)
+ {
+ if ( (CCTK_EQUALS(MoL_ODE_Method,"Generic"))
+ &&(CCTK_EQUALS(Generic_Type,"RK")) )
+ {
+ /* if (MoL_Intermediate_Steps == 3)
+ {
+ cctkGH->CCTK_DELTA_TIME = 0.25 * (*Original_Delta_Time);
+ cctkGH->cctk_time = (*Original_Time);
+ }
+ else if (MoL_Intermediate_Steps == 4)
+ {
+ cctkGH->CCTK_DELTA_TIME = (*Original_Delta_Time);
+ cctkGH->cctk_time = (*Original_Time);
+ }*/
+ }
+ else if ( ((CCTK_EQUALS(MoL_ODE_Method,"Generic"))&&
+ (CCTK_EQUALS(Generic_Type,"ICN"))) ||
+ (CCTK_EQUALS(MoL_ODE_Method,"ICN")) )
+ {
+ cctkGH->CCTK_DELTA_TIME = 0.5*(*Original_Delta_Time);
+ cctkGH->cctk_time = (*Original_Time)-0.5*(*Original_Delta_Time);
+ }
+ }
+ else if (*MoL_Intermediate_Step == 3)
+ {
+ /* if ( (CCTK_EQUALS(MoL_ODE_Method,"Generic"))
+ &&(CCTK_EQUALS(Generic_Type,"RK")) )
+ {
+ if (MoL_Intermediate_Steps == 4)
+ {
+ cctkGH->CCTK_DELTA_TIME = 0.5 * (*Original_Delta_Time);
+ cctkGH->cctk_time = (*Original_Time) - 0.5 * (*Original_Delta_Time);
+ }
+ }*/
+ }
+ /*
+ CCTK_VInfo(CCTK_THORNSTRING,"Time has been reset to %g",
+ cctkGH->cctk_time);
+ */
+ /*
+ printf("MoL has once more reset t: %f: and dt: %f.\n", cctkGH->cctk_time,
+ cctkGH->CCTK_DELTA_TIME);
+ */
+
+ return 0;
+}
+
+/********************************************************************
+ ********************* Local Routines *************************
+ ********************************************************************/