diff options
author | rhaas <rhaas@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b> | 2012-08-02 16:34:52 +0000 |
---|---|---|
committer | rhaas <rhaas@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b> | 2012-08-02 16:34:52 +0000 |
commit | 26067015fd74e5079d09a589fc3bab9e7fd13f22 (patch) | |
tree | a3939c89d8d4643ebf529722c1edfc8b8cbbe2a6 /src/IndexArrays.c | |
parent | 7923fe9d90ae7b78450708403bd7d451e0227d15 (diff) |
MoL: add Multirate capabilities. This add three new multirate RK schemes to MoL.
Flags indicate whether it is time to execute slow RHS computation.
For instance, in the RK4-RK2 scheme, there are 4 substeps in total, but the RK2 RHS are only evaluated in the very first and in the very last step of the four substeps.
From: Christian Reisswig, minor changes by Roland Haas
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/MoL/trunk@175 578cdeb0-5ea1-4b81-8215-5a3b8777ee0b
Diffstat (limited to 'src/IndexArrays.c')
-rw-r--r-- | src/IndexArrays.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/IndexArrays.c b/src/IndexArrays.c index d3ceccb..485a4bd 100644 --- a/src/IndexArrays.c +++ b/src/IndexArrays.c @@ -110,6 +110,23 @@ void MoL_SetupIndexArrays(CCTK_ARGUMENTS) } } + if (MoL_Num_Evolved_Vars_Slow) + { + EvolvedVariableIndexSlow = (CCTK_INT *)malloc(MoL_Num_Evolved_Vars_Slow * + sizeof(CCTK_INT)); + if (!EvolvedVariableIndexSlow) + { + CCTK_WARN(0,"Failed to allocate the slow evolved variable index array"); + } + + RHSVariableIndexSlow = (CCTK_INT *)malloc(MoL_Num_Evolved_Vars_Slow * + sizeof(CCTK_INT)); + if (!RHSVariableIndexSlow) + { + CCTK_WARN(0,"Failed to allocate the slow RHS variable index array"); + } + } + if (MoL_Num_Constrained_Vars) { ConstrainedVariableIndex = (CCTK_INT *)malloc(MoL_Num_Constrained_Vars * @@ -335,6 +352,18 @@ void MoL_SetupIndexArrays(CCTK_ARGUMENTS) "Averaging iterative Crank Nicholson with %i iterations", MoL_Intermediate_Steps); } + else if (CCTK_EQUALS(ODE_Method,"RK2-MR-2:1")) + { + sprintf(infoline, "Multi-rate 2:1 Runge-Kutta 2"); + } + else if (CCTK_EQUALS(ODE_Method,"RK4-MR-2:1")) + { + sprintf(infoline, "Multi-rate 2:1 Runge-Kutta 4"); + } + else if (CCTK_EQUALS(ODE_Method,"RK4-RK2")) + { + sprintf(infoline, "Multi-rate 2:1 Runge-Kutta 4 and Runge-Kutta 2"); + } else { CCTK_WARN(0, "ODE_Method not recognized!"); @@ -345,6 +374,12 @@ void MoL_SetupIndexArrays(CCTK_ARGUMENTS) free(infoline); infoline = NULL; + // These scalars must be 1 oustide of the MoL loop. + // They will only be zero for certain substeps when multirate methods are used. + // Otherwise, they are guaranteed to always be ONE. + *MoL_SlowPostStep = 1; + *MoL_SlowStep = 1; + return; } @@ -381,6 +416,18 @@ void MoL_FreeIndexArrays(CCTK_ARGUMENTS) RHSVariableIndex = NULL; } + if (EvolvedVariableIndexSlow) + { + free(EvolvedVariableIndexSlow); + EvolvedVariableIndexSlow = NULL; + } + + if (RHSVariableIndexSlow) + { + free(RHSVariableIndexSlow); + RHSVariableIndexSlow = NULL; + } + if (ConstrainedVariableIndex) { free(ConstrainedVariableIndex); |