aboutsummaryrefslogtreecommitdiff
path: root/src/IndexArrays.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/IndexArrays.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/IndexArrays.c')
-rw-r--r--src/IndexArrays.c211
1 files changed, 211 insertions, 0 deletions
diff --git a/src/IndexArrays.c b/src/IndexArrays.c
new file mode 100644
index 0000000..93d2347
--- /dev/null
+++ b/src/IndexArrays.c
@@ -0,0 +1,211 @@
+ /*@@
+ @file IndexArrays.c
+ @date Mon Jun 3 13:15:30 2002
+ @author Ian Hawke
+ @desc
+ Routines for dealing with the index arrays in
+ @seefile ExternalVariables.h
+ @enddesc
+ @version $Header$
+ @@*/
+
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "ExternalVariables.h"
+
+static const char *rcsid = "$Header$";
+
+CCTK_FILEVERSION(CactusMoL2_MoL2_IndexArrays_c);
+
+/********************************************************************
+ ********************* Local Data Types ***********************
+ ********************************************************************/
+
+/********************************************************************
+ ********************* Local Routine Prototypes *********************
+ ********************************************************************/
+
+/********************************************************************
+ ***************** Scheduled Routine Prototypes *********************
+ ********************************************************************/
+
+void MoL_SetupIndexArrays(CCTK_ARGUMENTS);
+
+void MoL_FreeIndexArrays();
+
+/********************************************************************
+ ********************* Other Routine Prototypes *********************
+ ********************************************************************/
+
+/********************************************************************
+ ********************* Local Data *****************************
+ ********************************************************************/
+
+/********************************************************************
+ ********************* External Routines **********************
+ ********************************************************************/
+
+ /*@@
+ @routine MoL_SetupIndexArrays
+ @date Mon Jun 3 13:24:05 2002
+ @author Ian Hawke
+ @desc
+ Allocates sufficient space for the index arrays.
+ These arrays are defined in the external file
+ @seefile ExternalVariables.h
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+void MoL_SetupIndexArrays(CCTK_ARGUMENTS)
+{
+
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ char *infoline;
+
+ /*
+ We only want to set up the index arrays once.
+ With mesh refinement this routine could be scheduled
+ multiple times, leading to multiple copies of the
+ index arrays used at different times!!!
+ */
+
+ if (EvolvedVariableIndex)
+ {
+ return;
+ }
+
+ EvolvedVariableIndex = (CCTK_INT *)malloc(MoL_Num_Evolved_Vars *
+ sizeof(CCTK_INT));
+ if (!EvolvedVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the evolved variable index array");
+ }
+
+ RHSVariableIndex = (CCTK_INT *)malloc(MoL_Num_Evolved_Vars *
+ sizeof(CCTK_INT));
+ if (!RHSVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the RHS variable index array");
+ }
+
+ ConstrainedVariableIndex = (CCTK_INT *)malloc(MoL_Num_Constrained_Vars *
+ sizeof(CCTK_INT));
+ if (!ConstrainedVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the constrained variable index array");
+ }
+
+ SandRVariableIndex = (CCTK_INT *)malloc(MoL_Num_SaveAndRestore_Vars *
+ sizeof(CCTK_INT));
+ if (!SandRVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the save and restore variable index array");
+ }
+
+ infoline = (char *)malloc(100*sizeof(char));
+ if (!infoline)
+ {
+ CCTK_WARN(0, "Failed to malloc 100 characters!");
+ }
+ if (CCTK_EQUALS(MoL_ODE_Method,"Generic"))
+ {
+ if (CCTK_EQUALS(Generic_Type,"ICN"))
+ {
+ sprintf(infoline,"Generic Iterative Crank Nicholson with %i iterations",
+ MoL_Intermediate_Steps);
+ }
+ else if (CCTK_EQUALS(Generic_Type,"RK"))
+ {
+ sprintf(infoline, "Generic Runge-Kutta %i",MoL_Intermediate_Steps);
+ }
+ else
+ {
+ CCTK_WARN(0, "Generic_Type not recognized!");
+ }
+ }
+ else if (CCTK_EQUALS(MoL_ODE_Method,"RK2"))
+ {
+ sprintf(infoline, "Runge-Kutta 2");
+ }
+ else if (CCTK_EQUALS(MoL_ODE_Method,"ICN"))
+ {
+ sprintf(infoline, "Iterative Crank Nicholson with %i iterations",
+ MoL_Intermediate_Steps);
+ }
+ else
+ {
+ CCTK_WARN(0, "MoL_ODE_Method not recognized!");
+ }
+
+ CCTK_VInfo(CCTK_THORNSTRING, "Using %s as the time integrator.", infoline);
+
+ free(infoline);
+ infoline = NULL;
+
+ return;
+
+}
+
+ /*@@
+ @routine MoL_FreeIndexArrays
+ @date Mon Jun 3 13:26:15 2002
+ @author Ian Hawke
+ @desc
+ Frees the external index arrays.
+ These arrays are defined in the external file
+ @seefile ExternalVariables.h
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+void MoL_FreeIndexArrays()
+{
+
+ if (EvolvedVariableIndex)
+ {
+ free(EvolvedVariableIndex);
+ EvolvedVariableIndex = NULL;
+ }
+
+ if (RHSVariableIndex)
+ {
+ free(RHSVariableIndex);
+ RHSVariableIndex = NULL;
+ }
+
+ if (ConstrainedVariableIndex)
+ {
+ free(ConstrainedVariableIndex);
+ ConstrainedVariableIndex = NULL;
+ }
+
+ if (SandRVariableIndex)
+ {
+ free(SandRVariableIndex);
+ SandRVariableIndex = NULL;
+ }
+
+ return;
+
+}
+
+/********************************************************************
+ ********************* Local Routines *************************
+ ********************************************************************/