diff options
author | eschnett <eschnett@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b> | 2013-01-22 21:00:28 +0000 |
---|---|---|
committer | eschnett <eschnett@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b> | 2013-01-22 21:00:28 +0000 |
commit | a4ed7cfd73db6ef8418ffb47f4237cc529f8c710 (patch) | |
tree | bfd603e9eb86fc9ad01ee2b841013903752d1859 /src/Euler.c | |
parent | 15f9511f821e350bc8c0c850b6f0a65ff786df87 (diff) |
MoL Update
New integrator Euler. This is an explicit, first-order method, mostly
useful for debugging.
New integrators AB (Adams-Bashforth) with various orders. These are
explicit integrators using several past timelevels to provide
higher-order integration with a single RHS evaluation each.
Introduce LinearCombination, a generic routine to calculate linear
combinations of grid functions. This simplifies existing code, and can
be overloaded if MoL should run on a device (e.g. with OpenCL).
Replace cctk_lsh with cctk_ash where necessary.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/MoL/trunk@190 578cdeb0-5ea1-4b81-8215-5a3b8777ee0b
Diffstat (limited to 'src/Euler.c')
-rw-r--r-- | src/Euler.c | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/Euler.c b/src/Euler.c new file mode 100644 index 0000000..0033cd1 --- /dev/null +++ b/src/Euler.c @@ -0,0 +1,116 @@ + /*@@ + @file Euler.c + @date 2012-12-05 + @author Erik Schnetter + @desc + An explicit Euler time integrator. This method is unstable in most + cases, but is sometimes useful for debugging. + @enddesc + @version $Header$ + @@*/ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +#include "ExternalVariables.h" +#include "Operators.h" + +static const char *rcsid = "$Header$"; + +CCTK_FILEVERSION(CactusBase_MoL_Euler_c); + +/******************************************************************** + ********************* Local Data Types *********************** + ********************************************************************/ + +/******************************************************************** + ********************* Local Routine Prototypes ********************* + ********************************************************************/ + +/******************************************************************** + ***************** Scheduled Routine Prototypes ********************* + ********************************************************************/ + +void MoL_EulerAdd(CCTK_ARGUMENTS); + +/******************************************************************** + ********************* Other Routine Prototypes ********************* + ********************************************************************/ + +/******************************************************************** + ********************* Local Data ***************************** + ********************************************************************/ + +/******************************************************************** + ********************* External Routines ********************** + ********************************************************************/ + + /*@@ + @routine MoL_EulerAdd + @date 2012-12-05 + @author Erik Schnetter + @desc + Performs first order Euler time integration. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +void MoL_EulerAdd(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + int totalsize = 1; + for (int arraydim = 0; arraydim < cctk_dim; arraydim++) + { + totalsize *= cctk_ash[arraydim]; + } + + switch (*MoL_Intermediate_Step) + { + case 1: + { + for (int var = 0; var < MoLNumEvolvedVariables; var++) + { + int const nsrcs = 2; + CCTK_INT const srcs[] = + {EvolvedVariableIndex[var], RHSVariableIndex[var]}; + CCTK_INT const tls[] = {1, 0}; + CCTK_REAL const facts[] = {1.0, CCTK_DELTA_TIME}; + MoL_LinearCombination(cctkGH, + EvolvedVariableIndex[var], 0.0, + srcs, tls, facts, nsrcs); + } + + for (int var = 0; var < MoLNumEvolvedArrayVariables; var++) + { + int const nsrcs = 2; + CCTK_INT const srcs[] = + {EvolvedArrayVariableIndex[var], RHSArrayVariableIndex[var]}; + CCTK_INT const tls[] = {1, 0}; + CCTK_REAL const facts[] = {1.0, CCTK_DELTA_TIME}; + MoL_LinearCombination(cctkGH, + EvolvedArrayVariableIndex[var], 0.0, + srcs, tls, facts, nsrcs); + } + + break; + } + default: + { + CCTK_WARN(CCTK_WARN_ABORT, + "Euler expects MoL_Intermediate_Step to be in [1,1]. " + "This should be caught at ParamCheck - bug Ian!"); + } + } +} + +/******************************************************************** + ********************* Local Routines ************************* + ********************************************************************/ |