aboutsummaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
authorBarry Wardell <barry.wardell@gmail.com>2012-02-09 09:49:35 +0000
committerBarry Wardell <barry.wardell@gmail.com>2012-02-09 10:14:42 +0000
commit3f0dc8ca3ddee5c78c6922abc9707d464a2d0506 (patch)
tree008d2b88e137c272ff34c7a1363a8e3c9196dbe8 /Examples
parent4b9da3393b67b7b8f75396c6d8e7abef86ee7b27 (diff)
parent90ef11c6391568bf00fc7258f7f7060a81c0dfe8 (diff)
Merge remote-tracking branch 'origin/piraha'
Conflicts: Tools/CodeGen/Kranc.m
Diffstat (limited to 'Examples')
-rw-r--r--Examples/EMScript.kranc35
-rw-r--r--Examples/EMScript/configuration.ccl6
-rw-r--r--Examples/EMScript/interface.ccl80
-rw-r--r--Examples/EMScript/param.ccl345
-rw-r--r--Examples/EMScript/schedule.ccl126
-rw-r--r--Examples/EMScript/src/Boundaries.cc457
-rw-r--r--Examples/EMScript/src/Differencing.h291
-rw-r--r--Examples/EMScript/src/EM_constraints.cc354
-rw-r--r--Examples/EMScript/src/EM_energy.cc235
-rw-r--r--Examples/EMScript/src/EM_evol.cc400
-rw-r--r--Examples/EMScript/src/EM_initial.cc259
-rw-r--r--Examples/EMScript/src/RegisterMoL.cc24
-rw-r--r--Examples/EMScript/src/RegisterSymmetries.cc64
-rw-r--r--Examples/EMScript/src/Startup.cc10
-rw-r--r--Examples/EMScript/src/make.code.defn3
-rw-r--r--Examples/Funwave.kranc24
-rw-r--r--Examples/SimpleWave/param.ccl6
-rw-r--r--Examples/SimpleWave/src/Differencing.h144
-rw-r--r--Examples/SimpleWave/src/calc_rhs.cc4
-rw-r--r--Examples/SimpleWave/src/initial_sine.cc4
-rw-r--r--Examples/SimpleWaveScript.kranc26
-rw-r--r--Examples/SimpleWaveScript/configuration.ccl6
-rw-r--r--Examples/SimpleWaveScript/interface.ccl52
-rw-r--r--Examples/SimpleWaveScript/param.ccl198
-rw-r--r--Examples/SimpleWaveScript/schedule.ccl101
-rw-r--r--Examples/SimpleWaveScript/src/Boundaries.cc249
-rw-r--r--Examples/SimpleWaveScript/src/Differencing.h288
-rw-r--r--Examples/SimpleWaveScript/src/RegisterMoL.cc20
-rw-r--r--Examples/SimpleWaveScript/src/RegisterSymmetries.cc29
-rw-r--r--Examples/SimpleWaveScript/src/Startup.cc10
-rw-r--r--Examples/SimpleWaveScript/src/calc_rhs.cc187
-rw-r--r--Examples/SimpleWaveScript/src/initial_sine_calc.cc175
-rw-r--r--Examples/SimpleWaveScript/src/make.code.defn3
-rw-r--r--Examples/SimpleWaveScript2.kranc0
-rw-r--r--Examples/emscript_sine.par65
35 files changed, 4122 insertions, 158 deletions
diff --git a/Examples/EMScript.kranc b/Examples/EMScript.kranc
new file mode 100644
index 0000000..007d6d0
--- /dev/null
+++ b/Examples/EMScript.kranc
@@ -0,0 +1,35 @@
+begin thorn EMScript
+
+begin variables
+ El_i B_i CEl CB rho
+end variables
+
+begin temporaries
+ sigma
+end temporaries
+
+begin calculation EM_initial scheduled at initial
+ sigma = 1
+ El1 = sigma*cos(2*PI*(x + y))
+ El2 = -1*(1 - sigma)*cos(2*PI*x) - sigma*cos(2*PI*(x + y))
+ El3 = 0
+ B1 = 0
+ B2 = 0
+ B3 = (1 - sigma)*cos(2*PI*x) + sigma*cos(2*PI*(x + y))
+end calculation
+
+begin calculation EM_evol scheduled at MoL_CalcRHS
+ D_t El_a = Eps_abc * Euc^be * Euc^cf * D_e B_f
+ D_t B_a = -1*Eps_abc * Euc^be * Euc^cf * D_e El_f
+end calculation
+
+begin calculation EM_constraints scheduled at analysis
+ CEl = D_b El_a * Euc^ab
+ CB = D_b B_a * Euc^ab
+end calculation
+
+begin calculation EM_energy scheduled at analysis
+ rho = Euc^ab * El_a * El_b/2 + Euc^ab * B_a * B_b/2
+end calculation
+
+end thorn
diff --git a/Examples/EMScript/configuration.ccl b/Examples/EMScript/configuration.ccl
new file mode 100644
index 0000000..585220a
--- /dev/null
+++ b/Examples/EMScript/configuration.ccl
@@ -0,0 +1,6 @@
+# File produced by Kranc
+
+REQUIRES GenericFD
+REQUIRES LoopControl
+REQUIRES OpenCL OpenCLRunTime
+REQUIRES Vectors
diff --git a/Examples/EMScript/interface.ccl b/Examples/EMScript/interface.ccl
new file mode 100644
index 0000000..569d68b
--- /dev/null
+++ b/Examples/EMScript/interface.ccl
@@ -0,0 +1,80 @@
+# File produced by Kranc
+
+implements: My_New_Implementation
+
+inherits: ADMBase Grid GenericFD Boundary
+
+
+
+USES INCLUDE: GenericFD.h
+USES INCLUDE: Symmetry.h
+USES INCLUDE: sbp_calc_coeffs.h
+USES INCLUDE: Boundary.h
+USES INCLUDE: loopcontrol.h
+USES INCLUDE: OpenCLRunTime.h
+USES INCLUDE: vectors.h
+
+CCTK_INT FUNCTION MoLRegisterEvolved(CCTK_INT IN EvolvedIndex, CCTK_INT IN RHSIndex)
+USES FUNCTION MoLRegisterEvolved
+
+SUBROUTINE Diff_coeff(CCTK_POINTER_TO_CONST IN cctkGH, CCTK_INT IN dir, CCTK_INT IN nsize, CCTK_INT OUT ARRAY imin, CCTK_INT OUT ARRAY imax, CCTK_REAL OUT ARRAY q, CCTK_INT IN table_handle)
+USES FUNCTION Diff_coeff
+
+CCTK_INT FUNCTION MultiPatch_GetMap(CCTK_POINTER_TO_CONST IN cctkGH)
+USES FUNCTION MultiPatch_GetMap
+
+CCTK_INT FUNCTION Boundary_SelectGroupForBC(CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN group_name, CCTK_STRING IN bc_name)
+USES FUNCTION Boundary_SelectGroupForBC
+
+CCTK_INT FUNCTION Boundary_SelectVarForBC(CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN var_name, CCTK_STRING IN bc_name)
+USES FUNCTION Boundary_SelectVarForBC
+
+public:
+CCTK_REAL CB_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0'
+{
+ CB
+} "CB_group"
+
+public:
+CCTK_REAL CEl_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0'
+{
+ CEl
+} "CEl_group"
+
+public:
+CCTK_REAL rho_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0'
+{
+ rho
+} "rho_group"
+
+public:
+CCTK_REAL B_group type=GF timelevels=3 tags='tensortypealias="D" tensorweight=0'
+{
+ B1,
+ B2,
+ B3
+} "B_group"
+
+public:
+CCTK_REAL El_group type=GF timelevels=3 tags='tensortypealias="D" tensorweight=0'
+{
+ El1,
+ El2,
+ El3
+} "El_group"
+
+public:
+CCTK_REAL B_grouprhs type=GF timelevels=3 tags='tensortypealias="D" tensorweight=0'
+{
+ B1rhs,
+ B2rhs,
+ B3rhs
+} "B_grouprhs"
+
+public:
+CCTK_REAL El_grouprhs type=GF timelevels=3 tags='tensortypealias="D" tensorweight=0'
+{
+ El1rhs,
+ El2rhs,
+ El3rhs
+} "El_grouprhs"
diff --git a/Examples/EMScript/param.ccl b/Examples/EMScript/param.ccl
new file mode 100644
index 0000000..5f97309
--- /dev/null
+++ b/Examples/EMScript/param.ccl
@@ -0,0 +1,345 @@
+# File produced by Kranc
+
+
+shares: GenericFD
+
+USES CCTK_STRING jacobian_group
+USES CCTK_STRING jacobian_derivative_group
+USES CCTK_INT jacobian_identity_map
+
+
+shares: MethodOfLines
+
+USES CCTK_INT MoL_Num_Evolved_Vars
+USES CCTK_INT MoL_Num_ArrayEvolved_Vars
+
+restricted:
+CCTK_INT verbose "verbose" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 0
+
+restricted:
+CCTK_INT fdOrder "fdOrder"
+{
+ *:* :: ""
+} 2
+
+restricted:
+CCTK_INT EMScript_MaxNumEvolvedVars "Number of evolved variables used by this thorn" ACCUMULATOR-BASE=MethodofLines::MoL_Num_Evolved_Vars STEERABLE=RECOVER
+{
+ 6:6 :: "Number of evolved variables used by this thorn"
+} 6
+
+restricted:
+CCTK_INT EMScript_MaxNumArrayEvolvedVars "Number of Array evolved variables used by this thorn" ACCUMULATOR-BASE=MethodofLines::MoL_Num_ArrayEvolved_Vars STEERABLE=RECOVER
+{
+ 0:0 :: "Number of Array evolved variables used by this thorn"
+} 0
+
+restricted:
+CCTK_INT timelevels "Number of active timelevels" STEERABLE=RECOVER
+{
+ 0:3 :: ""
+} 3
+
+restricted:
+CCTK_INT rhs_timelevels "Number of active RHS timelevels" STEERABLE=RECOVER
+{
+ 0:3 :: ""
+} 1
+
+restricted:
+CCTK_INT other_timelevels "Number of active timelevels for non-evolved grid functions" STEERABLE=RECOVER
+{
+ 0:3 :: ""
+} 1
+
+restricted:
+CCTK_INT EM_initial_calc_every "EM_initial_calc_every" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 1
+
+restricted:
+CCTK_INT EM_evol_calc_every "EM_evol_calc_every" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 1
+
+restricted:
+CCTK_INT EM_constraints_calc_every "EM_constraints_calc_every" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 1
+
+restricted:
+CCTK_INT EM_energy_calc_every "EM_energy_calc_every" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 1
+
+restricted:
+CCTK_INT EM_initial_calc_offset "EM_initial_calc_offset" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 0
+
+restricted:
+CCTK_INT EM_evol_calc_offset "EM_evol_calc_offset" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 0
+
+restricted:
+CCTK_INT EM_constraints_calc_offset "EM_constraints_calc_offset" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 0
+
+restricted:
+CCTK_INT EM_energy_calc_offset "EM_energy_calc_offset" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 0
+
+private:
+KEYWORD B1_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "skip"
+
+private:
+KEYWORD B2_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "skip"
+
+private:
+KEYWORD B3_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "skip"
+
+private:
+KEYWORD El1_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "skip"
+
+private:
+KEYWORD El2_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "skip"
+
+private:
+KEYWORD El3_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "skip"
+
+private:
+KEYWORD B_group_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "none"
+
+private:
+KEYWORD El_group_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "none"
+
+private:
+CCTK_REAL B1_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL B2_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL B3_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL El1_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL El2_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL El3_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL B_group_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL El_group_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL B1_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL B2_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL B3_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL El1_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL El2_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL El3_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL B_group_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL El_group_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL B1_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
+private:
+CCTK_REAL B2_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
+private:
+CCTK_REAL B3_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
+private:
+CCTK_REAL El1_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
+private:
+CCTK_REAL El2_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
+private:
+CCTK_REAL El3_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
+private:
+CCTK_REAL B_group_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
+private:
+CCTK_REAL El_group_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
diff --git a/Examples/EMScript/schedule.ccl b/Examples/EMScript/schedule.ccl
new file mode 100644
index 0000000..db3fb0f
--- /dev/null
+++ b/Examples/EMScript/schedule.ccl
@@ -0,0 +1,126 @@
+# File produced by Kranc
+
+
+if (other_timelevels == 1)
+{
+ STORAGE: CB_group[1]
+}
+
+if (other_timelevels == 1)
+{
+ STORAGE: CEl_group[1]
+}
+
+if (other_timelevels == 1)
+{
+ STORAGE: rho_group[1]
+}
+
+if (timelevels == 1)
+{
+ STORAGE: B_group[1]
+}
+if (timelevels == 2)
+{
+ STORAGE: B_group[2]
+}
+if (timelevels == 3)
+{
+ STORAGE: B_group[3]
+}
+
+if (timelevels == 1)
+{
+ STORAGE: El_group[1]
+}
+if (timelevels == 2)
+{
+ STORAGE: El_group[2]
+}
+if (timelevels == 3)
+{
+ STORAGE: El_group[3]
+}
+
+if (rhs_timelevels == 1)
+{
+ STORAGE: B_grouprhs[1]
+}
+if (rhs_timelevels == 2)
+{
+ STORAGE: B_grouprhs[2]
+}
+if (rhs_timelevels == 3)
+{
+ STORAGE: B_grouprhs[3]
+}
+
+if (rhs_timelevels == 1)
+{
+ STORAGE: El_grouprhs[1]
+}
+if (rhs_timelevels == 2)
+{
+ STORAGE: El_grouprhs[2]
+}
+if (rhs_timelevels == 3)
+{
+ STORAGE: El_grouprhs[3]
+}
+
+schedule EMScript_Startup at STARTUP
+{
+ LANG: C
+ OPTIONS: meta
+} "create banner"
+
+schedule EMScript_RegisterVars in MoL_Register
+{
+ LANG: C
+ OPTIONS: meta
+} "Register Variables for MoL"
+
+schedule EMScript_RegisterSymmetries in SymmetryRegister
+{
+ LANG: C
+ OPTIONS: meta
+} "register symmetries"
+
+schedule EM_initial at initial
+{
+ LANG: C
+} "EM_initial"
+
+schedule EM_evol in MoL_CalcRHS
+{
+ LANG: C
+} "EM_evol"
+
+schedule EM_constraints at analysis
+{
+ LANG: C
+} "EM_constraints"
+
+schedule EM_energy at analysis
+{
+ LANG: C
+} "EM_energy"
+
+schedule EMScript_SelectBoundConds in MoL_PostStep
+{
+ LANG: C
+ OPTIONS: level
+ SYNC: B_group
+ SYNC: El_group
+} "select boundary conditions"
+
+schedule EMScript_CheckBoundaries at BASEGRID
+{
+ LANG: C
+ OPTIONS: meta
+} "check boundaries treatment"
+
+schedule group ApplyBCs as EMScript_ApplyBCs in MoL_PostStep after EMScript_SelectBoundConds
+{
+ # no language specified
+} "Apply boundary conditions controlled by thorn Boundary"
diff --git a/Examples/EMScript/src/Boundaries.cc b/Examples/EMScript/src/Boundaries.cc
new file mode 100644
index 0000000..b091436
--- /dev/null
+++ b/Examples/EMScript/src/Boundaries.cc
@@ -0,0 +1,457 @@
+/* File produced by Kranc */
+
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "cctk_Faces.h"
+#include "util_Table.h"
+#include "Symmetry.h"
+
+
+/* the boundary treatment is split into 3 steps: */
+/* 1. excision */
+/* 2. symmetries */
+/* 3. "other" boundary conditions, e.g. radiative */
+
+/* to simplify scheduling and testing, the 3 steps */
+/* are currently applied in separate functions */
+
+
+extern "C" void EMScript_CheckBoundaries(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ return;
+}
+
+extern "C" void EMScript_SelectBoundConds(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT ierr = 0;
+
+ if (CCTK_EQUALS(B_group_bound, "none" ) ||
+ CCTK_EQUALS(B_group_bound, "static") ||
+ CCTK_EQUALS(B_group_bound, "flat" ) ||
+ CCTK_EQUALS(B_group_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "My_New_Implementation::B_group", B_group_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register B_group_bound BC for My_New_Implementation::B_group!");
+ }
+
+ if (CCTK_EQUALS(El_group_bound, "none" ) ||
+ CCTK_EQUALS(El_group_bound, "static") ||
+ CCTK_EQUALS(El_group_bound, "flat" ) ||
+ CCTK_EQUALS(El_group_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "My_New_Implementation::El_group", El_group_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register El_group_bound BC for My_New_Implementation::El_group!");
+ }
+
+ if (CCTK_EQUALS(B1_bound, "none" ) ||
+ CCTK_EQUALS(B1_bound, "static") ||
+ CCTK_EQUALS(B1_bound, "flat" ) ||
+ CCTK_EQUALS(B1_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "My_New_Implementation::B1", B1_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register B1_bound BC for My_New_Implementation::B1!");
+ }
+
+ if (CCTK_EQUALS(B2_bound, "none" ) ||
+ CCTK_EQUALS(B2_bound, "static") ||
+ CCTK_EQUALS(B2_bound, "flat" ) ||
+ CCTK_EQUALS(B2_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "My_New_Implementation::B2", B2_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register B2_bound BC for My_New_Implementation::B2!");
+ }
+
+ if (CCTK_EQUALS(B3_bound, "none" ) ||
+ CCTK_EQUALS(B3_bound, "static") ||
+ CCTK_EQUALS(B3_bound, "flat" ) ||
+ CCTK_EQUALS(B3_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "My_New_Implementation::B3", B3_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register B3_bound BC for My_New_Implementation::B3!");
+ }
+
+ if (CCTK_EQUALS(El1_bound, "none" ) ||
+ CCTK_EQUALS(El1_bound, "static") ||
+ CCTK_EQUALS(El1_bound, "flat" ) ||
+ CCTK_EQUALS(El1_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "My_New_Implementation::El1", El1_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register El1_bound BC for My_New_Implementation::El1!");
+ }
+
+ if (CCTK_EQUALS(El2_bound, "none" ) ||
+ CCTK_EQUALS(El2_bound, "static") ||
+ CCTK_EQUALS(El2_bound, "flat" ) ||
+ CCTK_EQUALS(El2_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "My_New_Implementation::El2", El2_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register El2_bound BC for My_New_Implementation::El2!");
+ }
+
+ if (CCTK_EQUALS(El3_bound, "none" ) ||
+ CCTK_EQUALS(El3_bound, "static") ||
+ CCTK_EQUALS(El3_bound, "flat" ) ||
+ CCTK_EQUALS(El3_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "My_New_Implementation::El3", El3_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register El3_bound BC for My_New_Implementation::El3!");
+ }
+
+ if (CCTK_EQUALS(B_group_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_B_group_bound = -1;
+ if (handle_B_group_bound < 0) handle_B_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_B_group_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_B_group_bound , B_group_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_B_group_bound ,B_group_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_B_group_bound,
+ "My_New_Implementation::B_group", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for My_New_Implementation::B_group!");
+
+ }
+
+ if (CCTK_EQUALS(El_group_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_El_group_bound = -1;
+ if (handle_El_group_bound < 0) handle_El_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_El_group_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_El_group_bound , El_group_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_El_group_bound ,El_group_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_El_group_bound,
+ "My_New_Implementation::El_group", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for My_New_Implementation::El_group!");
+
+ }
+
+ if (CCTK_EQUALS(B1_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_B1_bound = -1;
+ if (handle_B1_bound < 0) handle_B1_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_B1_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_B1_bound , B1_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_B1_bound ,B1_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_B1_bound,
+ "My_New_Implementation::B1", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for My_New_Implementation::B1!");
+
+ }
+
+ if (CCTK_EQUALS(B2_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_B2_bound = -1;
+ if (handle_B2_bound < 0) handle_B2_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_B2_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_B2_bound , B2_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_B2_bound ,B2_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_B2_bound,
+ "My_New_Implementation::B2", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for My_New_Implementation::B2!");
+
+ }
+
+ if (CCTK_EQUALS(B3_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_B3_bound = -1;
+ if (handle_B3_bound < 0) handle_B3_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_B3_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_B3_bound , B3_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_B3_bound ,B3_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_B3_bound,
+ "My_New_Implementation::B3", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for My_New_Implementation::B3!");
+
+ }
+
+ if (CCTK_EQUALS(El1_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_El1_bound = -1;
+ if (handle_El1_bound < 0) handle_El1_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_El1_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_El1_bound , El1_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_El1_bound ,El1_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_El1_bound,
+ "My_New_Implementation::El1", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for My_New_Implementation::El1!");
+
+ }
+
+ if (CCTK_EQUALS(El2_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_El2_bound = -1;
+ if (handle_El2_bound < 0) handle_El2_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_El2_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_El2_bound , El2_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_El2_bound ,El2_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_El2_bound,
+ "My_New_Implementation::El2", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for My_New_Implementation::El2!");
+
+ }
+
+ if (CCTK_EQUALS(El3_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_El3_bound = -1;
+ if (handle_El3_bound < 0) handle_El3_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_El3_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_El3_bound , El3_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_El3_bound ,El3_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_El3_bound,
+ "My_New_Implementation::El3", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for My_New_Implementation::El3!");
+
+ }
+
+ if (CCTK_EQUALS(B_group_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_B_group_bound = -1;
+ if (handle_B_group_bound < 0) handle_B_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_B_group_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_B_group_bound ,B_group_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_B_group_bound,
+ "My_New_Implementation::B_group", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Scalar BC for My_New_Implementation::B_group!");
+
+ }
+
+ if (CCTK_EQUALS(El_group_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_El_group_bound = -1;
+ if (handle_El_group_bound < 0) handle_El_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_El_group_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_El_group_bound ,El_group_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_El_group_bound,
+ "My_New_Implementation::El_group", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Scalar BC for My_New_Implementation::El_group!");
+
+ }
+
+ if (CCTK_EQUALS(B1_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_B1_bound = -1;
+ if (handle_B1_bound < 0) handle_B1_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_B1_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_B1_bound ,B1_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_B1_bound,
+ "My_New_Implementation::B1", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Error in registering Scalar BC for My_New_Implementation::B1!");
+
+ }
+
+ if (CCTK_EQUALS(B2_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_B2_bound = -1;
+ if (handle_B2_bound < 0) handle_B2_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_B2_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_B2_bound ,B2_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_B2_bound,
+ "My_New_Implementation::B2", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Error in registering Scalar BC for My_New_Implementation::B2!");
+
+ }
+
+ if (CCTK_EQUALS(B3_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_B3_bound = -1;
+ if (handle_B3_bound < 0) handle_B3_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_B3_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_B3_bound ,B3_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_B3_bound,
+ "My_New_Implementation::B3", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Error in registering Scalar BC for My_New_Implementation::B3!");
+
+ }
+
+ if (CCTK_EQUALS(El1_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_El1_bound = -1;
+ if (handle_El1_bound < 0) handle_El1_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_El1_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_El1_bound ,El1_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_El1_bound,
+ "My_New_Implementation::El1", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Error in registering Scalar BC for My_New_Implementation::El1!");
+
+ }
+
+ if (CCTK_EQUALS(El2_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_El2_bound = -1;
+ if (handle_El2_bound < 0) handle_El2_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_El2_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_El2_bound ,El2_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_El2_bound,
+ "My_New_Implementation::El2", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Error in registering Scalar BC for My_New_Implementation::El2!");
+
+ }
+
+ if (CCTK_EQUALS(El3_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_El3_bound = -1;
+ if (handle_El3_bound < 0) handle_El3_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_El3_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_El3_bound ,El3_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_El3_bound,
+ "My_New_Implementation::El3", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Error in registering Scalar BC for My_New_Implementation::El3!");
+
+ }
+ return;
+}
+
+
+
+/* template for entries in parameter file:
+#$bound$#My_New_Implementation::B_group_bound = "skip"
+#$bound$#My_New_Implementation::B_group_bound_speed = 1.0
+#$bound$#My_New_Implementation::B_group_bound_limit = 0.0
+#$bound$#My_New_Implementation::B_group_bound_scalar = 0.0
+
+#$bound$#My_New_Implementation::El_group_bound = "skip"
+#$bound$#My_New_Implementation::El_group_bound_speed = 1.0
+#$bound$#My_New_Implementation::El_group_bound_limit = 0.0
+#$bound$#My_New_Implementation::El_group_bound_scalar = 0.0
+
+#$bound$#My_New_Implementation::B1_bound = "skip"
+#$bound$#My_New_Implementation::B1_bound_speed = 1.0
+#$bound$#My_New_Implementation::B1_bound_limit = 0.0
+#$bound$#My_New_Implementation::B1_bound_scalar = 0.0
+
+#$bound$#My_New_Implementation::B2_bound = "skip"
+#$bound$#My_New_Implementation::B2_bound_speed = 1.0
+#$bound$#My_New_Implementation::B2_bound_limit = 0.0
+#$bound$#My_New_Implementation::B2_bound_scalar = 0.0
+
+#$bound$#My_New_Implementation::B3_bound = "skip"
+#$bound$#My_New_Implementation::B3_bound_speed = 1.0
+#$bound$#My_New_Implementation::B3_bound_limit = 0.0
+#$bound$#My_New_Implementation::B3_bound_scalar = 0.0
+
+#$bound$#My_New_Implementation::El1_bound = "skip"
+#$bound$#My_New_Implementation::El1_bound_speed = 1.0
+#$bound$#My_New_Implementation::El1_bound_limit = 0.0
+#$bound$#My_New_Implementation::El1_bound_scalar = 0.0
+
+#$bound$#My_New_Implementation::El2_bound = "skip"
+#$bound$#My_New_Implementation::El2_bound_speed = 1.0
+#$bound$#My_New_Implementation::El2_bound_limit = 0.0
+#$bound$#My_New_Implementation::El2_bound_scalar = 0.0
+
+#$bound$#My_New_Implementation::El3_bound = "skip"
+#$bound$#My_New_Implementation::El3_bound_speed = 1.0
+#$bound$#My_New_Implementation::El3_bound_limit = 0.0
+#$bound$#My_New_Implementation::El3_bound_scalar = 0.0
+
+*/
+
diff --git a/Examples/EMScript/src/Differencing.h b/Examples/EMScript/src/Differencing.h
new file mode 100644
index 0000000..1933a29
--- /dev/null
+++ b/Examples/EMScript/src/Differencing.h
@@ -0,0 +1,291 @@
+static char const * const differencing =
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder21(u) (kmul(p1o2dx,ksub(KRANC_GFOFFSET3D(u,1,0,0),KRANC_GFOFFSET3D(u,-1,0,0))))\n"
+"#else\n"
+"# define PDstandardfdOrder21(u) (PDstandardfdOrder21_impl(u,p1o2dx,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder21_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder21_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o2dx,ksub(KRANC_GFOFFSET3D(u,1,0,0),KRANC_GFOFFSET3D(u,-1,0,0)));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder22(u) (kmul(p1o2dy,ksub(KRANC_GFOFFSET3D(u,0,1,0),KRANC_GFOFFSET3D(u,0,-1,0))))\n"
+"#else\n"
+"# define PDstandardfdOrder22(u) (PDstandardfdOrder22_impl(u,p1o2dy,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder22_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder22_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o2dy,ksub(KRANC_GFOFFSET3D(u,0,1,0),KRANC_GFOFFSET3D(u,0,-1,0)));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder23(u) (kmul(p1o2dz,ksub(KRANC_GFOFFSET3D(u,0,0,1),KRANC_GFOFFSET3D(u,0,0,-1))))\n"
+"#else\n"
+"# define PDstandardfdOrder23(u) (PDstandardfdOrder23_impl(u,p1o2dz,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder23_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder23_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o2dz,ksub(KRANC_GFOFFSET3D(u,0,0,1),KRANC_GFOFFSET3D(u,0,0,-1)));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder41(u) (kmul(p1o12dx,kadd(KRANC_GFOFFSET3D(u,-2,0,0),kmadd(KRANC_GFOFFSET3D(u,-1,0,0),ToReal(-8),kmsub(KRANC_GFOFFSET3D(u,1,0,0),ToReal(8),KRANC_GFOFFSET3D(u,2,0,0))))))\n"
+"#else\n"
+"# define PDstandardfdOrder41(u) (PDstandardfdOrder41_impl(u,p1o12dx,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder41_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o12dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder41_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o12dx, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o12dx,kadd(KRANC_GFOFFSET3D(u,-2,0,0),kmadd(KRANC_GFOFFSET3D(u,-1,0,0),ToReal(-8),kmsub(KRANC_GFOFFSET3D(u,1,0,0),ToReal(8),KRANC_GFOFFSET3D(u,2,0,0)))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder42(u) (kmul(p1o12dy,kadd(KRANC_GFOFFSET3D(u,0,-2,0),kmadd(KRANC_GFOFFSET3D(u,0,-1,0),ToReal(-8),kmsub(KRANC_GFOFFSET3D(u,0,1,0),ToReal(8),KRANC_GFOFFSET3D(u,0,2,0))))))\n"
+"#else\n"
+"# define PDstandardfdOrder42(u) (PDstandardfdOrder42_impl(u,p1o12dy,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder42_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o12dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder42_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o12dy, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o12dy,kadd(KRANC_GFOFFSET3D(u,0,-2,0),kmadd(KRANC_GFOFFSET3D(u,0,-1,0),ToReal(-8),kmsub(KRANC_GFOFFSET3D(u,0,1,0),ToReal(8),KRANC_GFOFFSET3D(u,0,2,0)))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder43(u) (kmul(p1o12dz,kadd(KRANC_GFOFFSET3D(u,0,0,-2),kmadd(KRANC_GFOFFSET3D(u,0,0,-1),ToReal(-8),kmsub(KRANC_GFOFFSET3D(u,0,0,1),ToReal(8),KRANC_GFOFFSET3D(u,0,0,2))))))\n"
+"#else\n"
+"# define PDstandardfdOrder43(u) (PDstandardfdOrder43_impl(u,p1o12dz,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder43_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o12dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder43_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o12dz, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o12dz,kadd(KRANC_GFOFFSET3D(u,0,0,-2),kmadd(KRANC_GFOFFSET3D(u,0,0,-1),ToReal(-8),kmsub(KRANC_GFOFFSET3D(u,0,0,1),ToReal(8),KRANC_GFOFFSET3D(u,0,0,2)))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder211(u) (kmul(p1odx2,kadd(KRANC_GFOFFSET3D(u,-1,0,0),kmadd(KRANC_GFOFFSET3D(u,0,0,0),ToReal(-2),KRANC_GFOFFSET3D(u,1,0,0)))))\n"
+"#else\n"
+"# define PDstandardfdOrder211(u) (PDstandardfdOrder211_impl(u,p1odx2,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder211_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder211_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1odx2,kadd(KRANC_GFOFFSET3D(u,-1,0,0),kmadd(KRANC_GFOFFSET3D(u,0,0,0),ToReal(-2),KRANC_GFOFFSET3D(u,1,0,0))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder222(u) (kmul(p1ody2,kadd(KRANC_GFOFFSET3D(u,0,-1,0),kmadd(KRANC_GFOFFSET3D(u,0,0,0),ToReal(-2),KRANC_GFOFFSET3D(u,0,1,0)))))\n"
+"#else\n"
+"# define PDstandardfdOrder222(u) (PDstandardfdOrder222_impl(u,p1ody2,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder222_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder222_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1ody2,kadd(KRANC_GFOFFSET3D(u,0,-1,0),kmadd(KRANC_GFOFFSET3D(u,0,0,0),ToReal(-2),KRANC_GFOFFSET3D(u,0,1,0))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder233(u) (kmul(p1odz2,kadd(KRANC_GFOFFSET3D(u,0,0,-1),kmadd(KRANC_GFOFFSET3D(u,0,0,0),ToReal(-2),KRANC_GFOFFSET3D(u,0,0,1)))))\n"
+"#else\n"
+"# define PDstandardfdOrder233(u) (PDstandardfdOrder233_impl(u,p1odz2,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder233_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder233_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1odz2,kadd(KRANC_GFOFFSET3D(u,0,0,-1),kmadd(KRANC_GFOFFSET3D(u,0,0,0),ToReal(-2),KRANC_GFOFFSET3D(u,0,0,1))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder411(u) (kmul(pm1o12dx2,kadd(KRANC_GFOFFSET3D(u,-2,0,0),kadd(KRANC_GFOFFSET3D(u,2,0,0),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,0),KRANC_GFOFFSET3D(u,1,0,0)),ToReal(-16),kmul(KRANC_GFOFFSET3D(u,0,0,0),ToReal(30)))))))\n"
+"#else\n"
+"# define PDstandardfdOrder411(u) (PDstandardfdOrder411_impl(u,pm1o12dx2,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder411_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const pm1o12dx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder411_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const pm1o12dx2, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(pm1o12dx2,kadd(KRANC_GFOFFSET3D(u,-2,0,0),kadd(KRANC_GFOFFSET3D(u,2,0,0),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,0),KRANC_GFOFFSET3D(u,1,0,0)),ToReal(-16),kmul(KRANC_GFOFFSET3D(u,0,0,0),ToReal(30))))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder422(u) (kmul(pm1o12dy2,kadd(KRANC_GFOFFSET3D(u,0,-2,0),kadd(KRANC_GFOFFSET3D(u,0,2,0),kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,0),KRANC_GFOFFSET3D(u,0,1,0)),ToReal(-16),kmul(KRANC_GFOFFSET3D(u,0,0,0),ToReal(30)))))))\n"
+"#else\n"
+"# define PDstandardfdOrder422(u) (PDstandardfdOrder422_impl(u,pm1o12dy2,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder422_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const pm1o12dy2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder422_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const pm1o12dy2, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(pm1o12dy2,kadd(KRANC_GFOFFSET3D(u,0,-2,0),kadd(KRANC_GFOFFSET3D(u,0,2,0),kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,0),KRANC_GFOFFSET3D(u,0,1,0)),ToReal(-16),kmul(KRANC_GFOFFSET3D(u,0,0,0),ToReal(30))))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder433(u) (kmul(pm1o12dz2,kadd(KRANC_GFOFFSET3D(u,0,0,-2),kadd(KRANC_GFOFFSET3D(u,0,0,2),kmadd(kadd(KRANC_GFOFFSET3D(u,0,0,-1),KRANC_GFOFFSET3D(u,0,0,1)),ToReal(-16),kmul(KRANC_GFOFFSET3D(u,0,0,0),ToReal(30)))))))\n"
+"#else\n"
+"# define PDstandardfdOrder433(u) (PDstandardfdOrder433_impl(u,pm1o12dz2,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder433_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const pm1o12dz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder433_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const pm1o12dz2, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(pm1o12dz2,kadd(KRANC_GFOFFSET3D(u,0,0,-2),kadd(KRANC_GFOFFSET3D(u,0,0,2),kmadd(kadd(KRANC_GFOFFSET3D(u,0,0,-1),KRANC_GFOFFSET3D(u,0,0,1)),ToReal(-16),kmul(KRANC_GFOFFSET3D(u,0,0,0),ToReal(30))))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder212(u) (kmul(p1o4dxdy,kadd(KRANC_GFOFFSET3D(u,-1,-1,0),ksub(KRANC_GFOFFSET3D(u,1,1,0),kadd(KRANC_GFOFFSET3D(u,1,-1,0),KRANC_GFOFFSET3D(u,-1,1,0))))))\n"
+"#else\n"
+"# define PDstandardfdOrder212(u) (PDstandardfdOrder212_impl(u,p1o4dxdy,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder212_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder212_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o4dxdy,kadd(KRANC_GFOFFSET3D(u,-1,-1,0),ksub(KRANC_GFOFFSET3D(u,1,1,0),kadd(KRANC_GFOFFSET3D(u,1,-1,0),KRANC_GFOFFSET3D(u,-1,1,0)))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder213(u) (kmul(p1o4dxdz,kadd(KRANC_GFOFFSET3D(u,-1,0,-1),ksub(KRANC_GFOFFSET3D(u,1,0,1),kadd(KRANC_GFOFFSET3D(u,1,0,-1),KRANC_GFOFFSET3D(u,-1,0,1))))))\n"
+"#else\n"
+"# define PDstandardfdOrder213(u) (PDstandardfdOrder213_impl(u,p1o4dxdz,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder213_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder213_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o4dxdz,kadd(KRANC_GFOFFSET3D(u,-1,0,-1),ksub(KRANC_GFOFFSET3D(u,1,0,1),kadd(KRANC_GFOFFSET3D(u,1,0,-1),KRANC_GFOFFSET3D(u,-1,0,1)))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder221(u) (kmul(p1o4dxdy,kadd(KRANC_GFOFFSET3D(u,-1,-1,0),ksub(KRANC_GFOFFSET3D(u,1,1,0),kadd(KRANC_GFOFFSET3D(u,1,-1,0),KRANC_GFOFFSET3D(u,-1,1,0))))))\n"
+"#else\n"
+"# define PDstandardfdOrder221(u) (PDstandardfdOrder221_impl(u,p1o4dxdy,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder221_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder221_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o4dxdy,kadd(KRANC_GFOFFSET3D(u,-1,-1,0),ksub(KRANC_GFOFFSET3D(u,1,1,0),kadd(KRANC_GFOFFSET3D(u,1,-1,0),KRANC_GFOFFSET3D(u,-1,1,0)))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder223(u) (kmul(p1o4dydz,kadd(KRANC_GFOFFSET3D(u,0,-1,-1),ksub(KRANC_GFOFFSET3D(u,0,1,1),kadd(KRANC_GFOFFSET3D(u,0,1,-1),KRANC_GFOFFSET3D(u,0,-1,1))))))\n"
+"#else\n"
+"# define PDstandardfdOrder223(u) (PDstandardfdOrder223_impl(u,p1o4dydz,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder223_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder223_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o4dydz,kadd(KRANC_GFOFFSET3D(u,0,-1,-1),ksub(KRANC_GFOFFSET3D(u,0,1,1),kadd(KRANC_GFOFFSET3D(u,0,1,-1),KRANC_GFOFFSET3D(u,0,-1,1)))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder231(u) (kmul(p1o4dxdz,kadd(KRANC_GFOFFSET3D(u,-1,0,-1),ksub(KRANC_GFOFFSET3D(u,1,0,1),kadd(KRANC_GFOFFSET3D(u,1,0,-1),KRANC_GFOFFSET3D(u,-1,0,1))))))\n"
+"#else\n"
+"# define PDstandardfdOrder231(u) (PDstandardfdOrder231_impl(u,p1o4dxdz,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder231_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder231_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o4dxdz,kadd(KRANC_GFOFFSET3D(u,-1,0,-1),ksub(KRANC_GFOFFSET3D(u,1,0,1),kadd(KRANC_GFOFFSET3D(u,1,0,-1),KRANC_GFOFFSET3D(u,-1,0,1)))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder232(u) (kmul(p1o4dydz,kadd(KRANC_GFOFFSET3D(u,0,-1,-1),ksub(KRANC_GFOFFSET3D(u,0,1,1),kadd(KRANC_GFOFFSET3D(u,0,1,-1),KRANC_GFOFFSET3D(u,0,-1,1))))))\n"
+"#else\n"
+"# define PDstandardfdOrder232(u) (PDstandardfdOrder232_impl(u,p1o4dydz,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder232_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder232_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o4dydz,kadd(KRANC_GFOFFSET3D(u,0,-1,-1),ksub(KRANC_GFOFFSET3D(u,0,1,1),kadd(KRANC_GFOFFSET3D(u,0,1,-1),KRANC_GFOFFSET3D(u,0,-1,1)))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder412(u) (kmul(p1o144dxdy,kadd(KRANC_GFOFFSET3D(u,-2,-2,0),kadd(KRANC_GFOFFSET3D(u,2,2,0),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,1,0),KRANC_GFOFFSET3D(u,1,-1,0)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,-2,0),kadd(KRANC_GFOFFSET3D(u,1,2,0),kadd(KRANC_GFOFFSET3D(u,-2,-1,0),KRANC_GFOFFSET3D(u,2,1,0)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,-1,2,0),kadd(KRANC_GFOFFSET3D(u,1,-2,0),kadd(KRANC_GFOFFSET3D(u,-2,1,0),KRANC_GFOFFSET3D(u,2,-1,0)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,-1,-1,0),KRANC_GFOFFSET3D(u,1,1,0)),ToReal(64))),KRANC_GFOFFSET3D(u,2,-2,0)),KRANC_GFOFFSET3D(u,-2,2,0))))))))\n"
+"#else\n"
+"# define PDstandardfdOrder412(u) (PDstandardfdOrder412_impl(u,p1o144dxdy,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder412_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder412_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o144dxdy,kadd(KRANC_GFOFFSET3D(u,-2,-2,0),kadd(KRANC_GFOFFSET3D(u,2,2,0),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,1,0),KRANC_GFOFFSET3D(u,1,-1,0)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,-2,0),kadd(KRANC_GFOFFSET3D(u,1,2,0),kadd(KRANC_GFOFFSET3D(u,-2,-1,0),KRANC_GFOFFSET3D(u,2,1,0)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,-1,2,0),kadd(KRANC_GFOFFSET3D(u,1,-2,0),kadd(KRANC_GFOFFSET3D(u,-2,1,0),KRANC_GFOFFSET3D(u,2,-1,0)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,-1,-1,0),KRANC_GFOFFSET3D(u,1,1,0)),ToReal(64))),KRANC_GFOFFSET3D(u,2,-2,0)),KRANC_GFOFFSET3D(u,-2,2,0)))))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder413(u) (kmul(p1o144dxdz,kadd(KRANC_GFOFFSET3D(u,-2,0,-2),kadd(KRANC_GFOFFSET3D(u,2,0,2),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,1),KRANC_GFOFFSET3D(u,1,0,-1)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,-2),kadd(KRANC_GFOFFSET3D(u,1,0,2),kadd(KRANC_GFOFFSET3D(u,-2,0,-1),KRANC_GFOFFSET3D(u,2,0,1)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,2),kadd(KRANC_GFOFFSET3D(u,1,0,-2),kadd(KRANC_GFOFFSET3D(u,-2,0,1),KRANC_GFOFFSET3D(u,2,0,-1)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,-1,0,-1),KRANC_GFOFFSET3D(u,1,0,1)),ToReal(64))),KRANC_GFOFFSET3D(u,2,0,-2)),KRANC_GFOFFSET3D(u,-2,0,2))))))))\n"
+"#else\n"
+"# define PDstandardfdOrder413(u) (PDstandardfdOrder413_impl(u,p1o144dxdz,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder413_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder413_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o144dxdz,kadd(KRANC_GFOFFSET3D(u,-2,0,-2),kadd(KRANC_GFOFFSET3D(u,2,0,2),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,1),KRANC_GFOFFSET3D(u,1,0,-1)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,-2),kadd(KRANC_GFOFFSET3D(u,1,0,2),kadd(KRANC_GFOFFSET3D(u,-2,0,-1),KRANC_GFOFFSET3D(u,2,0,1)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,2),kadd(KRANC_GFOFFSET3D(u,1,0,-2),kadd(KRANC_GFOFFSET3D(u,-2,0,1),KRANC_GFOFFSET3D(u,2,0,-1)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,-1,0,-1),KRANC_GFOFFSET3D(u,1,0,1)),ToReal(64))),KRANC_GFOFFSET3D(u,2,0,-2)),KRANC_GFOFFSET3D(u,-2,0,2)))))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder421(u) (kmul(p1o144dxdy,kadd(KRANC_GFOFFSET3D(u,-2,-2,0),kadd(KRANC_GFOFFSET3D(u,2,2,0),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,1,0),KRANC_GFOFFSET3D(u,1,-1,0)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,-2,0),kadd(KRANC_GFOFFSET3D(u,1,2,0),kadd(KRANC_GFOFFSET3D(u,-2,-1,0),KRANC_GFOFFSET3D(u,2,1,0)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,-1,2,0),kadd(KRANC_GFOFFSET3D(u,1,-2,0),kadd(KRANC_GFOFFSET3D(u,-2,1,0),KRANC_GFOFFSET3D(u,2,-1,0)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,-1,-1,0),KRANC_GFOFFSET3D(u,1,1,0)),ToReal(64))),KRANC_GFOFFSET3D(u,2,-2,0)),KRANC_GFOFFSET3D(u,-2,2,0))))))))\n"
+"#else\n"
+"# define PDstandardfdOrder421(u) (PDstandardfdOrder421_impl(u,p1o144dxdy,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder421_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder421_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o144dxdy,kadd(KRANC_GFOFFSET3D(u,-2,-2,0),kadd(KRANC_GFOFFSET3D(u,2,2,0),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,1,0),KRANC_GFOFFSET3D(u,1,-1,0)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,-2,0),kadd(KRANC_GFOFFSET3D(u,1,2,0),kadd(KRANC_GFOFFSET3D(u,-2,-1,0),KRANC_GFOFFSET3D(u,2,1,0)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,-1,2,0),kadd(KRANC_GFOFFSET3D(u,1,-2,0),kadd(KRANC_GFOFFSET3D(u,-2,1,0),KRANC_GFOFFSET3D(u,2,-1,0)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,-1,-1,0),KRANC_GFOFFSET3D(u,1,1,0)),ToReal(64))),KRANC_GFOFFSET3D(u,2,-2,0)),KRANC_GFOFFSET3D(u,-2,2,0)))))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder423(u) (kmul(p1o144dydz,kadd(KRANC_GFOFFSET3D(u,0,-2,-2),kadd(KRANC_GFOFFSET3D(u,0,2,2),kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,1),KRANC_GFOFFSET3D(u,0,1,-1)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,-2),kadd(KRANC_GFOFFSET3D(u,0,1,2),kadd(KRANC_GFOFFSET3D(u,0,-2,-1),KRANC_GFOFFSET3D(u,0,2,1)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,2),kadd(KRANC_GFOFFSET3D(u,0,1,-2),kadd(KRANC_GFOFFSET3D(u,0,-2,1),KRANC_GFOFFSET3D(u,0,2,-1)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,0,-1,-1),KRANC_GFOFFSET3D(u,0,1,1)),ToReal(64))),KRANC_GFOFFSET3D(u,0,2,-2)),KRANC_GFOFFSET3D(u,0,-2,2))))))))\n"
+"#else\n"
+"# define PDstandardfdOrder423(u) (PDstandardfdOrder423_impl(u,p1o144dydz,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder423_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder423_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o144dydz,kadd(KRANC_GFOFFSET3D(u,0,-2,-2),kadd(KRANC_GFOFFSET3D(u,0,2,2),kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,1),KRANC_GFOFFSET3D(u,0,1,-1)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,-2),kadd(KRANC_GFOFFSET3D(u,0,1,2),kadd(KRANC_GFOFFSET3D(u,0,-2,-1),KRANC_GFOFFSET3D(u,0,2,1)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,2),kadd(KRANC_GFOFFSET3D(u,0,1,-2),kadd(KRANC_GFOFFSET3D(u,0,-2,1),KRANC_GFOFFSET3D(u,0,2,-1)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,0,-1,-1),KRANC_GFOFFSET3D(u,0,1,1)),ToReal(64))),KRANC_GFOFFSET3D(u,0,2,-2)),KRANC_GFOFFSET3D(u,0,-2,2)))))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder431(u) (kmul(p1o144dxdz,kadd(KRANC_GFOFFSET3D(u,-2,0,-2),kadd(KRANC_GFOFFSET3D(u,2,0,2),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,1),KRANC_GFOFFSET3D(u,1,0,-1)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,-2),kadd(KRANC_GFOFFSET3D(u,1,0,2),kadd(KRANC_GFOFFSET3D(u,-2,0,-1),KRANC_GFOFFSET3D(u,2,0,1)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,2),kadd(KRANC_GFOFFSET3D(u,1,0,-2),kadd(KRANC_GFOFFSET3D(u,-2,0,1),KRANC_GFOFFSET3D(u,2,0,-1)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,-1,0,-1),KRANC_GFOFFSET3D(u,1,0,1)),ToReal(64))),KRANC_GFOFFSET3D(u,2,0,-2)),KRANC_GFOFFSET3D(u,-2,0,2))))))))\n"
+"#else\n"
+"# define PDstandardfdOrder431(u) (PDstandardfdOrder431_impl(u,p1o144dxdz,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder431_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder431_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o144dxdz,kadd(KRANC_GFOFFSET3D(u,-2,0,-2),kadd(KRANC_GFOFFSET3D(u,2,0,2),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,1),KRANC_GFOFFSET3D(u,1,0,-1)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,-2),kadd(KRANC_GFOFFSET3D(u,1,0,2),kadd(KRANC_GFOFFSET3D(u,-2,0,-1),KRANC_GFOFFSET3D(u,2,0,1)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,-1,0,2),kadd(KRANC_GFOFFSET3D(u,1,0,-2),kadd(KRANC_GFOFFSET3D(u,-2,0,1),KRANC_GFOFFSET3D(u,2,0,-1)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,-1,0,-1),KRANC_GFOFFSET3D(u,1,0,1)),ToReal(64))),KRANC_GFOFFSET3D(u,2,0,-2)),KRANC_GFOFFSET3D(u,-2,0,2)))))));\n"
+"}\n"
+"#endif\n"
+"\n"
+"#ifndef KRANC_DIFF_FUNCTIONS\n"
+"# define PDstandardfdOrder432(u) (kmul(p1o144dydz,kadd(KRANC_GFOFFSET3D(u,0,-2,-2),kadd(KRANC_GFOFFSET3D(u,0,2,2),kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,1),KRANC_GFOFFSET3D(u,0,1,-1)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,-2),kadd(KRANC_GFOFFSET3D(u,0,1,2),kadd(KRANC_GFOFFSET3D(u,0,-2,-1),KRANC_GFOFFSET3D(u,0,2,1)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,2),kadd(KRANC_GFOFFSET3D(u,0,1,-2),kadd(KRANC_GFOFFSET3D(u,0,-2,1),KRANC_GFOFFSET3D(u,0,2,-1)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,0,-1,-1),KRANC_GFOFFSET3D(u,0,1,1)),ToReal(64))),KRANC_GFOFFSET3D(u,0,2,-2)),KRANC_GFOFFSET3D(u,0,-2,2))))))))\n"
+"#else\n"
+"# define PDstandardfdOrder432(u) (PDstandardfdOrder432_impl(u,p1o144dydz,cdj,cdk))\n"
+"static CCTK_REAL_VEC PDstandardfdOrder432_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;\n"
+"static CCTK_REAL_VEC PDstandardfdOrder432_impl(CCTK_REAL const* restrict const u, CCTK_REAL_VEC const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk)\n"
+"{\n"
+" ptrdiff_t const cdi=sizeof(CCTK_REAL);\n"
+" return kmul(p1o144dydz,kadd(KRANC_GFOFFSET3D(u,0,-2,-2),kadd(KRANC_GFOFFSET3D(u,0,2,2),kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,1),KRANC_GFOFFSET3D(u,0,1,-1)),ToReal(-64),kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,-2),kadd(KRANC_GFOFFSET3D(u,0,1,2),kadd(KRANC_GFOFFSET3D(u,0,-2,-1),KRANC_GFOFFSET3D(u,0,2,1)))),ToReal(-8),ksub(ksub(kmadd(kadd(KRANC_GFOFFSET3D(u,0,-1,2),kadd(KRANC_GFOFFSET3D(u,0,1,-2),kadd(KRANC_GFOFFSET3D(u,0,-2,1),KRANC_GFOFFSET3D(u,0,2,-1)))),ToReal(8),kmul(kadd(KRANC_GFOFFSET3D(u,0,-1,-1),KRANC_GFOFFSET3D(u,0,1,1)),ToReal(64))),KRANC_GFOFFSET3D(u,0,2,-2)),KRANC_GFOFFSET3D(u,0,-2,2)))))));\n"
+"}\n"
+"#endif\n"
+"\n"
+""
+;
diff --git a/Examples/EMScript/src/EM_constraints.cc b/Examples/EMScript/src/EM_constraints.cc
new file mode 100644
index 0000000..fc8e97e
--- /dev/null
+++ b/Examples/EMScript/src/EM_constraints.cc
@@ -0,0 +1,354 @@
+/* File produced by Kranc */
+
+#define KRANC_C
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "GenericFD.h"
+#include "Differencing.h"
+#include "cctk_Loop.h"
+#include "loopcontrol.h"
+#include "OpenCLRunTime.h"
+#include "vectors.h"
+
+/* Define macros used in calculations */
+#define INITVALUE (42)
+#define QAD(x) (SQR(SQR(x)))
+#define INV(x) (kdiv(ToReal(1.0),x))
+#define SQR(x) (kmul(x,x))
+#define CUB(x) (kmul(x,SQR(x)))
+
+extern "C" void EM_constraints_SelectBCs(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT ierr = 0;
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "My_New_Implementation::CB_group","flat");
+ if (ierr < 0)
+ CCTK_WARN(1, "Failed to register flat BC for My_New_Implementation::CB_group.");
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "My_New_Implementation::CEl_group","flat");
+ if (ierr < 0)
+ CCTK_WARN(1, "Failed to register flat BC for My_New_Implementation::CEl_group.");
+ return;
+}
+
+static void EM_constraints_Body(cGH const * restrict const cctkGH, int const dir, int const face, CCTK_REAL const normal[3], CCTK_REAL const tangentA[3], CCTK_REAL const tangentB[3], int const imin[3], int const imax[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[])
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ char const * const source =
+ "\n"
+ "/* Declare finite differencing variables */\n"
+ "\n"
+ "/* Include user-supplied include files */\n"
+ "\n"
+ "/* Initialise finite differencing variables */\n"
+ "ptrdiff_t const di = 1;\n"
+ "ptrdiff_t const dj = CCTK_GFINDEX3D(cctkGH,0,1,0) - CCTK_GFINDEX3D(cctkGH,0,0,0);\n"
+ "ptrdiff_t const dk = CCTK_GFINDEX3D(cctkGH,0,0,1) - CCTK_GFINDEX3D(cctkGH,0,0,0);\n"
+ "ptrdiff_t const cdi = sizeof(CCTK_REAL) * di;\n"
+ "ptrdiff_t const cdj = sizeof(CCTK_REAL) * dj;\n"
+ "ptrdiff_t const cdk = sizeof(CCTK_REAL) * dk;\n"
+ "CCTK_REAL_VEC const dx = ToReal(CCTK_DELTA_SPACE(0));\n"
+ "CCTK_REAL_VEC const dy = ToReal(CCTK_DELTA_SPACE(1));\n"
+ "CCTK_REAL_VEC const dz = ToReal(CCTK_DELTA_SPACE(2));\n"
+ "CCTK_REAL_VEC const dt = ToReal(CCTK_DELTA_TIME);\n"
+ "CCTK_REAL_VEC const t = ToReal(cctk_time);\n"
+ "CCTK_REAL_VEC const dxi = INV(dx);\n"
+ "CCTK_REAL_VEC const dyi = INV(dy);\n"
+ "CCTK_REAL_VEC const dzi = INV(dz);\n"
+ "CCTK_REAL_VEC const khalf = ToReal(0.5);\n"
+ "CCTK_REAL_VEC const kthird = ToReal(1.0/3.0);\n"
+ "CCTK_REAL_VEC const ktwothird = ToReal(2.0/3.0);\n"
+ "CCTK_REAL_VEC const kfourthird = ToReal(4.0/3.0);\n"
+ "CCTK_REAL_VEC const keightthird = ToReal(8.0/3.0);\n"
+ "CCTK_REAL_VEC const hdxi = kmul(ToReal(0.5), dxi);\n"
+ "CCTK_REAL_VEC const hdyi = kmul(ToReal(0.5), dyi);\n"
+ "CCTK_REAL_VEC const hdzi = kmul(ToReal(0.5), dzi);\n"
+ "\n"
+ "/* Initialize predefined quantities */\n"
+ "CCTK_REAL_VEC const p1o12dx = kmul(INV(dx),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o12dy = kmul(INV(dy),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o12dz = kmul(INV(dz),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o144dxdy = kmul(INV(dx),kmul(INV(dy),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o144dxdz = kmul(INV(dx),kmul(INV(dz),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o144dydz = kmul(INV(dy),kmul(INV(dz),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o2dx = kmul(INV(dx),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o2dy = kmul(INV(dy),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o2dz = kmul(INV(dz),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o4dxdy = kmul(INV(dx),kmul(INV(dy),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1o4dxdz = kmul(INV(dx),kmul(INV(dz),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1o4dydz = kmul(INV(dy),kmul(INV(dz),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1odx2 = INV(SQR(dx));\n"
+ "CCTK_REAL_VEC const p1ody2 = INV(SQR(dy));\n"
+ "CCTK_REAL_VEC const p1odz2 = INV(SQR(dz));\n"
+ "CCTK_REAL_VEC const pm1o12dx2 = kmul(INV(SQR(dx)),ToReal(-0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const pm1o12dy2 = kmul(INV(SQR(dy)),ToReal(-0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const pm1o12dz2 = kmul(INV(SQR(dz)),ToReal(-0.0833333333333333333333333333333));\n"
+ "\n"
+ "/* Jacobian variable pointers */\n"
+ "bool const use_jacobian = (!CCTK_IsFunctionAliased(\"MultiPatch_GetMap\") || MultiPatch_GetMap(cctkGH) != jacobian_identity_map)\n"
+ " && strlen(jacobian_group) > 0;\n"
+ "if (use_jacobian && strlen(jacobian_derivative_group) == 0)\n"
+ "{\n"
+ " CCTK_WARN (1, \"GenericFD::jacobian_group and GenericFD::jacobian_derivative_group must both be set to valid group names\");\n"
+ "}\n"
+ "\n"
+ "CCTK_REAL const *restrict jacobian_ptrs[9];\n"
+ "if (use_jacobian) GenericFD_GroupDataPointers(cctkGH, jacobian_group,\n"
+ " 9, jacobian_ptrs);\n"
+ "\n"
+ "CCTK_REAL const *restrict const J11 = use_jacobian ? jacobian_ptrs[0] : 0;\n"
+ "CCTK_REAL const *restrict const J12 = use_jacobian ? jacobian_ptrs[1] : 0;\n"
+ "CCTK_REAL const *restrict const J13 = use_jacobian ? jacobian_ptrs[2] : 0;\n"
+ "CCTK_REAL const *restrict const J21 = use_jacobian ? jacobian_ptrs[3] : 0;\n"
+ "CCTK_REAL const *restrict const J22 = use_jacobian ? jacobian_ptrs[4] : 0;\n"
+ "CCTK_REAL const *restrict const J23 = use_jacobian ? jacobian_ptrs[5] : 0;\n"
+ "CCTK_REAL const *restrict const J31 = use_jacobian ? jacobian_ptrs[6] : 0;\n"
+ "CCTK_REAL const *restrict const J32 = use_jacobian ? jacobian_ptrs[7] : 0;\n"
+ "CCTK_REAL const *restrict const J33 = use_jacobian ? jacobian_ptrs[8] : 0;\n"
+ "\n"
+ "CCTK_REAL const *restrict jacobian_derivative_ptrs[18];\n"
+ "if (use_jacobian) GenericFD_GroupDataPointers(cctkGH, jacobian_derivative_group,\n"
+ " 18, jacobian_derivative_ptrs);\n"
+ "\n"
+ "CCTK_REAL const *restrict const dJ111 = use_jacobian ? jacobian_derivative_ptrs[0] : 0;\n"
+ "CCTK_REAL const *restrict const dJ112 = use_jacobian ? jacobian_derivative_ptrs[1] : 0;\n"
+ "CCTK_REAL const *restrict const dJ113 = use_jacobian ? jacobian_derivative_ptrs[2] : 0;\n"
+ "CCTK_REAL const *restrict const dJ122 = use_jacobian ? jacobian_derivative_ptrs[3] : 0;\n"
+ "CCTK_REAL const *restrict const dJ123 = use_jacobian ? jacobian_derivative_ptrs[4] : 0;\n"
+ "CCTK_REAL const *restrict const dJ133 = use_jacobian ? jacobian_derivative_ptrs[5] : 0;\n"
+ "CCTK_REAL const *restrict const dJ211 = use_jacobian ? jacobian_derivative_ptrs[6] : 0;\n"
+ "CCTK_REAL const *restrict const dJ212 = use_jacobian ? jacobian_derivative_ptrs[7] : 0;\n"
+ "CCTK_REAL const *restrict const dJ213 = use_jacobian ? jacobian_derivative_ptrs[8] : 0;\n"
+ "CCTK_REAL const *restrict const dJ222 = use_jacobian ? jacobian_derivative_ptrs[9] : 0;\n"
+ "CCTK_REAL const *restrict const dJ223 = use_jacobian ? jacobian_derivative_ptrs[10] : 0;\n"
+ "CCTK_REAL const *restrict const dJ233 = use_jacobian ? jacobian_derivative_ptrs[11] : 0;\n"
+ "CCTK_REAL const *restrict const dJ311 = use_jacobian ? jacobian_derivative_ptrs[12] : 0;\n"
+ "CCTK_REAL const *restrict const dJ312 = use_jacobian ? jacobian_derivative_ptrs[13] : 0;\n"
+ "CCTK_REAL const *restrict const dJ313 = use_jacobian ? jacobian_derivative_ptrs[14] : 0;\n"
+ "CCTK_REAL const *restrict const dJ322 = use_jacobian ? jacobian_derivative_ptrs[15] : 0;\n"
+ "CCTK_REAL const *restrict const dJ323 = use_jacobian ? jacobian_derivative_ptrs[16] : 0;\n"
+ "CCTK_REAL const *restrict const dJ333 = use_jacobian ? jacobian_derivative_ptrs[17] : 0;\n"
+ "\n"
+ "/* Assign local copies of arrays functions */\n"
+ "\n"
+ "\n"
+ "\n"
+ "/* Calculate temporaries and arrays functions */\n"
+ "\n"
+ "/* Copy local copies back to grid functions */\n"
+ "\n"
+ "/* Loop over the grid points */\n"
+ "#pragma omp parallel\n"
+ "LC_LOOP3VEC (EM_constraints,\n"
+ " i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2],\n"
+ " cctk_lsh[0],cctk_lsh[1],cctk_lsh[2],\n"
+ " CCTK_REAL_VEC_SIZE)\n"
+ "{\n"
+ " ptrdiff_t const index = di*i + dj*j + dk*k;\n"
+ " \n"
+ " /* Assign local copies of grid functions */\n"
+ " \n"
+ " CCTK_REAL_VEC B1L = vec_load(B1[index]);\n"
+ " CCTK_REAL_VEC B2L = vec_load(B2[index]);\n"
+ " CCTK_REAL_VEC B3L = vec_load(B3[index]);\n"
+ " CCTK_REAL_VEC El1L = vec_load(El1[index]);\n"
+ " CCTK_REAL_VEC El2L = vec_load(El2[index]);\n"
+ " CCTK_REAL_VEC El3L = vec_load(El3[index]);\n"
+ " \n"
+ " \n"
+ " CCTK_REAL_VEC J11L, J12L, J13L, J21L, J22L, J23L, J31L, J32L, J33L;\n"
+ " \n"
+ " if (use_jacobian)\n"
+ " {\n"
+ " J11L = vec_load(J11[index]);\n"
+ " J12L = vec_load(J12[index]);\n"
+ " J13L = vec_load(J13[index]);\n"
+ " J21L = vec_load(J21[index]);\n"
+ " J22L = vec_load(J22[index]);\n"
+ " J23L = vec_load(J23[index]);\n"
+ " J31L = vec_load(J31[index]);\n"
+ " J32L = vec_load(J32[index]);\n"
+ " J33L = vec_load(J33[index]);\n"
+ " }\n"
+ " \n"
+ " /* Include user supplied include files */\n"
+ " \n"
+ " /* Precompute derivatives */\n"
+ " CCTK_REAL_VEC PDstandard1B1;\n"
+ " CCTK_REAL_VEC PDstandard2B1;\n"
+ " CCTK_REAL_VEC PDstandard3B1;\n"
+ " CCTK_REAL_VEC PDstandard1B2;\n"
+ " CCTK_REAL_VEC PDstandard2B2;\n"
+ " CCTK_REAL_VEC PDstandard3B2;\n"
+ " CCTK_REAL_VEC PDstandard1B3;\n"
+ " CCTK_REAL_VEC PDstandard2B3;\n"
+ " CCTK_REAL_VEC PDstandard3B3;\n"
+ " CCTK_REAL_VEC PDstandard1El1;\n"
+ " CCTK_REAL_VEC PDstandard2El1;\n"
+ " CCTK_REAL_VEC PDstandard3El1;\n"
+ " CCTK_REAL_VEC PDstandard1El2;\n"
+ " CCTK_REAL_VEC PDstandard2El2;\n"
+ " CCTK_REAL_VEC PDstandard3El2;\n"
+ " CCTK_REAL_VEC PDstandard1El3;\n"
+ " CCTK_REAL_VEC PDstandard2El3;\n"
+ " CCTK_REAL_VEC PDstandard3El3;\n"
+ " \n"
+ " switch(fdOrder)\n"
+ " {\n"
+ " case 2:\n"
+ " PDstandard1B1 = PDstandardfdOrder21(&B1[index]);\n"
+ " PDstandard2B1 = PDstandardfdOrder22(&B1[index]);\n"
+ " PDstandard3B1 = PDstandardfdOrder23(&B1[index]);\n"
+ " PDstandard1B2 = PDstandardfdOrder21(&B2[index]);\n"
+ " PDstandard2B2 = PDstandardfdOrder22(&B2[index]);\n"
+ " PDstandard3B2 = PDstandardfdOrder23(&B2[index]);\n"
+ " PDstandard1B3 = PDstandardfdOrder21(&B3[index]);\n"
+ " PDstandard2B3 = PDstandardfdOrder22(&B3[index]);\n"
+ " PDstandard3B3 = PDstandardfdOrder23(&B3[index]);\n"
+ " PDstandard1El1 = PDstandardfdOrder21(&El1[index]);\n"
+ " PDstandard2El1 = PDstandardfdOrder22(&El1[index]);\n"
+ " PDstandard3El1 = PDstandardfdOrder23(&El1[index]);\n"
+ " PDstandard1El2 = PDstandardfdOrder21(&El2[index]);\n"
+ " PDstandard2El2 = PDstandardfdOrder22(&El2[index]);\n"
+ " PDstandard3El2 = PDstandardfdOrder23(&El2[index]);\n"
+ " PDstandard1El3 = PDstandardfdOrder21(&El3[index]);\n"
+ " PDstandard2El3 = PDstandardfdOrder22(&El3[index]);\n"
+ " PDstandard3El3 = PDstandardfdOrder23(&El3[index]);\n"
+ " break;\n"
+ " \n"
+ " case 4:\n"
+ " PDstandard1B1 = PDstandardfdOrder41(&B1[index]);\n"
+ " PDstandard2B1 = PDstandardfdOrder42(&B1[index]);\n"
+ " PDstandard3B1 = PDstandardfdOrder43(&B1[index]);\n"
+ " PDstandard1B2 = PDstandardfdOrder41(&B2[index]);\n"
+ " PDstandard2B2 = PDstandardfdOrder42(&B2[index]);\n"
+ " PDstandard3B2 = PDstandardfdOrder43(&B2[index]);\n"
+ " PDstandard1B3 = PDstandardfdOrder41(&B3[index]);\n"
+ " PDstandard2B3 = PDstandardfdOrder42(&B3[index]);\n"
+ " PDstandard3B3 = PDstandardfdOrder43(&B3[index]);\n"
+ " PDstandard1El1 = PDstandardfdOrder41(&El1[index]);\n"
+ " PDstandard2El1 = PDstandardfdOrder42(&El1[index]);\n"
+ " PDstandard3El1 = PDstandardfdOrder43(&El1[index]);\n"
+ " PDstandard1El2 = PDstandardfdOrder41(&El2[index]);\n"
+ " PDstandard2El2 = PDstandardfdOrder42(&El2[index]);\n"
+ " PDstandard3El2 = PDstandardfdOrder43(&El2[index]);\n"
+ " PDstandard1El3 = PDstandardfdOrder41(&El3[index]);\n"
+ " PDstandard2El3 = PDstandardfdOrder42(&El3[index]);\n"
+ " PDstandard3El3 = PDstandardfdOrder43(&El3[index]);\n"
+ " break;\n"
+ " }\n"
+ " \n"
+ " /* Calculate temporaries and grid functions */\n"
+ " CCTK_REAL_VEC JacPDstandard1B1;\n"
+ " CCTK_REAL_VEC JacPDstandard1El1;\n"
+ " CCTK_REAL_VEC JacPDstandard2B2;\n"
+ " CCTK_REAL_VEC JacPDstandard2El2;\n"
+ " CCTK_REAL_VEC JacPDstandard3B3;\n"
+ " CCTK_REAL_VEC JacPDstandard3El3;\n"
+ " \n"
+ " if (use_jacobian)\n"
+ " {\n"
+ " JacPDstandard1B1 = \n"
+ " kmadd(J11L,PDstandard1B1,kmadd(J21L,PDstandard2B1,kmul(J31L,PDstandard3B1)));\n"
+ " \n"
+ " JacPDstandard1El1 = \n"
+ " kmadd(J11L,PDstandard1El1,kmadd(J21L,PDstandard2El1,kmul(J31L,PDstandard3El1)));\n"
+ " \n"
+ " JacPDstandard2B2 = \n"
+ " kmadd(J12L,PDstandard1B2,kmadd(J22L,PDstandard2B2,kmul(J32L,PDstandard3B2)));\n"
+ " \n"
+ " JacPDstandard2El2 = \n"
+ " kmadd(J12L,PDstandard1El2,kmadd(J22L,PDstandard2El2,kmul(J32L,PDstandard3El2)));\n"
+ " \n"
+ " JacPDstandard3B3 = \n"
+ " kmadd(J13L,PDstandard1B3,kmadd(J23L,PDstandard2B3,kmul(J33L,PDstandard3B3)));\n"
+ " \n"
+ " JacPDstandard3El3 = \n"
+ " kmadd(J13L,PDstandard1El3,kmadd(J23L,PDstandard2El3,kmul(J33L,PDstandard3El3)));\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " JacPDstandard1B1 = PDstandard1B1;\n"
+ " \n"
+ " JacPDstandard1El1 = PDstandard1El1;\n"
+ " \n"
+ " JacPDstandard2B2 = PDstandard2B2;\n"
+ " \n"
+ " JacPDstandard2El2 = PDstandard2El2;\n"
+ " \n"
+ " JacPDstandard3B3 = PDstandard3B3;\n"
+ " \n"
+ " JacPDstandard3El3 = PDstandard3El3;\n"
+ " }\n"
+ " \n"
+ " CCTK_REAL_VEC CElL = \n"
+ " kadd(JacPDstandard1El1,kadd(JacPDstandard2El2,JacPDstandard3El3));\n"
+ " \n"
+ " CCTK_REAL_VEC CBL = \n"
+ " kadd(JacPDstandard1B1,kadd(JacPDstandard2B2,JacPDstandard3B3));\n"
+ " \n"
+ " /* Copy local copies back to grid functions */\n"
+ " vec_store_nta_partial(CB[index],CBL);\n"
+ " vec_store_nta_partial(CEl[index],CElL);\n"
+ "}\n"
+ "LC_ENDLOOP3VEC (EM_constraints);\n"
+ ""
+ ;
+
+ char const * const groups[] = {"My_New_Implementation::B_group","My_New_Implementation::CB_group","My_New_Implementation::CEl_group","My_New_Implementation::El_group",NULL};
+
+ static struct OpenCLKernel * kernel = NULL;
+ char const * const sources[] = {differencing, source, NULL};
+ OpenCLRunTime_CallKernel (cctkGH, CCTK_THORNSTRING, "EM_constraints",
+ sources, groups, NULL, NULL, NULL, -1,
+ imin, imax, &kernel);
+
+}
+
+extern "C" void EM_constraints(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Entering EM_constraints_Body");
+ }
+
+ if (cctk_iteration % EM_constraints_calc_every != EM_constraints_calc_offset)
+ {
+ return;
+ }
+
+ const char *groups[] = {"My_New_Implementation::B_group","My_New_Implementation::CB_group","My_New_Implementation::CEl_group","My_New_Implementation::El_group"};
+ GenericFD_AssertGroupStorage(cctkGH, "EM_constraints", 4, groups);
+
+ switch(fdOrder)
+ {
+ case 2:
+ GenericFD_EnsureStencilFits(cctkGH, "EM_constraints", 1, 1, 1);
+ break;
+
+ case 4:
+ GenericFD_EnsureStencilFits(cctkGH, "EM_constraints", 2, 2, 2);
+ break;
+ }
+
+ GenericFD_LoopOverInterior(cctkGH, &EM_constraints_Body);
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Leaving EM_constraints_Body");
+ }
+}
diff --git a/Examples/EMScript/src/EM_energy.cc b/Examples/EMScript/src/EM_energy.cc
new file mode 100644
index 0000000..5a7875c
--- /dev/null
+++ b/Examples/EMScript/src/EM_energy.cc
@@ -0,0 +1,235 @@
+/* File produced by Kranc */
+
+#define KRANC_C
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "GenericFD.h"
+#include "Differencing.h"
+#include "cctk_Loop.h"
+#include "loopcontrol.h"
+#include "OpenCLRunTime.h"
+#include "vectors.h"
+
+/* Define macros used in calculations */
+#define INITVALUE (42)
+#define QAD(x) (SQR(SQR(x)))
+#define INV(x) (kdiv(ToReal(1.0),x))
+#define SQR(x) (kmul(x,x))
+#define CUB(x) (kmul(x,SQR(x)))
+
+extern "C" void EM_energy_SelectBCs(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT ierr = 0;
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "My_New_Implementation::rho_group","flat");
+ if (ierr < 0)
+ CCTK_WARN(1, "Failed to register flat BC for My_New_Implementation::rho_group.");
+ return;
+}
+
+static void EM_energy_Body(cGH const * restrict const cctkGH, int const dir, int const face, CCTK_REAL const normal[3], CCTK_REAL const tangentA[3], CCTK_REAL const tangentB[3], int const imin[3], int const imax[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[])
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ char const * const source =
+ "\n"
+ "/* Declare finite differencing variables */\n"
+ "\n"
+ "/* Include user-supplied include files */\n"
+ "\n"
+ "/* Initialise finite differencing variables */\n"
+ "ptrdiff_t const di = 1;\n"
+ "ptrdiff_t const dj = CCTK_GFINDEX3D(cctkGH,0,1,0) - CCTK_GFINDEX3D(cctkGH,0,0,0);\n"
+ "ptrdiff_t const dk = CCTK_GFINDEX3D(cctkGH,0,0,1) - CCTK_GFINDEX3D(cctkGH,0,0,0);\n"
+ "ptrdiff_t const cdi = sizeof(CCTK_REAL) * di;\n"
+ "ptrdiff_t const cdj = sizeof(CCTK_REAL) * dj;\n"
+ "ptrdiff_t const cdk = sizeof(CCTK_REAL) * dk;\n"
+ "CCTK_REAL_VEC const dx = ToReal(CCTK_DELTA_SPACE(0));\n"
+ "CCTK_REAL_VEC const dy = ToReal(CCTK_DELTA_SPACE(1));\n"
+ "CCTK_REAL_VEC const dz = ToReal(CCTK_DELTA_SPACE(2));\n"
+ "CCTK_REAL_VEC const dt = ToReal(CCTK_DELTA_TIME);\n"
+ "CCTK_REAL_VEC const t = ToReal(cctk_time);\n"
+ "CCTK_REAL_VEC const dxi = INV(dx);\n"
+ "CCTK_REAL_VEC const dyi = INV(dy);\n"
+ "CCTK_REAL_VEC const dzi = INV(dz);\n"
+ "CCTK_REAL_VEC const khalf = ToReal(0.5);\n"
+ "CCTK_REAL_VEC const kthird = ToReal(1.0/3.0);\n"
+ "CCTK_REAL_VEC const ktwothird = ToReal(2.0/3.0);\n"
+ "CCTK_REAL_VEC const kfourthird = ToReal(4.0/3.0);\n"
+ "CCTK_REAL_VEC const keightthird = ToReal(8.0/3.0);\n"
+ "CCTK_REAL_VEC const hdxi = kmul(ToReal(0.5), dxi);\n"
+ "CCTK_REAL_VEC const hdyi = kmul(ToReal(0.5), dyi);\n"
+ "CCTK_REAL_VEC const hdzi = kmul(ToReal(0.5), dzi);\n"
+ "\n"
+ "/* Initialize predefined quantities */\n"
+ "CCTK_REAL_VEC const p1o12dx = kmul(INV(dx),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o12dy = kmul(INV(dy),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o12dz = kmul(INV(dz),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o144dxdy = kmul(INV(dx),kmul(INV(dy),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o144dxdz = kmul(INV(dx),kmul(INV(dz),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o144dydz = kmul(INV(dy),kmul(INV(dz),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o2dx = kmul(INV(dx),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o2dy = kmul(INV(dy),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o2dz = kmul(INV(dz),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o4dxdy = kmul(INV(dx),kmul(INV(dy),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1o4dxdz = kmul(INV(dx),kmul(INV(dz),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1o4dydz = kmul(INV(dy),kmul(INV(dz),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1odx2 = INV(SQR(dx));\n"
+ "CCTK_REAL_VEC const p1ody2 = INV(SQR(dy));\n"
+ "CCTK_REAL_VEC const p1odz2 = INV(SQR(dz));\n"
+ "CCTK_REAL_VEC const pm1o12dx2 = kmul(INV(SQR(dx)),ToReal(-0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const pm1o12dy2 = kmul(INV(SQR(dy)),ToReal(-0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const pm1o12dz2 = kmul(INV(SQR(dz)),ToReal(-0.0833333333333333333333333333333));\n"
+ "\n"
+ "/* Jacobian variable pointers */\n"
+ "bool const use_jacobian = (!CCTK_IsFunctionAliased(\"MultiPatch_GetMap\") || MultiPatch_GetMap(cctkGH) != jacobian_identity_map)\n"
+ " && strlen(jacobian_group) > 0;\n"
+ "if (use_jacobian && strlen(jacobian_derivative_group) == 0)\n"
+ "{\n"
+ " CCTK_WARN (1, \"GenericFD::jacobian_group and GenericFD::jacobian_derivative_group must both be set to valid group names\");\n"
+ "}\n"
+ "\n"
+ "CCTK_REAL const *restrict jacobian_ptrs[9];\n"
+ "if (use_jacobian) GenericFD_GroupDataPointers(cctkGH, jacobian_group,\n"
+ " 9, jacobian_ptrs);\n"
+ "\n"
+ "CCTK_REAL const *restrict const J11 = use_jacobian ? jacobian_ptrs[0] : 0;\n"
+ "CCTK_REAL const *restrict const J12 = use_jacobian ? jacobian_ptrs[1] : 0;\n"
+ "CCTK_REAL const *restrict const J13 = use_jacobian ? jacobian_ptrs[2] : 0;\n"
+ "CCTK_REAL const *restrict const J21 = use_jacobian ? jacobian_ptrs[3] : 0;\n"
+ "CCTK_REAL const *restrict const J22 = use_jacobian ? jacobian_ptrs[4] : 0;\n"
+ "CCTK_REAL const *restrict const J23 = use_jacobian ? jacobian_ptrs[5] : 0;\n"
+ "CCTK_REAL const *restrict const J31 = use_jacobian ? jacobian_ptrs[6] : 0;\n"
+ "CCTK_REAL const *restrict const J32 = use_jacobian ? jacobian_ptrs[7] : 0;\n"
+ "CCTK_REAL const *restrict const J33 = use_jacobian ? jacobian_ptrs[8] : 0;\n"
+ "\n"
+ "CCTK_REAL const *restrict jacobian_derivative_ptrs[18];\n"
+ "if (use_jacobian) GenericFD_GroupDataPointers(cctkGH, jacobian_derivative_group,\n"
+ " 18, jacobian_derivative_ptrs);\n"
+ "\n"
+ "CCTK_REAL const *restrict const dJ111 = use_jacobian ? jacobian_derivative_ptrs[0] : 0;\n"
+ "CCTK_REAL const *restrict const dJ112 = use_jacobian ? jacobian_derivative_ptrs[1] : 0;\n"
+ "CCTK_REAL const *restrict const dJ113 = use_jacobian ? jacobian_derivative_ptrs[2] : 0;\n"
+ "CCTK_REAL const *restrict const dJ122 = use_jacobian ? jacobian_derivative_ptrs[3] : 0;\n"
+ "CCTK_REAL const *restrict const dJ123 = use_jacobian ? jacobian_derivative_ptrs[4] : 0;\n"
+ "CCTK_REAL const *restrict const dJ133 = use_jacobian ? jacobian_derivative_ptrs[5] : 0;\n"
+ "CCTK_REAL const *restrict const dJ211 = use_jacobian ? jacobian_derivative_ptrs[6] : 0;\n"
+ "CCTK_REAL const *restrict const dJ212 = use_jacobian ? jacobian_derivative_ptrs[7] : 0;\n"
+ "CCTK_REAL const *restrict const dJ213 = use_jacobian ? jacobian_derivative_ptrs[8] : 0;\n"
+ "CCTK_REAL const *restrict const dJ222 = use_jacobian ? jacobian_derivative_ptrs[9] : 0;\n"
+ "CCTK_REAL const *restrict const dJ223 = use_jacobian ? jacobian_derivative_ptrs[10] : 0;\n"
+ "CCTK_REAL const *restrict const dJ233 = use_jacobian ? jacobian_derivative_ptrs[11] : 0;\n"
+ "CCTK_REAL const *restrict const dJ311 = use_jacobian ? jacobian_derivative_ptrs[12] : 0;\n"
+ "CCTK_REAL const *restrict const dJ312 = use_jacobian ? jacobian_derivative_ptrs[13] : 0;\n"
+ "CCTK_REAL const *restrict const dJ313 = use_jacobian ? jacobian_derivative_ptrs[14] : 0;\n"
+ "CCTK_REAL const *restrict const dJ322 = use_jacobian ? jacobian_derivative_ptrs[15] : 0;\n"
+ "CCTK_REAL const *restrict const dJ323 = use_jacobian ? jacobian_derivative_ptrs[16] : 0;\n"
+ "CCTK_REAL const *restrict const dJ333 = use_jacobian ? jacobian_derivative_ptrs[17] : 0;\n"
+ "\n"
+ "/* Assign local copies of arrays functions */\n"
+ "\n"
+ "\n"
+ "\n"
+ "/* Calculate temporaries and arrays functions */\n"
+ "\n"
+ "/* Copy local copies back to grid functions */\n"
+ "\n"
+ "/* Loop over the grid points */\n"
+ "#pragma omp parallel\n"
+ "LC_LOOP3VEC (EM_energy,\n"
+ " i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2],\n"
+ " cctk_lsh[0],cctk_lsh[1],cctk_lsh[2],\n"
+ " CCTK_REAL_VEC_SIZE)\n"
+ "{\n"
+ " ptrdiff_t const index = di*i + dj*j + dk*k;\n"
+ " \n"
+ " /* Assign local copies of grid functions */\n"
+ " \n"
+ " CCTK_REAL_VEC B1L = vec_load(B1[index]);\n"
+ " CCTK_REAL_VEC B2L = vec_load(B2[index]);\n"
+ " CCTK_REAL_VEC B3L = vec_load(B3[index]);\n"
+ " CCTK_REAL_VEC El1L = vec_load(El1[index]);\n"
+ " CCTK_REAL_VEC El2L = vec_load(El2[index]);\n"
+ " CCTK_REAL_VEC El3L = vec_load(El3[index]);\n"
+ " \n"
+ " \n"
+ " \n"
+ " /* Include user supplied include files */\n"
+ " \n"
+ " /* Precompute derivatives */\n"
+ " \n"
+ " switch(fdOrder)\n"
+ " {\n"
+ " case 2:\n"
+ " break;\n"
+ " \n"
+ " case 4:\n"
+ " break;\n"
+ " }\n"
+ " \n"
+ " /* Calculate temporaries and grid functions */\n"
+ " CCTK_REAL_VEC rhoL = \n"
+ " kmul(kadd(SQR(B1L),kadd(SQR(B2L),kadd(SQR(B3L),kadd(SQR(El1L),kadd(SQR(El2L),SQR(El3L)))))),ToReal(0.5));\n"
+ " \n"
+ " /* Copy local copies back to grid functions */\n"
+ " vec_store_nta_partial(rho[index],rhoL);\n"
+ "}\n"
+ "LC_ENDLOOP3VEC (EM_energy);\n"
+ ""
+ ;
+
+ char const * const groups[] = {"My_New_Implementation::B_group","My_New_Implementation::El_group","My_New_Implementation::rho_group",NULL};
+
+ static struct OpenCLKernel * kernel = NULL;
+ char const * const sources[] = {differencing, source, NULL};
+ OpenCLRunTime_CallKernel (cctkGH, CCTK_THORNSTRING, "EM_energy",
+ sources, groups, NULL, NULL, NULL, -1,
+ imin, imax, &kernel);
+
+}
+
+extern "C" void EM_energy(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Entering EM_energy_Body");
+ }
+
+ if (cctk_iteration % EM_energy_calc_every != EM_energy_calc_offset)
+ {
+ return;
+ }
+
+ const char *groups[] = {"My_New_Implementation::B_group","My_New_Implementation::El_group","My_New_Implementation::rho_group"};
+ GenericFD_AssertGroupStorage(cctkGH, "EM_energy", 3, groups);
+
+ switch(fdOrder)
+ {
+ case 2:
+ break;
+
+ case 4:
+ break;
+ }
+
+ GenericFD_LoopOverEverything(cctkGH, &EM_energy_Body);
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Leaving EM_energy_Body");
+ }
+}
diff --git a/Examples/EMScript/src/EM_evol.cc b/Examples/EMScript/src/EM_evol.cc
new file mode 100644
index 0000000..4e66517
--- /dev/null
+++ b/Examples/EMScript/src/EM_evol.cc
@@ -0,0 +1,400 @@
+/* File produced by Kranc */
+
+#define KRANC_C
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "GenericFD.h"
+#include "Differencing.h"
+#include "cctk_Loop.h"
+#include "loopcontrol.h"
+#include "OpenCLRunTime.h"
+#include "vectors.h"
+
+/* Define macros used in calculations */
+#define INITVALUE (42)
+#define QAD(x) (SQR(SQR(x)))
+#define INV(x) (kdiv(ToReal(1.0),x))
+#define SQR(x) (kmul(x,x))
+#define CUB(x) (kmul(x,SQR(x)))
+
+extern "C" void EM_evol_SelectBCs(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT ierr = 0;
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "My_New_Implementation::B_grouprhs","flat");
+ if (ierr < 0)
+ CCTK_WARN(1, "Failed to register flat BC for My_New_Implementation::B_grouprhs.");
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "My_New_Implementation::El_grouprhs","flat");
+ if (ierr < 0)
+ CCTK_WARN(1, "Failed to register flat BC for My_New_Implementation::El_grouprhs.");
+ return;
+}
+
+static void EM_evol_Body(cGH const * restrict const cctkGH, int const dir, int const face, CCTK_REAL const normal[3], CCTK_REAL const tangentA[3], CCTK_REAL const tangentB[3], int const imin[3], int const imax[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[])
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ char const * const source =
+ "\n"
+ "/* Declare finite differencing variables */\n"
+ "\n"
+ "/* Include user-supplied include files */\n"
+ "\n"
+ "/* Initialise finite differencing variables */\n"
+ "ptrdiff_t const di = 1;\n"
+ "ptrdiff_t const dj = CCTK_GFINDEX3D(cctkGH,0,1,0) - CCTK_GFINDEX3D(cctkGH,0,0,0);\n"
+ "ptrdiff_t const dk = CCTK_GFINDEX3D(cctkGH,0,0,1) - CCTK_GFINDEX3D(cctkGH,0,0,0);\n"
+ "ptrdiff_t const cdi = sizeof(CCTK_REAL) * di;\n"
+ "ptrdiff_t const cdj = sizeof(CCTK_REAL) * dj;\n"
+ "ptrdiff_t const cdk = sizeof(CCTK_REAL) * dk;\n"
+ "CCTK_REAL_VEC const dx = ToReal(CCTK_DELTA_SPACE(0));\n"
+ "CCTK_REAL_VEC const dy = ToReal(CCTK_DELTA_SPACE(1));\n"
+ "CCTK_REAL_VEC const dz = ToReal(CCTK_DELTA_SPACE(2));\n"
+ "CCTK_REAL_VEC const dt = ToReal(CCTK_DELTA_TIME);\n"
+ "CCTK_REAL_VEC const t = ToReal(cctk_time);\n"
+ "CCTK_REAL_VEC const dxi = INV(dx);\n"
+ "CCTK_REAL_VEC const dyi = INV(dy);\n"
+ "CCTK_REAL_VEC const dzi = INV(dz);\n"
+ "CCTK_REAL_VEC const khalf = ToReal(0.5);\n"
+ "CCTK_REAL_VEC const kthird = ToReal(1.0/3.0);\n"
+ "CCTK_REAL_VEC const ktwothird = ToReal(2.0/3.0);\n"
+ "CCTK_REAL_VEC const kfourthird = ToReal(4.0/3.0);\n"
+ "CCTK_REAL_VEC const keightthird = ToReal(8.0/3.0);\n"
+ "CCTK_REAL_VEC const hdxi = kmul(ToReal(0.5), dxi);\n"
+ "CCTK_REAL_VEC const hdyi = kmul(ToReal(0.5), dyi);\n"
+ "CCTK_REAL_VEC const hdzi = kmul(ToReal(0.5), dzi);\n"
+ "\n"
+ "/* Initialize predefined quantities */\n"
+ "CCTK_REAL_VEC const p1o12dx = kmul(INV(dx),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o12dy = kmul(INV(dy),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o12dz = kmul(INV(dz),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o144dxdy = kmul(INV(dx),kmul(INV(dy),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o144dxdz = kmul(INV(dx),kmul(INV(dz),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o144dydz = kmul(INV(dy),kmul(INV(dz),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o2dx = kmul(INV(dx),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o2dy = kmul(INV(dy),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o2dz = kmul(INV(dz),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o4dxdy = kmul(INV(dx),kmul(INV(dy),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1o4dxdz = kmul(INV(dx),kmul(INV(dz),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1o4dydz = kmul(INV(dy),kmul(INV(dz),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1odx2 = INV(SQR(dx));\n"
+ "CCTK_REAL_VEC const p1ody2 = INV(SQR(dy));\n"
+ "CCTK_REAL_VEC const p1odz2 = INV(SQR(dz));\n"
+ "CCTK_REAL_VEC const pm1o12dx2 = kmul(INV(SQR(dx)),ToReal(-0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const pm1o12dy2 = kmul(INV(SQR(dy)),ToReal(-0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const pm1o12dz2 = kmul(INV(SQR(dz)),ToReal(-0.0833333333333333333333333333333));\n"
+ "\n"
+ "/* Jacobian variable pointers */\n"
+ "bool const use_jacobian = (!CCTK_IsFunctionAliased(\"MultiPatch_GetMap\") || MultiPatch_GetMap(cctkGH) != jacobian_identity_map)\n"
+ " && strlen(jacobian_group) > 0;\n"
+ "if (use_jacobian && strlen(jacobian_derivative_group) == 0)\n"
+ "{\n"
+ " CCTK_WARN (1, \"GenericFD::jacobian_group and GenericFD::jacobian_derivative_group must both be set to valid group names\");\n"
+ "}\n"
+ "\n"
+ "CCTK_REAL const *restrict jacobian_ptrs[9];\n"
+ "if (use_jacobian) GenericFD_GroupDataPointers(cctkGH, jacobian_group,\n"
+ " 9, jacobian_ptrs);\n"
+ "\n"
+ "CCTK_REAL const *restrict const J11 = use_jacobian ? jacobian_ptrs[0] : 0;\n"
+ "CCTK_REAL const *restrict const J12 = use_jacobian ? jacobian_ptrs[1] : 0;\n"
+ "CCTK_REAL const *restrict const J13 = use_jacobian ? jacobian_ptrs[2] : 0;\n"
+ "CCTK_REAL const *restrict const J21 = use_jacobian ? jacobian_ptrs[3] : 0;\n"
+ "CCTK_REAL const *restrict const J22 = use_jacobian ? jacobian_ptrs[4] : 0;\n"
+ "CCTK_REAL const *restrict const J23 = use_jacobian ? jacobian_ptrs[5] : 0;\n"
+ "CCTK_REAL const *restrict const J31 = use_jacobian ? jacobian_ptrs[6] : 0;\n"
+ "CCTK_REAL const *restrict const J32 = use_jacobian ? jacobian_ptrs[7] : 0;\n"
+ "CCTK_REAL const *restrict const J33 = use_jacobian ? jacobian_ptrs[8] : 0;\n"
+ "\n"
+ "CCTK_REAL const *restrict jacobian_derivative_ptrs[18];\n"
+ "if (use_jacobian) GenericFD_GroupDataPointers(cctkGH, jacobian_derivative_group,\n"
+ " 18, jacobian_derivative_ptrs);\n"
+ "\n"
+ "CCTK_REAL const *restrict const dJ111 = use_jacobian ? jacobian_derivative_ptrs[0] : 0;\n"
+ "CCTK_REAL const *restrict const dJ112 = use_jacobian ? jacobian_derivative_ptrs[1] : 0;\n"
+ "CCTK_REAL const *restrict const dJ113 = use_jacobian ? jacobian_derivative_ptrs[2] : 0;\n"
+ "CCTK_REAL const *restrict const dJ122 = use_jacobian ? jacobian_derivative_ptrs[3] : 0;\n"
+ "CCTK_REAL const *restrict const dJ123 = use_jacobian ? jacobian_derivative_ptrs[4] : 0;\n"
+ "CCTK_REAL const *restrict const dJ133 = use_jacobian ? jacobian_derivative_ptrs[5] : 0;\n"
+ "CCTK_REAL const *restrict const dJ211 = use_jacobian ? jacobian_derivative_ptrs[6] : 0;\n"
+ "CCTK_REAL const *restrict const dJ212 = use_jacobian ? jacobian_derivative_ptrs[7] : 0;\n"
+ "CCTK_REAL const *restrict const dJ213 = use_jacobian ? jacobian_derivative_ptrs[8] : 0;\n"
+ "CCTK_REAL const *restrict const dJ222 = use_jacobian ? jacobian_derivative_ptrs[9] : 0;\n"
+ "CCTK_REAL const *restrict const dJ223 = use_jacobian ? jacobian_derivative_ptrs[10] : 0;\n"
+ "CCTK_REAL const *restrict const dJ233 = use_jacobian ? jacobian_derivative_ptrs[11] : 0;\n"
+ "CCTK_REAL const *restrict const dJ311 = use_jacobian ? jacobian_derivative_ptrs[12] : 0;\n"
+ "CCTK_REAL const *restrict const dJ312 = use_jacobian ? jacobian_derivative_ptrs[13] : 0;\n"
+ "CCTK_REAL const *restrict const dJ313 = use_jacobian ? jacobian_derivative_ptrs[14] : 0;\n"
+ "CCTK_REAL const *restrict const dJ322 = use_jacobian ? jacobian_derivative_ptrs[15] : 0;\n"
+ "CCTK_REAL const *restrict const dJ323 = use_jacobian ? jacobian_derivative_ptrs[16] : 0;\n"
+ "CCTK_REAL const *restrict const dJ333 = use_jacobian ? jacobian_derivative_ptrs[17] : 0;\n"
+ "\n"
+ "/* Assign local copies of arrays functions */\n"
+ "\n"
+ "\n"
+ "\n"
+ "/* Calculate temporaries and arrays functions */\n"
+ "\n"
+ "/* Copy local copies back to grid functions */\n"
+ "\n"
+ "/* Loop over the grid points */\n"
+ "#pragma omp parallel\n"
+ "LC_LOOP3VEC (EM_evol,\n"
+ " i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2],\n"
+ " cctk_lsh[0],cctk_lsh[1],cctk_lsh[2],\n"
+ " CCTK_REAL_VEC_SIZE)\n"
+ "{\n"
+ " ptrdiff_t const index = di*i + dj*j + dk*k;\n"
+ " \n"
+ " /* Assign local copies of grid functions */\n"
+ " \n"
+ " CCTK_REAL_VEC B1L = vec_load(B1[index]);\n"
+ " CCTK_REAL_VEC B2L = vec_load(B2[index]);\n"
+ " CCTK_REAL_VEC B3L = vec_load(B3[index]);\n"
+ " CCTK_REAL_VEC El1L = vec_load(El1[index]);\n"
+ " CCTK_REAL_VEC El2L = vec_load(El2[index]);\n"
+ " CCTK_REAL_VEC El3L = vec_load(El3[index]);\n"
+ " \n"
+ " \n"
+ " CCTK_REAL_VEC J11L, J12L, J13L, J21L, J22L, J23L, J31L, J32L, J33L;\n"
+ " \n"
+ " if (use_jacobian)\n"
+ " {\n"
+ " J11L = vec_load(J11[index]);\n"
+ " J12L = vec_load(J12[index]);\n"
+ " J13L = vec_load(J13[index]);\n"
+ " J21L = vec_load(J21[index]);\n"
+ " J22L = vec_load(J22[index]);\n"
+ " J23L = vec_load(J23[index]);\n"
+ " J31L = vec_load(J31[index]);\n"
+ " J32L = vec_load(J32[index]);\n"
+ " J33L = vec_load(J33[index]);\n"
+ " }\n"
+ " \n"
+ " /* Include user supplied include files */\n"
+ " \n"
+ " /* Precompute derivatives */\n"
+ " CCTK_REAL_VEC PDstandard1B1;\n"
+ " CCTK_REAL_VEC PDstandard2B1;\n"
+ " CCTK_REAL_VEC PDstandard3B1;\n"
+ " CCTK_REAL_VEC PDstandard1B2;\n"
+ " CCTK_REAL_VEC PDstandard2B2;\n"
+ " CCTK_REAL_VEC PDstandard3B2;\n"
+ " CCTK_REAL_VEC PDstandard1B3;\n"
+ " CCTK_REAL_VEC PDstandard2B3;\n"
+ " CCTK_REAL_VEC PDstandard3B3;\n"
+ " CCTK_REAL_VEC PDstandard1El1;\n"
+ " CCTK_REAL_VEC PDstandard2El1;\n"
+ " CCTK_REAL_VEC PDstandard3El1;\n"
+ " CCTK_REAL_VEC PDstandard1El2;\n"
+ " CCTK_REAL_VEC PDstandard2El2;\n"
+ " CCTK_REAL_VEC PDstandard3El2;\n"
+ " CCTK_REAL_VEC PDstandard1El3;\n"
+ " CCTK_REAL_VEC PDstandard2El3;\n"
+ " CCTK_REAL_VEC PDstandard3El3;\n"
+ " \n"
+ " switch(fdOrder)\n"
+ " {\n"
+ " case 2:\n"
+ " PDstandard1B1 = PDstandardfdOrder21(&B1[index]);\n"
+ " PDstandard2B1 = PDstandardfdOrder22(&B1[index]);\n"
+ " PDstandard3B1 = PDstandardfdOrder23(&B1[index]);\n"
+ " PDstandard1B2 = PDstandardfdOrder21(&B2[index]);\n"
+ " PDstandard2B2 = PDstandardfdOrder22(&B2[index]);\n"
+ " PDstandard3B2 = PDstandardfdOrder23(&B2[index]);\n"
+ " PDstandard1B3 = PDstandardfdOrder21(&B3[index]);\n"
+ " PDstandard2B3 = PDstandardfdOrder22(&B3[index]);\n"
+ " PDstandard3B3 = PDstandardfdOrder23(&B3[index]);\n"
+ " PDstandard1El1 = PDstandardfdOrder21(&El1[index]);\n"
+ " PDstandard2El1 = PDstandardfdOrder22(&El1[index]);\n"
+ " PDstandard3El1 = PDstandardfdOrder23(&El1[index]);\n"
+ " PDstandard1El2 = PDstandardfdOrder21(&El2[index]);\n"
+ " PDstandard2El2 = PDstandardfdOrder22(&El2[index]);\n"
+ " PDstandard3El2 = PDstandardfdOrder23(&El2[index]);\n"
+ " PDstandard1El3 = PDstandardfdOrder21(&El3[index]);\n"
+ " PDstandard2El3 = PDstandardfdOrder22(&El3[index]);\n"
+ " PDstandard3El3 = PDstandardfdOrder23(&El3[index]);\n"
+ " break;\n"
+ " \n"
+ " case 4:\n"
+ " PDstandard1B1 = PDstandardfdOrder41(&B1[index]);\n"
+ " PDstandard2B1 = PDstandardfdOrder42(&B1[index]);\n"
+ " PDstandard3B1 = PDstandardfdOrder43(&B1[index]);\n"
+ " PDstandard1B2 = PDstandardfdOrder41(&B2[index]);\n"
+ " PDstandard2B2 = PDstandardfdOrder42(&B2[index]);\n"
+ " PDstandard3B2 = PDstandardfdOrder43(&B2[index]);\n"
+ " PDstandard1B3 = PDstandardfdOrder41(&B3[index]);\n"
+ " PDstandard2B3 = PDstandardfdOrder42(&B3[index]);\n"
+ " PDstandard3B3 = PDstandardfdOrder43(&B3[index]);\n"
+ " PDstandard1El1 = PDstandardfdOrder41(&El1[index]);\n"
+ " PDstandard2El1 = PDstandardfdOrder42(&El1[index]);\n"
+ " PDstandard3El1 = PDstandardfdOrder43(&El1[index]);\n"
+ " PDstandard1El2 = PDstandardfdOrder41(&El2[index]);\n"
+ " PDstandard2El2 = PDstandardfdOrder42(&El2[index]);\n"
+ " PDstandard3El2 = PDstandardfdOrder43(&El2[index]);\n"
+ " PDstandard1El3 = PDstandardfdOrder41(&El3[index]);\n"
+ " PDstandard2El3 = PDstandardfdOrder42(&El3[index]);\n"
+ " PDstandard3El3 = PDstandardfdOrder43(&El3[index]);\n"
+ " break;\n"
+ " }\n"
+ " \n"
+ " /* Calculate temporaries and grid functions */\n"
+ " CCTK_REAL_VEC JacPDstandard1B2;\n"
+ " CCTK_REAL_VEC JacPDstandard1B3;\n"
+ " CCTK_REAL_VEC JacPDstandard1El2;\n"
+ " CCTK_REAL_VEC JacPDstandard1El3;\n"
+ " CCTK_REAL_VEC JacPDstandard2B1;\n"
+ " CCTK_REAL_VEC JacPDstandard2B3;\n"
+ " CCTK_REAL_VEC JacPDstandard2El1;\n"
+ " CCTK_REAL_VEC JacPDstandard2El3;\n"
+ " CCTK_REAL_VEC JacPDstandard3B1;\n"
+ " CCTK_REAL_VEC JacPDstandard3B2;\n"
+ " CCTK_REAL_VEC JacPDstandard3El1;\n"
+ " CCTK_REAL_VEC JacPDstandard3El2;\n"
+ " \n"
+ " if (use_jacobian)\n"
+ " {\n"
+ " JacPDstandard1B2 = \n"
+ " kmadd(J11L,PDstandard1B2,kmadd(J21L,PDstandard2B2,kmul(J31L,PDstandard3B2)));\n"
+ " \n"
+ " JacPDstandard1B3 = \n"
+ " kmadd(J11L,PDstandard1B3,kmadd(J21L,PDstandard2B3,kmul(J31L,PDstandard3B3)));\n"
+ " \n"
+ " JacPDstandard1El2 = \n"
+ " kmadd(J11L,PDstandard1El2,kmadd(J21L,PDstandard2El2,kmul(J31L,PDstandard3El2)));\n"
+ " \n"
+ " JacPDstandard1El3 = \n"
+ " kmadd(J11L,PDstandard1El3,kmadd(J21L,PDstandard2El3,kmul(J31L,PDstandard3El3)));\n"
+ " \n"
+ " JacPDstandard2B1 = \n"
+ " kmadd(J12L,PDstandard1B1,kmadd(J22L,PDstandard2B1,kmul(J32L,PDstandard3B1)));\n"
+ " \n"
+ " JacPDstandard2B3 = \n"
+ " kmadd(J12L,PDstandard1B3,kmadd(J22L,PDstandard2B3,kmul(J32L,PDstandard3B3)));\n"
+ " \n"
+ " JacPDstandard2El1 = \n"
+ " kmadd(J12L,PDstandard1El1,kmadd(J22L,PDstandard2El1,kmul(J32L,PDstandard3El1)));\n"
+ " \n"
+ " JacPDstandard2El3 = \n"
+ " kmadd(J12L,PDstandard1El3,kmadd(J22L,PDstandard2El3,kmul(J32L,PDstandard3El3)));\n"
+ " \n"
+ " JacPDstandard3B1 = \n"
+ " kmadd(J13L,PDstandard1B1,kmadd(J23L,PDstandard2B1,kmul(J33L,PDstandard3B1)));\n"
+ " \n"
+ " JacPDstandard3B2 = \n"
+ " kmadd(J13L,PDstandard1B2,kmadd(J23L,PDstandard2B2,kmul(J33L,PDstandard3B2)));\n"
+ " \n"
+ " JacPDstandard3El1 = \n"
+ " kmadd(J13L,PDstandard1El1,kmadd(J23L,PDstandard2El1,kmul(J33L,PDstandard3El1)));\n"
+ " \n"
+ " JacPDstandard3El2 = \n"
+ " kmadd(J13L,PDstandard1El2,kmadd(J23L,PDstandard2El2,kmul(J33L,PDstandard3El2)));\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " JacPDstandard1B2 = PDstandard1B2;\n"
+ " \n"
+ " JacPDstandard1B3 = PDstandard1B3;\n"
+ " \n"
+ " JacPDstandard1El2 = PDstandard1El2;\n"
+ " \n"
+ " JacPDstandard1El3 = PDstandard1El3;\n"
+ " \n"
+ " JacPDstandard2B1 = PDstandard2B1;\n"
+ " \n"
+ " JacPDstandard2B3 = PDstandard2B3;\n"
+ " \n"
+ " JacPDstandard2El1 = PDstandard2El1;\n"
+ " \n"
+ " JacPDstandard2El3 = PDstandard2El3;\n"
+ " \n"
+ " JacPDstandard3B1 = PDstandard3B1;\n"
+ " \n"
+ " JacPDstandard3B2 = PDstandard3B2;\n"
+ " \n"
+ " JacPDstandard3El1 = PDstandard3El1;\n"
+ " \n"
+ " JacPDstandard3El2 = PDstandard3El2;\n"
+ " }\n"
+ " \n"
+ " CCTK_REAL_VEC El1rhsL = ksub(JacPDstandard2B3,JacPDstandard3B2);\n"
+ " \n"
+ " CCTK_REAL_VEC El2rhsL = ksub(JacPDstandard3B1,JacPDstandard1B3);\n"
+ " \n"
+ " CCTK_REAL_VEC El3rhsL = ksub(JacPDstandard1B2,JacPDstandard2B1);\n"
+ " \n"
+ " CCTK_REAL_VEC B1rhsL = ksub(JacPDstandard3El2,JacPDstandard2El3);\n"
+ " \n"
+ " CCTK_REAL_VEC B2rhsL = ksub(JacPDstandard1El3,JacPDstandard3El1);\n"
+ " \n"
+ " CCTK_REAL_VEC B3rhsL = ksub(JacPDstandard2El1,JacPDstandard1El2);\n"
+ " \n"
+ " /* Copy local copies back to grid functions */\n"
+ " vec_store_nta_partial(B1rhs[index],B1rhsL);\n"
+ " vec_store_nta_partial(B2rhs[index],B2rhsL);\n"
+ " vec_store_nta_partial(B3rhs[index],B3rhsL);\n"
+ " vec_store_nta_partial(El1rhs[index],El1rhsL);\n"
+ " vec_store_nta_partial(El2rhs[index],El2rhsL);\n"
+ " vec_store_nta_partial(El3rhs[index],El3rhsL);\n"
+ "}\n"
+ "LC_ENDLOOP3VEC (EM_evol);\n"
+ ""
+ ;
+
+ char const * const groups[] = {"My_New_Implementation::B_group","My_New_Implementation::B_grouprhs","My_New_Implementation::El_group","My_New_Implementation::El_grouprhs",NULL};
+
+ static struct OpenCLKernel * kernel = NULL;
+ char const * const sources[] = {differencing, source, NULL};
+ OpenCLRunTime_CallKernel (cctkGH, CCTK_THORNSTRING, "EM_evol",
+ sources, groups, NULL, NULL, NULL, -1,
+ imin, imax, &kernel);
+
+}
+
+extern "C" void EM_evol(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Entering EM_evol_Body");
+ }
+
+ if (cctk_iteration % EM_evol_calc_every != EM_evol_calc_offset)
+ {
+ return;
+ }
+
+ const char *groups[] = {"My_New_Implementation::B_group","My_New_Implementation::B_grouprhs","My_New_Implementation::El_group","My_New_Implementation::El_grouprhs"};
+ GenericFD_AssertGroupStorage(cctkGH, "EM_evol", 4, groups);
+
+ switch(fdOrder)
+ {
+ case 2:
+ GenericFD_EnsureStencilFits(cctkGH, "EM_evol", 1, 1, 1);
+ break;
+
+ case 4:
+ GenericFD_EnsureStencilFits(cctkGH, "EM_evol", 2, 2, 2);
+ break;
+ }
+
+ GenericFD_LoopOverInterior(cctkGH, &EM_evol_Body);
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Leaving EM_evol_Body");
+ }
+}
diff --git a/Examples/EMScript/src/EM_initial.cc b/Examples/EMScript/src/EM_initial.cc
new file mode 100644
index 0000000..34e72f1
--- /dev/null
+++ b/Examples/EMScript/src/EM_initial.cc
@@ -0,0 +1,259 @@
+/* File produced by Kranc */
+
+#define KRANC_C
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "GenericFD.h"
+#include "Differencing.h"
+#include "cctk_Loop.h"
+#include "loopcontrol.h"
+#include "OpenCLRunTime.h"
+#include "vectors.h"
+
+/* Define macros used in calculations */
+#define INITVALUE (42)
+#define QAD(x) (SQR(SQR(x)))
+#define INV(x) (kdiv(ToReal(1.0),x))
+#define SQR(x) (kmul(x,x))
+#define CUB(x) (kmul(x,SQR(x)))
+
+extern "C" void EM_initial_SelectBCs(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT ierr = 0;
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "My_New_Implementation::B_group","flat");
+ if (ierr < 0)
+ CCTK_WARN(1, "Failed to register flat BC for My_New_Implementation::B_group.");
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "My_New_Implementation::El_group","flat");
+ if (ierr < 0)
+ CCTK_WARN(1, "Failed to register flat BC for My_New_Implementation::El_group.");
+ return;
+}
+
+static void EM_initial_Body(cGH const * restrict const cctkGH, int const dir, int const face, CCTK_REAL const normal[3], CCTK_REAL const tangentA[3], CCTK_REAL const tangentB[3], int const imin[3], int const imax[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[])
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ char const * const source =
+ "\n"
+ "/* Declare finite differencing variables */\n"
+ "\n"
+ "/* Include user-supplied include files */\n"
+ "\n"
+ "/* Initialise finite differencing variables */\n"
+ "ptrdiff_t const di = 1;\n"
+ "ptrdiff_t const dj = CCTK_GFINDEX3D(cctkGH,0,1,0) - CCTK_GFINDEX3D(cctkGH,0,0,0);\n"
+ "ptrdiff_t const dk = CCTK_GFINDEX3D(cctkGH,0,0,1) - CCTK_GFINDEX3D(cctkGH,0,0,0);\n"
+ "ptrdiff_t const cdi = sizeof(CCTK_REAL) * di;\n"
+ "ptrdiff_t const cdj = sizeof(CCTK_REAL) * dj;\n"
+ "ptrdiff_t const cdk = sizeof(CCTK_REAL) * dk;\n"
+ "CCTK_REAL_VEC const dx = ToReal(CCTK_DELTA_SPACE(0));\n"
+ "CCTK_REAL_VEC const dy = ToReal(CCTK_DELTA_SPACE(1));\n"
+ "CCTK_REAL_VEC const dz = ToReal(CCTK_DELTA_SPACE(2));\n"
+ "CCTK_REAL_VEC const dt = ToReal(CCTK_DELTA_TIME);\n"
+ "CCTK_REAL_VEC const t = ToReal(cctk_time);\n"
+ "CCTK_REAL_VEC const dxi = INV(dx);\n"
+ "CCTK_REAL_VEC const dyi = INV(dy);\n"
+ "CCTK_REAL_VEC const dzi = INV(dz);\n"
+ "CCTK_REAL_VEC const khalf = ToReal(0.5);\n"
+ "CCTK_REAL_VEC const kthird = ToReal(1.0/3.0);\n"
+ "CCTK_REAL_VEC const ktwothird = ToReal(2.0/3.0);\n"
+ "CCTK_REAL_VEC const kfourthird = ToReal(4.0/3.0);\n"
+ "CCTK_REAL_VEC const keightthird = ToReal(8.0/3.0);\n"
+ "CCTK_REAL_VEC const hdxi = kmul(ToReal(0.5), dxi);\n"
+ "CCTK_REAL_VEC const hdyi = kmul(ToReal(0.5), dyi);\n"
+ "CCTK_REAL_VEC const hdzi = kmul(ToReal(0.5), dzi);\n"
+ "\n"
+ "/* Initialize predefined quantities */\n"
+ "CCTK_REAL_VEC const p1o12dx = kmul(INV(dx),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o12dy = kmul(INV(dy),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o12dz = kmul(INV(dz),ToReal(0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const p1o144dxdy = kmul(INV(dx),kmul(INV(dy),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o144dxdz = kmul(INV(dx),kmul(INV(dz),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o144dydz = kmul(INV(dy),kmul(INV(dz),ToReal(0.00694444444444444444444444444444)));\n"
+ "CCTK_REAL_VEC const p1o2dx = kmul(INV(dx),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o2dy = kmul(INV(dy),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o2dz = kmul(INV(dz),ToReal(0.5));\n"
+ "CCTK_REAL_VEC const p1o4dxdy = kmul(INV(dx),kmul(INV(dy),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1o4dxdz = kmul(INV(dx),kmul(INV(dz),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1o4dydz = kmul(INV(dy),kmul(INV(dz),ToReal(0.25)));\n"
+ "CCTK_REAL_VEC const p1odx2 = INV(SQR(dx));\n"
+ "CCTK_REAL_VEC const p1ody2 = INV(SQR(dy));\n"
+ "CCTK_REAL_VEC const p1odz2 = INV(SQR(dz));\n"
+ "CCTK_REAL_VEC const pm1o12dx2 = kmul(INV(SQR(dx)),ToReal(-0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const pm1o12dy2 = kmul(INV(SQR(dy)),ToReal(-0.0833333333333333333333333333333));\n"
+ "CCTK_REAL_VEC const pm1o12dz2 = kmul(INV(SQR(dz)),ToReal(-0.0833333333333333333333333333333));\n"
+ "\n"
+ "/* Jacobian variable pointers */\n"
+ "bool const use_jacobian = (!CCTK_IsFunctionAliased(\"MultiPatch_GetMap\") || MultiPatch_GetMap(cctkGH) != jacobian_identity_map)\n"
+ " && strlen(jacobian_group) > 0;\n"
+ "if (use_jacobian && strlen(jacobian_derivative_group) == 0)\n"
+ "{\n"
+ " CCTK_WARN (1, \"GenericFD::jacobian_group and GenericFD::jacobian_derivative_group must both be set to valid group names\");\n"
+ "}\n"
+ "\n"
+ "CCTK_REAL const *restrict jacobian_ptrs[9];\n"
+ "if (use_jacobian) GenericFD_GroupDataPointers(cctkGH, jacobian_group,\n"
+ " 9, jacobian_ptrs);\n"
+ "\n"
+ "CCTK_REAL const *restrict const J11 = use_jacobian ? jacobian_ptrs[0] : 0;\n"
+ "CCTK_REAL const *restrict const J12 = use_jacobian ? jacobian_ptrs[1] : 0;\n"
+ "CCTK_REAL const *restrict const J13 = use_jacobian ? jacobian_ptrs[2] : 0;\n"
+ "CCTK_REAL const *restrict const J21 = use_jacobian ? jacobian_ptrs[3] : 0;\n"
+ "CCTK_REAL const *restrict const J22 = use_jacobian ? jacobian_ptrs[4] : 0;\n"
+ "CCTK_REAL const *restrict const J23 = use_jacobian ? jacobian_ptrs[5] : 0;\n"
+ "CCTK_REAL const *restrict const J31 = use_jacobian ? jacobian_ptrs[6] : 0;\n"
+ "CCTK_REAL const *restrict const J32 = use_jacobian ? jacobian_ptrs[7] : 0;\n"
+ "CCTK_REAL const *restrict const J33 = use_jacobian ? jacobian_ptrs[8] : 0;\n"
+ "\n"
+ "CCTK_REAL const *restrict jacobian_derivative_ptrs[18];\n"
+ "if (use_jacobian) GenericFD_GroupDataPointers(cctkGH, jacobian_derivative_group,\n"
+ " 18, jacobian_derivative_ptrs);\n"
+ "\n"
+ "CCTK_REAL const *restrict const dJ111 = use_jacobian ? jacobian_derivative_ptrs[0] : 0;\n"
+ "CCTK_REAL const *restrict const dJ112 = use_jacobian ? jacobian_derivative_ptrs[1] : 0;\n"
+ "CCTK_REAL const *restrict const dJ113 = use_jacobian ? jacobian_derivative_ptrs[2] : 0;\n"
+ "CCTK_REAL const *restrict const dJ122 = use_jacobian ? jacobian_derivative_ptrs[3] : 0;\n"
+ "CCTK_REAL const *restrict const dJ123 = use_jacobian ? jacobian_derivative_ptrs[4] : 0;\n"
+ "CCTK_REAL const *restrict const dJ133 = use_jacobian ? jacobian_derivative_ptrs[5] : 0;\n"
+ "CCTK_REAL const *restrict const dJ211 = use_jacobian ? jacobian_derivative_ptrs[6] : 0;\n"
+ "CCTK_REAL const *restrict const dJ212 = use_jacobian ? jacobian_derivative_ptrs[7] : 0;\n"
+ "CCTK_REAL const *restrict const dJ213 = use_jacobian ? jacobian_derivative_ptrs[8] : 0;\n"
+ "CCTK_REAL const *restrict const dJ222 = use_jacobian ? jacobian_derivative_ptrs[9] : 0;\n"
+ "CCTK_REAL const *restrict const dJ223 = use_jacobian ? jacobian_derivative_ptrs[10] : 0;\n"
+ "CCTK_REAL const *restrict const dJ233 = use_jacobian ? jacobian_derivative_ptrs[11] : 0;\n"
+ "CCTK_REAL const *restrict const dJ311 = use_jacobian ? jacobian_derivative_ptrs[12] : 0;\n"
+ "CCTK_REAL const *restrict const dJ312 = use_jacobian ? jacobian_derivative_ptrs[13] : 0;\n"
+ "CCTK_REAL const *restrict const dJ313 = use_jacobian ? jacobian_derivative_ptrs[14] : 0;\n"
+ "CCTK_REAL const *restrict const dJ322 = use_jacobian ? jacobian_derivative_ptrs[15] : 0;\n"
+ "CCTK_REAL const *restrict const dJ323 = use_jacobian ? jacobian_derivative_ptrs[16] : 0;\n"
+ "CCTK_REAL const *restrict const dJ333 = use_jacobian ? jacobian_derivative_ptrs[17] : 0;\n"
+ "\n"
+ "/* Assign local copies of arrays functions */\n"
+ "\n"
+ "\n"
+ "\n"
+ "/* Calculate temporaries and arrays functions */\n"
+ "\n"
+ "/* Copy local copies back to grid functions */\n"
+ "\n"
+ "/* Loop over the grid points */\n"
+ "#pragma omp parallel\n"
+ "LC_LOOP3VEC (EM_initial,\n"
+ " i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2],\n"
+ " cctk_lsh[0],cctk_lsh[1],cctk_lsh[2],\n"
+ " CCTK_REAL_VEC_SIZE)\n"
+ "{\n"
+ " ptrdiff_t const index = di*i + dj*j + dk*k;\n"
+ " \n"
+ " /* Assign local copies of grid functions */\n"
+ " \n"
+ " CCTK_REAL_VEC xL = vec_load(x[index]);\n"
+ " CCTK_REAL_VEC yL = vec_load(y[index]);\n"
+ " \n"
+ " \n"
+ " \n"
+ " /* Include user supplied include files */\n"
+ " \n"
+ " /* Precompute derivatives */\n"
+ " \n"
+ " switch(fdOrder)\n"
+ " {\n"
+ " case 2:\n"
+ " break;\n"
+ " \n"
+ " case 4:\n"
+ " break;\n"
+ " }\n"
+ " \n"
+ " /* Calculate temporaries and grid functions */\n"
+ " CCTK_REAL_VEC sigma = ToReal(1);\n"
+ " \n"
+ " CCTK_REAL_VEC csetemp0 = kadd(xL,yL);\n"
+ " \n"
+ " CCTK_REAL_VEC El1L = \n"
+ " kmul(sigma,kcos(kmul(csetemp0,kmul(Pi,ToReal(2)))));\n"
+ " \n"
+ " CCTK_REAL_VEC csetemp1 = ksub(ToReal(1),sigma);\n"
+ " \n"
+ " CCTK_REAL_VEC csetemp2 = kmul(xL,kmul(Pi,ToReal(2)));\n"
+ " \n"
+ " CCTK_REAL_VEC El2L = \n"
+ " knmadd(sigma,kcos(kmul(csetemp0,kmul(Pi,ToReal(2)))),kmul(csetemp1,kcos(csetemp2)));\n"
+ " \n"
+ " CCTK_REAL_VEC El3L = ToReal(0);\n"
+ " \n"
+ " CCTK_REAL_VEC B1L = ToReal(0);\n"
+ " \n"
+ " CCTK_REAL_VEC B2L = ToReal(0);\n"
+ " \n"
+ " CCTK_REAL_VEC B3L = \n"
+ " kmadd(csetemp1,kcos(csetemp2),kmul(sigma,kcos(kmul(csetemp0,kmul(Pi,ToReal(2))))));\n"
+ " \n"
+ " /* Copy local copies back to grid functions */\n"
+ " vec_store_nta_partial(B1[index],B1L);\n"
+ " vec_store_nta_partial(B2[index],B2L);\n"
+ " vec_store_nta_partial(B3[index],B3L);\n"
+ " vec_store_nta_partial(El1[index],El1L);\n"
+ " vec_store_nta_partial(El2[index],El2L);\n"
+ " vec_store_nta_partial(El3[index],El3L);\n"
+ "}\n"
+ "LC_ENDLOOP3VEC (EM_initial);\n"
+ ""
+ ;
+
+ char const * const groups[] = {"My_New_Implementation::B_group","My_New_Implementation::El_group","grid::coordinates",NULL};
+
+ static struct OpenCLKernel * kernel = NULL;
+ char const * const sources[] = {differencing, source, NULL};
+ OpenCLRunTime_CallKernel (cctkGH, CCTK_THORNSTRING, "EM_initial",
+ sources, groups, NULL, NULL, NULL, -1,
+ imin, imax, &kernel);
+
+}
+
+extern "C" void EM_initial(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Entering EM_initial_Body");
+ }
+
+ if (cctk_iteration % EM_initial_calc_every != EM_initial_calc_offset)
+ {
+ return;
+ }
+
+ const char *groups[] = {"My_New_Implementation::B_group","My_New_Implementation::El_group","grid::coordinates"};
+ GenericFD_AssertGroupStorage(cctkGH, "EM_initial", 3, groups);
+
+ switch(fdOrder)
+ {
+ case 2:
+ break;
+
+ case 4:
+ break;
+ }
+
+ GenericFD_LoopOverEverything(cctkGH, &EM_initial_Body);
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Leaving EM_initial_Body");
+ }
+}
diff --git a/Examples/EMScript/src/RegisterMoL.cc b/Examples/EMScript/src/RegisterMoL.cc
new file mode 100644
index 0000000..1f1ea18
--- /dev/null
+++ b/Examples/EMScript/src/RegisterMoL.cc
@@ -0,0 +1,24 @@
+/* File produced by Kranc */
+
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+
+extern "C" void EMScript_RegisterVars(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT ierr = 0;
+
+ /* Register all the evolved grid functions with MoL */
+ ierr += MoLRegisterEvolved(CCTK_VarIndex("My_New_Implementation::B1"), CCTK_VarIndex("My_New_Implementation::B1rhs"));
+ ierr += MoLRegisterEvolved(CCTK_VarIndex("My_New_Implementation::B2"), CCTK_VarIndex("My_New_Implementation::B2rhs"));
+ ierr += MoLRegisterEvolved(CCTK_VarIndex("My_New_Implementation::B3"), CCTK_VarIndex("My_New_Implementation::B3rhs"));
+ ierr += MoLRegisterEvolved(CCTK_VarIndex("My_New_Implementation::El1"), CCTK_VarIndex("My_New_Implementation::El1rhs"));
+ ierr += MoLRegisterEvolved(CCTK_VarIndex("My_New_Implementation::El2"), CCTK_VarIndex("My_New_Implementation::El2rhs"));
+ ierr += MoLRegisterEvolved(CCTK_VarIndex("My_New_Implementation::El3"), CCTK_VarIndex("My_New_Implementation::El3rhs"));
+
+ /* Register all the evolved Array functions with MoL */
+ return;
+}
diff --git a/Examples/EMScript/src/RegisterSymmetries.cc b/Examples/EMScript/src/RegisterSymmetries.cc
new file mode 100644
index 0000000..29654ac
--- /dev/null
+++ b/Examples/EMScript/src/RegisterSymmetries.cc
@@ -0,0 +1,64 @@
+/* File produced by Kranc */
+
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "Symmetry.h"
+
+extern "C" void EMScript_RegisterSymmetries(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+
+ /* array holding symmetry definitions */
+ CCTK_INT sym[3];
+
+
+ /* Register symmetries of grid functions */
+ sym[0] = -1;
+ sym[1] = 1;
+ sym[2] = 1;
+ SetCartSymVN(cctkGH, sym, "My_New_Implementation::B1");
+
+ sym[0] = 1;
+ sym[1] = -1;
+ sym[2] = 1;
+ SetCartSymVN(cctkGH, sym, "My_New_Implementation::B2");
+
+ sym[0] = 1;
+ sym[1] = 1;
+ sym[2] = -1;
+ SetCartSymVN(cctkGH, sym, "My_New_Implementation::B3");
+
+ sym[0] = -1;
+ sym[1] = 1;
+ sym[2] = 1;
+ SetCartSymVN(cctkGH, sym, "My_New_Implementation::El1");
+
+ sym[0] = 1;
+ sym[1] = -1;
+ sym[2] = 1;
+ SetCartSymVN(cctkGH, sym, "My_New_Implementation::El2");
+
+ sym[0] = 1;
+ sym[1] = 1;
+ sym[2] = -1;
+ SetCartSymVN(cctkGH, sym, "My_New_Implementation::El3");
+
+ sym[0] = 1;
+ sym[1] = 1;
+ sym[2] = 1;
+ SetCartSymVN(cctkGH, sym, "My_New_Implementation::CB");
+
+ sym[0] = 1;
+ sym[1] = 1;
+ sym[2] = 1;
+ SetCartSymVN(cctkGH, sym, "My_New_Implementation::CEl");
+
+ sym[0] = 1;
+ sym[1] = 1;
+ sym[2] = 1;
+ SetCartSymVN(cctkGH, sym, "My_New_Implementation::rho");
+
+}
diff --git a/Examples/EMScript/src/Startup.cc b/Examples/EMScript/src/Startup.cc
new file mode 100644
index 0000000..00bdff6
--- /dev/null
+++ b/Examples/EMScript/src/Startup.cc
@@ -0,0 +1,10 @@
+/* File produced by Kranc */
+
+#include "cctk.h"
+
+extern "C" int EMScript_Startup(void)
+{
+ const char * banner = "EMScript";
+ CCTK_RegisterBanner(banner);
+ return 0;
+}
diff --git a/Examples/EMScript/src/make.code.defn b/Examples/EMScript/src/make.code.defn
new file mode 100644
index 0000000..0d52b41
--- /dev/null
+++ b/Examples/EMScript/src/make.code.defn
@@ -0,0 +1,3 @@
+# File produced by Kranc
+
+SRCS = Startup.cc RegisterMoL.cc RegisterSymmetries.cc EM_initial.cc EM_evol.cc EM_constraints.cc EM_energy.cc Boundaries.cc
diff --git a/Examples/Funwave.kranc b/Examples/Funwave.kranc
new file mode 100644
index 0000000..a081292
--- /dev/null
+++ b/Examples/Funwave.kranc
@@ -0,0 +1,24 @@
+begin thorn FunwaveSources
+
+# parameters section?
+inherit Funwave
+
+begin variables
+end variables
+
+begin temporaries
+end temporaries
+
+begin derivatives
+ Dp u_i = (u_(i+1) - u_(i))/h
+ Dz v_i = (v_(i+1) - v_(i-1))/(2*h)
+end derivatives
+
+begin calculation sourceterms scheduled in funw_source
+ sourcex = gamma1*mask9*(-u1p + u4)*(Dp_1 p + Dp_2 q) +
+ gamma1*mask9*(-(gamma2*mask9*(u1pp + u2 + u3)) + u4*Dz_1 u + u*Dz_1 u4 +
+ v4*Dz_2 u + v*Dz_2 u4)*max(h,mindepthfrc) -
+ cd*u*sqrt(u**2 + v**2)
+end calculation
+
+end thorn
diff --git a/Examples/SimpleWave/param.ccl b/Examples/SimpleWave/param.ccl
index 41f8cd6..9c1c428 100644
--- a/Examples/SimpleWave/param.ccl
+++ b/Examples/SimpleWave/param.ccl
@@ -17,12 +17,6 @@ CCTK_INT verbose "verbose" STEERABLE=ALWAYS
} 0
restricted:
-CCTK_REAL hlleAlpha "hlleAlpha"
-{
- "*:*" :: ""
-} 0
-
-restricted:
CCTK_INT SimpleWave_MaxNumEvolvedVars "Number of evolved variables used by this thorn" ACCUMULATOR-BASE=MethodofLines::MoL_Num_Evolved_Vars STEERABLE=RECOVER
{
2:2 :: "Number of evolved variables used by this thorn"
diff --git a/Examples/SimpleWave/src/Differencing.h b/Examples/SimpleWave/src/Differencing.h
index fc6d45d..ef21b0b 100644
--- a/Examples/SimpleWave/src/Differencing.h
+++ b/Examples/SimpleWave/src/Differencing.h
@@ -70,147 +70,3 @@ static CCTK_REAL PDstandard2nd33_impl(CCTK_REAL const* restrict const u, CCTK_RE
}
#endif
-#ifndef KRANC_DIFF_FUNCTIONS
-# define DiffPlus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o1)
-#else
-# define DiffPlus1(u) (DiffPlus1_impl(u,p1o1,cdj,cdk))
-static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return (-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o1;
-}
-#endif
-
-#ifndef KRANC_DIFF_FUNCTIONS
-# define DiffPlus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o1)
-#else
-# define DiffPlus2(u) (DiffPlus2_impl(u,p1o1,cdj,cdk))
-static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return (-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o1;
-}
-#endif
-
-#ifndef KRANC_DIFF_FUNCTIONS
-# define DiffPlus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1o1)
-#else
-# define DiffPlus3(u) (DiffPlus3_impl(u,p1o1,cdj,cdk))
-static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return (-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1o1;
-}
-#endif
-
-#ifndef KRANC_DIFF_FUNCTIONS
-# define DiffMinus1(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,-1,0,0))*p1o1)
-#else
-# define DiffMinus1(u) (DiffMinus1_impl(u,p1o1,cdj,cdk))
-static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return (KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,-1,0,0))*p1o1;
-}
-#endif
-
-#ifndef KRANC_DIFF_FUNCTIONS
-# define DiffMinus2(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,-1,0))*p1o1)
-#else
-# define DiffMinus2(u) (DiffMinus2_impl(u,p1o1,cdj,cdk))
-static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return (KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,-1,0))*p1o1;
-}
-#endif
-
-#ifndef KRANC_DIFF_FUNCTIONS
-# define DiffMinus3(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,0,-1))*p1o1)
-#else
-# define DiffMinus3(u) (DiffMinus3_impl(u,p1o1,cdj,cdk))
-static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return (KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,0,-1))*p1o1;
-}
-#endif
-
-#ifndef KRANC_DIFF_FUNCTIONS
-# define ShiftMinus1(u) (KRANC_GFOFFSET3D(u,-1,0,0)*p1o1)
-#else
-# define ShiftMinus1(u) (ShiftMinus1_impl(u,p1o1,cdj,cdk))
-static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return KRANC_GFOFFSET3D(u,-1,0,0)*p1o1;
-}
-#endif
-
-#ifndef KRANC_DIFF_FUNCTIONS
-# define ShiftMinus2(u) (KRANC_GFOFFSET3D(u,0,-1,0)*p1o1)
-#else
-# define ShiftMinus2(u) (ShiftMinus2_impl(u,p1o1,cdj,cdk))
-static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return KRANC_GFOFFSET3D(u,0,-1,0)*p1o1;
-}
-#endif
-
-#ifndef KRANC_DIFF_FUNCTIONS
-# define ShiftMinus3(u) (KRANC_GFOFFSET3D(u,0,0,-1)*p1o1)
-#else
-# define ShiftMinus3(u) (ShiftMinus3_impl(u,p1o1,cdj,cdk))
-static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return KRANC_GFOFFSET3D(u,0,0,-1)*p1o1;
-}
-#endif
-
-#ifndef KRANC_DIFF_FUNCTIONS
-# define PDplus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx)
-#else
-# define PDplus1(u) (PDplus1_impl(u,p1odx,cdj,cdk))
-static CCTK_REAL PDplus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL PDplus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return (-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx;
-}
-#endif
-
-#ifndef KRANC_DIFF_FUNCTIONS
-# define PDplus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody)
-#else
-# define PDplus2(u) (PDplus2_impl(u,p1ody,cdj,cdk))
-static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return (-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody;
-}
-#endif
-
-#ifndef KRANC_DIFF_FUNCTIONS
-# define PDplus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz)
-#else
-# define PDplus3(u) (PDplus3_impl(u,p1odz,cdj,cdk))
-static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
-static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, ptrdiff_t const cdj, ptrdiff_t const cdk)
-{
- ptrdiff_t const cdi=sizeof(CCTK_REAL);
- return (-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz;
-}
-#endif
-
diff --git a/Examples/SimpleWave/src/calc_rhs.cc b/Examples/SimpleWave/src/calc_rhs.cc
index b742e82..f2af270 100644
--- a/Examples/SimpleWave/src/calc_rhs.cc
+++ b/Examples/SimpleWave/src/calc_rhs.cc
@@ -69,15 +69,11 @@ static void calc_rhs_Body(cGH const * restrict const cctkGH, int const dir, int
CCTK_REAL const hdzi = 0.5 * dzi;
/* Initialize predefined quantities */
- CCTK_REAL const p1o1 = 1;
CCTK_REAL const p1o2dx = 0.5*INV(dx);
CCTK_REAL const p1o2dy = 0.5*INV(dy);
CCTK_REAL const p1o2dz = 0.5*INV(dz);
- CCTK_REAL const p1odx = INV(dx);
CCTK_REAL const p1odx2 = INV(SQR(dx));
- CCTK_REAL const p1ody = INV(dy);
CCTK_REAL const p1ody2 = INV(SQR(dy));
- CCTK_REAL const p1odz = INV(dz);
CCTK_REAL const p1odz2 = INV(SQR(dz));
/* Assign local copies of arrays functions */
diff --git a/Examples/SimpleWave/src/initial_sine.cc b/Examples/SimpleWave/src/initial_sine.cc
index a37a221..c8a5656 100644
--- a/Examples/SimpleWave/src/initial_sine.cc
+++ b/Examples/SimpleWave/src/initial_sine.cc
@@ -57,15 +57,11 @@ static void initial_sine_Body(cGH const * restrict const cctkGH, int const dir,
CCTK_REAL const hdzi = 0.5 * dzi;
/* Initialize predefined quantities */
- CCTK_REAL const p1o1 = 1;
CCTK_REAL const p1o2dx = 0.5*INV(dx);
CCTK_REAL const p1o2dy = 0.5*INV(dy);
CCTK_REAL const p1o2dz = 0.5*INV(dz);
- CCTK_REAL const p1odx = INV(dx);
CCTK_REAL const p1odx2 = INV(SQR(dx));
- CCTK_REAL const p1ody = INV(dy);
CCTK_REAL const p1ody2 = INV(SQR(dy));
- CCTK_REAL const p1odz = INV(dz);
CCTK_REAL const p1odz2 = INV(SQR(dz));
/* Assign local copies of arrays functions */
diff --git a/Examples/SimpleWaveScript.kranc b/Examples/SimpleWaveScript.kranc
new file mode 100644
index 0000000..0aeb6ae
--- /dev/null
+++ b/Examples/SimpleWaveScript.kranc
@@ -0,0 +1,26 @@
+begin thorn SimpleWaveScript
+
+begin variables
+ phi pi
+end variables
+
+begin temporaries
+ foo bar
+end temporaries
+
+begin derivatives
+ Du u_i = (u_(i+1) - u_(i-1))/h
+ Dv v_i = (v_(i+1,j) - u_(i-1,j))/h
+end derivatives
+
+begin calculation initial_sine_calc scheduled at initial
+ phi = sin(2*PI*(x-t))
+ pi = -2*pi*cos(2*PI*(x-t))
+end calculation
+
+begin calculation calc_rhs scheduled at mol_calcrhs
+ D_t phi = pi
+ D_t pi = Euc^ij*D_ij phi
+end calculation
+
+end thorn
diff --git a/Examples/SimpleWaveScript/configuration.ccl b/Examples/SimpleWaveScript/configuration.ccl
new file mode 100644
index 0000000..0a66ec2
--- /dev/null
+++ b/Examples/SimpleWaveScript/configuration.ccl
@@ -0,0 +1,6 @@
+# File produced by Kranc
+
+REQUIRES GenericFD
+OPTIONAL LoopControl
+{
+}
diff --git a/Examples/SimpleWaveScript/interface.ccl b/Examples/SimpleWaveScript/interface.ccl
new file mode 100644
index 0000000..c6571e1
--- /dev/null
+++ b/Examples/SimpleWaveScript/interface.ccl
@@ -0,0 +1,52 @@
+# File produced by Kranc
+
+implements: SimpleWaveScript
+
+inherits: Grid GenericFD Boundary
+
+
+
+USES INCLUDE: GenericFD.h
+USES INCLUDE: Symmetry.h
+USES INCLUDE: sbp_calc_coeffs.h
+USES INCLUDE: Boundary.h
+USES INCLUDE: loopcontrol.h
+
+CCTK_INT FUNCTION MoLRegisterEvolved(CCTK_INT IN EvolvedIndex, CCTK_INT IN RHSIndex)
+USES FUNCTION MoLRegisterEvolved
+
+SUBROUTINE Diff_coeff(CCTK_POINTER_TO_CONST IN cctkGH, CCTK_INT IN dir, CCTK_INT IN nsize, CCTK_INT OUT ARRAY imin, CCTK_INT OUT ARRAY imax, CCTK_REAL OUT ARRAY q, CCTK_INT IN table_handle)
+USES FUNCTION Diff_coeff
+
+CCTK_INT FUNCTION MultiPatch_GetMap(CCTK_POINTER_TO_CONST IN cctkGH)
+USES FUNCTION MultiPatch_GetMap
+
+CCTK_INT FUNCTION Boundary_SelectGroupForBC(CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN group_name, CCTK_STRING IN bc_name)
+USES FUNCTION Boundary_SelectGroupForBC
+
+CCTK_INT FUNCTION Boundary_SelectVarForBC(CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN var_name, CCTK_STRING IN bc_name)
+USES FUNCTION Boundary_SelectVarForBC
+
+public:
+CCTK_REAL phi_group type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0'
+{
+ phi
+} "phi_group"
+
+public:
+CCTK_REAL pi_group type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0'
+{
+ pi
+} "pi_group"
+
+public:
+CCTK_REAL phi_grouprhs type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0'
+{
+ phirhs
+} "phi_grouprhs"
+
+public:
+CCTK_REAL pi_grouprhs type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0'
+{
+ pirhs
+} "pi_grouprhs"
diff --git a/Examples/SimpleWaveScript/param.ccl b/Examples/SimpleWaveScript/param.ccl
new file mode 100644
index 0000000..456ff0e
--- /dev/null
+++ b/Examples/SimpleWaveScript/param.ccl
@@ -0,0 +1,198 @@
+# File produced by Kranc
+
+
+shares: GenericFD
+
+
+
+shares: MethodOfLines
+
+USES CCTK_INT MoL_Num_Evolved_Vars
+USES CCTK_INT MoL_Num_ArrayEvolved_Vars
+
+restricted:
+CCTK_INT verbose "verbose" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 0
+
+restricted:
+CCTK_INT fdOrder "fdOrder"
+{
+ *:* :: ""
+} 2
+
+restricted:
+CCTK_INT SimpleWaveScript_MaxNumEvolvedVars "Number of evolved variables used by this thorn" ACCUMULATOR-BASE=MethodofLines::MoL_Num_Evolved_Vars STEERABLE=RECOVER
+{
+ 2:2 :: "Number of evolved variables used by this thorn"
+} 2
+
+restricted:
+CCTK_INT SimpleWaveScript_MaxNumArrayEvolvedVars "Number of Array evolved variables used by this thorn" ACCUMULATOR-BASE=MethodofLines::MoL_Num_ArrayEvolved_Vars STEERABLE=RECOVER
+{
+ 0:0 :: "Number of Array evolved variables used by this thorn"
+} 0
+
+restricted:
+CCTK_INT timelevels "Number of active timelevels" STEERABLE=RECOVER
+{
+ 0:3 :: ""
+} 3
+
+restricted:
+CCTK_INT rhs_timelevels "Number of active RHS timelevels" STEERABLE=RECOVER
+{
+ 0:3 :: ""
+} 1
+
+restricted:
+CCTK_INT other_timelevels "Number of active timelevels for non-evolved grid functions" STEERABLE=RECOVER
+{
+ 0:3 :: ""
+} 1
+
+restricted:
+CCTK_INT initial_sine_calc_calc_every "initial_sine_calc_calc_every" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 1
+
+restricted:
+CCTK_INT calc_rhs_calc_every "calc_rhs_calc_every" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 1
+
+restricted:
+CCTK_INT initial_sine_calc_calc_offset "initial_sine_calc_calc_offset" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 0
+
+restricted:
+CCTK_INT calc_rhs_calc_offset "calc_rhs_calc_offset" STEERABLE=ALWAYS
+{
+ *:* :: ""
+} 0
+
+private:
+KEYWORD phi_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "skip"
+
+private:
+KEYWORD pi_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "skip"
+
+private:
+KEYWORD phi_group_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "none"
+
+private:
+KEYWORD pi_group_bound "Boundary condition to implement" STEERABLE=ALWAYS
+{
+ "flat" :: "Flat boundary condition"
+ "none" :: "No boundary condition"
+ "static" :: "Boundaries held fixed"
+ "radiative" :: "Radiation boundary condition"
+ "scalar" :: "Dirichlet boundary condition"
+ "newrad" :: "Improved radiative boundary condition"
+ "skip" :: "skip boundary condition code"
+} "none"
+
+private:
+CCTK_REAL phi_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL pi_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL phi_group_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL pi_group_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
+{
+ "0:*" :: "outgoing characteristic speed > 0"
+} 1.
+
+private:
+CCTK_REAL phi_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL pi_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL phi_group_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL pi_group_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
+{
+ "*:*" :: "value of limit value is unrestricted"
+} 0.
+
+private:
+CCTK_REAL phi_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
+private:
+CCTK_REAL pi_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
+private:
+CCTK_REAL phi_group_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
+private:
+CCTK_REAL pi_group_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
+{
+ "*:*" :: "unrestricted"
+} 0.
+
diff --git a/Examples/SimpleWaveScript/schedule.ccl b/Examples/SimpleWaveScript/schedule.ccl
new file mode 100644
index 0000000..49113c0
--- /dev/null
+++ b/Examples/SimpleWaveScript/schedule.ccl
@@ -0,0 +1,101 @@
+# File produced by Kranc
+
+
+if (timelevels == 1)
+{
+ STORAGE: phi_group[1]
+}
+if (timelevels == 2)
+{
+ STORAGE: phi_group[2]
+}
+if (timelevels == 3)
+{
+ STORAGE: phi_group[3]
+}
+
+if (timelevels == 1)
+{
+ STORAGE: pi_group[1]
+}
+if (timelevels == 2)
+{
+ STORAGE: pi_group[2]
+}
+if (timelevels == 3)
+{
+ STORAGE: pi_group[3]
+}
+
+if (rhs_timelevels == 1)
+{
+ STORAGE: phi_grouprhs[1]
+}
+if (rhs_timelevels == 2)
+{
+ STORAGE: phi_grouprhs[2]
+}
+if (rhs_timelevels == 3)
+{
+ STORAGE: phi_grouprhs[3]
+}
+
+if (rhs_timelevels == 1)
+{
+ STORAGE: pi_grouprhs[1]
+}
+if (rhs_timelevels == 2)
+{
+ STORAGE: pi_grouprhs[2]
+}
+if (rhs_timelevels == 3)
+{
+ STORAGE: pi_grouprhs[3]
+}
+
+schedule SimpleWaveScript_Startup at STARTUP
+{
+ LANG: C
+ OPTIONS: meta
+} "create banner"
+
+schedule SimpleWaveScript_RegisterVars in MoL_Register
+{
+ LANG: C
+ OPTIONS: meta
+} "Register Variables for MoL"
+
+schedule SimpleWaveScript_RegisterSymmetries in SymmetryRegister
+{
+ LANG: C
+ OPTIONS: meta
+} "register symmetries"
+
+schedule initial_sine_calc at initial
+{
+ LANG: C
+} "initial_sine_calc"
+
+schedule calc_rhs in mol_calcrhs
+{
+ LANG: C
+} "calc_rhs"
+
+schedule SimpleWaveScript_SelectBoundConds in MoL_PostStep
+{
+ LANG: C
+ OPTIONS: level
+ SYNC: phi_group
+ SYNC: pi_group
+} "select boundary conditions"
+
+schedule SimpleWaveScript_CheckBoundaries at BASEGRID
+{
+ LANG: C
+ OPTIONS: meta
+} "check boundaries treatment"
+
+schedule group ApplyBCs as SimpleWaveScript_ApplyBCs in MoL_PostStep after SimpleWaveScript_SelectBoundConds
+{
+ # no language specified
+} "Apply boundary conditions controlled by thorn Boundary"
diff --git a/Examples/SimpleWaveScript/src/Boundaries.cc b/Examples/SimpleWaveScript/src/Boundaries.cc
new file mode 100644
index 0000000..1100378
--- /dev/null
+++ b/Examples/SimpleWaveScript/src/Boundaries.cc
@@ -0,0 +1,249 @@
+/* File produced by Kranc */
+
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "cctk_Faces.h"
+#include "util_Table.h"
+#include "Symmetry.h"
+
+
+/* the boundary treatment is split into 3 steps: */
+/* 1. excision */
+/* 2. symmetries */
+/* 3. "other" boundary conditions, e.g. radiative */
+
+/* to simplify scheduling and testing, the 3 steps */
+/* are currently applied in separate functions */
+
+
+extern "C" void SimpleWaveScript_CheckBoundaries(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ return;
+}
+
+extern "C" void SimpleWaveScript_SelectBoundConds(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT ierr = 0;
+
+ if (CCTK_EQUALS(phi_group_bound, "none" ) ||
+ CCTK_EQUALS(phi_group_bound, "static") ||
+ CCTK_EQUALS(phi_group_bound, "flat" ) ||
+ CCTK_EQUALS(phi_group_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "SimpleWaveScript::phi_group", phi_group_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register phi_group_bound BC for SimpleWaveScript::phi_group!");
+ }
+
+ if (CCTK_EQUALS(pi_group_bound, "none" ) ||
+ CCTK_EQUALS(pi_group_bound, "static") ||
+ CCTK_EQUALS(pi_group_bound, "flat" ) ||
+ CCTK_EQUALS(pi_group_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "SimpleWaveScript::pi_group", pi_group_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register pi_group_bound BC for SimpleWaveScript::pi_group!");
+ }
+
+ if (CCTK_EQUALS(phi_bound, "none" ) ||
+ CCTK_EQUALS(phi_bound, "static") ||
+ CCTK_EQUALS(phi_bound, "flat" ) ||
+ CCTK_EQUALS(phi_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "SimpleWaveScript::phi", phi_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register phi_bound BC for SimpleWaveScript::phi!");
+ }
+
+ if (CCTK_EQUALS(pi_bound, "none" ) ||
+ CCTK_EQUALS(pi_bound, "static") ||
+ CCTK_EQUALS(pi_bound, "flat" ) ||
+ CCTK_EQUALS(pi_bound, "zero" ) )
+ {
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1,
+ "SimpleWaveScript::pi", pi_bound);
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register pi_bound BC for SimpleWaveScript::pi!");
+ }
+
+ if (CCTK_EQUALS(phi_group_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_phi_group_bound = -1;
+ if (handle_phi_group_bound < 0) handle_phi_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_phi_group_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_phi_group_bound , phi_group_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_phi_group_bound ,phi_group_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_phi_group_bound,
+ "SimpleWaveScript::phi_group", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for SimpleWaveScript::phi_group!");
+
+ }
+
+ if (CCTK_EQUALS(pi_group_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_pi_group_bound = -1;
+ if (handle_pi_group_bound < 0) handle_pi_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_pi_group_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_pi_group_bound , pi_group_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_pi_group_bound ,pi_group_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_pi_group_bound,
+ "SimpleWaveScript::pi_group", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for SimpleWaveScript::pi_group!");
+
+ }
+
+ if (CCTK_EQUALS(phi_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_phi_bound = -1;
+ if (handle_phi_bound < 0) handle_phi_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_phi_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_phi_bound , phi_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_phi_bound ,phi_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_phi_bound,
+ "SimpleWaveScript::phi", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for SimpleWaveScript::phi!");
+
+ }
+
+ if (CCTK_EQUALS(pi_bound, "radiative"))
+ {
+ /* select radiation boundary condition */
+ static CCTK_INT handle_pi_bound = -1;
+ if (handle_pi_bound < 0) handle_pi_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_pi_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_pi_bound , pi_bound_limit, "LIMIT") < 0)
+ CCTK_WARN(0, "could not set LIMIT value in table!");
+ if (Util_TableSetReal(handle_pi_bound ,pi_bound_speed, "SPEED") < 0)
+ CCTK_WARN(0, "could not set SPEED value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_pi_bound,
+ "SimpleWaveScript::pi", "Radiation");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Radiation BC for SimpleWaveScript::pi!");
+
+ }
+
+ if (CCTK_EQUALS(phi_group_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_phi_group_bound = -1;
+ if (handle_phi_group_bound < 0) handle_phi_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_phi_group_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_phi_group_bound ,phi_group_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_phi_group_bound,
+ "SimpleWaveScript::phi_group", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Scalar BC for SimpleWaveScript::phi_group!");
+
+ }
+
+ if (CCTK_EQUALS(pi_group_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_pi_group_bound = -1;
+ if (handle_pi_group_bound < 0) handle_pi_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_pi_group_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_pi_group_bound ,pi_group_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_pi_group_bound,
+ "SimpleWaveScript::pi_group", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Failed to register Scalar BC for SimpleWaveScript::pi_group!");
+
+ }
+
+ if (CCTK_EQUALS(phi_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_phi_bound = -1;
+ if (handle_phi_bound < 0) handle_phi_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_phi_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_phi_bound ,phi_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_phi_bound,
+ "SimpleWaveScript::phi", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Error in registering Scalar BC for SimpleWaveScript::phi!");
+
+ }
+
+ if (CCTK_EQUALS(pi_bound, "scalar"))
+ {
+ /* select scalar boundary condition */
+ static CCTK_INT handle_pi_bound = -1;
+ if (handle_pi_bound < 0) handle_pi_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
+ if (handle_pi_bound < 0) CCTK_WARN(0, "could not create table!");
+ if (Util_TableSetReal(handle_pi_bound ,pi_bound_scalar, "SCALAR") < 0)
+ CCTK_WARN(0, "could not set SCALAR value in table!");
+
+ ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_pi_bound,
+ "SimpleWaveScript::pi", "scalar");
+
+ if (ierr < 0)
+ CCTK_WARN(0, "Error in registering Scalar BC for SimpleWaveScript::pi!");
+
+ }
+ return;
+}
+
+
+
+/* template for entries in parameter file:
+#$bound$#SimpleWaveScript::phi_group_bound = "skip"
+#$bound$#SimpleWaveScript::phi_group_bound_speed = 1.0
+#$bound$#SimpleWaveScript::phi_group_bound_limit = 0.0
+#$bound$#SimpleWaveScript::phi_group_bound_scalar = 0.0
+
+#$bound$#SimpleWaveScript::pi_group_bound = "skip"
+#$bound$#SimpleWaveScript::pi_group_bound_speed = 1.0
+#$bound$#SimpleWaveScript::pi_group_bound_limit = 0.0
+#$bound$#SimpleWaveScript::pi_group_bound_scalar = 0.0
+
+#$bound$#SimpleWaveScript::phi_bound = "skip"
+#$bound$#SimpleWaveScript::phi_bound_speed = 1.0
+#$bound$#SimpleWaveScript::phi_bound_limit = 0.0
+#$bound$#SimpleWaveScript::phi_bound_scalar = 0.0
+
+#$bound$#SimpleWaveScript::pi_bound = "skip"
+#$bound$#SimpleWaveScript::pi_bound_speed = 1.0
+#$bound$#SimpleWaveScript::pi_bound_limit = 0.0
+#$bound$#SimpleWaveScript::pi_bound_scalar = 0.0
+
+*/
+
diff --git a/Examples/SimpleWaveScript/src/Differencing.h b/Examples/SimpleWaveScript/src/Differencing.h
new file mode 100644
index 0000000..98de1a1
--- /dev/null
+++ b/Examples/SimpleWaveScript/src/Differencing.h
@@ -0,0 +1,288 @@
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder21(u) ((-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx)
+#else
+# define PDstandardfdOrder21(u) (PDstandardfdOrder21_impl(u,p1o2dx,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder22(u) ((-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy)
+#else
+# define PDstandardfdOrder22(u) (PDstandardfdOrder22_impl(u,p1o2dy,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder23(u) ((-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz)
+#else
+# define PDstandardfdOrder23(u) (PDstandardfdOrder23_impl(u,p1o2dz,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder41(u) ((-8*KRANC_GFOFFSET3D(u,-1,0,0) + 8*KRANC_GFOFFSET3D(u,1,0,0) + KRANC_GFOFFSET3D(u,-2,0,0) - KRANC_GFOFFSET3D(u,2,0,0))*p1o12dx)
+#else
+# define PDstandardfdOrder41(u) (PDstandardfdOrder41_impl(u,p1o12dx,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder41_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder41_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dx, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-8*KRANC_GFOFFSET3D(u,-1,0,0) + 8*KRANC_GFOFFSET3D(u,1,0,0) + KRANC_GFOFFSET3D(u,-2,0,0) - KRANC_GFOFFSET3D(u,2,0,0))*p1o12dx;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder42(u) ((-8*KRANC_GFOFFSET3D(u,0,-1,0) + 8*KRANC_GFOFFSET3D(u,0,1,0) + KRANC_GFOFFSET3D(u,0,-2,0) - KRANC_GFOFFSET3D(u,0,2,0))*p1o12dy)
+#else
+# define PDstandardfdOrder42(u) (PDstandardfdOrder42_impl(u,p1o12dy,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder42_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder42_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dy, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-8*KRANC_GFOFFSET3D(u,0,-1,0) + 8*KRANC_GFOFFSET3D(u,0,1,0) + KRANC_GFOFFSET3D(u,0,-2,0) - KRANC_GFOFFSET3D(u,0,2,0))*p1o12dy;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder43(u) ((-8*KRANC_GFOFFSET3D(u,0,0,-1) + 8*KRANC_GFOFFSET3D(u,0,0,1) + KRANC_GFOFFSET3D(u,0,0,-2) - KRANC_GFOFFSET3D(u,0,0,2))*p1o12dz)
+#else
+# define PDstandardfdOrder43(u) (PDstandardfdOrder43_impl(u,p1o12dz,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder43_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder43_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dz, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-8*KRANC_GFOFFSET3D(u,0,0,-1) + 8*KRANC_GFOFFSET3D(u,0,0,1) + KRANC_GFOFFSET3D(u,0,0,-2) - KRANC_GFOFFSET3D(u,0,0,2))*p1o12dz;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder211(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx2)
+#else
+# define PDstandardfdOrder211(u) (PDstandardfdOrder211_impl(u,p1odx2,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder211_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder211_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx2;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder222(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody2)
+#else
+# define PDstandardfdOrder222(u) (PDstandardfdOrder222_impl(u,p1ody2,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder222_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder222_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody2;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder233(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz2)
+#else
+# define PDstandardfdOrder233(u) (PDstandardfdOrder233_impl(u,p1odz2,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder233_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder233_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz2;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder411(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*pm1o12dx2)
+#else
+# define PDstandardfdOrder411(u) (PDstandardfdOrder411_impl(u,pm1o12dx2,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder411_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder411_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dx2, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*pm1o12dx2;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder422(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*pm1o12dy2)
+#else
+# define PDstandardfdOrder422(u) (PDstandardfdOrder422_impl(u,pm1o12dy2,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder422_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dy2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder422_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dy2, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*pm1o12dy2;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder433(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*pm1o12dz2)
+#else
+# define PDstandardfdOrder433(u) (PDstandardfdOrder433_impl(u,pm1o12dz2,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder433_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder433_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dz2, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*pm1o12dz2;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder212(u) ((KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy)
+#else
+# define PDstandardfdOrder212(u) (PDstandardfdOrder212_impl(u,p1o4dxdy,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder212_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder212_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder213(u) ((KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz)
+#else
+# define PDstandardfdOrder213(u) (PDstandardfdOrder213_impl(u,p1o4dxdz,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder213_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder213_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder221(u) ((KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy)
+#else
+# define PDstandardfdOrder221(u) (PDstandardfdOrder221_impl(u,p1o4dxdy,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder221_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder221_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder223(u) ((KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz)
+#else
+# define PDstandardfdOrder223(u) (PDstandardfdOrder223_impl(u,p1o4dydz,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder223_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder223_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder231(u) ((KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz)
+#else
+# define PDstandardfdOrder231(u) (PDstandardfdOrder231_impl(u,p1o4dxdz,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder231_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder231_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder232(u) ((KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz)
+#else
+# define PDstandardfdOrder232(u) (PDstandardfdOrder232_impl(u,p1o4dydz,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder232_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder232_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder412(u) ((-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy)
+#else
+# define PDstandardfdOrder412(u) (PDstandardfdOrder412_impl(u,p1o144dxdy,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder412_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder412_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder413(u) ((-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz)
+#else
+# define PDstandardfdOrder413(u) (PDstandardfdOrder413_impl(u,p1o144dxdz,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder413_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder413_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder421(u) ((-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy)
+#else
+# define PDstandardfdOrder421(u) (PDstandardfdOrder421_impl(u,p1o144dxdy,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder421_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder421_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder423(u) ((-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz)
+#else
+# define PDstandardfdOrder423(u) (PDstandardfdOrder423_impl(u,p1o144dydz,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder423_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder423_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder431(u) ((-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz)
+#else
+# define PDstandardfdOrder431(u) (PDstandardfdOrder431_impl(u,p1o144dxdz,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder431_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder431_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz;
+}
+#endif
+
+#ifndef KRANC_DIFF_FUNCTIONS
+# define PDstandardfdOrder432(u) ((-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz)
+#else
+# define PDstandardfdOrder432(u) (PDstandardfdOrder432_impl(u,p1o144dydz,cdj,cdk))
+static CCTK_REAL PDstandardfdOrder432_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED;
+static CCTK_REAL PDstandardfdOrder432_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk)
+{
+ ptrdiff_t const cdi=sizeof(CCTK_REAL);
+ return (-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz;
+}
+#endif
+
diff --git a/Examples/SimpleWaveScript/src/RegisterMoL.cc b/Examples/SimpleWaveScript/src/RegisterMoL.cc
new file mode 100644
index 0000000..097cad2
--- /dev/null
+++ b/Examples/SimpleWaveScript/src/RegisterMoL.cc
@@ -0,0 +1,20 @@
+/* File produced by Kranc */
+
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+
+extern "C" void SimpleWaveScript_RegisterVars(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT ierr = 0;
+
+ /* Register all the evolved grid functions with MoL */
+ ierr += MoLRegisterEvolved(CCTK_VarIndex("SimpleWaveScript::phi"), CCTK_VarIndex("SimpleWaveScript::phirhs"));
+ ierr += MoLRegisterEvolved(CCTK_VarIndex("SimpleWaveScript::pi"), CCTK_VarIndex("SimpleWaveScript::pirhs"));
+
+ /* Register all the evolved Array functions with MoL */
+ return;
+}
diff --git a/Examples/SimpleWaveScript/src/RegisterSymmetries.cc b/Examples/SimpleWaveScript/src/RegisterSymmetries.cc
new file mode 100644
index 0000000..c127d56
--- /dev/null
+++ b/Examples/SimpleWaveScript/src/RegisterSymmetries.cc
@@ -0,0 +1,29 @@
+/* File produced by Kranc */
+
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "Symmetry.h"
+
+extern "C" void SimpleWaveScript_RegisterSymmetries(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+
+ /* array holding symmetry definitions */
+ CCTK_INT sym[3];
+
+
+ /* Register symmetries of grid functions */
+ sym[0] = 1;
+ sym[1] = 1;
+ sym[2] = 1;
+ SetCartSymVN(cctkGH, sym, "SimpleWaveScript::phi");
+
+ sym[0] = 1;
+ sym[1] = 1;
+ sym[2] = 1;
+ SetCartSymVN(cctkGH, sym, "SimpleWaveScript::pi");
+
+}
diff --git a/Examples/SimpleWaveScript/src/Startup.cc b/Examples/SimpleWaveScript/src/Startup.cc
new file mode 100644
index 0000000..8c9fa0f
--- /dev/null
+++ b/Examples/SimpleWaveScript/src/Startup.cc
@@ -0,0 +1,10 @@
+/* File produced by Kranc */
+
+#include "cctk.h"
+
+extern "C" int SimpleWaveScript_Startup(void)
+{
+ const char * banner = "SimpleWaveScript";
+ CCTK_RegisterBanner(banner);
+ return 0;
+}
diff --git a/Examples/SimpleWaveScript/src/calc_rhs.cc b/Examples/SimpleWaveScript/src/calc_rhs.cc
new file mode 100644
index 0000000..dac65b8
--- /dev/null
+++ b/Examples/SimpleWaveScript/src/calc_rhs.cc
@@ -0,0 +1,187 @@
+/* File produced by Kranc */
+
+#define KRANC_C
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "GenericFD.h"
+#include "Differencing.h"
+#include "cctk_Loop.h"
+#include "loopcontrol.h"
+
+/* Define macros used in calculations */
+#define INITVALUE (42)
+#define QAD(x) (SQR(SQR(x)))
+#define INV(x) ((1.0) / (x))
+#define SQR(x) ((x) * (x))
+#define CUB(x) ((x) * (x) * (x))
+
+extern "C" void calc_rhs_SelectBCs(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT ierr = 0;
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "SimpleWaveScript::phi_grouprhs","flat");
+ if (ierr < 0)
+ CCTK_WARN(1, "Failed to register flat BC for SimpleWaveScript::phi_grouprhs.");
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "SimpleWaveScript::pi_grouprhs","flat");
+ if (ierr < 0)
+ CCTK_WARN(1, "Failed to register flat BC for SimpleWaveScript::pi_grouprhs.");
+ return;
+}
+
+static void calc_rhs_Body(cGH const * restrict const cctkGH, int const dir, int const face, CCTK_REAL const normal[3], CCTK_REAL const tangentA[3], CCTK_REAL const tangentB[3], int const imin[3], int const imax[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[])
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+
+ /* Declare finite differencing variables */
+
+ /* Include user-supplied include files */
+
+ /* Initialise finite differencing variables */
+ ptrdiff_t const di = 1;
+ ptrdiff_t const dj = CCTK_GFINDEX3D(cctkGH,0,1,0) - CCTK_GFINDEX3D(cctkGH,0,0,0);
+ ptrdiff_t const dk = CCTK_GFINDEX3D(cctkGH,0,0,1) - CCTK_GFINDEX3D(cctkGH,0,0,0);
+ ptrdiff_t const cdi = sizeof(CCTK_REAL) * di;
+ ptrdiff_t const cdj = sizeof(CCTK_REAL) * dj;
+ ptrdiff_t const cdk = sizeof(CCTK_REAL) * dk;
+ CCTK_REAL const dx = ToReal(CCTK_DELTA_SPACE(0));
+ CCTK_REAL const dy = ToReal(CCTK_DELTA_SPACE(1));
+ CCTK_REAL const dz = ToReal(CCTK_DELTA_SPACE(2));
+ CCTK_REAL const dt = ToReal(CCTK_DELTA_TIME);
+ CCTK_REAL const t = ToReal(cctk_time);
+ CCTK_REAL const dxi = INV(dx);
+ CCTK_REAL const dyi = INV(dy);
+ CCTK_REAL const dzi = INV(dz);
+ CCTK_REAL const khalf = 0.5;
+ CCTK_REAL const kthird = 1/3.0;
+ CCTK_REAL const ktwothird = 2.0/3.0;
+ CCTK_REAL const kfourthird = 4.0/3.0;
+ CCTK_REAL const keightthird = 8.0/3.0;
+ CCTK_REAL const hdxi = 0.5 * dxi;
+ CCTK_REAL const hdyi = 0.5 * dyi;
+ CCTK_REAL const hdzi = 0.5 * dzi;
+
+ /* Initialize predefined quantities */
+ CCTK_REAL const p1o12dx = 0.0833333333333333333333333333333*INV(dx);
+ CCTK_REAL const p1o12dy = 0.0833333333333333333333333333333*INV(dy);
+ CCTK_REAL const p1o12dz = 0.0833333333333333333333333333333*INV(dz);
+ CCTK_REAL const p1o144dxdy = 0.00694444444444444444444444444444*INV(dx)*INV(dy);
+ CCTK_REAL const p1o144dxdz = 0.00694444444444444444444444444444*INV(dx)*INV(dz);
+ CCTK_REAL const p1o144dydz = 0.00694444444444444444444444444444*INV(dy)*INV(dz);
+ CCTK_REAL const p1o2dx = 0.5*INV(dx);
+ CCTK_REAL const p1o2dy = 0.5*INV(dy);
+ CCTK_REAL const p1o2dz = 0.5*INV(dz);
+ CCTK_REAL const p1o4dxdy = 0.25*INV(dx)*INV(dy);
+ CCTK_REAL const p1o4dxdz = 0.25*INV(dx)*INV(dz);
+ CCTK_REAL const p1o4dydz = 0.25*INV(dy)*INV(dz);
+ CCTK_REAL const p1odx2 = INV(SQR(dx));
+ CCTK_REAL const p1ody2 = INV(SQR(dy));
+ CCTK_REAL const p1odz2 = INV(SQR(dz));
+ CCTK_REAL const pm1o12dx2 = -0.0833333333333333333333333333333*INV(SQR(dx));
+ CCTK_REAL const pm1o12dy2 = -0.0833333333333333333333333333333*INV(SQR(dy));
+ CCTK_REAL const pm1o12dz2 = -0.0833333333333333333333333333333*INV(SQR(dz));
+
+ /* Assign local copies of arrays functions */
+
+
+
+ /* Calculate temporaries and arrays functions */
+
+ /* Copy local copies back to grid functions */
+
+ /* Loop over the grid points */
+ #pragma omp parallel
+ CCTK_LOOP3 (calc_rhs,
+ i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2],
+ cctk_lsh[0],cctk_lsh[1],cctk_lsh[2])
+ {
+ ptrdiff_t const index = di*i + dj*j + dk*k;
+
+ /* Assign local copies of grid functions */
+
+ CCTK_REAL phiL = phi[index];
+ CCTK_REAL piL = pi[index];
+
+
+ /* Include user supplied include files */
+
+ /* Precompute derivatives */
+ CCTK_REAL PDstandard11phi;
+ CCTK_REAL PDstandard22phi;
+ CCTK_REAL PDstandard33phi;
+
+ switch(fdOrder)
+ {
+ case 2:
+ PDstandard11phi = PDstandardfdOrder211(&phi[index]);
+ PDstandard22phi = PDstandardfdOrder222(&phi[index]);
+ PDstandard33phi = PDstandardfdOrder233(&phi[index]);
+ break;
+
+ case 4:
+ PDstandard11phi = PDstandardfdOrder411(&phi[index]);
+ PDstandard22phi = PDstandardfdOrder422(&phi[index]);
+ PDstandard33phi = PDstandardfdOrder433(&phi[index]);
+ break;
+ }
+
+ /* Calculate temporaries and grid functions */
+ CCTK_REAL phirhsL = piL;
+
+ CCTK_REAL pirhsL = PDstandard11phi + PDstandard22phi +
+ PDstandard33phi;
+
+ /* Copy local copies back to grid functions */
+ phirhs[index] = phirhsL;
+ pirhs[index] = pirhsL;
+ }
+ CCTK_ENDLOOP3 (calc_rhs);
+}
+
+extern "C" void calc_rhs(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Entering calc_rhs_Body");
+ }
+
+ if (cctk_iteration % calc_rhs_calc_every != calc_rhs_calc_offset)
+ {
+ return;
+ }
+
+ const char *groups[] = {"SimpleWaveScript::phi_group","SimpleWaveScript::phi_grouprhs","SimpleWaveScript::pi_group","SimpleWaveScript::pi_grouprhs"};
+ GenericFD_AssertGroupStorage(cctkGH, "calc_rhs", 4, groups);
+
+ switch(fdOrder)
+ {
+ case 2:
+ GenericFD_EnsureStencilFits(cctkGH, "calc_rhs", 1, 1, 1);
+ break;
+
+ case 4:
+ GenericFD_EnsureStencilFits(cctkGH, "calc_rhs", 2, 2, 2);
+ break;
+ }
+
+ GenericFD_LoopOverInterior(cctkGH, &calc_rhs_Body);
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Leaving calc_rhs_Body");
+ }
+}
diff --git a/Examples/SimpleWaveScript/src/initial_sine_calc.cc b/Examples/SimpleWaveScript/src/initial_sine_calc.cc
new file mode 100644
index 0000000..cfea639
--- /dev/null
+++ b/Examples/SimpleWaveScript/src/initial_sine_calc.cc
@@ -0,0 +1,175 @@
+/* File produced by Kranc */
+
+#define KRANC_C
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "GenericFD.h"
+#include "Differencing.h"
+#include "cctk_Loop.h"
+#include "loopcontrol.h"
+
+/* Define macros used in calculations */
+#define INITVALUE (42)
+#define QAD(x) (SQR(SQR(x)))
+#define INV(x) ((1.0) / (x))
+#define SQR(x) ((x) * (x))
+#define CUB(x) ((x) * (x) * (x))
+
+extern "C" void initial_sine_calc_SelectBCs(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT ierr = 0;
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "SimpleWaveScript::phi_group","flat");
+ if (ierr < 0)
+ CCTK_WARN(1, "Failed to register flat BC for SimpleWaveScript::phi_group.");
+ ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "SimpleWaveScript::pi_group","flat");
+ if (ierr < 0)
+ CCTK_WARN(1, "Failed to register flat BC for SimpleWaveScript::pi_group.");
+ return;
+}
+
+static void initial_sine_calc_Body(cGH const * restrict const cctkGH, int const dir, int const face, CCTK_REAL const normal[3], CCTK_REAL const tangentA[3], CCTK_REAL const tangentB[3], int const imin[3], int const imax[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[])
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+
+ /* Declare finite differencing variables */
+
+ /* Include user-supplied include files */
+
+ /* Initialise finite differencing variables */
+ ptrdiff_t const di = 1;
+ ptrdiff_t const dj = CCTK_GFINDEX3D(cctkGH,0,1,0) - CCTK_GFINDEX3D(cctkGH,0,0,0);
+ ptrdiff_t const dk = CCTK_GFINDEX3D(cctkGH,0,0,1) - CCTK_GFINDEX3D(cctkGH,0,0,0);
+ ptrdiff_t const cdi = sizeof(CCTK_REAL) * di;
+ ptrdiff_t const cdj = sizeof(CCTK_REAL) * dj;
+ ptrdiff_t const cdk = sizeof(CCTK_REAL) * dk;
+ CCTK_REAL const dx = ToReal(CCTK_DELTA_SPACE(0));
+ CCTK_REAL const dy = ToReal(CCTK_DELTA_SPACE(1));
+ CCTK_REAL const dz = ToReal(CCTK_DELTA_SPACE(2));
+ CCTK_REAL const dt = ToReal(CCTK_DELTA_TIME);
+ CCTK_REAL const t = ToReal(cctk_time);
+ CCTK_REAL const dxi = INV(dx);
+ CCTK_REAL const dyi = INV(dy);
+ CCTK_REAL const dzi = INV(dz);
+ CCTK_REAL const khalf = 0.5;
+ CCTK_REAL const kthird = 1/3.0;
+ CCTK_REAL const ktwothird = 2.0/3.0;
+ CCTK_REAL const kfourthird = 4.0/3.0;
+ CCTK_REAL const keightthird = 8.0/3.0;
+ CCTK_REAL const hdxi = 0.5 * dxi;
+ CCTK_REAL const hdyi = 0.5 * dyi;
+ CCTK_REAL const hdzi = 0.5 * dzi;
+
+ /* Initialize predefined quantities */
+ CCTK_REAL const p1o12dx = 0.0833333333333333333333333333333*INV(dx);
+ CCTK_REAL const p1o12dy = 0.0833333333333333333333333333333*INV(dy);
+ CCTK_REAL const p1o12dz = 0.0833333333333333333333333333333*INV(dz);
+ CCTK_REAL const p1o144dxdy = 0.00694444444444444444444444444444*INV(dx)*INV(dy);
+ CCTK_REAL const p1o144dxdz = 0.00694444444444444444444444444444*INV(dx)*INV(dz);
+ CCTK_REAL const p1o144dydz = 0.00694444444444444444444444444444*INV(dy)*INV(dz);
+ CCTK_REAL const p1o2dx = 0.5*INV(dx);
+ CCTK_REAL const p1o2dy = 0.5*INV(dy);
+ CCTK_REAL const p1o2dz = 0.5*INV(dz);
+ CCTK_REAL const p1o4dxdy = 0.25*INV(dx)*INV(dy);
+ CCTK_REAL const p1o4dxdz = 0.25*INV(dx)*INV(dz);
+ CCTK_REAL const p1o4dydz = 0.25*INV(dy)*INV(dz);
+ CCTK_REAL const p1odx2 = INV(SQR(dx));
+ CCTK_REAL const p1ody2 = INV(SQR(dy));
+ CCTK_REAL const p1odz2 = INV(SQR(dz));
+ CCTK_REAL const pm1o12dx2 = -0.0833333333333333333333333333333*INV(SQR(dx));
+ CCTK_REAL const pm1o12dy2 = -0.0833333333333333333333333333333*INV(SQR(dy));
+ CCTK_REAL const pm1o12dz2 = -0.0833333333333333333333333333333*INV(SQR(dz));
+
+ /* Assign local copies of arrays functions */
+
+
+
+ /* Calculate temporaries and arrays functions */
+
+ /* Copy local copies back to grid functions */
+
+ /* Loop over the grid points */
+ #pragma omp parallel
+ CCTK_LOOP3 (initial_sine_calc,
+ i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2],
+ cctk_lsh[0],cctk_lsh[1],cctk_lsh[2])
+ {
+ ptrdiff_t const index = di*i + dj*j + dk*k;
+
+ /* Assign local copies of grid functions */
+
+ CCTK_REAL piL = pi[index];
+ CCTK_REAL xL = x[index];
+
+
+ /* Include user supplied include files */
+
+ /* Precompute derivatives */
+
+ switch(fdOrder)
+ {
+ case 2:
+ break;
+
+ case 4:
+ break;
+ }
+
+ /* Calculate temporaries and grid functions */
+ CCTK_REAL phiL = Sin(2*Pi*(xL - cctk_time));
+
+ piL = -2*piL*Cos(2*Pi*(xL - cctk_time));
+
+ /* Copy local copies back to grid functions */
+ phi[index] = phiL;
+ pi[index] = piL;
+ }
+ CCTK_ENDLOOP3 (initial_sine_calc);
+}
+
+extern "C" void initial_sine_calc(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Entering initial_sine_calc_Body");
+ }
+
+ if (cctk_iteration % initial_sine_calc_calc_every != initial_sine_calc_calc_offset)
+ {
+ return;
+ }
+
+ const char *groups[] = {"grid::coordinates","SimpleWaveScript::phi_group","SimpleWaveScript::pi_group"};
+ GenericFD_AssertGroupStorage(cctkGH, "initial_sine_calc", 3, groups);
+
+ switch(fdOrder)
+ {
+ case 2:
+ break;
+
+ case 4:
+ break;
+ }
+
+ GenericFD_LoopOverEverything(cctkGH, &initial_sine_calc_Body);
+
+ if (verbose > 1)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,"Leaving initial_sine_calc_Body");
+ }
+}
diff --git a/Examples/SimpleWaveScript/src/make.code.defn b/Examples/SimpleWaveScript/src/make.code.defn
new file mode 100644
index 0000000..de3faa3
--- /dev/null
+++ b/Examples/SimpleWaveScript/src/make.code.defn
@@ -0,0 +1,3 @@
+# File produced by Kranc
+
+SRCS = Startup.cc RegisterMoL.cc RegisterSymmetries.cc initial_sine_calc.cc calc_rhs.cc Boundaries.cc
diff --git a/Examples/SimpleWaveScript2.kranc b/Examples/SimpleWaveScript2.kranc
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Examples/SimpleWaveScript2.kranc
diff --git a/Examples/emscript_sine.par b/Examples/emscript_sine.par
new file mode 100644
index 0000000..8a00e59
--- /dev/null
+++ b/Examples/emscript_sine.par
@@ -0,0 +1,65 @@
+
+Cactus::cctk_final_time = 1
+Cactus::terminate = "time"
+
+ActiveThorns = "IOUtil Carpet CarpetLib CarpetSlab CoordBase CoordBase SymBase CartGrid3D Slab CarpetIOBasic CarpetIOASCII EMScript Time MoL Periodic Boundary GenericFD CarpetReduce LoopControl"
+
+CoordBase::domainsize = minmax
+
+CoordBase::boundary_size_x_lower = 2
+CoordBase::boundary_size_y_lower = 2
+CoordBase::boundary_size_z_lower = 2
+CoordBase::boundary_shiftout_x_lower = 1
+CoordBase::boundary_shiftout_y_lower = 1
+CoordBase::boundary_shiftout_z_lower = 1
+
+CoordBase::boundary_size_x_upper = 2
+CoordBase::boundary_size_y_upper = 2
+CoordBase::boundary_size_z_upper = 2
+CoordBase::boundary_shiftout_x_upper = 0
+CoordBase::boundary_shiftout_y_upper = 0
+CoordBase::boundary_shiftout_z_upper = 0
+
+CartGrid3D::type = "coordbase"
+CartGrid3D::domain = "full"
+CartGrid3D::avoid_origin = "no"
+
+CoordBase::xmin = 0
+CoordBase::ymin = 0
+CoordBase::zmin = 0
+CoordBase::xmax = 1
+CoordBase::ymax = 1
+CoordBase::zmax = 1
+CoordBase::dx = 0.05
+CoordBase::dy = 0.05
+CoordBase::dz = 0.05
+
+driver::ghost_size = 2
+Carpet::domain_from_coordbase = "yes"
+Carpet::poison_new_timelevels = "yes"
+Carpet::check_for_poison = "no"
+Carpet::poison_value = 113
+
+Carpet::max_refinement_levels = 1
+Carpet::prolongation_order_space = 3
+Carpet::prolongation_order_time = 2
+Carpet::init_each_timelevel = no
+Carpet::print_timestats_every = 0
+
+Periodic::periodic = yes
+
+Time::dtfac = 0.5
+
+MethodOfLines::ode_method = "RK4"
+MethodOfLines::MoL_NaN_Check = "no"
+MethodOfLines::initial_data_is_crap = "yes"
+MethodOfLines::MoL_Intermediate_Steps = 4
+MethodOfLines::MoL_Num_Scratch_Levels = 1
+
+IO::out_dir = $parfile
+
+CarpetIOBasic::outInfo_every = 1
+CarpetIOBasic::outInfo_vars = "EMScript::El1"
+
+IOASCII::out1D_every = 1
+IOASCII::out1D_vars = "EMScript::El1 EMScript::B1"