From b3b10b90e2521535afe397d23e08f9e90f3fb32c Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Thu, 15 Dec 2011 17:49:26 +0100 Subject: EM example: Add generated thorn --- Examples/EM/configuration.ccl | 3 + Examples/EM/interface.ccl | 72 ++++++ Examples/EM/param.ccl | 335 +++++++++++++++++++++++++ Examples/EM/schedule.ccl | 125 ++++++++++ Examples/EM/src/Boundaries.cc | 457 ++++++++++++++++++++++++++++++++++ Examples/EM/src/Differencing.h | 36 +++ Examples/EM/src/EM_constraints.cc | 146 +++++++++++ Examples/EM/src/EM_energy.cc | 135 ++++++++++ Examples/EM/src/EM_evol.cc | 162 ++++++++++++ Examples/EM/src/EM_initial.cc | 147 +++++++++++ Examples/EM/src/RegisterMoL.cc | 22 ++ Examples/EM/src/RegisterSymmetries.cc | 64 +++++ Examples/EM/src/Startup.cc | 10 + Examples/EM/src/make.code.defn | 3 + 14 files changed, 1717 insertions(+) create mode 100644 Examples/EM/configuration.ccl create mode 100644 Examples/EM/interface.ccl create mode 100644 Examples/EM/param.ccl create mode 100644 Examples/EM/schedule.ccl create mode 100644 Examples/EM/src/Boundaries.cc create mode 100644 Examples/EM/src/Differencing.h create mode 100644 Examples/EM/src/EM_constraints.cc create mode 100644 Examples/EM/src/EM_energy.cc create mode 100644 Examples/EM/src/EM_evol.cc create mode 100644 Examples/EM/src/EM_initial.cc create mode 100644 Examples/EM/src/RegisterMoL.cc create mode 100644 Examples/EM/src/RegisterSymmetries.cc create mode 100644 Examples/EM/src/Startup.cc create mode 100644 Examples/EM/src/make.code.defn (limited to 'Examples') diff --git a/Examples/EM/configuration.ccl b/Examples/EM/configuration.ccl new file mode 100644 index 0000000..023aac7 --- /dev/null +++ b/Examples/EM/configuration.ccl @@ -0,0 +1,3 @@ +# File produced by Kranc + +REQUIRES GenericFD diff --git a/Examples/EM/interface.ccl b/Examples/EM/interface.ccl new file mode 100644 index 0000000..58b38f2 --- /dev/null +++ b/Examples/EM/interface.ccl @@ -0,0 +1,72 @@ +# File produced by Kranc + +implements: EM + +inherits: Grid GenericFD Boundary + + + +USES INCLUDE: GenericFD.h +USES INCLUDE: Symmetry.h +USES INCLUDE: sbp_calc_coeffs.h +USES INCLUDE: Boundary.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 constraints type=GF timelevels=1 tags='' +{ + CEl, + CB +} "constraints" + +public: +CCTK_REAL endens type=GF timelevels=1 tags='' +{ + rho +} "endens" + +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/EM/param.ccl b/Examples/EM/param.ccl new file mode 100644 index 0000000..fad7962 --- /dev/null +++ b/Examples/EM/param.ccl @@ -0,0 +1,335 @@ +# File produced by Kranc + + +shares: GenericFD + + + +shares: MethodOfLines + +USES CCTK_INT MoL_Num_Evolved_Vars + +restricted: +CCTK_INT verbose "verbose" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_REAL sigma "sigma" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL hlleAlpha "hlleAlpha" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_INT EM_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 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 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/EM/schedule.ccl b/Examples/EM/schedule.ccl new file mode 100644 index 0000000..fea3ede --- /dev/null +++ b/Examples/EM/schedule.ccl @@ -0,0 +1,125 @@ +# File produced by Kranc + + +STORAGE: constraints[1] + +STORAGE: endens[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 EM_Startup at STARTUP +{ + LANG: C + OPTIONS: meta +} "create banner" + +schedule EM_RegisterVars in MoL_Register +{ + LANG: C + OPTIONS: meta +} "Register Variables for MoL" + +schedule EM_RegisterSymmetries in SymmetryRegister +{ + LANG: C + OPTIONS: meta +} "register symmetries" + +schedule EM_initial at CCTK_INITIAL +{ + LANG: C +} "EM_initial" + +schedule EM_evol in MoL_CalcRHS +{ + LANG: C +} "EM_evol" + +schedule group EM_constraints_group in MoL_PseudoEvolution +{ + # no language specified +} "EM_constraints" + +schedule EM_constraints in EM_constraints_group +{ + LANG: C +} "EM_constraints" + +schedule group EM_energy_group in MoL_PseudoEvolution +{ + # no language specified +} "EM_energy" + +schedule EM_energy in EM_energy_group +{ + LANG: C +} "EM_energy" + +schedule EM_SelectBoundConds in MoL_PostStep +{ + LANG: C + OPTIONS: level + SYNC: B_group + SYNC: El_group +} "select boundary conditions" + +schedule EM_CheckBoundaries at BASEGRID +{ + LANG: C + OPTIONS: meta +} "check boundaries treatment" + +schedule group ApplyBCs as EM_ApplyBCs in MoL_PostStep after EM_SelectBoundConds +{ + # no language specified +} "Apply boundary conditions controlled by thorn Boundary" diff --git a/Examples/EM/src/Boundaries.cc b/Examples/EM/src/Boundaries.cc new file mode 100644 index 0000000..c87be53 --- /dev/null +++ b/Examples/EM/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 EM_CheckBoundaries(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + return; +} + +extern "C" void EM_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, + "EM::B_group", B_group_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register B_group_bound BC for EM::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, + "EM::El_group", El_group_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register El_group_bound BC for EM::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, + "EM::B1", B1_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register B1_bound BC for EM::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, + "EM::B2", B2_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register B2_bound BC for EM::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, + "EM::B3", B3_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register B3_bound BC for EM::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, + "EM::El1", El1_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register El1_bound BC for EM::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, + "EM::El2", El2_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register El2_bound BC for EM::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, + "EM::El3", El3_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register El3_bound BC for EM::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, + "EM::B_group", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EM::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, + "EM::El_group", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EM::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, + "EM::B1", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EM::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, + "EM::B2", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EM::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, + "EM::B3", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EM::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, + "EM::El1", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EM::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, + "EM::El2", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EM::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, + "EM::El3", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EM::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, + "EM::B_group", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Scalar BC for EM::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, + "EM::El_group", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Scalar BC for EM::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, + "EM::B1", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for EM::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, + "EM::B2", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for EM::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, + "EM::B3", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for EM::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, + "EM::El1", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for EM::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, + "EM::El2", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for EM::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, + "EM::El3", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for EM::El3!"); + + } + return; +} + + + +/* template for entries in parameter file: +#$bound$#EM::B_group_bound = "skip" +#$bound$#EM::B_group_bound_speed = 1.0 +#$bound$#EM::B_group_bound_limit = 0.0 +#$bound$#EM::B_group_bound_scalar = 0.0 + +#$bound$#EM::El_group_bound = "skip" +#$bound$#EM::El_group_bound_speed = 1.0 +#$bound$#EM::El_group_bound_limit = 0.0 +#$bound$#EM::El_group_bound_scalar = 0.0 + +#$bound$#EM::B1_bound = "skip" +#$bound$#EM::B1_bound_speed = 1.0 +#$bound$#EM::B1_bound_limit = 0.0 +#$bound$#EM::B1_bound_scalar = 0.0 + +#$bound$#EM::B2_bound = "skip" +#$bound$#EM::B2_bound_speed = 1.0 +#$bound$#EM::B2_bound_limit = 0.0 +#$bound$#EM::B2_bound_scalar = 0.0 + +#$bound$#EM::B3_bound = "skip" +#$bound$#EM::B3_bound_speed = 1.0 +#$bound$#EM::B3_bound_limit = 0.0 +#$bound$#EM::B3_bound_scalar = 0.0 + +#$bound$#EM::El1_bound = "skip" +#$bound$#EM::El1_bound_speed = 1.0 +#$bound$#EM::El1_bound_limit = 0.0 +#$bound$#EM::El1_bound_scalar = 0.0 + +#$bound$#EM::El2_bound = "skip" +#$bound$#EM::El2_bound_speed = 1.0 +#$bound$#EM::El2_bound_limit = 0.0 +#$bound$#EM::El2_bound_scalar = 0.0 + +#$bound$#EM::El3_bound = "skip" +#$bound$#EM::El3_bound_speed = 1.0 +#$bound$#EM::El3_bound_limit = 0.0 +#$bound$#EM::El3_bound_scalar = 0.0 + +*/ + diff --git a/Examples/EM/src/Differencing.h b/Examples/EM/src/Differencing.h new file mode 100644 index 0000000..7740e61 --- /dev/null +++ b/Examples/EM/src/Differencing.h @@ -0,0 +1,36 @@ +#define PDstandard2nd1(u) (p1o2dx*(-(u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) +#define PDstandard2nd2(u) (p1o2dy*(-(u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) +#define PDstandard2nd3(u) (p1o2dz*(-(u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) +#define PDstandard2nd11(u) (p1odx2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) +#define PDstandard2nd22(u) (p1ody2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) +#define PDstandard2nd33(u) (p1odz2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) +#define PDstandard2nd12(u) (p1o4dxdy*((u)[di*(-1)+dj*(-1)+dk*(0)] - (u)[di*(-1)+dj*(1)+dk*(0)] - (u)[di*(1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)])) +#define PDstandard2nd13(u) (p1o4dxdz*((u)[di*(-1)+dj*(0)+dk*(-1)] - (u)[di*(-1)+dj*(0)+dk*(1)] - (u)[di*(1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)])) +#define PDstandard2nd21(u) (p1o4dxdy*((u)[di*(-1)+dj*(-1)+dk*(0)] - (u)[di*(-1)+dj*(1)+dk*(0)] - (u)[di*(1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)])) +#define PDstandard2nd23(u) (p1o4dydz*((u)[di*(0)+dj*(-1)+dk*(-1)] - (u)[di*(0)+dj*(-1)+dk*(1)] - (u)[di*(0)+dj*(1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)])) +#define PDstandard2nd31(u) (p1o4dxdz*((u)[di*(-1)+dj*(0)+dk*(-1)] - (u)[di*(-1)+dj*(0)+dk*(1)] - (u)[di*(1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)])) +#define PDstandard2nd32(u) (p1o4dydz*((u)[di*(0)+dj*(-1)+dk*(-1)] - (u)[di*(0)+dj*(-1)+dk*(1)] - (u)[di*(0)+dj*(1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)])) +#define PDstandard4th1(u) (p1o12dx*(-8*(u)[di*(-1)+dj*(0)+dk*(0)] + 8*(u)[di*(1)+dj*(0)+dk*(0)] + (u)[di*(-2)+dj*(0)+dk*(0)] - (u)[di*(2)+dj*(0)+dk*(0)])) +#define PDstandard4th2(u) (p1o12dy*(-8*(u)[di*(0)+dj*(-1)+dk*(0)] + 8*(u)[di*(0)+dj*(1)+dk*(0)] + (u)[di*(0)+dj*(-2)+dk*(0)] - (u)[di*(0)+dj*(2)+dk*(0)])) +#define PDstandard4th3(u) (p1o12dz*(-8*(u)[di*(0)+dj*(0)+dk*(-1)] + 8*(u)[di*(0)+dj*(0)+dk*(1)] + (u)[di*(0)+dj*(0)+dk*(-2)] - (u)[di*(0)+dj*(0)+dk*(2)])) +#define PDstandard4th11(u) (pm1o12dx2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)]) + (u)[di*(-2)+dj*(0)+dk*(0)] + (u)[di*(2)+dj*(0)+dk*(0)])) +#define PDstandard4th22(u) (pm1o12dy2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)]) + (u)[di*(0)+dj*(-2)+dk*(0)] + (u)[di*(0)+dj*(2)+dk*(0)])) +#define PDstandard4th33(u) (pm1o12dz2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)]) + (u)[di*(0)+dj*(0)+dk*(-2)] + (u)[di*(0)+dj*(0)+dk*(2)])) +#define PDstandard4th12(u) (p1o144dxdy*(-64*((u)[di*(-1)+dj*(1)+dk*(0)] + (u)[di*(1)+dj*(-1)+dk*(0)]) + 64*((u)[di*(-1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)]) + 8*((u)[di*(-1)+dj*(2)+dk*(0)] + (u)[di*(1)+dj*(-2)+dk*(0)] + (u)[di*(-2)+dj*(1)+dk*(0)] + (u)[di*(2)+dj*(-1)+dk*(0)]) - 8*((u)[di*(-1)+dj*(-2)+dk*(0)] + (u)[di*(1)+dj*(2)+dk*(0)] + (u)[di*(-2)+dj*(-1)+dk*(0)] + (u)[di*(2)+dj*(1)+dk*(0)]) + (u)[di*(-2)+dj*(-2)+dk*(0)] - (u)[di*(-2)+dj*(2)+dk*(0)] - (u)[di*(2)+dj*(-2)+dk*(0)] + (u)[di*(2)+dj*(2)+dk*(0)])) +#define PDstandard4th13(u) (p1o144dxdz*(-64*((u)[di*(-1)+dj*(0)+dk*(1)] + (u)[di*(1)+dj*(0)+dk*(-1)]) + 64*((u)[di*(-1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)]) + 8*((u)[di*(-1)+dj*(0)+dk*(2)] + (u)[di*(1)+dj*(0)+dk*(-2)] + (u)[di*(-2)+dj*(0)+dk*(1)] + (u)[di*(2)+dj*(0)+dk*(-1)]) - 8*((u)[di*(-1)+dj*(0)+dk*(-2)] + (u)[di*(1)+dj*(0)+dk*(2)] + (u)[di*(-2)+dj*(0)+dk*(-1)] + (u)[di*(2)+dj*(0)+dk*(1)]) + (u)[di*(-2)+dj*(0)+dk*(-2)] - (u)[di*(-2)+dj*(0)+dk*(2)] - (u)[di*(2)+dj*(0)+dk*(-2)] + (u)[di*(2)+dj*(0)+dk*(2)])) +#define PDstandard4th21(u) (p1o144dxdy*(-64*((u)[di*(-1)+dj*(1)+dk*(0)] + (u)[di*(1)+dj*(-1)+dk*(0)]) + 64*((u)[di*(-1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)]) + 8*((u)[di*(-1)+dj*(2)+dk*(0)] + (u)[di*(1)+dj*(-2)+dk*(0)] + (u)[di*(-2)+dj*(1)+dk*(0)] + (u)[di*(2)+dj*(-1)+dk*(0)]) - 8*((u)[di*(-1)+dj*(-2)+dk*(0)] + (u)[di*(1)+dj*(2)+dk*(0)] + (u)[di*(-2)+dj*(-1)+dk*(0)] + (u)[di*(2)+dj*(1)+dk*(0)]) + (u)[di*(-2)+dj*(-2)+dk*(0)] - (u)[di*(-2)+dj*(2)+dk*(0)] - (u)[di*(2)+dj*(-2)+dk*(0)] + (u)[di*(2)+dj*(2)+dk*(0)])) +#define PDstandard4th23(u) (p1o144dydz*(-64*((u)[di*(0)+dj*(-1)+dk*(1)] + (u)[di*(0)+dj*(1)+dk*(-1)]) + 64*((u)[di*(0)+dj*(-1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)]) + 8*((u)[di*(0)+dj*(-1)+dk*(2)] + (u)[di*(0)+dj*(1)+dk*(-2)] + (u)[di*(0)+dj*(-2)+dk*(1)] + (u)[di*(0)+dj*(2)+dk*(-1)]) - 8*((u)[di*(0)+dj*(-1)+dk*(-2)] + (u)[di*(0)+dj*(1)+dk*(2)] + (u)[di*(0)+dj*(-2)+dk*(-1)] + (u)[di*(0)+dj*(2)+dk*(1)]) + (u)[di*(0)+dj*(-2)+dk*(-2)] - (u)[di*(0)+dj*(-2)+dk*(2)] - (u)[di*(0)+dj*(2)+dk*(-2)] + (u)[di*(0)+dj*(2)+dk*(2)])) +#define PDstandard4th31(u) (p1o144dxdz*(-64*((u)[di*(-1)+dj*(0)+dk*(1)] + (u)[di*(1)+dj*(0)+dk*(-1)]) + 64*((u)[di*(-1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)]) + 8*((u)[di*(-1)+dj*(0)+dk*(2)] + (u)[di*(1)+dj*(0)+dk*(-2)] + (u)[di*(-2)+dj*(0)+dk*(1)] + (u)[di*(2)+dj*(0)+dk*(-1)]) - 8*((u)[di*(-1)+dj*(0)+dk*(-2)] + (u)[di*(1)+dj*(0)+dk*(2)] + (u)[di*(-2)+dj*(0)+dk*(-1)] + (u)[di*(2)+dj*(0)+dk*(1)]) + (u)[di*(-2)+dj*(0)+dk*(-2)] - (u)[di*(-2)+dj*(0)+dk*(2)] - (u)[di*(2)+dj*(0)+dk*(-2)] + (u)[di*(2)+dj*(0)+dk*(2)])) +#define PDstandard4th32(u) (p1o144dydz*(-64*((u)[di*(0)+dj*(-1)+dk*(1)] + (u)[di*(0)+dj*(1)+dk*(-1)]) + 64*((u)[di*(0)+dj*(-1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)]) + 8*((u)[di*(0)+dj*(-1)+dk*(2)] + (u)[di*(0)+dj*(1)+dk*(-2)] + (u)[di*(0)+dj*(-2)+dk*(1)] + (u)[di*(0)+dj*(2)+dk*(-1)]) - 8*((u)[di*(0)+dj*(-1)+dk*(-2)] + (u)[di*(0)+dj*(1)+dk*(2)] + (u)[di*(0)+dj*(-2)+dk*(-1)] + (u)[di*(0)+dj*(2)+dk*(1)]) + (u)[di*(0)+dj*(-2)+dk*(-2)] - (u)[di*(0)+dj*(-2)+dk*(2)] - (u)[di*(0)+dj*(2)+dk*(-2)] + (u)[di*(0)+dj*(2)+dk*(2)])) +#define DiffPlus1(u) (p1o1*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) +#define DiffPlus2(u) (p1o1*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) +#define DiffPlus3(u) (p1o1*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(1)])) +#define DiffMinus1(u) (p1o1*((u)[di*(0)+dj*(0)+dk*(0)] - (u)[di*(-1)+dj*(0)+dk*(0)])) +#define DiffMinus2(u) (p1o1*((u)[di*(0)+dj*(0)+dk*(0)] - (u)[di*(0)+dj*(-1)+dk*(0)])) +#define DiffMinus3(u) (p1o1*((u)[di*(0)+dj*(0)+dk*(0)] - (u)[di*(0)+dj*(0)+dk*(-1)])) +#define ShiftMinus1(u) (p1o1*(u)[di*(-1)+dj*(0)+dk*(0)]) +#define ShiftMinus2(u) (p1o1*(u)[di*(0)+dj*(-1)+dk*(0)]) +#define ShiftMinus3(u) (p1o1*(u)[di*(0)+dj*(0)+dk*(-1)]) +#define PDplus1(u) (p1odx*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) +#define PDplus2(u) (p1ody*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) +#define PDplus3(u) (p1odz*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(1)])) diff --git a/Examples/EM/src/EM_constraints.cc b/Examples/EM/src/EM_constraints.cc new file mode 100644 index 0000000..d26cb66 --- /dev/null +++ b/Examples/EM/src/EM_constraints.cc @@ -0,0 +1,146 @@ +/* File produced by Kranc */ + +#define KRANC_C + +#include +#include +#include +#include +#include +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" +#include "GenericFD.h" +#include "Differencing.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)) + +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 min[3], int const max[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[]) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + + /* Declare the variables used for looping over grid points */ + CCTK_INT i, j, k; + // CCTK_INT index = INITVALUE; + + /* Declare finite differencing variables */ + + 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[] = {"EM::B_group","EM::constraints","EM::El_group"}; + GenericFD_AssertGroupStorage(cctkGH, "EM_constraints", 3, groups); + + GenericFD_EnsureStencilFits(cctkGH, "EM_constraints", 1, 1, 1); + + /* 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); + 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 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 p1o1 = 1; + 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 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)); + 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)); + + /* Loop over the grid points */ + for (k = min[2]; k < max[2]; k++) + { + for (j = min[1]; j < max[1]; j++) + { + for (i = min[0]; i < max[0]; i++) + { + int const index = CCTK_GFINDEX3D(cctkGH,i,j,k) ; + + /* Assign local copies of grid functions */ + + CCTK_REAL B1L = B1[index]; + CCTK_REAL B2L = B2[index]; + CCTK_REAL B3L = B3[index]; + CCTK_REAL El1L = El1[index]; + CCTK_REAL El2L = El2[index]; + CCTK_REAL El3L = El3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDstandard2nd1B1 = PDstandard2nd1(&B1[index]); + CCTK_REAL const PDstandard2nd2B2 = PDstandard2nd2(&B2[index]); + CCTK_REAL const PDstandard2nd3B3 = PDstandard2nd3(&B3[index]); + CCTK_REAL const PDstandard2nd1El1 = PDstandard2nd1(&El1[index]); + CCTK_REAL const PDstandard2nd2El2 = PDstandard2nd2(&El2[index]); + CCTK_REAL const PDstandard2nd3El3 = PDstandard2nd3(&El3[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL CElL = PDstandard2nd1El1 + PDstandard2nd2El2 + + PDstandard2nd3El3; + + CCTK_REAL CBL = PDstandard2nd1B1 + PDstandard2nd2B2 + + PDstandard2nd3B3; + + /* Copy local copies back to grid functions */ + CB[index] = CBL; + CEl[index] = CElL; + } + } + } +} + +extern "C" void EM_constraints(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &EM_constraints_Body); +} diff --git a/Examples/EM/src/EM_energy.cc b/Examples/EM/src/EM_energy.cc new file mode 100644 index 0000000..2318bd8 --- /dev/null +++ b/Examples/EM/src/EM_energy.cc @@ -0,0 +1,135 @@ +/* File produced by Kranc */ + +#define KRANC_C + +#include +#include +#include +#include +#include +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" +#include "GenericFD.h" +#include "Differencing.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)) + +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 min[3], int const max[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[]) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + + /* Declare the variables used for looping over grid points */ + CCTK_INT i, j, k; + // CCTK_INT index = INITVALUE; + + /* Declare finite differencing variables */ + + 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[] = {"EM::B_group","EM::El_group","EM::endens"}; + GenericFD_AssertGroupStorage(cctkGH, "EM_energy", 3, groups); + + + /* 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); + 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 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 p1o1 = 1; + 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 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)); + 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)); + + /* Loop over the grid points */ + for (k = min[2]; k < max[2]; k++) + { + for (j = min[1]; j < max[1]; j++) + { + for (i = min[0]; i < max[0]; i++) + { + int const index = CCTK_GFINDEX3D(cctkGH,i,j,k) ; + + /* Assign local copies of grid functions */ + + CCTK_REAL B1L = B1[index]; + CCTK_REAL B2L = B2[index]; + CCTK_REAL B3L = B3[index]; + CCTK_REAL El1L = El1[index]; + CCTK_REAL El2L = El2[index]; + CCTK_REAL El3L = El3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL rhoL = 0.5*(SQR(B1L) + SQR(B2L) + SQR(B3L) + SQR(El1L) + + SQR(El2L) + SQR(El3L)); + + /* Copy local copies back to grid functions */ + rho[index] = rhoL; + } + } + } +} + +extern "C" void EM_energy(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &EM_energy_Body); +} diff --git a/Examples/EM/src/EM_evol.cc b/Examples/EM/src/EM_evol.cc new file mode 100644 index 0000000..311d5ca --- /dev/null +++ b/Examples/EM/src/EM_evol.cc @@ -0,0 +1,162 @@ +/* File produced by Kranc */ + +#define KRANC_C + +#include +#include +#include +#include +#include +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" +#include "GenericFD.h" +#include "Differencing.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)) + +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 min[3], int const max[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[]) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + + /* Declare the variables used for looping over grid points */ + CCTK_INT i, j, k; + // CCTK_INT index = INITVALUE; + + /* Declare finite differencing variables */ + + 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[] = {"EM::B_group","EM::B_grouprhs","EM::El_group","EM::El_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "EM_evol", 4, groups); + + GenericFD_EnsureStencilFits(cctkGH, "EM_evol", 1, 1, 1); + + /* 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); + 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 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 p1o1 = 1; + 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 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)); + 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)); + + /* Loop over the grid points */ + for (k = min[2]; k < max[2]; k++) + { + for (j = min[1]; j < max[1]; j++) + { + for (i = min[0]; i < max[0]; i++) + { + int const index = CCTK_GFINDEX3D(cctkGH,i,j,k) ; + + /* Assign local copies of grid functions */ + + CCTK_REAL B1L = B1[index]; + CCTK_REAL B2L = B2[index]; + CCTK_REAL B3L = B3[index]; + CCTK_REAL El1L = El1[index]; + CCTK_REAL El2L = El2[index]; + CCTK_REAL El3L = El3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDstandard2nd2B1 = PDstandard2nd2(&B1[index]); + CCTK_REAL const PDstandard2nd3B1 = PDstandard2nd3(&B1[index]); + CCTK_REAL const PDstandard2nd1B2 = PDstandard2nd1(&B2[index]); + CCTK_REAL const PDstandard2nd3B2 = PDstandard2nd3(&B2[index]); + CCTK_REAL const PDstandard2nd1B3 = PDstandard2nd1(&B3[index]); + CCTK_REAL const PDstandard2nd2B3 = PDstandard2nd2(&B3[index]); + CCTK_REAL const PDstandard2nd2El1 = PDstandard2nd2(&El1[index]); + CCTK_REAL const PDstandard2nd3El1 = PDstandard2nd3(&El1[index]); + CCTK_REAL const PDstandard2nd1El2 = PDstandard2nd1(&El2[index]); + CCTK_REAL const PDstandard2nd3El2 = PDstandard2nd3(&El2[index]); + CCTK_REAL const PDstandard2nd1El3 = PDstandard2nd1(&El3[index]); + CCTK_REAL const PDstandard2nd2El3 = PDstandard2nd2(&El3[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL El1rhsL = PDstandard2nd2B3 - PDstandard2nd3B2; + + CCTK_REAL El2rhsL = -PDstandard2nd1B3 + PDstandard2nd3B1; + + CCTK_REAL El3rhsL = PDstandard2nd1B2 - PDstandard2nd2B1; + + CCTK_REAL B1rhsL = -PDstandard2nd2El3 + PDstandard2nd3El2; + + CCTK_REAL B2rhsL = PDstandard2nd1El3 - PDstandard2nd3El1; + + CCTK_REAL B3rhsL = -PDstandard2nd1El2 + PDstandard2nd2El1; + + /* Copy local copies back to grid functions */ + B1rhs[index] = B1rhsL; + B2rhs[index] = B2rhsL; + B3rhs[index] = B3rhsL; + El1rhs[index] = El1rhsL; + El2rhs[index] = El2rhsL; + El3rhs[index] = El3rhsL; + } + } + } +} + +extern "C" void EM_evol(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &EM_evol_Body); +} diff --git a/Examples/EM/src/EM_initial.cc b/Examples/EM/src/EM_initial.cc new file mode 100644 index 0000000..9b2f83e --- /dev/null +++ b/Examples/EM/src/EM_initial.cc @@ -0,0 +1,147 @@ +/* File produced by Kranc */ + +#define KRANC_C + +#include +#include +#include +#include +#include +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" +#include "GenericFD.h" +#include "Differencing.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)) + +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 min[3], int const max[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[]) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + + /* Declare the variables used for looping over grid points */ + CCTK_INT i, j, k; + // CCTK_INT index = INITVALUE; + + /* Declare finite differencing variables */ + + 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[] = {"EM::B_group","EM::El_group","grid::coordinates"}; + GenericFD_AssertGroupStorage(cctkGH, "EM_initial", 3, groups); + + + /* 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); + 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 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 p1o1 = 1; + 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 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)); + 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)); + + /* Loop over the grid points */ + for (k = min[2]; k < max[2]; k++) + { + for (j = min[1]; j < max[1]; j++) + { + for (i = min[0]; i < max[0]; i++) + { + int const index = CCTK_GFINDEX3D(cctkGH,i,j,k) ; + + /* Assign local copies of grid functions */ + + CCTK_REAL xL = x[index]; + CCTK_REAL yL = y[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL El1L = Cos(2*Pi*(xL + yL))*ToReal(sigma); + + CCTK_REAL El2L = Cos(2*Pi*xL)*(-1 + ToReal(sigma)) - Cos(2*Pi*(xL + + yL))*ToReal(sigma); + + CCTK_REAL El3L = 0; + + CCTK_REAL B1L = 0; + + CCTK_REAL B2L = 0; + + CCTK_REAL B3L = -(Cos(2*Pi*xL)*(-1 + ToReal(sigma))) + Cos(2*Pi*(xL + + yL))*ToReal(sigma); + + /* Copy local copies back to grid functions */ + B1[index] = B1L; + B2[index] = B2L; + B3[index] = B3L; + El1[index] = El1L; + El2[index] = El2L; + El3[index] = El3L; + } + } + } +} + +extern "C" void EM_initial(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &EM_initial_Body); +} diff --git a/Examples/EM/src/RegisterMoL.cc b/Examples/EM/src/RegisterMoL.cc new file mode 100644 index 0000000..34583ae --- /dev/null +++ b/Examples/EM/src/RegisterMoL.cc @@ -0,0 +1,22 @@ +/* File produced by Kranc */ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +extern "C" void EM_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("EM::B1"), CCTK_VarIndex("EM::B1rhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("EM::B2"), CCTK_VarIndex("EM::B2rhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("EM::B3"), CCTK_VarIndex("EM::B3rhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("EM::El1"), CCTK_VarIndex("EM::El1rhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("EM::El2"), CCTK_VarIndex("EM::El2rhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("EM::El3"), CCTK_VarIndex("EM::El3rhs")); + return; +} diff --git a/Examples/EM/src/RegisterSymmetries.cc b/Examples/EM/src/RegisterSymmetries.cc new file mode 100644 index 0000000..5854d6d --- /dev/null +++ b/Examples/EM/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 EM_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, "EM::B1"); + + sym[0] = 1; + sym[1] = -1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EM::B2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = -1; + SetCartSymVN(cctkGH, sym, "EM::B3"); + + sym[0] = -1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EM::El1"); + + sym[0] = 1; + sym[1] = -1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EM::El2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = -1; + SetCartSymVN(cctkGH, sym, "EM::El3"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EM::CEl"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EM::CB"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EM::rho"); + +} diff --git a/Examples/EM/src/Startup.cc b/Examples/EM/src/Startup.cc new file mode 100644 index 0000000..4375127 --- /dev/null +++ b/Examples/EM/src/Startup.cc @@ -0,0 +1,10 @@ +/* File produced by Kranc */ + +#include "cctk.h" + +extern "C" int EM_Startup(void) +{ + const char * banner = "EM"; + CCTK_RegisterBanner(banner); + return 0; +} diff --git a/Examples/EM/src/make.code.defn b/Examples/EM/src/make.code.defn new file mode 100644 index 0000000..0d52b41 --- /dev/null +++ b/Examples/EM/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 -- cgit v1.2.3