diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2011-12-15 17:50:44 +0100 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2011-12-15 17:50:44 +0100 |
commit | 5a6220b9e1cf72fda06201a69249c612856bbf3f (patch) | |
tree | 0f0e2285722b5874934dd35500778e2684f6fa94 /Examples/Wave | |
parent | bf4d0bb6c24789892065492cf533325c8b079046 (diff) |
Wave example: Add generated thorn
Diffstat (limited to 'Examples/Wave')
-rw-r--r-- | Examples/Wave/configuration.ccl | 3 | ||||
-rw-r--r-- | Examples/Wave/interface.ccl | 63 | ||||
-rw-r--r-- | Examples/Wave/param.ccl | 283 | ||||
-rw-r--r-- | Examples/Wave/schedule.ccl | 136 | ||||
-rw-r--r-- | Examples/Wave/src/Boundaries.cc | 197 | ||||
-rw-r--r-- | Examples/Wave/src/Differencing.h | 53 | ||||
-rw-r--r-- | Examples/Wave/src/RegisterMoL.cc | 18 | ||||
-rw-r--r-- | Examples/Wave/src/RegisterSymmetries.cc | 64 | ||||
-rw-r--r-- | Examples/Wave/src/Startup.cc | 10 | ||||
-rw-r--r-- | Examples/Wave/src/make.code.defn | 3 | ||||
-rw-r--r-- | Examples/Wave/src/wave_boundary.cc | 173 | ||||
-rw-r--r-- | Examples/Wave/src/wave_calc_errors.cc | 142 | ||||
-rw-r--r-- | Examples/Wave/src/wave_calc_norm.cc | 168 | ||||
-rw-r--r-- | Examples/Wave/src/wave_evolve.cc | 157 | ||||
-rw-r--r-- | Examples/Wave/src/wave_exact_gaussian.cc | 152 | ||||
-rw-r--r-- | Examples/Wave/src/wave_exact_sine.cc | 150 | ||||
-rw-r--r-- | Examples/Wave/src/wave_import_exact.cc | 140 |
17 files changed, 1912 insertions, 0 deletions
diff --git a/Examples/Wave/configuration.ccl b/Examples/Wave/configuration.ccl new file mode 100644 index 0000000..023aac7 --- /dev/null +++ b/Examples/Wave/configuration.ccl @@ -0,0 +1,3 @@ +# File produced by Kranc + +REQUIRES GenericFD diff --git a/Examples/Wave/interface.ccl b/Examples/Wave/interface.ccl new file mode 100644 index 0000000..ab486ea --- /dev/null +++ b/Examples/Wave/interface.ccl @@ -0,0 +1,63 @@ +# File produced by Kranc + +implements: Wave + +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 errors type=GF timelevels=3 tags='' +{ + phiError, + piError +} "errors" + +public: +CCTK_REAL exact type=GF timelevels=3 tags='' +{ + phiExact, + piExact +} "exact" + +public: +CCTK_REAL norms type=GF timelevels=3 tags='' +{ + VL2, + VDP, + EL2 +} "norms" + +public: +CCTK_REAL evolved type=GF timelevels=3 tags='' +{ + phi, + pi +} "evolved" + +public: +CCTK_REAL evolvedrhs type=GF timelevels=3 tags='' +{ + phirhs, + pirhs +} "evolvedrhs" diff --git a/Examples/Wave/param.ccl b/Examples/Wave/param.ccl new file mode 100644 index 0000000..3b37c58 --- /dev/null +++ b/Examples/Wave/param.ccl @@ -0,0 +1,283 @@ +# 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 periodicity "periodicity" +{ + "*:*" :: "" +} 1 + +restricted: +CCTK_REAL amplitude "amplitude" +{ + "*:*" :: "" +} 1 + +restricted: +CCTK_REAL n1 "n1" +{ + "*:*" :: "" +} 1 + +restricted: +CCTK_REAL n2 "n2" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL n3 "n3" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL nSigma "nSigma" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL r0 "r0" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL t0 "t0" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL x0 "x0" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL hlleAlpha "hlleAlpha" +{ + "*:*" :: "" +} 0 + +private: +KEYWORD initial_data "initial_data" +{ + "gaussian" :: "gaussian" + "sine" :: "sine" +} "gaussian" + +private: +KEYWORD boundary_condition "boundary_condition" +{ + "none" :: "none" + "radiative" :: "radiative" +} "radiative" + +restricted: +CCTK_INT Wave_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 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 wave_exact_sine_calc_every "wave_exact_sine_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT wave_exact_gaussian_calc_every "wave_exact_gaussian_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT wave_import_exact_calc_every "wave_import_exact_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT wave_evolve_calc_every "wave_evolve_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT wave_calc_errors_calc_every "wave_calc_errors_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT wave_calc_norm_calc_every "wave_calc_norm_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT wave_boundary_calc_every "wave_boundary_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT wave_exact_sine_calc_offset "wave_exact_sine_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT wave_exact_gaussian_calc_offset "wave_exact_gaussian_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT wave_import_exact_calc_offset "wave_import_exact_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT wave_evolve_calc_offset "wave_evolve_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT wave_calc_errors_calc_offset "wave_calc_errors_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT wave_calc_norm_calc_offset "wave_calc_norm_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT wave_boundary_calc_offset "wave_boundary_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 evolved_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 evolved_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 evolved_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 evolved_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + diff --git a/Examples/Wave/schedule.ccl b/Examples/Wave/schedule.ccl new file mode 100644 index 0000000..ea09733 --- /dev/null +++ b/Examples/Wave/schedule.ccl @@ -0,0 +1,136 @@ +# File produced by Kranc + + +STORAGE: errors[3] + +STORAGE: exact[3] + +STORAGE: norms[3] + +if (timelevels == 1) +{ + STORAGE: evolved[1] +} +if (timelevels == 2) +{ + STORAGE: evolved[2] +} +if (timelevels == 3) +{ + STORAGE: evolved[3] +} + +if (rhs_timelevels == 1) +{ + STORAGE: evolvedrhs[1] +} +if (rhs_timelevels == 2) +{ + STORAGE: evolvedrhs[2] +} +if (rhs_timelevels == 3) +{ + STORAGE: evolvedrhs[3] +} + +schedule Wave_Startup at STARTUP +{ + LANG: C + OPTIONS: meta +} "create banner" + +schedule Wave_RegisterVars in MoL_Register +{ + LANG: C + OPTIONS: meta +} "Register Variables for MoL" + +schedule Wave_RegisterSymmetries in SymmetryRegister +{ + LANG: C + OPTIONS: meta +} "register symmetries" + + +if (CCTK_EQUALS(initial_data, "sine")) +{ + schedule wave_exact_sine AT INITIAL before import_exact + { + LANG: C + } "wave_exact_sine" +} + + +if (CCTK_EQUALS(initial_data, "sine")) +{ + schedule wave_exact_sine AT POSTSTEP before calc_errors + { + LANG: C + } "wave_exact_sine" +} + + +if (CCTK_EQUALS(initial_data, "gaussian")) +{ + schedule wave_exact_gaussian AT INITIAL before import_exact + { + LANG: C + } "wave_exact_gaussian" +} + + +if (CCTK_EQUALS(initial_data, "gaussian")) +{ + schedule wave_exact_gaussian AT POSTSTEP before calc_errors + { + LANG: C + } "wave_exact_gaussian" +} + +schedule wave_import_exact at INITIAL as import_exact +{ + LANG: C +} "wave_import_exact" + +schedule wave_evolve in MoL_CalcRHS as evolve +{ + LANG: C +} "wave_evolve" + +schedule wave_calc_errors at ANALYSIS as calc_errors +{ + LANG: C +} "wave_calc_errors" + +schedule wave_calc_norm at ANALYSIS as calc_norm +{ + LANG: C + SYNC: norms +} "wave_calc_norm" + + +if (CCTK_EQUALS(boundary_condition, "radiative")) +{ + schedule wave_boundary in MoL_RHSBoundaries + { + LANG: C + } "wave_boundary" +} + +schedule Wave_SelectBoundConds in MoL_PostStep +{ + LANG: C + OPTIONS: level + SYNC: evolved +} "select boundary conditions" + +schedule Wave_CheckBoundaries at BASEGRID +{ + LANG: C + OPTIONS: meta +} "check boundaries treatment" + +schedule group ApplyBCs as Wave_ApplyBCs in MoL_PostStep after Wave_SelectBoundConds +{ + # no language specified +} "Apply boundary conditions controlled by thorn Boundary" diff --git a/Examples/Wave/src/Boundaries.cc b/Examples/Wave/src/Boundaries.cc new file mode 100644 index 0000000..672d7f3 --- /dev/null +++ b/Examples/Wave/src/Boundaries.cc @@ -0,0 +1,197 @@ +/* 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 Wave_CheckBoundaries(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + return; +} + +extern "C" void Wave_SelectBoundConds(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + CCTK_INT ierr = 0; + + if (CCTK_EQUALS(evolved_bound, "none" ) || + CCTK_EQUALS(evolved_bound, "static") || + CCTK_EQUALS(evolved_bound, "flat" ) || + CCTK_EQUALS(evolved_bound, "zero" ) ) + { + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "Wave::evolved", evolved_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register evolved_bound BC for Wave::evolved!"); + } + + 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, + "Wave::phi", phi_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register phi_bound BC for Wave::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, + "Wave::pi", pi_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register pi_bound BC for Wave::pi!"); + } + + if (CCTK_EQUALS(evolved_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_evolved_bound = -1; + if (handle_evolved_bound < 0) handle_evolved_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_evolved_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_evolved_bound , evolved_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_evolved_bound ,evolved_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_evolved_bound, + "Wave::evolved", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for Wave::evolved!"); + + } + + 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, + "Wave::phi", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for Wave::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, + "Wave::pi", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for Wave::pi!"); + + } + + if (CCTK_EQUALS(evolved_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_evolved_bound = -1; + if (handle_evolved_bound < 0) handle_evolved_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_evolved_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_evolved_bound ,evolved_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_evolved_bound, + "Wave::evolved", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Scalar BC for Wave::evolved!"); + + } + + 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, + "Wave::phi", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for Wave::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, + "Wave::pi", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for Wave::pi!"); + + } + return; +} + + + +/* template for entries in parameter file: +#$bound$#Wave::evolved_bound = "skip" +#$bound$#Wave::evolved_bound_speed = 1.0 +#$bound$#Wave::evolved_bound_limit = 0.0 +#$bound$#Wave::evolved_bound_scalar = 0.0 + +#$bound$#Wave::phi_bound = "skip" +#$bound$#Wave::phi_bound_speed = 1.0 +#$bound$#Wave::phi_bound_limit = 0.0 +#$bound$#Wave::phi_bound_scalar = 0.0 + +#$bound$#Wave::pi_bound = "skip" +#$bound$#Wave::pi_bound_speed = 1.0 +#$bound$#Wave::pi_bound_limit = 0.0 +#$bound$#Wave::pi_bound_scalar = 0.0 + +*/ + diff --git a/Examples/Wave/src/Differencing.h b/Examples/Wave/src/Differencing.h new file mode 100644 index 0000000..e7810c7 --- /dev/null +++ b/Examples/Wave/src/Differencing.h @@ -0,0 +1,53 @@ +#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 PDonesided2nd1(u) (pm1o2dx*(3*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(2*dir1)+dj*(0)+dk*(0)] - 4*(u)[di*(dir1)+dj*(0)+dk*(0)])*dir1) +#define PDonesided2nd2(u) (pm1o2dy*(3*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(2*dir2)+dk*(0)] - 4*(u)[di*(0)+dj*(dir2)+dk*(0)])*dir2) +#define PDonesided2nd3(u) (pm1o2dz*(3*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(2*dir3)] - 4*(u)[di*(0)+dj*(0)+dk*(dir3)])*dir3) +#define Diss2nd(u) (-(p1odxdydz*diss*((6*(u)[di*(0)+dj*(0)+dk*(0)] - 4*((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)])*INV(dxi)*INV(dyi) + ((6*(u)[di*(0)+dj*(0)+dk*(0)] - 4*((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)])*INV(dxi) + (6*(u)[di*(0)+dj*(0)+dk*(0)] - 4*((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)])*INV(dyi))*INV(dzi)))) +#define Diss4th(u) (p1odxdydz*diss*((-20*(u)[di*(0)+dj*(0)+dk*(0)] + 15*((u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)]) - 6*((u)[di*(0)+dj*(0)+dk*(-2)] + (u)[di*(0)+dj*(0)+dk*(2)]) + (u)[di*(0)+dj*(0)+dk*(-3)] + (u)[di*(0)+dj*(0)+dk*(3)])*INV(dxi)*INV(dyi) + ((15*((u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)]) - 6*((u)[di*(0)+dj*(-2)+dk*(0)] + (u)[di*(0)+dj*(2)+dk*(0)]) + (u)[di*(0)+dj*(-3)+dk*(0)] + (u)[di*(0)+dj*(3)+dk*(0)])*INV(dxi) + (15*((u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)]) - 6*((u)[di*(-2)+dj*(0)+dk*(0)] + (u)[di*(2)+dj*(0)+dk*(0)]) + (u)[di*(-3)+dj*(0)+dk*(0)] + (u)[di*(3)+dj*(0)+dk*(0)])*INV(dyi) - 20*(u)[di*(0)+dj*(0)+dk*(0)]*(INV(dxi) + INV(dyi)))*INV(dzi))) +#define PDzero1(u) (p1o2dx*(-(u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) +#define PDzero2(u) (p1o2dy*(-(u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) +#define PDzero3(u) (p1o2dz*(-(u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) +#define PDzero11(u) (p1o4dx2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(-2)+dj*(0)+dk*(0)] + (u)[di*(2)+dj*(0)+dk*(0)])) +#define PDzero12(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 PDzero13(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 PDzero21(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 PDzero22(u) (p1o4dy2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(-2)+dk*(0)] + (u)[di*(0)+dj*(2)+dk*(0)])) +#define PDzero23(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 PDzero31(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 PDzero32(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 PDzero33(u) (p1o4dz2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(-2)] + (u)[di*(0)+dj*(0)+dk*(2)])) +#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)])) +#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)]) diff --git a/Examples/Wave/src/RegisterMoL.cc b/Examples/Wave/src/RegisterMoL.cc new file mode 100644 index 0000000..2d73922 --- /dev/null +++ b/Examples/Wave/src/RegisterMoL.cc @@ -0,0 +1,18 @@ +/* File produced by Kranc */ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +extern "C" void Wave_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("Wave::phi"), CCTK_VarIndex("Wave::phirhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("Wave::pi"), CCTK_VarIndex("Wave::pirhs")); + return; +} diff --git a/Examples/Wave/src/RegisterSymmetries.cc b/Examples/Wave/src/RegisterSymmetries.cc new file mode 100644 index 0000000..c522d51 --- /dev/null +++ b/Examples/Wave/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 Wave_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, "Wave::phi"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Wave::pi"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Wave::phiError"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Wave::piError"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Wave::phiExact"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Wave::piExact"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Wave::VL2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Wave::VDP"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Wave::EL2"); + +} diff --git a/Examples/Wave/src/Startup.cc b/Examples/Wave/src/Startup.cc new file mode 100644 index 0000000..9281f39 --- /dev/null +++ b/Examples/Wave/src/Startup.cc @@ -0,0 +1,10 @@ +/* File produced by Kranc */ + +#include "cctk.h" + +extern "C" int Wave_Startup(void) +{ + const char * banner = "Wave"; + CCTK_RegisterBanner(banner); + return 0; +} diff --git a/Examples/Wave/src/make.code.defn b/Examples/Wave/src/make.code.defn new file mode 100644 index 0000000..4dcd739 --- /dev/null +++ b/Examples/Wave/src/make.code.defn @@ -0,0 +1,3 @@ +# File produced by Kranc + +SRCS = Startup.cc RegisterMoL.cc RegisterSymmetries.cc wave_exact_sine.cc wave_exact_gaussian.cc wave_import_exact.cc wave_evolve.cc wave_calc_errors.cc wave_calc_norm.cc wave_boundary.cc Boundaries.cc diff --git a/Examples/Wave/src/wave_boundary.cc b/Examples/Wave/src/wave_boundary.cc new file mode 100644 index 0000000..0341182 --- /dev/null +++ b/Examples/Wave/src/wave_boundary.cc @@ -0,0 +1,173 @@ +/* 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" + +/* 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 wave_boundary_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 */, "Wave::evolvedrhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Wave::evolvedrhs."); + return; +} + +static void wave_boundary_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 wave_boundary_Body"); + } + + if (cctk_iteration % wave_boundary_calc_every != wave_boundary_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::evolved","Wave::evolvedrhs","grid::coordinates"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_boundary", 3, groups); + + GenericFD_EnsureStencilFits(cctkGH, "wave_boundary", 2, 2, 2); + + /* 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 p1o4dx2 = 0.25*INV(SQR(dx)); + CCTK_REAL const p1o4dxdy = 0.25*INV(dx)*INV(dy); + CCTK_REAL const p1o4dxdz = 0.25*INV(dx)*INV(dz); + CCTK_REAL const p1o4dy2 = 0.25*INV(SQR(dy)); + CCTK_REAL const p1o4dydz = 0.25*INV(dy)*INV(dz); + CCTK_REAL const p1o4dz2 = 0.25*INV(SQR(dz)); + CCTK_REAL const p1odx = INV(dx); + CCTK_REAL const p1odx2 = INV(SQR(dx)); + CCTK_REAL const p1odxdydz = INV(dx)*INV(dy)*INV(dz); + 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)); + CCTK_REAL const pm1o2dx = -0.5*INV(dx); + CCTK_REAL const pm1o2dy = -0.5*INV(dy); + CCTK_REAL const pm1o2dz = -0.5*INV(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 phiL = phi[index]; + CCTK_REAL piL = pi[index]; + CCTK_REAL rL = r[index]; + CCTK_REAL xL = x[index]; + CCTK_REAL yL = y[index]; + CCTK_REAL zL = z[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL norm1 = -(xL*INV(rL)); + + CCTK_REAL norm2 = -(yL*INV(rL)); + + CCTK_REAL norm3 = -(zL*INV(rL)); + + ptrdiff_t dir1 = Sign(norm1); + + ptrdiff_t dir2 = Sign(norm2); + + ptrdiff_t dir3 = Sign(norm3); + + CCTK_REAL phirhsL = PDonesided2nd1(&phi[index])*norm1 + + PDonesided2nd2(&phi[index])*norm2 + + PDonesided2nd3(&phi[index])*norm3 - phiL*INV(rL); + + CCTK_REAL pirhsL = PDonesided2nd1(&pi[index])*norm1 + + PDonesided2nd2(&pi[index])*norm2 + PDonesided2nd3(&pi[index])*norm3 + - piL*INV(rL); + + /* Copy local copies back to grid functions */ + phirhs[index] = phirhsL; + pirhs[index] = pirhsL; + } + } + } +} + +extern "C" void wave_boundary(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverBoundary(cctkGH, &wave_boundary_Body); +} diff --git a/Examples/Wave/src/wave_calc_errors.cc b/Examples/Wave/src/wave_calc_errors.cc new file mode 100644 index 0000000..395f33a --- /dev/null +++ b/Examples/Wave/src/wave_calc_errors.cc @@ -0,0 +1,142 @@ +/* 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" + +/* 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 wave_calc_errors_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 wave_calc_errors_Body"); + } + + if (cctk_iteration % wave_calc_errors_calc_every != wave_calc_errors_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::errors","Wave::evolved","Wave::exact"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_calc_errors", 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 p1o4dx2 = 0.25*INV(SQR(dx)); + CCTK_REAL const p1o4dxdy = 0.25*INV(dx)*INV(dy); + CCTK_REAL const p1o4dxdz = 0.25*INV(dx)*INV(dz); + CCTK_REAL const p1o4dy2 = 0.25*INV(SQR(dy)); + CCTK_REAL const p1o4dydz = 0.25*INV(dy)*INV(dz); + CCTK_REAL const p1o4dz2 = 0.25*INV(SQR(dz)); + CCTK_REAL const p1odx = INV(dx); + CCTK_REAL const p1odx2 = INV(SQR(dx)); + CCTK_REAL const p1odxdydz = INV(dx)*INV(dy)*INV(dz); + 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)); + CCTK_REAL const pm1o2dx = -0.5*INV(dx); + CCTK_REAL const pm1o2dy = -0.5*INV(dy); + CCTK_REAL const pm1o2dz = -0.5*INV(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 phiL = phi[index]; + CCTK_REAL phiExactL = phiExact[index]; + CCTK_REAL piL = pi[index]; + CCTK_REAL piExactL = piExact[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL phiErrorL = -phiExactL + phiL; + + CCTK_REAL piErrorL = -piExactL + piL; + + /* Copy local copies back to grid functions */ + phiError[index] = phiErrorL; + piError[index] = piErrorL; + } + } + } +} + +extern "C" void wave_calc_errors(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &wave_calc_errors_Body); +} diff --git a/Examples/Wave/src/wave_calc_norm.cc b/Examples/Wave/src/wave_calc_norm.cc new file mode 100644 index 0000000..9546f10 --- /dev/null +++ b/Examples/Wave/src/wave_calc_norm.cc @@ -0,0 +1,168 @@ +/* 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" + +/* 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 wave_calc_norm_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 */, "Wave::norms","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Wave::norms."); + return; +} + +static void wave_calc_norm_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 wave_calc_norm_Body"); + } + + if (cctk_iteration % wave_calc_norm_calc_every != wave_calc_norm_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::errors","Wave::evolved","Wave::norms"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_calc_norm", 3, groups); + + GenericFD_EnsureStencilFits(cctkGH, "wave_calc_norm", 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 p1o4dx2 = 0.25*INV(SQR(dx)); + CCTK_REAL const p1o4dxdy = 0.25*INV(dx)*INV(dy); + CCTK_REAL const p1o4dxdz = 0.25*INV(dx)*INV(dz); + CCTK_REAL const p1o4dy2 = 0.25*INV(SQR(dy)); + CCTK_REAL const p1o4dydz = 0.25*INV(dy)*INV(dz); + CCTK_REAL const p1o4dz2 = 0.25*INV(SQR(dz)); + CCTK_REAL const p1odx = INV(dx); + CCTK_REAL const p1odx2 = INV(SQR(dx)); + CCTK_REAL const p1odxdydz = INV(dx)*INV(dy)*INV(dz); + 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)); + CCTK_REAL const pm1o2dx = -0.5*INV(dx); + CCTK_REAL const pm1o2dy = -0.5*INV(dy); + CCTK_REAL const pm1o2dz = -0.5*INV(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 phiL = phi[index]; + CCTK_REAL phiErrorL = phiError[index]; + CCTK_REAL piL = pi[index]; + CCTK_REAL piErrorL = piError[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDplus1phi = PDplus1(&phi[index]); + CCTK_REAL const PDplus2phi = PDplus2(&phi[index]); + CCTK_REAL const PDplus3phi = PDplus3(&phi[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL VL2squared = SQR(phiL) + SQR(piL); + + CCTK_REAL VL2L = sqrt(VL2squared); + + CCTK_REAL VDPsquared = SQR(PDplus1phi) + SQR(PDplus2phi) + + SQR(PDplus3phi) + SQR(piL); + + CCTK_REAL VDPL = sqrt(VDPsquared); + + CCTK_REAL EL2squared = SQR(phiErrorL) + SQR(piErrorL); + + CCTK_REAL EL2L = sqrt(EL2squared); + + /* Copy local copies back to grid functions */ + EL2[index] = EL2L; + VDP[index] = VDPL; + VL2[index] = VL2L; + } + } + } +} + +extern "C" void wave_calc_norm(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &wave_calc_norm_Body); +} diff --git a/Examples/Wave/src/wave_evolve.cc b/Examples/Wave/src/wave_evolve.cc new file mode 100644 index 0000000..b3d11e1 --- /dev/null +++ b/Examples/Wave/src/wave_evolve.cc @@ -0,0 +1,157 @@ +/* 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" + +/* 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 wave_evolve_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 */, "Wave::evolvedrhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Wave::evolvedrhs."); + return; +} + +static void wave_evolve_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 wave_evolve_Body"); + } + + if (cctk_iteration % wave_evolve_calc_every != wave_evolve_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::evolved","Wave::evolvedrhs"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_evolve", 2, groups); + + GenericFD_EnsureStencilFits(cctkGH, "wave_evolve", 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 p1o4dx2 = 0.25*INV(SQR(dx)); + CCTK_REAL const p1o4dxdy = 0.25*INV(dx)*INV(dy); + CCTK_REAL const p1o4dxdz = 0.25*INV(dx)*INV(dz); + CCTK_REAL const p1o4dy2 = 0.25*INV(SQR(dy)); + CCTK_REAL const p1o4dydz = 0.25*INV(dy)*INV(dz); + CCTK_REAL const p1o4dz2 = 0.25*INV(SQR(dz)); + CCTK_REAL const p1odx = INV(dx); + CCTK_REAL const p1odx2 = INV(SQR(dx)); + CCTK_REAL const p1odxdydz = INV(dx)*INV(dy)*INV(dz); + 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)); + CCTK_REAL const pm1o2dx = -0.5*INV(dx); + CCTK_REAL const pm1o2dy = -0.5*INV(dy); + CCTK_REAL const pm1o2dz = -0.5*INV(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 phiL = phi[index]; + CCTK_REAL piL = pi[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDstandard2nd11phi = PDstandard2nd11(&phi[index]); + CCTK_REAL const PDstandard2nd22phi = PDstandard2nd22(&phi[index]); + CCTK_REAL const PDstandard2nd33phi = PDstandard2nd33(&phi[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL phirhsL = piL; + + CCTK_REAL pirhsL = PDstandard2nd11phi + PDstandard2nd22phi + + PDstandard2nd33phi; + + /* Copy local copies back to grid functions */ + phirhs[index] = phirhsL; + pirhs[index] = pirhsL; + } + } + } +} + +extern "C" void wave_evolve(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &wave_evolve_Body); +} diff --git a/Examples/Wave/src/wave_exact_gaussian.cc b/Examples/Wave/src/wave_exact_gaussian.cc new file mode 100644 index 0000000..1efc9b5 --- /dev/null +++ b/Examples/Wave/src/wave_exact_gaussian.cc @@ -0,0 +1,152 @@ +/* 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" + +/* 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 wave_exact_gaussian_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 wave_exact_gaussian_Body"); + } + + if (cctk_iteration % wave_exact_gaussian_calc_every != wave_exact_gaussian_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::exact","grid::coordinates"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_exact_gaussian", 2, 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 p1o4dx2 = 0.25*INV(SQR(dx)); + CCTK_REAL const p1o4dxdy = 0.25*INV(dx)*INV(dy); + CCTK_REAL const p1o4dxdz = 0.25*INV(dx)*INV(dz); + CCTK_REAL const p1o4dy2 = 0.25*INV(SQR(dy)); + CCTK_REAL const p1o4dydz = 0.25*INV(dy)*INV(dz); + CCTK_REAL const p1o4dz2 = 0.25*INV(SQR(dz)); + CCTK_REAL const p1odx = INV(dx); + CCTK_REAL const p1odx2 = INV(SQR(dx)); + CCTK_REAL const p1odxdydz = INV(dx)*INV(dy)*INV(dz); + 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)); + CCTK_REAL const pm1o2dx = -0.5*INV(dx); + CCTK_REAL const pm1o2dy = -0.5*INV(dy); + CCTK_REAL const pm1o2dz = -0.5*INV(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 rL = r[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL rEps = pow(1.e-24 + QAD(rL),0.25); + + CCTK_REAL phiExactL = (-(CUB(-rL + cctk_time + + ToReal(t0))*exp(-(INV(SQR(ToReal(nSigma)))*SQR(-rL + cctk_time + + ToReal(t0))))) + CUB(rL + cctk_time + + ToReal(t0))*exp(-(INV(SQR(ToReal(nSigma)))*SQR(rL + cctk_time + + ToReal(t0)))))*INV(rEps); + + CCTK_REAL piExactL = + INV(rEps)*(INV(SQR(ToReal(nSigma)))*(2*exp(-(INV(SQR(ToReal(nSigma)))*SQR(-rL + + cctk_time + ToReal(t0))))*QAD(-rL + cctk_time + ToReal(t0)) - + 2*exp(-(INV(SQR(ToReal(nSigma)))*SQR(rL + cctk_time + ToReal(t0))))*QAD(rL + + cctk_time + ToReal(t0))) - 3*exp(-(INV(SQR(ToReal(nSigma)))*SQR(-rL + cctk_time + + ToReal(t0))))*SQR(-rL + cctk_time + ToReal(t0)) + + 3*exp(-(INV(SQR(ToReal(nSigma)))*SQR(rL + cctk_time + ToReal(t0))))*SQR(rL + + cctk_time + ToReal(t0))); + + /* Copy local copies back to grid functions */ + phiExact[index] = phiExactL; + piExact[index] = piExactL; + } + } + } +} + +extern "C" void wave_exact_gaussian(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &wave_exact_gaussian_Body); +} diff --git a/Examples/Wave/src/wave_exact_sine.cc b/Examples/Wave/src/wave_exact_sine.cc new file mode 100644 index 0000000..96e788a --- /dev/null +++ b/Examples/Wave/src/wave_exact_sine.cc @@ -0,0 +1,150 @@ +/* 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" + +/* 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 wave_exact_sine_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 wave_exact_sine_Body"); + } + + if (cctk_iteration % wave_exact_sine_calc_every != wave_exact_sine_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::exact","grid::coordinates"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_exact_sine", 2, 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 p1o4dx2 = 0.25*INV(SQR(dx)); + CCTK_REAL const p1o4dxdy = 0.25*INV(dx)*INV(dy); + CCTK_REAL const p1o4dxdz = 0.25*INV(dx)*INV(dz); + CCTK_REAL const p1o4dy2 = 0.25*INV(SQR(dy)); + CCTK_REAL const p1o4dydz = 0.25*INV(dy)*INV(dz); + CCTK_REAL const p1o4dz2 = 0.25*INV(SQR(dz)); + CCTK_REAL const p1odx = INV(dx); + CCTK_REAL const p1odx2 = INV(SQR(dx)); + CCTK_REAL const p1odxdydz = INV(dx)*INV(dy)*INV(dz); + 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)); + CCTK_REAL const pm1o2dx = -0.5*INV(dx); + CCTK_REAL const pm1o2dy = -0.5*INV(dy); + CCTK_REAL const pm1o2dz = -0.5*INV(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]; + CCTK_REAL zL = z[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL piconst = 3.1415926535897932385; + + CCTK_REAL phiExactL = + Sin(2*piconst*INV(ToReal(periodicity))*(-(cctk_time*sqrt(SQR(ToReal(n1)) + + SQR(ToReal(n2)) + SQR(ToReal(n3)))) + xL*ToReal(n1) + yL*ToReal(n2) + + zL*ToReal(n3)))*ToReal(amplitude); + + CCTK_REAL piExactL = + -2*piconst*Cos(2*piconst*INV(ToReal(periodicity))*(-(cctk_time*sqrt(SQR(ToReal(n1)) + + SQR(ToReal(n2)) + SQR(ToReal(n3)))) + xL*ToReal(n1) + yL*ToReal(n2) + + zL*ToReal(n3)))*INV(ToReal(periodicity))*sqrt(SQR(ToReal(n1)) + + SQR(ToReal(n2)) + SQR(ToReal(n3)))*ToReal(amplitude); + + /* Copy local copies back to grid functions */ + phiExact[index] = phiExactL; + piExact[index] = piExactL; + } + } + } +} + +extern "C" void wave_exact_sine(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &wave_exact_sine_Body); +} diff --git a/Examples/Wave/src/wave_import_exact.cc b/Examples/Wave/src/wave_import_exact.cc new file mode 100644 index 0000000..8263c88 --- /dev/null +++ b/Examples/Wave/src/wave_import_exact.cc @@ -0,0 +1,140 @@ +/* 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" + +/* 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 wave_import_exact_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 wave_import_exact_Body"); + } + + if (cctk_iteration % wave_import_exact_calc_every != wave_import_exact_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::evolved","Wave::exact"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_import_exact", 2, 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 p1o4dx2 = 0.25*INV(SQR(dx)); + CCTK_REAL const p1o4dxdy = 0.25*INV(dx)*INV(dy); + CCTK_REAL const p1o4dxdz = 0.25*INV(dx)*INV(dz); + CCTK_REAL const p1o4dy2 = 0.25*INV(SQR(dy)); + CCTK_REAL const p1o4dydz = 0.25*INV(dy)*INV(dz); + CCTK_REAL const p1o4dz2 = 0.25*INV(SQR(dz)); + CCTK_REAL const p1odx = INV(dx); + CCTK_REAL const p1odx2 = INV(SQR(dx)); + CCTK_REAL const p1odxdydz = INV(dx)*INV(dy)*INV(dz); + 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)); + CCTK_REAL const pm1o2dx = -0.5*INV(dx); + CCTK_REAL const pm1o2dy = -0.5*INV(dy); + CCTK_REAL const pm1o2dz = -0.5*INV(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 phiExactL = phiExact[index]; + CCTK_REAL piExactL = piExact[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL phiL = phiExactL; + + CCTK_REAL piL = piExactL; + + /* Copy local copies back to grid functions */ + phi[index] = phiL; + pi[index] = piL; + } + } + } +} + +extern "C" void wave_import_exact(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &wave_import_exact_Body); +} |