diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2011-12-15 17:52:49 +0100 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2011-12-15 17:52:49 +0100 |
commit | 66a50302592d30e421babe0ff8446c717c272d9a (patch) | |
tree | e4aacaa9d9f1c10b3a73eabf4ed8d3cb3a3f8966 /Examples | |
parent | 0f41e814e8b6342f9b64f295b40536ba327950b0 (diff) |
Euler example: Add generated thorn
Diffstat (limited to 'Examples')
-rw-r--r-- | Examples/Euler/configuration.ccl | 3 | ||||
-rw-r--r-- | Examples/Euler/interface.ccl | 187 | ||||
-rw-r--r-- | Examples/Euler/param.ccl | 449 | ||||
-rw-r--r-- | Examples/Euler/schedule.ccl | 269 | ||||
-rw-r--r-- | Examples/Euler/src/Boundaries.cc | 457 | ||||
-rw-r--r-- | Examples/Euler/src/Differencing.h | 42 | ||||
-rw-r--r-- | Examples/Euler/src/RegisterMoL.cc | 21 | ||||
-rw-r--r-- | Examples/Euler/src/RegisterSymmetries.cc | 194 | ||||
-rw-r--r-- | Examples/Euler/src/Startup.cc | 10 | ||||
-rw-r--r-- | Examples/Euler/src/euler_conserved.cc | 149 | ||||
-rw-r--r-- | Examples/Euler/src/euler_conserved_flux_1.cc | 170 | ||||
-rw-r--r-- | Examples/Euler/src/euler_flux_1.cc | 208 | ||||
-rw-r--r-- | Examples/Euler/src/euler_initial_shock.cc | 147 | ||||
-rw-r--r-- | Examples/Euler/src/euler_primitives.cc | 149 | ||||
-rw-r--r-- | Examples/Euler/src/euler_reconstruct_1.cc | 231 | ||||
-rw-r--r-- | Examples/Euler/src/euler_rhs_1.cc | 177 | ||||
-rw-r--r-- | Examples/Euler/src/euler_zero_rhs.cc | 143 | ||||
-rw-r--r-- | Examples/Euler/src/make.code.defn | 3 |
18 files changed, 3009 insertions, 0 deletions
diff --git a/Examples/Euler/configuration.ccl b/Examples/Euler/configuration.ccl new file mode 100644 index 0000000..023aac7 --- /dev/null +++ b/Examples/Euler/configuration.ccl @@ -0,0 +1,3 @@ +# File produced by Kranc + +REQUIRES GenericFD diff --git a/Examples/Euler/interface.ccl b/Examples/Euler/interface.ccl new file mode 100644 index 0000000..14f077c --- /dev/null +++ b/Examples/Euler/interface.ccl @@ -0,0 +1,187 @@ +# File produced by Kranc + +implements: Euler + +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 DenF_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + DenF +} "DenF_group" + +public: +CCTK_REAL DenLeft_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + DenLeft +} "DenLeft_group" + +public: +CCTK_REAL DenRight_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + DenRight +} "DenRight_group" + +public: +CCTK_REAL EnF_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + EnF +} "EnF_group" + +public: +CCTK_REAL EnLeft_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + EnLeft +} "EnLeft_group" + +public: +CCTK_REAL EnRight_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + EnRight +} "EnRight_group" + +public: +CCTK_REAL p_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + p +} "p_group" + +public: +CCTK_REAL pLeft_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + pLeft +} "pLeft_group" + +public: +CCTK_REAL pRight_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + pRight +} "pRight_group" + +public: +CCTK_REAL rho_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + rho +} "rho_group" + +public: +CCTK_REAL rhoLeft_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + rhoLeft +} "rhoLeft_group" + +public: +CCTK_REAL rhoRight_group type=GF timelevels=1 tags='tensortypealias="Scalar" tensorweight=0' +{ + rhoRight +} "rhoRight_group" + +public: +CCTK_REAL SF_group type=GF timelevels=1 tags='tensortypealias="U" tensorweight=0' +{ + SF1, + SF2, + SF3 +} "SF_group" + +public: +CCTK_REAL SLeft_group type=GF timelevels=1 tags='tensortypealias="U" tensorweight=0' +{ + SLeft1, + SLeft2, + SLeft3 +} "SLeft_group" + +public: +CCTK_REAL SRight_group type=GF timelevels=1 tags='tensortypealias="U" tensorweight=0' +{ + SRight1, + SRight2, + SRight3 +} "SRight_group" + +public: +CCTK_REAL v_group type=GF timelevels=1 tags='tensortypealias="U" tensorweight=0' +{ + v1, + v2, + v3 +} "v_group" + +public: +CCTK_REAL vLeft_group type=GF timelevels=1 tags='tensortypealias="U" tensorweight=0' +{ + vLeft1, + vLeft2, + vLeft3 +} "vLeft_group" + +public: +CCTK_REAL vRight_group type=GF timelevels=1 tags='tensortypealias="U" tensorweight=0' +{ + vRight1, + vRight2, + vRight3 +} "vRight_group" + +public: +CCTK_REAL Den_group type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0' +{ + Den +} "Den_group" + +public: +CCTK_REAL En_group type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0' +{ + En +} "En_group" + +public: +CCTK_REAL S_group type=GF timelevels=3 tags='tensortypealias="U" tensorweight=0' +{ + S1, + S2, + S3 +} "S_group" + +public: +CCTK_REAL Den_grouprhs type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0' +{ + Denrhs +} "Den_grouprhs" + +public: +CCTK_REAL En_grouprhs type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0' +{ + Enrhs +} "En_grouprhs" + +public: +CCTK_REAL S_grouprhs type=GF timelevels=3 tags='tensortypealias="U" tensorweight=0' +{ + S1rhs, + S2rhs, + S3rhs +} "S_grouprhs" diff --git a/Examples/Euler/param.ccl b/Examples/Euler/param.ccl new file mode 100644 index 0000000..7475248 --- /dev/null +++ b/Examples/Euler/param.ccl @@ -0,0 +1,449 @@ +# 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 v0 "v0" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL amp "amp" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL rhoR0 "rhoR0" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL rhoL0 "rhoL0" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL vR0 "vR0" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL vL0 "vL0" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL pR0 "pR0" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL pL0 "pL0" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL gamma "gamma" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL alpha "alpha" +{ + "*:*" :: "" +} 0 + +restricted: +CCTK_REAL hlleAlpha "hlleAlpha" +{ + "*:*" :: "" +} 0 + +private: +KEYWORD initial_data "initial_data" +{ + "shock" :: "shock" +} "shock" + +restricted: +CCTK_INT Euler_MaxNumEvolvedVars "Number of evolved variables used by this thorn" ACCUMULATOR-BASE=MethodofLines::MoL_Num_Evolved_Vars STEERABLE=RECOVER +{ + 5:5 :: "Number of evolved variables used by this thorn" +} 5 + +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 euler_initial_shock_calc_every "euler_initial_shock_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT euler_primitives_calc_every "euler_primitives_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT euler_conserved_calc_every "euler_conserved_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT euler_zero_rhs_calc_every "euler_zero_rhs_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT euler_reconstruct_1_calc_every "euler_reconstruct_1_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT euler_conserved_flux_1_calc_every "euler_conserved_flux_1_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT euler_flux_1_calc_every "euler_flux_1_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT euler_rhs_1_calc_every "euler_rhs_1_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT euler_initial_shock_calc_offset "euler_initial_shock_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT euler_primitives_calc_offset "euler_primitives_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT euler_conserved_calc_offset "euler_conserved_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT euler_zero_rhs_calc_offset "euler_zero_rhs_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT euler_reconstruct_1_calc_offset "euler_reconstruct_1_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT euler_conserved_flux_1_calc_offset "euler_conserved_flux_1_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT euler_flux_1_calc_offset "euler_flux_1_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT euler_rhs_1_calc_offset "euler_rhs_1_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +private: +KEYWORD Den_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 En_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 S1_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 S2_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 S3_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 Den_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 En_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 S_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 Den_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL En_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL S1_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL S2_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL S3_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL Den_group_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL En_group_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL S_group_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL Den_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL En_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL S1_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL S2_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL S3_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL Den_group_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL En_group_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL S_group_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL Den_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + +private: +CCTK_REAL En_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + +private: +CCTK_REAL S1_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + +private: +CCTK_REAL S2_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + +private: +CCTK_REAL S3_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + +private: +CCTK_REAL Den_group_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + +private: +CCTK_REAL En_group_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + +private: +CCTK_REAL S_group_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + diff --git a/Examples/Euler/schedule.ccl b/Examples/Euler/schedule.ccl new file mode 100644 index 0000000..d65c9f2 --- /dev/null +++ b/Examples/Euler/schedule.ccl @@ -0,0 +1,269 @@ +# File produced by Kranc + + +STORAGE: DenF_group[1] + +STORAGE: DenLeft_group[1] + +STORAGE: DenRight_group[1] + +STORAGE: EnF_group[1] + +STORAGE: EnLeft_group[1] + +STORAGE: EnRight_group[1] + +STORAGE: p_group[1] + +STORAGE: pLeft_group[1] + +STORAGE: pRight_group[1] + +STORAGE: rho_group[1] + +STORAGE: rhoLeft_group[1] + +STORAGE: rhoRight_group[1] + +STORAGE: SF_group[1] + +STORAGE: SLeft_group[1] + +STORAGE: SRight_group[1] + +STORAGE: v_group[1] + +STORAGE: vLeft_group[1] + +STORAGE: vRight_group[1] + +if (timelevels == 1) +{ + STORAGE: Den_group[1] +} +if (timelevels == 2) +{ + STORAGE: Den_group[2] +} +if (timelevels == 3) +{ + STORAGE: Den_group[3] +} + +if (timelevels == 1) +{ + STORAGE: En_group[1] +} +if (timelevels == 2) +{ + STORAGE: En_group[2] +} +if (timelevels == 3) +{ + STORAGE: En_group[3] +} + +if (timelevels == 1) +{ + STORAGE: S_group[1] +} +if (timelevels == 2) +{ + STORAGE: S_group[2] +} +if (timelevels == 3) +{ + STORAGE: S_group[3] +} + +if (rhs_timelevels == 1) +{ + STORAGE: Den_grouprhs[1] +} +if (rhs_timelevels == 2) +{ + STORAGE: Den_grouprhs[2] +} +if (rhs_timelevels == 3) +{ + STORAGE: Den_grouprhs[3] +} + +if (rhs_timelevels == 1) +{ + STORAGE: En_grouprhs[1] +} +if (rhs_timelevels == 2) +{ + STORAGE: En_grouprhs[2] +} +if (rhs_timelevels == 3) +{ + STORAGE: En_grouprhs[3] +} + +if (rhs_timelevels == 1) +{ + STORAGE: S_grouprhs[1] +} +if (rhs_timelevels == 2) +{ + STORAGE: S_grouprhs[2] +} +if (rhs_timelevels == 3) +{ + STORAGE: S_grouprhs[3] +} + +schedule Euler_Startup at STARTUP +{ + LANG: C + OPTIONS: meta +} "create banner" + +schedule Euler_RegisterVars in MoL_Register +{ + LANG: C + OPTIONS: meta +} "Register Variables for MoL" + +schedule Euler_RegisterSymmetries in SymmetryRegister +{ + LANG: C + OPTIONS: meta +} "register symmetries" + + +if (CCTK_EQUALS(initial_data, "shock")) +{ + schedule euler_initial_shock at CCTK_INITIAL as euler_initial + { + LANG: C + } "euler_initial_shock" +} + +schedule euler_primitives in MoL_PostStep after Euler_ApplyBCs +{ + LANG: C +} "euler_primitives" + +schedule euler_conserved at INITIAL after euler_initial +{ + LANG: C +} "euler_conserved" + +schedule euler_zero_rhs in MoL_CalcRHS +{ + LANG: C +} "euler_zero_rhs" + +schedule group euler_reconstruct_1_group in MoL_CalcRHS after euler_zero_rhs +{ + # no language specified +} "euler_reconstruct_1" + +schedule euler_reconstruct_1 in euler_reconstruct_1_group +{ + LANG: C +} "euler_reconstruct_1" + +schedule euler_reconstruct_1_SelectBCs in euler_reconstruct_1_bc_group +{ + LANG: C + OPTIONS: level + SYNC: pLeft_group + SYNC: pRight_group + SYNC: rhoLeft_group + SYNC: rhoRight_group + SYNC: vLeft_group + SYNC: vRight_group +} "euler_reconstruct_1_SelectBCs" + +schedule group ApplyBCs as euler_reconstruct_1_ApplyBCs in euler_reconstruct_1_bc_group after euler_reconstruct_1_SelectBCs +{ + # no language specified +} "Apply BCs for groups set in euler_reconstruct_1" + +schedule group euler_reconstruct_1_bc_group in euler_reconstruct_1_group after euler_reconstruct_1 +{ + # no language specified +} "euler_reconstruct_1" + +schedule group euler_reconstruct_1_bc_group at CCTK_POSTRESTRICT +{ + # no language specified +} "euler_reconstruct_1" + +schedule group euler_reconstruct_1_bc_group at CCTK_POSTRESTRICTINITIAL +{ + # no language specified +} "euler_reconstruct_1" + +schedule euler_conserved_flux_1 in MoL_CalcRHS after euler_reconstruct_1 +{ + LANG: C +} "euler_conserved_flux_1" + +schedule group euler_flux_1_group in MoL_CalcRHS after euler_conserved_flux_1 +{ + # no language specified +} "euler_flux_1" + +schedule euler_flux_1 in euler_flux_1_group +{ + LANG: C +} "euler_flux_1" + +schedule euler_flux_1_SelectBCs in euler_flux_1_bc_group +{ + LANG: C + OPTIONS: level + SYNC: DenF_group + SYNC: EnF_group + SYNC: SF_group +} "euler_flux_1_SelectBCs" + +schedule group ApplyBCs as euler_flux_1_ApplyBCs in euler_flux_1_bc_group after euler_flux_1_SelectBCs +{ + # no language specified +} "Apply BCs for groups set in euler_flux_1" + +schedule group euler_flux_1_bc_group in euler_flux_1_group after euler_flux_1 +{ + # no language specified +} "euler_flux_1" + +schedule group euler_flux_1_bc_group at CCTK_POSTRESTRICT +{ + # no language specified +} "euler_flux_1" + +schedule group euler_flux_1_bc_group at CCTK_POSTRESTRICTINITIAL +{ + # no language specified +} "euler_flux_1" + +schedule euler_rhs_1 in MoL_CalcRHS after euler_flux_1 +{ + LANG: C +} "euler_rhs_1" + +schedule Euler_SelectBoundConds in MoL_PostStep +{ + LANG: C + OPTIONS: level + SYNC: Den_group + SYNC: En_group + SYNC: S_group +} "select boundary conditions" + +schedule Euler_CheckBoundaries at BASEGRID +{ + LANG: C + OPTIONS: meta +} "check boundaries treatment" + +schedule group ApplyBCs as Euler_ApplyBCs in MoL_PostStep after Euler_SelectBoundConds +{ + # no language specified +} "Apply boundary conditions controlled by thorn Boundary" diff --git a/Examples/Euler/src/Boundaries.cc b/Examples/Euler/src/Boundaries.cc new file mode 100644 index 0000000..136e219 --- /dev/null +++ b/Examples/Euler/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 Euler_CheckBoundaries(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + return; +} + +extern "C" void Euler_SelectBoundConds(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + CCTK_INT ierr = 0; + + if (CCTK_EQUALS(Den_group_bound, "none" ) || + CCTK_EQUALS(Den_group_bound, "static") || + CCTK_EQUALS(Den_group_bound, "flat" ) || + CCTK_EQUALS(Den_group_bound, "zero" ) ) + { + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "Euler::Den_group", Den_group_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register Den_group_bound BC for Euler::Den_group!"); + } + + if (CCTK_EQUALS(En_group_bound, "none" ) || + CCTK_EQUALS(En_group_bound, "static") || + CCTK_EQUALS(En_group_bound, "flat" ) || + CCTK_EQUALS(En_group_bound, "zero" ) ) + { + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "Euler::En_group", En_group_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register En_group_bound BC for Euler::En_group!"); + } + + if (CCTK_EQUALS(S_group_bound, "none" ) || + CCTK_EQUALS(S_group_bound, "static") || + CCTK_EQUALS(S_group_bound, "flat" ) || + CCTK_EQUALS(S_group_bound, "zero" ) ) + { + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "Euler::S_group", S_group_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register S_group_bound BC for Euler::S_group!"); + } + + if (CCTK_EQUALS(Den_bound, "none" ) || + CCTK_EQUALS(Den_bound, "static") || + CCTK_EQUALS(Den_bound, "flat" ) || + CCTK_EQUALS(Den_bound, "zero" ) ) + { + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "Euler::Den", Den_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register Den_bound BC for Euler::Den!"); + } + + if (CCTK_EQUALS(En_bound, "none" ) || + CCTK_EQUALS(En_bound, "static") || + CCTK_EQUALS(En_bound, "flat" ) || + CCTK_EQUALS(En_bound, "zero" ) ) + { + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "Euler::En", En_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register En_bound BC for Euler::En!"); + } + + if (CCTK_EQUALS(S1_bound, "none" ) || + CCTK_EQUALS(S1_bound, "static") || + CCTK_EQUALS(S1_bound, "flat" ) || + CCTK_EQUALS(S1_bound, "zero" ) ) + { + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "Euler::S1", S1_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register S1_bound BC for Euler::S1!"); + } + + if (CCTK_EQUALS(S2_bound, "none" ) || + CCTK_EQUALS(S2_bound, "static") || + CCTK_EQUALS(S2_bound, "flat" ) || + CCTK_EQUALS(S2_bound, "zero" ) ) + { + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "Euler::S2", S2_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register S2_bound BC for Euler::S2!"); + } + + if (CCTK_EQUALS(S3_bound, "none" ) || + CCTK_EQUALS(S3_bound, "static") || + CCTK_EQUALS(S3_bound, "flat" ) || + CCTK_EQUALS(S3_bound, "zero" ) ) + { + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "Euler::S3", S3_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register S3_bound BC for Euler::S3!"); + } + + if (CCTK_EQUALS(Den_group_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_Den_group_bound = -1; + if (handle_Den_group_bound < 0) handle_Den_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_Den_group_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_Den_group_bound , Den_group_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_Den_group_bound ,Den_group_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_Den_group_bound, + "Euler::Den_group", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for Euler::Den_group!"); + + } + + if (CCTK_EQUALS(En_group_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_En_group_bound = -1; + if (handle_En_group_bound < 0) handle_En_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_En_group_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_En_group_bound , En_group_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_En_group_bound ,En_group_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_En_group_bound, + "Euler::En_group", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for Euler::En_group!"); + + } + + if (CCTK_EQUALS(S_group_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_S_group_bound = -1; + if (handle_S_group_bound < 0) handle_S_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_S_group_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_S_group_bound , S_group_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_S_group_bound ,S_group_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_S_group_bound, + "Euler::S_group", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for Euler::S_group!"); + + } + + if (CCTK_EQUALS(Den_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_Den_bound = -1; + if (handle_Den_bound < 0) handle_Den_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_Den_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_Den_bound , Den_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_Den_bound ,Den_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_Den_bound, + "Euler::Den", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for Euler::Den!"); + + } + + if (CCTK_EQUALS(En_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_En_bound = -1; + if (handle_En_bound < 0) handle_En_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_En_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_En_bound , En_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_En_bound ,En_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_En_bound, + "Euler::En", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for Euler::En!"); + + } + + if (CCTK_EQUALS(S1_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_S1_bound = -1; + if (handle_S1_bound < 0) handle_S1_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_S1_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_S1_bound , S1_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_S1_bound ,S1_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_S1_bound, + "Euler::S1", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for Euler::S1!"); + + } + + if (CCTK_EQUALS(S2_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_S2_bound = -1; + if (handle_S2_bound < 0) handle_S2_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_S2_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_S2_bound , S2_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_S2_bound ,S2_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_S2_bound, + "Euler::S2", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for Euler::S2!"); + + } + + if (CCTK_EQUALS(S3_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_S3_bound = -1; + if (handle_S3_bound < 0) handle_S3_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_S3_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_S3_bound , S3_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_S3_bound ,S3_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_S3_bound, + "Euler::S3", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for Euler::S3!"); + + } + + if (CCTK_EQUALS(Den_group_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_Den_group_bound = -1; + if (handle_Den_group_bound < 0) handle_Den_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_Den_group_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_Den_group_bound ,Den_group_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_Den_group_bound, + "Euler::Den_group", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Scalar BC for Euler::Den_group!"); + + } + + if (CCTK_EQUALS(En_group_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_En_group_bound = -1; + if (handle_En_group_bound < 0) handle_En_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_En_group_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_En_group_bound ,En_group_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_En_group_bound, + "Euler::En_group", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Scalar BC for Euler::En_group!"); + + } + + if (CCTK_EQUALS(S_group_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_S_group_bound = -1; + if (handle_S_group_bound < 0) handle_S_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_S_group_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_S_group_bound ,S_group_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_S_group_bound, + "Euler::S_group", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Scalar BC for Euler::S_group!"); + + } + + if (CCTK_EQUALS(Den_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_Den_bound = -1; + if (handle_Den_bound < 0) handle_Den_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_Den_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_Den_bound ,Den_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_Den_bound, + "Euler::Den", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for Euler::Den!"); + + } + + if (CCTK_EQUALS(En_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_En_bound = -1; + if (handle_En_bound < 0) handle_En_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_En_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_En_bound ,En_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_En_bound, + "Euler::En", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for Euler::En!"); + + } + + if (CCTK_EQUALS(S1_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_S1_bound = -1; + if (handle_S1_bound < 0) handle_S1_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_S1_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_S1_bound ,S1_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_S1_bound, + "Euler::S1", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for Euler::S1!"); + + } + + if (CCTK_EQUALS(S2_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_S2_bound = -1; + if (handle_S2_bound < 0) handle_S2_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_S2_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_S2_bound ,S2_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_S2_bound, + "Euler::S2", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for Euler::S2!"); + + } + + if (CCTK_EQUALS(S3_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_S3_bound = -1; + if (handle_S3_bound < 0) handle_S3_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_S3_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_S3_bound ,S3_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_S3_bound, + "Euler::S3", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for Euler::S3!"); + + } + return; +} + + + +/* template for entries in parameter file: +#$bound$#Euler::Den_group_bound = "skip" +#$bound$#Euler::Den_group_bound_speed = 1.0 +#$bound$#Euler::Den_group_bound_limit = 0.0 +#$bound$#Euler::Den_group_bound_scalar = 0.0 + +#$bound$#Euler::En_group_bound = "skip" +#$bound$#Euler::En_group_bound_speed = 1.0 +#$bound$#Euler::En_group_bound_limit = 0.0 +#$bound$#Euler::En_group_bound_scalar = 0.0 + +#$bound$#Euler::S_group_bound = "skip" +#$bound$#Euler::S_group_bound_speed = 1.0 +#$bound$#Euler::S_group_bound_limit = 0.0 +#$bound$#Euler::S_group_bound_scalar = 0.0 + +#$bound$#Euler::Den_bound = "skip" +#$bound$#Euler::Den_bound_speed = 1.0 +#$bound$#Euler::Den_bound_limit = 0.0 +#$bound$#Euler::Den_bound_scalar = 0.0 + +#$bound$#Euler::En_bound = "skip" +#$bound$#Euler::En_bound_speed = 1.0 +#$bound$#Euler::En_bound_limit = 0.0 +#$bound$#Euler::En_bound_scalar = 0.0 + +#$bound$#Euler::S1_bound = "skip" +#$bound$#Euler::S1_bound_speed = 1.0 +#$bound$#Euler::S1_bound_limit = 0.0 +#$bound$#Euler::S1_bound_scalar = 0.0 + +#$bound$#Euler::S2_bound = "skip" +#$bound$#Euler::S2_bound_speed = 1.0 +#$bound$#Euler::S2_bound_limit = 0.0 +#$bound$#Euler::S2_bound_scalar = 0.0 + +#$bound$#Euler::S3_bound = "skip" +#$bound$#Euler::S3_bound_speed = 1.0 +#$bound$#Euler::S3_bound_limit = 0.0 +#$bound$#Euler::S3_bound_scalar = 0.0 + +*/ + diff --git a/Examples/Euler/src/Differencing.h b/Examples/Euler/src/Differencing.h new file mode 100644 index 0000000..7129217 --- /dev/null +++ b/Examples/Euler/src/Differencing.h @@ -0,0 +1,42 @@ +#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*dir(1))+dj*(0)+dk*(0)] - 4*(u)[di*(dir(1))+dj*(0)+dk*(0)])*dir(1)) +#define PDonesided2nd2(u) (pm1o2dy*(3*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(2*dir(2))+dk*(0)] - 4*(u)[di*(0)+dj*(dir(2))+dk*(0)])*dir(2)) +#define PDonesided2nd3(u) (pm1o2dz*(3*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(2*dir(3))] - 4*(u)[di*(0)+dj*(0)+dk*(dir(3))])*dir(3)) +#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 PDminus1(u) (p1odx*((u)[di*(0)+dj*(0)+dk*(0)] - (u)[di*(-1)+dj*(0)+dk*(0)])) +#define PDminus2(u) (p1ody*((u)[di*(0)+dj*(0)+dk*(0)] - (u)[di*(0)+dj*(-1)+dk*(0)])) +#define PDminus3(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/Euler/src/RegisterMoL.cc b/Examples/Euler/src/RegisterMoL.cc new file mode 100644 index 0000000..c6bc9a5 --- /dev/null +++ b/Examples/Euler/src/RegisterMoL.cc @@ -0,0 +1,21 @@ +/* File produced by Kranc */ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +extern "C" void Euler_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("Euler::Den"), CCTK_VarIndex("Euler::Denrhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("Euler::En"), CCTK_VarIndex("Euler::Enrhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("Euler::S1"), CCTK_VarIndex("Euler::S1rhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("Euler::S2"), CCTK_VarIndex("Euler::S2rhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("Euler::S3"), CCTK_VarIndex("Euler::S3rhs")); + return; +} diff --git a/Examples/Euler/src/RegisterSymmetries.cc b/Examples/Euler/src/RegisterSymmetries.cc new file mode 100644 index 0000000..18fc370 --- /dev/null +++ b/Examples/Euler/src/RegisterSymmetries.cc @@ -0,0 +1,194 @@ +/* File produced by Kranc */ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" +#include "Symmetry.h" + +extern "C" void Euler_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, "Euler::Den"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::En"); + + sym[0] = -1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::S1"); + + sym[0] = 1; + sym[1] = -1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::S2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = -1; + SetCartSymVN(cctkGH, sym, "Euler::S3"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::DenF"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::DenLeft"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::DenRight"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::EnF"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::EnLeft"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::EnRight"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::p"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::pLeft"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::pRight"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::rho"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::rhoLeft"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::rhoRight"); + + sym[0] = -1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::SF1"); + + sym[0] = 1; + sym[1] = -1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::SF2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = -1; + SetCartSymVN(cctkGH, sym, "Euler::SF3"); + + sym[0] = -1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::SLeft1"); + + sym[0] = 1; + sym[1] = -1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::SLeft2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = -1; + SetCartSymVN(cctkGH, sym, "Euler::SLeft3"); + + sym[0] = -1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::SRight1"); + + sym[0] = 1; + sym[1] = -1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::SRight2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = -1; + SetCartSymVN(cctkGH, sym, "Euler::SRight3"); + + sym[0] = -1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::v1"); + + sym[0] = 1; + sym[1] = -1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::v2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = -1; + SetCartSymVN(cctkGH, sym, "Euler::v3"); + + sym[0] = -1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::vLeft1"); + + sym[0] = 1; + sym[1] = -1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::vLeft2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = -1; + SetCartSymVN(cctkGH, sym, "Euler::vLeft3"); + + sym[0] = -1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::vRight1"); + + sym[0] = 1; + sym[1] = -1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "Euler::vRight2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = -1; + SetCartSymVN(cctkGH, sym, "Euler::vRight3"); + +} diff --git a/Examples/Euler/src/Startup.cc b/Examples/Euler/src/Startup.cc new file mode 100644 index 0000000..88708d0 --- /dev/null +++ b/Examples/Euler/src/Startup.cc @@ -0,0 +1,10 @@ +/* File produced by Kranc */ + +#include "cctk.h" + +extern "C" int Euler_Startup(void) +{ + const char * banner = "Euler"; + CCTK_RegisterBanner(banner); + return 0; +} diff --git a/Examples/Euler/src/euler_conserved.cc b/Examples/Euler/src/euler_conserved.cc new file mode 100644 index 0000000..4b8252e --- /dev/null +++ b/Examples/Euler/src/euler_conserved.cc @@ -0,0 +1,149 @@ +/* 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 euler_conserved_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 euler_conserved_Body"); + } + + if (cctk_iteration % euler_conserved_calc_every != euler_conserved_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::Den_group","Euler::En_group","Euler::p_group","Euler::rho_group","Euler::S_group","Euler::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_conserved", 6, 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)); + 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 pL = p[index]; + CCTK_REAL rhoL = rho[index]; + CCTK_REAL v1L = v1[index]; + CCTK_REAL v2L = v2[index]; + CCTK_REAL v3L = v3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenL = rhoL; + + CCTK_REAL S1L = rhoL*v1L; + + CCTK_REAL S2L = rhoL*v2L; + + CCTK_REAL S3L = rhoL*v3L; + + CCTK_REAL EnL = pL*INV(-1 + ToReal(gamma)) + 0.5*rhoL*(SQR(v1L) + + SQR(v2L) + SQR(v3L)); + + /* Copy local copies back to grid functions */ + Den[index] = DenL; + En[index] = EnL; + S1[index] = S1L; + S2[index] = S2L; + S3[index] = S3L; + } + } + } +} + +extern "C" void euler_conserved(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &euler_conserved_Body); +} diff --git a/Examples/Euler/src/euler_conserved_flux_1.cc b/Examples/Euler/src/euler_conserved_flux_1.cc new file mode 100644 index 0000000..c6ab4b0 --- /dev/null +++ b/Examples/Euler/src/euler_conserved_flux_1.cc @@ -0,0 +1,170 @@ +/* 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 euler_conserved_flux_1_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 euler_conserved_flux_1_Body"); + } + + if (cctk_iteration % euler_conserved_flux_1_calc_every != euler_conserved_flux_1_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::DenLeft_group","Euler::DenRight_group","Euler::EnLeft_group","Euler::EnRight_group","Euler::pLeft_group","Euler::pRight_group","Euler::rhoLeft_group","Euler::rhoRight_group","Euler::SLeft_group","Euler::SRight_group","Euler::vLeft_group","Euler::vRight_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_conserved_flux_1", 12, 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)); + 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 pLeftL = pLeft[index]; + CCTK_REAL pRightL = pRight[index]; + CCTK_REAL rhoLeftL = rhoLeft[index]; + CCTK_REAL rhoRightL = rhoRight[index]; + CCTK_REAL vLeft1L = vLeft1[index]; + CCTK_REAL vLeft2L = vLeft2[index]; + CCTK_REAL vLeft3L = vLeft3[index]; + CCTK_REAL vRight1L = vRight1[index]; + CCTK_REAL vRight2L = vRight2[index]; + CCTK_REAL vRight3L = vRight3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenLeftL = rhoLeftL; + + CCTK_REAL DenRightL = rhoRightL; + + CCTK_REAL SLeft1L = rhoLeftL*vLeft1L; + + CCTK_REAL SLeft2L = rhoLeftL*vLeft2L; + + CCTK_REAL SLeft3L = rhoLeftL*vLeft3L; + + CCTK_REAL SRight1L = rhoRightL*vRight1L; + + CCTK_REAL SRight2L = rhoRightL*vRight2L; + + CCTK_REAL SRight3L = rhoRightL*vRight3L; + + CCTK_REAL EnLeftL = pLeftL*INV(-1 + ToReal(gamma)) + + 0.5*rhoLeftL*(SQR(vLeft1L) + SQR(vLeft2L) + SQR(vLeft3L)); + + CCTK_REAL EnRightL = pRightL*INV(-1 + ToReal(gamma)) + + 0.5*rhoRightL*(SQR(vRight1L) + SQR(vRight2L) + SQR(vRight3L)); + + /* Copy local copies back to grid functions */ + DenLeft[index] = DenLeftL; + DenRight[index] = DenRightL; + EnLeft[index] = EnLeftL; + EnRight[index] = EnRightL; + SLeft1[index] = SLeft1L; + SLeft2[index] = SLeft2L; + SLeft3[index] = SLeft3L; + SRight1[index] = SRight1L; + SRight2[index] = SRight2L; + SRight3[index] = SRight3L; + } + } + } +} + +extern "C" void euler_conserved_flux_1(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &euler_conserved_flux_1_Body); +} diff --git a/Examples/Euler/src/euler_flux_1.cc b/Examples/Euler/src/euler_flux_1.cc new file mode 100644 index 0000000..59f4eee --- /dev/null +++ b/Examples/Euler/src/euler_flux_1.cc @@ -0,0 +1,208 @@ +/* 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 euler_flux_1_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 */, "Euler::DenF_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::DenF_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "Euler::EnF_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::EnF_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "Euler::SF_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::SF_group."); + return; +} + +static void euler_flux_1_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 euler_flux_1_Body"); + } + + if (cctk_iteration % euler_flux_1_calc_every != euler_flux_1_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::DenF_group","Euler::DenLeft_group","Euler::DenRight_group","Euler::EnF_group","Euler::EnLeft_group","Euler::EnRight_group","Euler::pLeft_group","Euler::pRight_group","Euler::rhoLeft_group","Euler::rhoRight_group","Euler::SF_group","Euler::SLeft_group","Euler::SRight_group","Euler::vLeft_group","Euler::vRight_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_flux_1", 15, groups); + + GenericFD_EnsureStencilFits(cctkGH, "euler_flux_1", 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)); + 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 DenLeftL = DenLeft[index]; + CCTK_REAL DenRightL = DenRight[index]; + CCTK_REAL EnLeftL = EnLeft[index]; + CCTK_REAL EnRightL = EnRight[index]; + CCTK_REAL pLeftL = pLeft[index]; + CCTK_REAL pRightL = pRight[index]; + CCTK_REAL rhoLeftL = rhoLeft[index]; + CCTK_REAL rhoRightL = rhoRight[index]; + CCTK_REAL SLeft1L = SLeft1[index]; + CCTK_REAL SLeft2L = SLeft2[index]; + CCTK_REAL SLeft3L = SLeft3[index]; + CCTK_REAL SRight1L = SRight1[index]; + CCTK_REAL SRight2L = SRight2[index]; + CCTK_REAL SRight3L = SRight3[index]; + CCTK_REAL vLeft1L = vLeft1[index]; + CCTK_REAL vLeft2L = vLeft2[index]; + CCTK_REAL vLeft3L = vLeft3[index]; + CCTK_REAL vRight1L = vRight1[index]; + CCTK_REAL vRight2L = vRight2[index]; + CCTK_REAL vRight3L = vRight3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const ShiftMinus1DenRight = ShiftMinus1(&DenRight[index]); + CCTK_REAL const ShiftMinus1EnRight = ShiftMinus1(&EnRight[index]); + CCTK_REAL const ShiftMinus1pRight = ShiftMinus1(&pRight[index]); + CCTK_REAL const ShiftMinus1rhoRight = ShiftMinus1(&rhoRight[index]); + CCTK_REAL const ShiftMinus1SRight1 = ShiftMinus1(&SRight1[index]); + CCTK_REAL const ShiftMinus1SRight2 = ShiftMinus1(&SRight2[index]); + CCTK_REAL const ShiftMinus1SRight3 = ShiftMinus1(&SRight3[index]); + CCTK_REAL const ShiftMinus1vRight1 = ShiftMinus1(&vRight1[index]); + CCTK_REAL const ShiftMinus1vRight2 = ShiftMinus1(&vRight2[index]); + CCTK_REAL const ShiftMinus1vRight3 = ShiftMinus1(&vRight3[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL vRightTemp1 = ShiftMinus1vRight1; + + CCTK_REAL vRightTemp2 = ShiftMinus1vRight2; + + CCTK_REAL vRightTemp3 = ShiftMinus1vRight3; + + CCTK_REAL DenFL = 0.5*(rhoLeftL*vLeft1L + + ShiftMinus1rhoRight*vRightTemp1 + (-DenLeftL + + ShiftMinus1DenRight)*ToReal(alpha)); + + CCTK_REAL SF1L = 0.5*(pLeftL + ShiftMinus1pRight + + rhoLeftL*SQR(vLeft1L) + ShiftMinus1rhoRight*SQR(vRightTemp1) + + (ShiftMinus1SRight1 - SLeft1L)*ToReal(alpha)); + + CCTK_REAL SF2L = 0.5*(rhoLeftL*vLeft1L*vLeft2L + + ShiftMinus1rhoRight*vRightTemp1*vRightTemp2 + (ShiftMinus1SRight2 - + SLeft2L)*ToReal(alpha)); + + CCTK_REAL SF3L = 0.5*(rhoLeftL*vLeft1L*vLeft3L + + ShiftMinus1rhoRight*vRightTemp1*vRightTemp3 + (ShiftMinus1SRight3 - + SLeft3L)*ToReal(alpha)); + + CCTK_REAL EnFL = 0.5*((EnLeftL + pLeftL)*vLeft1L + + ShiftMinus1pRight*vRightTemp1 - EnLeftL*ToReal(alpha) + + ShiftMinus1EnRight*(vRightTemp1 + ToReal(alpha))); + + /* Copy local copies back to grid functions */ + DenF[index] = DenFL; + EnF[index] = EnFL; + SF1[index] = SF1L; + SF2[index] = SF2L; + SF3[index] = SF3L; + } + } + } +} + +extern "C" void euler_flux_1(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &euler_flux_1_Body); +} diff --git a/Examples/Euler/src/euler_initial_shock.cc b/Examples/Euler/src/euler_initial_shock.cc new file mode 100644 index 0000000..b8fe537 --- /dev/null +++ b/Examples/Euler/src/euler_initial_shock.cc @@ -0,0 +1,147 @@ +/* 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 euler_initial_shock_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 euler_initial_shock_Body"); + } + + if (cctk_iteration % euler_initial_shock_calc_every != euler_initial_shock_calc_offset) + { + return; + } + + const char *groups[] = {"grid::coordinates","Euler::p_group","Euler::rho_group","Euler::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_initial_shock", 4, 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)); + 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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL rhoL = Piecewise(List(List(ToReal(rhoL0),xL < 0.5)),0. + + ToReal(rhoR0)); + + CCTK_REAL v1L = Piecewise(List(List(ToReal(vL0),xL < 0.5)),0. + + ToReal(vR0)); + + CCTK_REAL v2L = 0; + + CCTK_REAL v3L = 0; + + CCTK_REAL pL = Piecewise(List(List(ToReal(pL0),xL < 0.5)),0. + + ToReal(pR0)); + + /* Copy local copies back to grid functions */ + p[index] = pL; + rho[index] = rhoL; + v1[index] = v1L; + v2[index] = v2L; + v3[index] = v3L; + } + } + } +} + +extern "C" void euler_initial_shock(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &euler_initial_shock_Body); +} diff --git a/Examples/Euler/src/euler_primitives.cc b/Examples/Euler/src/euler_primitives.cc new file mode 100644 index 0000000..27d26b9 --- /dev/null +++ b/Examples/Euler/src/euler_primitives.cc @@ -0,0 +1,149 @@ +/* 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 euler_primitives_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 euler_primitives_Body"); + } + + if (cctk_iteration % euler_primitives_calc_every != euler_primitives_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::Den_group","Euler::En_group","Euler::p_group","Euler::rho_group","Euler::S_group","Euler::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_primitives", 6, 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)); + 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 DenL = Den[index]; + CCTK_REAL EnL = En[index]; + CCTK_REAL S1L = S1[index]; + CCTK_REAL S2L = S2[index]; + CCTK_REAL S3L = S3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL rhoL = DenL; + + CCTK_REAL v1L = S1L*INV(DenL); + + CCTK_REAL v2L = S2L*INV(DenL); + + CCTK_REAL v3L = S3L*INV(DenL); + + CCTK_REAL pL = (EnL - 0.5*INV(DenL)*(SQR(S1L) + SQR(S2L) + + SQR(S3L)))*(-1 + ToReal(gamma)); + + /* Copy local copies back to grid functions */ + p[index] = pL; + rho[index] = rhoL; + v1[index] = v1L; + v2[index] = v2L; + v3[index] = v3L; + } + } + } +} + +extern "C" void euler_primitives(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &euler_primitives_Body); +} diff --git a/Examples/Euler/src/euler_reconstruct_1.cc b/Examples/Euler/src/euler_reconstruct_1.cc new file mode 100644 index 0000000..6fa5f9a --- /dev/null +++ b/Examples/Euler/src/euler_reconstruct_1.cc @@ -0,0 +1,231 @@ +/* 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 euler_reconstruct_1_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 */, "Euler::pLeft_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::pLeft_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "Euler::pRight_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::pRight_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "Euler::rhoLeft_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::rhoLeft_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "Euler::rhoRight_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::rhoRight_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "Euler::vLeft_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::vLeft_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "Euler::vRight_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::vRight_group."); + return; +} + +static void euler_reconstruct_1_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 euler_reconstruct_1_Body"); + } + + if (cctk_iteration % euler_reconstruct_1_calc_every != euler_reconstruct_1_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::p_group","Euler::pLeft_group","Euler::pRight_group","Euler::rho_group","Euler::rhoLeft_group","Euler::rhoRight_group","Euler::v_group","Euler::vLeft_group","Euler::vRight_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_reconstruct_1", 9, groups); + + GenericFD_EnsureStencilFits(cctkGH, "euler_reconstruct_1", 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)); + 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 pL = p[index]; + CCTK_REAL rhoL = rho[index]; + CCTK_REAL v1L = v1[index]; + CCTK_REAL v2L = v2[index]; + CCTK_REAL v3L = v3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const DiffPlus1p = DiffPlus1(&p[index]); + CCTK_REAL const DiffMinus1p = DiffMinus1(&p[index]); + CCTK_REAL const DiffPlus1rho = DiffPlus1(&rho[index]); + CCTK_REAL const DiffMinus1rho = DiffMinus1(&rho[index]); + CCTK_REAL const DiffPlus1v1 = DiffPlus1(&v1[index]); + CCTK_REAL const DiffMinus1v1 = DiffMinus1(&v1[index]); + CCTK_REAL const DiffPlus1v2 = DiffPlus1(&v2[index]); + CCTK_REAL const DiffMinus1v2 = DiffMinus1(&v2[index]); + CCTK_REAL const DiffPlus1v3 = DiffPlus1(&v3[index]); + CCTK_REAL const DiffMinus1v3 = DiffMinus1(&v3[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL slopeL = DiffMinus1rho; + + CCTK_REAL slopeR = DiffPlus1rho; + + CCTK_REAL slope = VanLeer(slopeL,slopeR); + + CCTK_REAL rhoLeftL = rhoL - 0.5*slope; + + CCTK_REAL rhoRightL = rhoL + 0.5*slope; + + slopeL = DiffMinus1v1; + + slopeR = DiffPlus1v1; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL vLeft1L = -0.5*slope + v1L; + + CCTK_REAL vRight1L = 0.5*slope + v1L; + + slopeL = DiffMinus1v2; + + slopeR = DiffPlus1v2; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL vLeft2L = -0.5*slope + v2L; + + CCTK_REAL vRight2L = 0.5*slope + v2L; + + slopeL = DiffMinus1v3; + + slopeR = DiffPlus1v3; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL vLeft3L = -0.5*slope + v3L; + + CCTK_REAL vRight3L = 0.5*slope + v3L; + + slopeL = DiffMinus1p; + + slopeR = DiffPlus1p; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL pLeftL = pL - 0.5*slope; + + CCTK_REAL pRightL = pL + 0.5*slope; + + /* Copy local copies back to grid functions */ + pLeft[index] = pLeftL; + pRight[index] = pRightL; + rhoLeft[index] = rhoLeftL; + rhoRight[index] = rhoRightL; + vLeft1[index] = vLeft1L; + vLeft2[index] = vLeft2L; + vLeft3[index] = vLeft3L; + vRight1[index] = vRight1L; + vRight2[index] = vRight2L; + vRight3[index] = vRight3L; + } + } + } +} + +extern "C" void euler_reconstruct_1(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &euler_reconstruct_1_Body); +} diff --git a/Examples/Euler/src/euler_rhs_1.cc b/Examples/Euler/src/euler_rhs_1.cc new file mode 100644 index 0000000..2467cbb --- /dev/null +++ b/Examples/Euler/src/euler_rhs_1.cc @@ -0,0 +1,177 @@ +/* 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 euler_rhs_1_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 */, "Euler::Den_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::Den_grouprhs."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "Euler::En_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::En_grouprhs."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "Euler::S_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for Euler::S_grouprhs."); + return; +} + +static void euler_rhs_1_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 euler_rhs_1_Body"); + } + + if (cctk_iteration % euler_rhs_1_calc_every != euler_rhs_1_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::DenF_group","Euler::Den_grouprhs","Euler::EnF_group","Euler::En_grouprhs","Euler::SF_group","Euler::S_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_rhs_1", 6, groups); + + GenericFD_EnsureStencilFits(cctkGH, "euler_rhs_1", 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)); + 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 DenFL = DenF[index]; + CCTK_REAL DenrhsL = Denrhs[index]; + CCTK_REAL EnFL = EnF[index]; + CCTK_REAL EnrhsL = Enrhs[index]; + CCTK_REAL S1rhsL = S1rhs[index]; + CCTK_REAL S2rhsL = S2rhs[index]; + CCTK_REAL S3rhsL = S3rhs[index]; + CCTK_REAL SF1L = SF1[index]; + CCTK_REAL SF2L = SF2[index]; + CCTK_REAL SF3L = SF3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDplus1DenF = PDplus1(&DenF[index]); + CCTK_REAL const PDplus1EnF = PDplus1(&EnF[index]); + CCTK_REAL const PDplus1SF1 = PDplus1(&SF1[index]); + CCTK_REAL const PDplus1SF2 = PDplus1(&SF2[index]); + CCTK_REAL const PDplus1SF3 = PDplus1(&SF3[index]); + + /* Calculate temporaries and grid functions */ + DenrhsL = DenrhsL - PDplus1DenF; + + S1rhsL = -PDplus1SF1 + S1rhsL; + + S2rhsL = -PDplus1SF2 + S2rhsL; + + S3rhsL = -PDplus1SF3 + S3rhsL; + + EnrhsL = EnrhsL - PDplus1EnF; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + Enrhs[index] = EnrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; + } + } + } +} + +extern "C" void euler_rhs_1(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &euler_rhs_1_Body); +} diff --git a/Examples/Euler/src/euler_zero_rhs.cc b/Examples/Euler/src/euler_zero_rhs.cc new file mode 100644 index 0000000..62157f2 --- /dev/null +++ b/Examples/Euler/src/euler_zero_rhs.cc @@ -0,0 +1,143 @@ +/* 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 euler_zero_rhs_Body(cGH const * restrict const cctkGH, int const dir, int const face, CCTK_REAL const normal[3], CCTK_REAL const tangentA[3], CCTK_REAL const tangentB[3], int const 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 euler_zero_rhs_Body"); + } + + if (cctk_iteration % euler_zero_rhs_calc_every != euler_zero_rhs_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::Den_grouprhs","Euler::En_grouprhs","Euler::S_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_zero_rhs", 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)); + 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 */ + + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenrhsL = 0; + + CCTK_REAL S1rhsL = 0; + + CCTK_REAL S2rhsL = 0; + + CCTK_REAL S3rhsL = 0; + + CCTK_REAL EnrhsL = 0; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + Enrhs[index] = EnrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; + } + } + } +} + +extern "C" void euler_zero_rhs(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &euler_zero_rhs_Body); +} diff --git a/Examples/Euler/src/make.code.defn b/Examples/Euler/src/make.code.defn new file mode 100644 index 0000000..4081620 --- /dev/null +++ b/Examples/Euler/src/make.code.defn @@ -0,0 +1,3 @@ +# File produced by Kranc + +SRCS = Startup.cc RegisterMoL.cc RegisterSymmetries.cc euler_initial_shock.cc euler_primitives.cc euler_conserved.cc euler_zero_rhs.cc euler_reconstruct_1.cc euler_conserved_flux_1.cc euler_flux_1.cc euler_rhs_1.cc Boundaries.cc |