diff options
Diffstat (limited to 'Examples/EulerSR/src')
22 files changed, 3586 insertions, 0 deletions
diff --git a/Examples/EulerSR/src/Boundaries.cc b/Examples/EulerSR/src/Boundaries.cc new file mode 100644 index 0000000..a862753 --- /dev/null +++ b/Examples/EulerSR/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 EulerSR_CheckBoundaries(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + return; +} + +extern "C" void EulerSR_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, + "EulerSR::Den_group", Den_group_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register Den_group_bound BC for EulerSR::Den_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, + "EulerSR::S_group", S_group_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register S_group_bound BC for EulerSR::S_group!"); + } + + if (CCTK_EQUALS(tau_group_bound, "none" ) || + CCTK_EQUALS(tau_group_bound, "static") || + CCTK_EQUALS(tau_group_bound, "flat" ) || + CCTK_EQUALS(tau_group_bound, "zero" ) ) + { + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "EulerSR::tau_group", tau_group_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register tau_group_bound BC for EulerSR::tau_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, + "EulerSR::Den", Den_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register Den_bound BC for EulerSR::Den!"); + } + + 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, + "EulerSR::S1", S1_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register S1_bound BC for EulerSR::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, + "EulerSR::S2", S2_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register S2_bound BC for EulerSR::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, + "EulerSR::S3", S3_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register S3_bound BC for EulerSR::S3!"); + } + + if (CCTK_EQUALS(tau_bound, "none" ) || + CCTK_EQUALS(tau_bound, "static") || + CCTK_EQUALS(tau_bound, "flat" ) || + CCTK_EQUALS(tau_bound, "zero" ) ) + { + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "EulerSR::tau", tau_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register tau_bound BC for EulerSR::tau!"); + } + + 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, + "EulerSR::Den_group", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EulerSR::Den_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, + "EulerSR::S_group", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EulerSR::S_group!"); + + } + + if (CCTK_EQUALS(tau_group_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_tau_group_bound = -1; + if (handle_tau_group_bound < 0) handle_tau_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_tau_group_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_tau_group_bound , tau_group_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_tau_group_bound ,tau_group_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_tau_group_bound, + "EulerSR::tau_group", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EulerSR::tau_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, + "EulerSR::Den", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EulerSR::Den!"); + + } + + 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, + "EulerSR::S1", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EulerSR::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, + "EulerSR::S2", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EulerSR::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, + "EulerSR::S3", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EulerSR::S3!"); + + } + + if (CCTK_EQUALS(tau_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_tau_bound = -1; + if (handle_tau_bound < 0) handle_tau_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_tau_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_tau_bound , tau_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_tau_bound ,tau_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_tau_bound, + "EulerSR::tau", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for EulerSR::tau!"); + + } + + 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, + "EulerSR::Den_group", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Scalar BC for EulerSR::Den_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, + "EulerSR::S_group", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Scalar BC for EulerSR::S_group!"); + + } + + if (CCTK_EQUALS(tau_group_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_tau_group_bound = -1; + if (handle_tau_group_bound < 0) handle_tau_group_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_tau_group_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_tau_group_bound ,tau_group_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_tau_group_bound, + "EulerSR::tau_group", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Scalar BC for EulerSR::tau_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, + "EulerSR::Den", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for EulerSR::Den!"); + + } + + 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, + "EulerSR::S1", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for EulerSR::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, + "EulerSR::S2", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for EulerSR::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, + "EulerSR::S3", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for EulerSR::S3!"); + + } + + if (CCTK_EQUALS(tau_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_tau_bound = -1; + if (handle_tau_bound < 0) handle_tau_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_tau_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_tau_bound ,tau_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_tau_bound, + "EulerSR::tau", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for EulerSR::tau!"); + + } + return; +} + + + +/* template for entries in parameter file: +#$bound$#EulerSR::Den_group_bound = "skip" +#$bound$#EulerSR::Den_group_bound_speed = 1.0 +#$bound$#EulerSR::Den_group_bound_limit = 0.0 +#$bound$#EulerSR::Den_group_bound_scalar = 0.0 + +#$bound$#EulerSR::S_group_bound = "skip" +#$bound$#EulerSR::S_group_bound_speed = 1.0 +#$bound$#EulerSR::S_group_bound_limit = 0.0 +#$bound$#EulerSR::S_group_bound_scalar = 0.0 + +#$bound$#EulerSR::tau_group_bound = "skip" +#$bound$#EulerSR::tau_group_bound_speed = 1.0 +#$bound$#EulerSR::tau_group_bound_limit = 0.0 +#$bound$#EulerSR::tau_group_bound_scalar = 0.0 + +#$bound$#EulerSR::Den_bound = "skip" +#$bound$#EulerSR::Den_bound_speed = 1.0 +#$bound$#EulerSR::Den_bound_limit = 0.0 +#$bound$#EulerSR::Den_bound_scalar = 0.0 + +#$bound$#EulerSR::S1_bound = "skip" +#$bound$#EulerSR::S1_bound_speed = 1.0 +#$bound$#EulerSR::S1_bound_limit = 0.0 +#$bound$#EulerSR::S1_bound_scalar = 0.0 + +#$bound$#EulerSR::S2_bound = "skip" +#$bound$#EulerSR::S2_bound_speed = 1.0 +#$bound$#EulerSR::S2_bound_limit = 0.0 +#$bound$#EulerSR::S2_bound_scalar = 0.0 + +#$bound$#EulerSR::S3_bound = "skip" +#$bound$#EulerSR::S3_bound_speed = 1.0 +#$bound$#EulerSR::S3_bound_limit = 0.0 +#$bound$#EulerSR::S3_bound_scalar = 0.0 + +#$bound$#EulerSR::tau_bound = "skip" +#$bound$#EulerSR::tau_bound_speed = 1.0 +#$bound$#EulerSR::tau_bound_limit = 0.0 +#$bound$#EulerSR::tau_bound_scalar = 0.0 + +*/ + diff --git a/Examples/EulerSR/src/Differencing.h b/Examples/EulerSR/src/Differencing.h new file mode 100644 index 0000000..0908172 --- /dev/null +++ b/Examples/EulerSR/src/Differencing.h @@ -0,0 +1,12 @@ +#define DiffPlus1(u) (p1o1*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) +#define DiffPlus2(u) (p1o1*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) +#define DiffPlus3(u) (p1o1*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(1)])) +#define DiffMinus1(u) (p1o1*((u)[di*(0)+dj*(0)+dk*(0)] - (u)[di*(-1)+dj*(0)+dk*(0)])) +#define DiffMinus2(u) (p1o1*((u)[di*(0)+dj*(0)+dk*(0)] - (u)[di*(0)+dj*(-1)+dk*(0)])) +#define DiffMinus3(u) (p1o1*((u)[di*(0)+dj*(0)+dk*(0)] - (u)[di*(0)+dj*(0)+dk*(-1)])) +#define ShiftMinus1(u) (p1o1*(u)[di*(-1)+dj*(0)+dk*(0)]) +#define ShiftMinus2(u) (p1o1*(u)[di*(0)+dj*(-1)+dk*(0)]) +#define ShiftMinus3(u) (p1o1*(u)[di*(0)+dj*(0)+dk*(-1)]) +#define PDplus1(u) (p1odx*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) +#define PDplus2(u) (p1ody*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) +#define PDplus3(u) (p1odz*(-(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(1)])) diff --git a/Examples/EulerSR/src/RegisterMoL.cc b/Examples/EulerSR/src/RegisterMoL.cc new file mode 100644 index 0000000..5f77b35 --- /dev/null +++ b/Examples/EulerSR/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 EulerSR_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("EulerSR::Den"), CCTK_VarIndex("EulerSR::Denrhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("EulerSR::S1"), CCTK_VarIndex("EulerSR::S1rhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("EulerSR::S2"), CCTK_VarIndex("EulerSR::S2rhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("EulerSR::S3"), CCTK_VarIndex("EulerSR::S3rhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("EulerSR::tau"), CCTK_VarIndex("EulerSR::taurhs")); + return; +} diff --git a/Examples/EulerSR/src/RegisterSymmetries.cc b/Examples/EulerSR/src/RegisterSymmetries.cc new file mode 100644 index 0000000..f3dd0d5 --- /dev/null +++ b/Examples/EulerSR/src/RegisterSymmetries.cc @@ -0,0 +1,209 @@ +/* File produced by Kranc */ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" +#include "Symmetry.h" + +extern "C" void EulerSR_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, "EulerSR::Den"); + + sym[0] = -1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::S1"); + + sym[0] = 1; + sym[1] = -1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::S2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = -1; + SetCartSymVN(cctkGH, sym, "EulerSR::S3"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::tau"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::DenFlux"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::DenLeft"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::DenRight"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::epsi"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::epsiLeft"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::epsiRight"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::h"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::p"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::rho"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::rhoLeft"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::rhoRight"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::S1Flux"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::S1Left"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::S1Right"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::S2Flux"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::S2Left"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::S2Right"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::S3Flux"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::S3Left"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::S3Right"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::tauFlux"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::tauLeft"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::tauRight"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::v1Left"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::v1Right"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::v2Left"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::v2Right"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::v3Left"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::v3Right"); + + sym[0] = -1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::v1"); + + sym[0] = 1; + sym[1] = -1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::v2"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = -1; + SetCartSymVN(cctkGH, sym, "EulerSR::v3"); + + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "EulerSR::W"); + +} diff --git a/Examples/EulerSR/src/Startup.cc b/Examples/EulerSR/src/Startup.cc new file mode 100644 index 0000000..dc65910 --- /dev/null +++ b/Examples/EulerSR/src/Startup.cc @@ -0,0 +1,10 @@ +/* File produced by Kranc */ + +#include "cctk.h" + +extern "C" int EulerSR_Startup(void) +{ + const char * banner = "EulerSR"; + CCTK_RegisterBanner(banner); + return 0; +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_conserved.cc b/Examples/EulerSR/src/eulersr_cons_calc_conserved.cc new file mode 100644 index 0000000..788478c --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_conserved.cc @@ -0,0 +1,142 @@ +/* File produced by Kranc */ + +#define KRANC_C + +#include <assert.h> +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" +#include "GenericFD.h" +#include "Differencing.h" + +/* Define macros used in calculations */ +#define INITVALUE (42) +#define QAD(x) (SQR(SQR(x))) +#define INV(x) ((1.0) / (x)) +#define SQR(x) ((x) * (x)) +#define CUB(x) ((x) * (x) * (x)) + +static void eulersr_cons_calc_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 eulersr_cons_calc_conserved_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_conserved_calc_every != eulersr_cons_calc_conserved_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_group","EulerSR::epsi_group","EulerSR::h_group","EulerSR::p_group","EulerSR::rho_group","EulerSR::S_group","EulerSR::tau_group","EulerSR::v_group","EulerSR::W_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_conserved", 9, 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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 epsiL = epsi[index]; + CCTK_REAL hL = h[index]; + 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]; + CCTK_REAL WL = W[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL Wx = 1 - SQR(v1L) - SQR(v2L) - SQR(v3L); + + WL = INV(sqrt(Wx)); + + pL = epsiL*rhoL*(-1 + ToReal(gamma)); + + hL = 1 + epsiL + pL*INV(rhoL); + + DenL = rhoL*WL; + + CCTK_REAL S1L = hL*rhoL*v1L*SQR(WL); + + CCTK_REAL S2L = hL*rhoL*v2L*SQR(WL); + + CCTK_REAL S3L = hL*rhoL*v3L*SQR(WL); + + CCTK_REAL tauL = -DenL - pL + hL*rhoL*SQR(WL); + + /* Copy local copies back to grid functions */ + Den[index] = DenL; + h[index] = hL; + p[index] = pL; + S1[index] = S1L; + S2[index] = S2L; + S3[index] = S3L; + tau[index] = tauL; + W[index] = WL; + } + } + } +} + +extern "C" void eulersr_cons_calc_conserved(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_conserved_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_flux_1.cc b/Examples/EulerSR/src/eulersr_cons_calc_flux_1.cc new file mode 100644 index 0000000..eefd139 --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_flux_1.cc @@ -0,0 +1,200 @@ +/* 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 eulersr_cons_calc_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 */, "EulerSR::Den_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::Den_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S1_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S1_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S2_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S2_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S3_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S3_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::tau_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::tau_flux_group."); + return; +} + +static void eulersr_cons_calc_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 eulersr_cons_calc_flux_1_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_flux_1_calc_every != eulersr_cons_calc_flux_1_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_flux_group","EulerSR::Den_lr_group","EulerSR::epsi_lr_group","EulerSR::rho_lr_group","EulerSR::S1_flux_group","EulerSR::S1_lr_group","EulerSR::S2_flux_group","EulerSR::S2_lr_group","EulerSR::S3_flux_group","EulerSR::S3_lr_group","EulerSR::tau_flux_group","EulerSR::tau_lr_group","EulerSR::v1_lr_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_flux_1", 13, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulersr_cons_calc_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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 epsiLeftL = epsiLeft[index]; + CCTK_REAL epsiRightL = epsiRight[index]; + CCTK_REAL rhoLeftL = rhoLeft[index]; + CCTK_REAL rhoRightL = rhoRight[index]; + CCTK_REAL S1LeftL = S1Left[index]; + CCTK_REAL S1RightL = S1Right[index]; + CCTK_REAL S2LeftL = S2Left[index]; + CCTK_REAL S2RightL = S2Right[index]; + CCTK_REAL S3LeftL = S3Left[index]; + CCTK_REAL S3RightL = S3Right[index]; + CCTK_REAL tauLeftL = tauLeft[index]; + CCTK_REAL tauRightL = tauRight[index]; + CCTK_REAL v1LeftL = v1Left[index]; + CCTK_REAL v1RightL = v1Right[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const ShiftMinus1DenRight = ShiftMinus1(&DenRight[index]); + CCTK_REAL const ShiftMinus1epsiRight = ShiftMinus1(&epsiRight[index]); + CCTK_REAL const ShiftMinus1rhoRight = ShiftMinus1(&rhoRight[index]); + CCTK_REAL const ShiftMinus1S1Right = ShiftMinus1(&S1Right[index]); + CCTK_REAL const ShiftMinus1S2Right = ShiftMinus1(&S2Right[index]); + CCTK_REAL const ShiftMinus1S3Right = ShiftMinus1(&S3Right[index]); + CCTK_REAL const ShiftMinus1tauRight = ShiftMinus1(&tauRight[index]); + CCTK_REAL const ShiftMinus1v1Right = ShiftMinus1(&v1Right[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenFluxLeft = DenLeftL*v1LeftL; + + CCTK_REAL DenFluxRight = ShiftMinus1DenRight*ShiftMinus1v1Right; + + CCTK_REAL DenFluxL = 0.5*(DenFluxLeft + DenFluxRight + (-DenLeftL + + ShiftMinus1DenRight)*ToReal(hlleAlpha)); + + CCTK_REAL S1FluxLeft = S1LeftL*v1LeftL + epsiLeftL*rhoLeftL*(-1 + + ToReal(gamma)); + + CCTK_REAL S1FluxRight = ShiftMinus1S1Right*ShiftMinus1v1Right + + ShiftMinus1epsiRight*ShiftMinus1rhoRight*(-1 + ToReal(gamma)); + + CCTK_REAL S1FluxL = 0.5*(S1FluxLeft + S1FluxRight + (-S1LeftL + + ShiftMinus1S1Right)*ToReal(hlleAlpha)); + + CCTK_REAL S2FluxLeft = S2LeftL*v1LeftL; + + CCTK_REAL S2FluxRight = ShiftMinus1S2Right*ShiftMinus1v1Right; + + CCTK_REAL S2FluxL = 0.5*(S2FluxLeft + S2FluxRight + (-S2LeftL + + ShiftMinus1S2Right)*ToReal(hlleAlpha)); + + CCTK_REAL S3FluxLeft = S3LeftL*v1LeftL; + + CCTK_REAL S3FluxRight = ShiftMinus1S3Right*ShiftMinus1v1Right; + + CCTK_REAL S3FluxL = 0.5*(S3FluxLeft + S3FluxRight + (-S3LeftL + + ShiftMinus1S3Right)*ToReal(hlleAlpha)); + + CCTK_REAL tauFluxLeft = v1LeftL*(tauLeftL + epsiLeftL*rhoLeftL*(-1 + + ToReal(gamma))); + + CCTK_REAL tauFluxRight = ShiftMinus1v1Right*(ShiftMinus1tauRight + + ShiftMinus1epsiRight*ShiftMinus1rhoRight*(-1 + ToReal(gamma))); + + CCTK_REAL tauFluxL = 0.5*(tauFluxLeft + tauFluxRight + + (ShiftMinus1tauRight - tauLeftL)*ToReal(hlleAlpha)); + + /* Copy local copies back to grid functions */ + DenFlux[index] = DenFluxL; + S1Flux[index] = S1FluxL; + S2Flux[index] = S2FluxL; + S3Flux[index] = S3FluxL; + tauFlux[index] = tauFluxL; + } + } + } +} + +extern "C" void eulersr_cons_calc_flux_1(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_flux_1_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_flux_2.cc b/Examples/EulerSR/src/eulersr_cons_calc_flux_2.cc new file mode 100644 index 0000000..b650410 --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_flux_2.cc @@ -0,0 +1,200 @@ +/* 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 eulersr_cons_calc_flux_2_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 */, "EulerSR::Den_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::Den_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S1_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S1_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S2_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S2_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S3_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S3_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::tau_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::tau_flux_group."); + return; +} + +static void eulersr_cons_calc_flux_2_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 eulersr_cons_calc_flux_2_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_flux_2_calc_every != eulersr_cons_calc_flux_2_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_flux_group","EulerSR::Den_lr_group","EulerSR::epsi_lr_group","EulerSR::rho_lr_group","EulerSR::S1_flux_group","EulerSR::S1_lr_group","EulerSR::S2_flux_group","EulerSR::S2_lr_group","EulerSR::S3_flux_group","EulerSR::S3_lr_group","EulerSR::tau_flux_group","EulerSR::tau_lr_group","EulerSR::v2_lr_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_flux_2", 13, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulersr_cons_calc_flux_2", 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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 epsiLeftL = epsiLeft[index]; + CCTK_REAL epsiRightL = epsiRight[index]; + CCTK_REAL rhoLeftL = rhoLeft[index]; + CCTK_REAL rhoRightL = rhoRight[index]; + CCTK_REAL S1LeftL = S1Left[index]; + CCTK_REAL S1RightL = S1Right[index]; + CCTK_REAL S2LeftL = S2Left[index]; + CCTK_REAL S2RightL = S2Right[index]; + CCTK_REAL S3LeftL = S3Left[index]; + CCTK_REAL S3RightL = S3Right[index]; + CCTK_REAL tauLeftL = tauLeft[index]; + CCTK_REAL tauRightL = tauRight[index]; + CCTK_REAL v2LeftL = v2Left[index]; + CCTK_REAL v2RightL = v2Right[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const ShiftMinus2DenRight = ShiftMinus2(&DenRight[index]); + CCTK_REAL const ShiftMinus2epsiRight = ShiftMinus2(&epsiRight[index]); + CCTK_REAL const ShiftMinus2rhoRight = ShiftMinus2(&rhoRight[index]); + CCTK_REAL const ShiftMinus2S1Right = ShiftMinus2(&S1Right[index]); + CCTK_REAL const ShiftMinus2S2Right = ShiftMinus2(&S2Right[index]); + CCTK_REAL const ShiftMinus2S3Right = ShiftMinus2(&S3Right[index]); + CCTK_REAL const ShiftMinus2tauRight = ShiftMinus2(&tauRight[index]); + CCTK_REAL const ShiftMinus2v2Right = ShiftMinus2(&v2Right[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenFluxLeft = DenLeftL*v2LeftL; + + CCTK_REAL DenFluxRight = ShiftMinus2DenRight*ShiftMinus2v2Right; + + CCTK_REAL DenFluxL = 0.5*(DenFluxLeft + DenFluxRight + (-DenLeftL + + ShiftMinus2DenRight)*ToReal(hlleAlpha)); + + CCTK_REAL S1FluxLeft = S1LeftL*v2LeftL; + + CCTK_REAL S1FluxRight = ShiftMinus2S1Right*ShiftMinus2v2Right; + + CCTK_REAL S1FluxL = 0.5*(S1FluxLeft + S1FluxRight + (-S1LeftL + + ShiftMinus2S1Right)*ToReal(hlleAlpha)); + + CCTK_REAL S2FluxLeft = S2LeftL*v2LeftL + epsiLeftL*rhoLeftL*(-1 + + ToReal(gamma)); + + CCTK_REAL S2FluxRight = ShiftMinus2S2Right*ShiftMinus2v2Right + + ShiftMinus2epsiRight*ShiftMinus2rhoRight*(-1 + ToReal(gamma)); + + CCTK_REAL S2FluxL = 0.5*(S2FluxLeft + S2FluxRight + (-S2LeftL + + ShiftMinus2S2Right)*ToReal(hlleAlpha)); + + CCTK_REAL S3FluxLeft = S3LeftL*v2LeftL; + + CCTK_REAL S3FluxRight = ShiftMinus2S3Right*ShiftMinus2v2Right; + + CCTK_REAL S3FluxL = 0.5*(S3FluxLeft + S3FluxRight + (-S3LeftL + + ShiftMinus2S3Right)*ToReal(hlleAlpha)); + + CCTK_REAL tauFluxLeft = v2LeftL*(tauLeftL + epsiLeftL*rhoLeftL*(-1 + + ToReal(gamma))); + + CCTK_REAL tauFluxRight = ShiftMinus2v2Right*(ShiftMinus2tauRight + + ShiftMinus2epsiRight*ShiftMinus2rhoRight*(-1 + ToReal(gamma))); + + CCTK_REAL tauFluxL = 0.5*(tauFluxLeft + tauFluxRight + + (ShiftMinus2tauRight - tauLeftL)*ToReal(hlleAlpha)); + + /* Copy local copies back to grid functions */ + DenFlux[index] = DenFluxL; + S1Flux[index] = S1FluxL; + S2Flux[index] = S2FluxL; + S3Flux[index] = S3FluxL; + tauFlux[index] = tauFluxL; + } + } + } +} + +extern "C" void eulersr_cons_calc_flux_2(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_flux_2_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_flux_3.cc b/Examples/EulerSR/src/eulersr_cons_calc_flux_3.cc new file mode 100644 index 0000000..7f4dbea --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_flux_3.cc @@ -0,0 +1,200 @@ +/* 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 eulersr_cons_calc_flux_3_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 */, "EulerSR::Den_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::Den_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S1_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S1_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S2_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S2_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S3_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S3_flux_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::tau_flux_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::tau_flux_group."); + return; +} + +static void eulersr_cons_calc_flux_3_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 eulersr_cons_calc_flux_3_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_flux_3_calc_every != eulersr_cons_calc_flux_3_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_flux_group","EulerSR::Den_lr_group","EulerSR::epsi_lr_group","EulerSR::rho_lr_group","EulerSR::S1_flux_group","EulerSR::S1_lr_group","EulerSR::S2_flux_group","EulerSR::S2_lr_group","EulerSR::S3_flux_group","EulerSR::S3_lr_group","EulerSR::tau_flux_group","EulerSR::tau_lr_group","EulerSR::v3_lr_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_flux_3", 13, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulersr_cons_calc_flux_3", 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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 epsiLeftL = epsiLeft[index]; + CCTK_REAL epsiRightL = epsiRight[index]; + CCTK_REAL rhoLeftL = rhoLeft[index]; + CCTK_REAL rhoRightL = rhoRight[index]; + CCTK_REAL S1LeftL = S1Left[index]; + CCTK_REAL S1RightL = S1Right[index]; + CCTK_REAL S2LeftL = S2Left[index]; + CCTK_REAL S2RightL = S2Right[index]; + CCTK_REAL S3LeftL = S3Left[index]; + CCTK_REAL S3RightL = S3Right[index]; + CCTK_REAL tauLeftL = tauLeft[index]; + CCTK_REAL tauRightL = tauRight[index]; + CCTK_REAL v3LeftL = v3Left[index]; + CCTK_REAL v3RightL = v3Right[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const ShiftMinus3DenRight = ShiftMinus3(&DenRight[index]); + CCTK_REAL const ShiftMinus3epsiRight = ShiftMinus3(&epsiRight[index]); + CCTK_REAL const ShiftMinus3rhoRight = ShiftMinus3(&rhoRight[index]); + CCTK_REAL const ShiftMinus3S1Right = ShiftMinus3(&S1Right[index]); + CCTK_REAL const ShiftMinus3S2Right = ShiftMinus3(&S2Right[index]); + CCTK_REAL const ShiftMinus3S3Right = ShiftMinus3(&S3Right[index]); + CCTK_REAL const ShiftMinus3tauRight = ShiftMinus3(&tauRight[index]); + CCTK_REAL const ShiftMinus3v3Right = ShiftMinus3(&v3Right[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenFluxLeft = DenLeftL*v3LeftL; + + CCTK_REAL DenFluxRight = ShiftMinus3DenRight*ShiftMinus3v3Right; + + CCTK_REAL DenFluxL = 0.5*(DenFluxLeft + DenFluxRight + (-DenLeftL + + ShiftMinus3DenRight)*ToReal(hlleAlpha)); + + CCTK_REAL S1FluxLeft = S1LeftL*v3LeftL; + + CCTK_REAL S1FluxRight = ShiftMinus3S1Right*ShiftMinus3v3Right; + + CCTK_REAL S1FluxL = 0.5*(S1FluxLeft + S1FluxRight + (-S1LeftL + + ShiftMinus3S1Right)*ToReal(hlleAlpha)); + + CCTK_REAL S2FluxLeft = S2LeftL*v3LeftL; + + CCTK_REAL S2FluxRight = ShiftMinus3S2Right*ShiftMinus3v3Right; + + CCTK_REAL S2FluxL = 0.5*(S2FluxLeft + S2FluxRight + (-S2LeftL + + ShiftMinus3S2Right)*ToReal(hlleAlpha)); + + CCTK_REAL S3FluxLeft = S3LeftL*v3LeftL + epsiLeftL*rhoLeftL*(-1 + + ToReal(gamma)); + + CCTK_REAL S3FluxRight = ShiftMinus3S3Right*ShiftMinus3v3Right + + ShiftMinus3epsiRight*ShiftMinus3rhoRight*(-1 + ToReal(gamma)); + + CCTK_REAL S3FluxL = 0.5*(S3FluxLeft + S3FluxRight + (-S3LeftL + + ShiftMinus3S3Right)*ToReal(hlleAlpha)); + + CCTK_REAL tauFluxLeft = v3LeftL*(tauLeftL + epsiLeftL*rhoLeftL*(-1 + + ToReal(gamma))); + + CCTK_REAL tauFluxRight = ShiftMinus3v3Right*(ShiftMinus3tauRight + + ShiftMinus3epsiRight*ShiftMinus3rhoRight*(-1 + ToReal(gamma))); + + CCTK_REAL tauFluxL = 0.5*(tauFluxLeft + tauFluxRight + + (ShiftMinus3tauRight - tauLeftL)*ToReal(hlleAlpha)); + + /* Copy local copies back to grid functions */ + DenFlux[index] = DenFluxL; + S1Flux[index] = S1FluxL; + S2Flux[index] = S2FluxL; + S3Flux[index] = S3FluxL; + tauFlux[index] = tauFluxL; + } + } + } +} + +extern "C" void eulersr_cons_calc_flux_3(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_flux_3_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_1.cc b/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_1.cc new file mode 100644 index 0000000..6885845 --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_1.cc @@ -0,0 +1,171 @@ +/* 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 eulersr_cons_calc_intercell_conserved_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 eulersr_cons_calc_intercell_conserved_1_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_intercell_conserved_1_calc_every != eulersr_cons_calc_intercell_conserved_1_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_lr_group","EulerSR::epsi_lr_group","EulerSR::h_group","EulerSR::p_group","EulerSR::rho_lr_group","EulerSR::S1_lr_group","EulerSR::S2_lr_group","EulerSR::S3_lr_group","EulerSR::tau_lr_group","EulerSR::v1_lr_group","EulerSR::v2_lr_group","EulerSR::v3_lr_group","EulerSR::W_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_intercell_conserved_1", 13, 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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 epsiLeftL = epsiLeft[index]; + CCTK_REAL epsiRightL = epsiRight[index]; + CCTK_REAL hL = h[index]; + CCTK_REAL pL = p[index]; + CCTK_REAL rhoLeftL = rhoLeft[index]; + CCTK_REAL rhoRightL = rhoRight[index]; + CCTK_REAL v1LeftL = v1Left[index]; + CCTK_REAL v1RightL = v1Right[index]; + CCTK_REAL v2LeftL = v2Left[index]; + CCTK_REAL v2RightL = v2Right[index]; + CCTK_REAL v3LeftL = v3Left[index]; + CCTK_REAL v3RightL = v3Right[index]; + CCTK_REAL WL = W[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL Wx = 1 - SQR(v1LeftL) - SQR(v2LeftL) - SQR(v3LeftL); + + WL = INV(sqrt(Wx)); + + pL = epsiLeftL*rhoLeftL*(-1 + ToReal(gamma)); + + hL = 1 + epsiLeftL + pL*INV(rhoLeftL); + + DenLeftL = rhoLeftL*WL; + + CCTK_REAL S1LeftL = hL*rhoLeftL*v1LeftL*SQR(WL); + + CCTK_REAL S2LeftL = hL*rhoLeftL*v2LeftL*SQR(WL); + + CCTK_REAL S3LeftL = hL*rhoLeftL*v3LeftL*SQR(WL); + + CCTK_REAL tauLeftL = -DenLeftL - pL + hL*rhoLeftL*SQR(WL); + + Wx = 1 - SQR(v1RightL) - SQR(v2RightL) - SQR(v3RightL); + + WL = INV(sqrt(Wx)); + + pL = epsiRightL*rhoRightL*(-1 + ToReal(gamma)); + + hL = 1 + epsiRightL + pL*INV(rhoRightL); + + DenRightL = rhoRightL*WL; + + CCTK_REAL S1RightL = hL*rhoRightL*v1RightL*SQR(WL); + + CCTK_REAL S2RightL = hL*rhoRightL*v2RightL*SQR(WL); + + CCTK_REAL S3RightL = hL*rhoRightL*v3RightL*SQR(WL); + + CCTK_REAL tauRightL = -DenRightL - pL + hL*rhoRightL*SQR(WL); + + /* Copy local copies back to grid functions */ + DenLeft[index] = DenLeftL; + DenRight[index] = DenRightL; + h[index] = hL; + p[index] = pL; + S1Left[index] = S1LeftL; + S1Right[index] = S1RightL; + S2Left[index] = S2LeftL; + S2Right[index] = S2RightL; + S3Left[index] = S3LeftL; + S3Right[index] = S3RightL; + tauLeft[index] = tauLeftL; + tauRight[index] = tauRightL; + W[index] = WL; + } + } + } +} + +extern "C" void eulersr_cons_calc_intercell_conserved_1(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_intercell_conserved_1_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_2.cc b/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_2.cc new file mode 100644 index 0000000..2263c6a --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_2.cc @@ -0,0 +1,171 @@ +/* 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 eulersr_cons_calc_intercell_conserved_2_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 eulersr_cons_calc_intercell_conserved_2_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_intercell_conserved_2_calc_every != eulersr_cons_calc_intercell_conserved_2_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_lr_group","EulerSR::epsi_lr_group","EulerSR::h_group","EulerSR::p_group","EulerSR::rho_lr_group","EulerSR::S1_lr_group","EulerSR::S2_lr_group","EulerSR::S3_lr_group","EulerSR::tau_lr_group","EulerSR::v1_lr_group","EulerSR::v2_lr_group","EulerSR::v3_lr_group","EulerSR::W_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_intercell_conserved_2", 13, 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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 epsiLeftL = epsiLeft[index]; + CCTK_REAL epsiRightL = epsiRight[index]; + CCTK_REAL hL = h[index]; + CCTK_REAL pL = p[index]; + CCTK_REAL rhoLeftL = rhoLeft[index]; + CCTK_REAL rhoRightL = rhoRight[index]; + CCTK_REAL v1LeftL = v1Left[index]; + CCTK_REAL v1RightL = v1Right[index]; + CCTK_REAL v2LeftL = v2Left[index]; + CCTK_REAL v2RightL = v2Right[index]; + CCTK_REAL v3LeftL = v3Left[index]; + CCTK_REAL v3RightL = v3Right[index]; + CCTK_REAL WL = W[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL Wx = 1 - SQR(v1LeftL) - SQR(v2LeftL) - SQR(v3LeftL); + + WL = INV(sqrt(Wx)); + + pL = epsiLeftL*rhoLeftL*(-1 + ToReal(gamma)); + + hL = 1 + epsiLeftL + pL*INV(rhoLeftL); + + DenLeftL = rhoLeftL*WL; + + CCTK_REAL S1LeftL = hL*rhoLeftL*v1LeftL*SQR(WL); + + CCTK_REAL S2LeftL = hL*rhoLeftL*v2LeftL*SQR(WL); + + CCTK_REAL S3LeftL = hL*rhoLeftL*v3LeftL*SQR(WL); + + CCTK_REAL tauLeftL = -DenLeftL - pL + hL*rhoLeftL*SQR(WL); + + Wx = 1 - SQR(v1RightL) - SQR(v2RightL) - SQR(v3RightL); + + WL = INV(sqrt(Wx)); + + pL = epsiRightL*rhoRightL*(-1 + ToReal(gamma)); + + hL = 1 + epsiRightL + pL*INV(rhoRightL); + + DenRightL = rhoRightL*WL; + + CCTK_REAL S1RightL = hL*rhoRightL*v1RightL*SQR(WL); + + CCTK_REAL S2RightL = hL*rhoRightL*v2RightL*SQR(WL); + + CCTK_REAL S3RightL = hL*rhoRightL*v3RightL*SQR(WL); + + CCTK_REAL tauRightL = -DenRightL - pL + hL*rhoRightL*SQR(WL); + + /* Copy local copies back to grid functions */ + DenLeft[index] = DenLeftL; + DenRight[index] = DenRightL; + h[index] = hL; + p[index] = pL; + S1Left[index] = S1LeftL; + S1Right[index] = S1RightL; + S2Left[index] = S2LeftL; + S2Right[index] = S2RightL; + S3Left[index] = S3LeftL; + S3Right[index] = S3RightL; + tauLeft[index] = tauLeftL; + tauRight[index] = tauRightL; + W[index] = WL; + } + } + } +} + +extern "C" void eulersr_cons_calc_intercell_conserved_2(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_intercell_conserved_2_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_3.cc b/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_3.cc new file mode 100644 index 0000000..f636073 --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_3.cc @@ -0,0 +1,171 @@ +/* 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 eulersr_cons_calc_intercell_conserved_3_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 eulersr_cons_calc_intercell_conserved_3_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_intercell_conserved_3_calc_every != eulersr_cons_calc_intercell_conserved_3_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_lr_group","EulerSR::epsi_lr_group","EulerSR::h_group","EulerSR::p_group","EulerSR::rho_lr_group","EulerSR::S1_lr_group","EulerSR::S2_lr_group","EulerSR::S3_lr_group","EulerSR::tau_lr_group","EulerSR::v1_lr_group","EulerSR::v2_lr_group","EulerSR::v3_lr_group","EulerSR::W_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_intercell_conserved_3", 13, 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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 epsiLeftL = epsiLeft[index]; + CCTK_REAL epsiRightL = epsiRight[index]; + CCTK_REAL hL = h[index]; + CCTK_REAL pL = p[index]; + CCTK_REAL rhoLeftL = rhoLeft[index]; + CCTK_REAL rhoRightL = rhoRight[index]; + CCTK_REAL v1LeftL = v1Left[index]; + CCTK_REAL v1RightL = v1Right[index]; + CCTK_REAL v2LeftL = v2Left[index]; + CCTK_REAL v2RightL = v2Right[index]; + CCTK_REAL v3LeftL = v3Left[index]; + CCTK_REAL v3RightL = v3Right[index]; + CCTK_REAL WL = W[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL Wx = 1 - SQR(v1LeftL) - SQR(v2LeftL) - SQR(v3LeftL); + + WL = INV(sqrt(Wx)); + + pL = epsiLeftL*rhoLeftL*(-1 + ToReal(gamma)); + + hL = 1 + epsiLeftL + pL*INV(rhoLeftL); + + DenLeftL = rhoLeftL*WL; + + CCTK_REAL S1LeftL = hL*rhoLeftL*v1LeftL*SQR(WL); + + CCTK_REAL S2LeftL = hL*rhoLeftL*v2LeftL*SQR(WL); + + CCTK_REAL S3LeftL = hL*rhoLeftL*v3LeftL*SQR(WL); + + CCTK_REAL tauLeftL = -DenLeftL - pL + hL*rhoLeftL*SQR(WL); + + Wx = 1 - SQR(v1RightL) - SQR(v2RightL) - SQR(v3RightL); + + WL = INV(sqrt(Wx)); + + pL = epsiRightL*rhoRightL*(-1 + ToReal(gamma)); + + hL = 1 + epsiRightL + pL*INV(rhoRightL); + + DenRightL = rhoRightL*WL; + + CCTK_REAL S1RightL = hL*rhoRightL*v1RightL*SQR(WL); + + CCTK_REAL S2RightL = hL*rhoRightL*v2RightL*SQR(WL); + + CCTK_REAL S3RightL = hL*rhoRightL*v3RightL*SQR(WL); + + CCTK_REAL tauRightL = -DenRightL - pL + hL*rhoRightL*SQR(WL); + + /* Copy local copies back to grid functions */ + DenLeft[index] = DenLeftL; + DenRight[index] = DenRightL; + h[index] = hL; + p[index] = pL; + S1Left[index] = S1LeftL; + S1Right[index] = S1RightL; + S2Left[index] = S2LeftL; + S2Right[index] = S2RightL; + S3Left[index] = S3LeftL; + S3Right[index] = S3RightL; + tauLeft[index] = tauLeftL; + tauRight[index] = tauRightL; + W[index] = WL; + } + } + } +} + +extern "C" void eulersr_cons_calc_intercell_conserved_3(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_intercell_conserved_3_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_primitives.cc b/Examples/EulerSR/src/eulersr_cons_calc_primitives.cc new file mode 100644 index 0000000..c1ca939 --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_primitives.cc @@ -0,0 +1,257 @@ +/* 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 eulersr_cons_calc_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 eulersr_cons_calc_primitives_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_primitives_calc_every != eulersr_cons_calc_primitives_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_group","EulerSR::epsi_group","EulerSR::h_group","EulerSR::p_group","EulerSR::rho_group","EulerSR::S_group","EulerSR::tau_group","EulerSR::v_group","EulerSR::W_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_primitives", 9, 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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 epsiL = epsi[index]; + CCTK_REAL hL = h[index]; + CCTK_REAL pL = p[index]; + CCTK_REAL rhoL = rho[index]; + CCTK_REAL S1L = S1[index]; + CCTK_REAL S2L = S2[index]; + CCTK_REAL S3L = S3[index]; + CCTK_REAL tauL = tau[index]; + CCTK_REAL WL = W[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL pBar = pL; + + CCTK_REAL f = 10; + + CCTK_REAL Z = DenL + pBar + tauL; + + CCTK_REAL Ssq = SQR(S1L) + SQR(S2L) + SQR(S3L); + + CCTK_REAL vsq = Ssq*INV(SQR(Z)); + + WL = INV(sqrt(1 - vsq)); + + rhoL = DenL*INV(WL); + + hL = Z*INV(rhoL)*INV(SQR(WL)); + + epsiL = hL - (pBar + rhoL)*INV(rhoL); + + CCTK_REAL pEOS = epsiL*rhoL*(-1 + ToReal(gamma)); + + f = -pBar + pEOS; + + CCTK_REAL cs = sqrt(epsiL*INV(hL)*(-1 + ToReal(gamma))*ToReal(gamma)); + + CCTK_REAL df = -1 + vsq*SQR(cs); + + pBar = pBar - f*INV(df); + + Z = DenL + pBar + tauL; + + Ssq = SQR(S1L) + SQR(S2L) + SQR(S3L); + + vsq = Ssq*INV(SQR(Z)); + + WL = INV(sqrt(1 - vsq)); + + rhoL = DenL*INV(WL); + + hL = Z*INV(rhoL)*INV(SQR(WL)); + + epsiL = hL - (pBar + rhoL)*INV(rhoL); + + pEOS = epsiL*rhoL*(-1 + ToReal(gamma)); + + f = -pBar + pEOS; + + cs = sqrt(epsiL*INV(hL)*(-1 + ToReal(gamma))*ToReal(gamma)); + + df = -1 + vsq*SQR(cs); + + pBar = pBar - f*INV(df); + + Z = DenL + pBar + tauL; + + Ssq = SQR(S1L) + SQR(S2L) + SQR(S3L); + + vsq = Ssq*INV(SQR(Z)); + + WL = INV(sqrt(1 - vsq)); + + rhoL = DenL*INV(WL); + + hL = Z*INV(rhoL)*INV(SQR(WL)); + + epsiL = hL - (pBar + rhoL)*INV(rhoL); + + pEOS = epsiL*rhoL*(-1 + ToReal(gamma)); + + f = -pBar + pEOS; + + cs = sqrt(epsiL*INV(hL)*(-1 + ToReal(gamma))*ToReal(gamma)); + + df = -1 + vsq*SQR(cs); + + pBar = pBar - f*INV(df); + + Z = DenL + pBar + tauL; + + Ssq = SQR(S1L) + SQR(S2L) + SQR(S3L); + + vsq = Ssq*INV(SQR(Z)); + + WL = INV(sqrt(1 - vsq)); + + rhoL = DenL*INV(WL); + + hL = Z*INV(rhoL)*INV(SQR(WL)); + + epsiL = hL - (pBar + rhoL)*INV(rhoL); + + pEOS = epsiL*rhoL*(-1 + ToReal(gamma)); + + f = -pBar + pEOS; + + cs = sqrt(epsiL*INV(hL)*(-1 + ToReal(gamma))*ToReal(gamma)); + + df = -1 + vsq*SQR(cs); + + pBar = pBar - f*INV(df); + + Z = DenL + pBar + tauL; + + Ssq = SQR(S1L) + SQR(S2L) + SQR(S3L); + + vsq = Ssq*INV(SQR(Z)); + + WL = INV(sqrt(1 - vsq)); + + rhoL = DenL*INV(WL); + + hL = Z*INV(rhoL)*INV(SQR(WL)); + + epsiL = hL - (pBar + rhoL)*INV(rhoL); + + pEOS = epsiL*rhoL*(-1 + ToReal(gamma)); + + f = -pBar + pEOS; + + cs = sqrt(epsiL*INV(hL)*(-1 + ToReal(gamma))*ToReal(gamma)); + + df = -1 + vsq*SQR(cs); + + pBar = pBar - f*INV(df); + + pL = pBar; + + CCTK_REAL v1L = S1L*INV(hL)*INV(rhoL)*INV(SQR(WL)); + + CCTK_REAL v2L = S2L*INV(hL)*INV(rhoL)*INV(SQR(WL)); + + CCTK_REAL v3L = S3L*INV(hL)*INV(rhoL)*INV(SQR(WL)); + + /* Copy local copies back to grid functions */ + epsi[index] = epsiL; + h[index] = hL; + p[index] = pL; + rho[index] = rhoL; + v1[index] = v1L; + v2[index] = v2L; + v3[index] = v3L; + W[index] = WL; + } + } + } +} + +extern "C" void eulersr_cons_calc_primitives(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_primitives_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_1.cc b/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_1.cc new file mode 100644 index 0000000..fd2111a --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_1.cc @@ -0,0 +1,207 @@ +/* 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 eulersr_cons_calc_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 */, "EulerSR::epsi_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::epsi_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::rho_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::rho_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::v1_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::v1_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::v2_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::v2_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::v3_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::v3_lr_group."); + return; +} + +static void eulersr_cons_calc_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 eulersr_cons_calc_reconstruct_1_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_reconstruct_1_calc_every != eulersr_cons_calc_reconstruct_1_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::epsi_group","EulerSR::epsi_lr_group","EulerSR::rho_group","EulerSR::rho_lr_group","EulerSR::v1_lr_group","EulerSR::v2_lr_group","EulerSR::v3_lr_group","EulerSR::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_reconstruct_1", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulersr_cons_calc_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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 epsiL = epsi[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 DiffPlus1epsi = DiffPlus1(&epsi[index]); + CCTK_REAL const DiffMinus1epsi = DiffMinus1(&epsi[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 v1LeftL = -0.5*slope + v1L; + + CCTK_REAL v1RightL = 0.5*slope + v1L; + + slopeL = DiffMinus1v2; + + slopeR = DiffPlus1v2; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v2LeftL = -0.5*slope + v2L; + + CCTK_REAL v2RightL = 0.5*slope + v2L; + + slopeL = DiffMinus1v3; + + slopeR = DiffPlus1v3; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v3LeftL = -0.5*slope + v3L; + + CCTK_REAL v3RightL = 0.5*slope + v3L; + + slopeL = DiffMinus1epsi; + + slopeR = DiffPlus1epsi; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL epsiLeftL = epsiL - 0.5*slope; + + CCTK_REAL epsiRightL = epsiL + 0.5*slope; + + /* Copy local copies back to grid functions */ + epsiLeft[index] = epsiLeftL; + epsiRight[index] = epsiRightL; + rhoLeft[index] = rhoLeftL; + rhoRight[index] = rhoRightL; + v1Left[index] = v1LeftL; + v1Right[index] = v1RightL; + v2Left[index] = v2LeftL; + v2Right[index] = v2RightL; + v3Left[index] = v3LeftL; + v3Right[index] = v3RightL; + } + } + } +} + +extern "C" void eulersr_cons_calc_reconstruct_1(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_reconstruct_1_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_2.cc b/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_2.cc new file mode 100644 index 0000000..6725583 --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_2.cc @@ -0,0 +1,207 @@ +/* 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 eulersr_cons_calc_reconstruct_2_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 */, "EulerSR::epsi_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::epsi_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::rho_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::rho_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::v1_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::v1_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::v2_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::v2_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::v3_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::v3_lr_group."); + return; +} + +static void eulersr_cons_calc_reconstruct_2_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 eulersr_cons_calc_reconstruct_2_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_reconstruct_2_calc_every != eulersr_cons_calc_reconstruct_2_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::epsi_group","EulerSR::epsi_lr_group","EulerSR::rho_group","EulerSR::rho_lr_group","EulerSR::v1_lr_group","EulerSR::v2_lr_group","EulerSR::v3_lr_group","EulerSR::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_reconstruct_2", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulersr_cons_calc_reconstruct_2", 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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 epsiL = epsi[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 DiffPlus2epsi = DiffPlus2(&epsi[index]); + CCTK_REAL const DiffMinus2epsi = DiffMinus2(&epsi[index]); + CCTK_REAL const DiffPlus2rho = DiffPlus2(&rho[index]); + CCTK_REAL const DiffMinus2rho = DiffMinus2(&rho[index]); + CCTK_REAL const DiffPlus2v1 = DiffPlus2(&v1[index]); + CCTK_REAL const DiffMinus2v1 = DiffMinus2(&v1[index]); + CCTK_REAL const DiffPlus2v2 = DiffPlus2(&v2[index]); + CCTK_REAL const DiffMinus2v2 = DiffMinus2(&v2[index]); + CCTK_REAL const DiffPlus2v3 = DiffPlus2(&v3[index]); + CCTK_REAL const DiffMinus2v3 = DiffMinus2(&v3[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL slopeL = DiffMinus2rho; + + CCTK_REAL slopeR = DiffPlus2rho; + + CCTK_REAL slope = VanLeer(slopeL,slopeR); + + CCTK_REAL rhoLeftL = rhoL - 0.5*slope; + + CCTK_REAL rhoRightL = rhoL + 0.5*slope; + + slopeL = DiffMinus2v1; + + slopeR = DiffPlus2v1; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v1LeftL = -0.5*slope + v1L; + + CCTK_REAL v1RightL = 0.5*slope + v1L; + + slopeL = DiffMinus2v2; + + slopeR = DiffPlus2v2; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v2LeftL = -0.5*slope + v2L; + + CCTK_REAL v2RightL = 0.5*slope + v2L; + + slopeL = DiffMinus2v3; + + slopeR = DiffPlus2v3; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v3LeftL = -0.5*slope + v3L; + + CCTK_REAL v3RightL = 0.5*slope + v3L; + + slopeL = DiffMinus2epsi; + + slopeR = DiffPlus2epsi; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL epsiLeftL = epsiL - 0.5*slope; + + CCTK_REAL epsiRightL = epsiL + 0.5*slope; + + /* Copy local copies back to grid functions */ + epsiLeft[index] = epsiLeftL; + epsiRight[index] = epsiRightL; + rhoLeft[index] = rhoLeftL; + rhoRight[index] = rhoRightL; + v1Left[index] = v1LeftL; + v1Right[index] = v1RightL; + v2Left[index] = v2LeftL; + v2Right[index] = v2RightL; + v3Left[index] = v3LeftL; + v3Right[index] = v3RightL; + } + } + } +} + +extern "C" void eulersr_cons_calc_reconstruct_2(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_reconstruct_2_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_3.cc b/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_3.cc new file mode 100644 index 0000000..7a913d0 --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_3.cc @@ -0,0 +1,207 @@ +/* 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 eulersr_cons_calc_reconstruct_3_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 */, "EulerSR::epsi_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::epsi_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::rho_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::rho_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::v1_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::v1_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::v2_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::v2_lr_group."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::v3_lr_group","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::v3_lr_group."); + return; +} + +static void eulersr_cons_calc_reconstruct_3_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 eulersr_cons_calc_reconstruct_3_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_reconstruct_3_calc_every != eulersr_cons_calc_reconstruct_3_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::epsi_group","EulerSR::epsi_lr_group","EulerSR::rho_group","EulerSR::rho_lr_group","EulerSR::v1_lr_group","EulerSR::v2_lr_group","EulerSR::v3_lr_group","EulerSR::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_reconstruct_3", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulersr_cons_calc_reconstruct_3", 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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 epsiL = epsi[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 DiffPlus3epsi = DiffPlus3(&epsi[index]); + CCTK_REAL const DiffMinus3epsi = DiffMinus3(&epsi[index]); + CCTK_REAL const DiffPlus3rho = DiffPlus3(&rho[index]); + CCTK_REAL const DiffMinus3rho = DiffMinus3(&rho[index]); + CCTK_REAL const DiffPlus3v1 = DiffPlus3(&v1[index]); + CCTK_REAL const DiffMinus3v1 = DiffMinus3(&v1[index]); + CCTK_REAL const DiffPlus3v2 = DiffPlus3(&v2[index]); + CCTK_REAL const DiffMinus3v2 = DiffMinus3(&v2[index]); + CCTK_REAL const DiffPlus3v3 = DiffPlus3(&v3[index]); + CCTK_REAL const DiffMinus3v3 = DiffMinus3(&v3[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL slopeL = DiffMinus3rho; + + CCTK_REAL slopeR = DiffPlus3rho; + + CCTK_REAL slope = VanLeer(slopeL,slopeR); + + CCTK_REAL rhoLeftL = rhoL - 0.5*slope; + + CCTK_REAL rhoRightL = rhoL + 0.5*slope; + + slopeL = DiffMinus3v1; + + slopeR = DiffPlus3v1; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v1LeftL = -0.5*slope + v1L; + + CCTK_REAL v1RightL = 0.5*slope + v1L; + + slopeL = DiffMinus3v2; + + slopeR = DiffPlus3v2; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v2LeftL = -0.5*slope + v2L; + + CCTK_REAL v2RightL = 0.5*slope + v2L; + + slopeL = DiffMinus3v3; + + slopeR = DiffPlus3v3; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v3LeftL = -0.5*slope + v3L; + + CCTK_REAL v3RightL = 0.5*slope + v3L; + + slopeL = DiffMinus3epsi; + + slopeR = DiffPlus3epsi; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL epsiLeftL = epsiL - 0.5*slope; + + CCTK_REAL epsiRightL = epsiL + 0.5*slope; + + /* Copy local copies back to grid functions */ + epsiLeft[index] = epsiLeftL; + epsiRight[index] = epsiRightL; + rhoLeft[index] = rhoLeftL; + rhoRight[index] = rhoRightL; + v1Left[index] = v1LeftL; + v1Right[index] = v1RightL; + v2Left[index] = v2LeftL; + v2Right[index] = v2RightL; + v3Left[index] = v3LeftL; + v3Right[index] = v3RightL; + } + } + } +} + +extern "C" void eulersr_cons_calc_reconstruct_3(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_reconstruct_3_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_rhs_1.cc b/Examples/EulerSR/src/eulersr_cons_calc_rhs_1.cc new file mode 100644 index 0000000..0dee465 --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_rhs_1.cc @@ -0,0 +1,156 @@ +/* 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 eulersr_cons_calc_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 */, "EulerSR::Den_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::Den_grouprhs."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S_grouprhs."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::tau_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::tau_grouprhs."); + return; +} + +static void eulersr_cons_calc_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 eulersr_cons_calc_rhs_1_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_rhs_1_calc_every != eulersr_cons_calc_rhs_1_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_flux_group","EulerSR::Den_grouprhs","EulerSR::S1_flux_group","EulerSR::S2_flux_group","EulerSR::S3_flux_group","EulerSR::S_grouprhs","EulerSR::tau_flux_group","EulerSR::tau_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_rhs_1", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulersr_cons_calc_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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 DenFluxL = DenFlux[index]; + CCTK_REAL DenrhsL = Denrhs[index]; + CCTK_REAL S1FluxL = S1Flux[index]; + CCTK_REAL S1rhsL = S1rhs[index]; + CCTK_REAL S2FluxL = S2Flux[index]; + CCTK_REAL S2rhsL = S2rhs[index]; + CCTK_REAL S3FluxL = S3Flux[index]; + CCTK_REAL S3rhsL = S3rhs[index]; + CCTK_REAL tauFluxL = tauFlux[index]; + CCTK_REAL taurhsL = taurhs[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDplus1DenFlux = PDplus1(&DenFlux[index]); + CCTK_REAL const PDplus1S1Flux = PDplus1(&S1Flux[index]); + CCTK_REAL const PDplus1S2Flux = PDplus1(&S2Flux[index]); + CCTK_REAL const PDplus1S3Flux = PDplus1(&S3Flux[index]); + CCTK_REAL const PDplus1tauFlux = PDplus1(&tauFlux[index]); + + /* Calculate temporaries and grid functions */ + DenrhsL = DenrhsL - PDplus1DenFlux; + + S1rhsL = -PDplus1S1Flux + S1rhsL; + + S2rhsL = -PDplus1S2Flux + S2rhsL; + + S3rhsL = -PDplus1S3Flux + S3rhsL; + + taurhsL = -PDplus1tauFlux + taurhsL; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; + taurhs[index] = taurhsL; + } + } + } +} + +extern "C" void eulersr_cons_calc_rhs_1(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_rhs_1_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_rhs_2.cc b/Examples/EulerSR/src/eulersr_cons_calc_rhs_2.cc new file mode 100644 index 0000000..f8a470b --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_rhs_2.cc @@ -0,0 +1,156 @@ +/* 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 eulersr_cons_calc_rhs_2_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 */, "EulerSR::Den_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::Den_grouprhs."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S_grouprhs."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::tau_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::tau_grouprhs."); + return; +} + +static void eulersr_cons_calc_rhs_2_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 eulersr_cons_calc_rhs_2_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_rhs_2_calc_every != eulersr_cons_calc_rhs_2_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_flux_group","EulerSR::Den_grouprhs","EulerSR::S1_flux_group","EulerSR::S2_flux_group","EulerSR::S3_flux_group","EulerSR::S_grouprhs","EulerSR::tau_flux_group","EulerSR::tau_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_rhs_2", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulersr_cons_calc_rhs_2", 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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 DenFluxL = DenFlux[index]; + CCTK_REAL DenrhsL = Denrhs[index]; + CCTK_REAL S1FluxL = S1Flux[index]; + CCTK_REAL S1rhsL = S1rhs[index]; + CCTK_REAL S2FluxL = S2Flux[index]; + CCTK_REAL S2rhsL = S2rhs[index]; + CCTK_REAL S3FluxL = S3Flux[index]; + CCTK_REAL S3rhsL = S3rhs[index]; + CCTK_REAL tauFluxL = tauFlux[index]; + CCTK_REAL taurhsL = taurhs[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDplus2DenFlux = PDplus2(&DenFlux[index]); + CCTK_REAL const PDplus2S1Flux = PDplus2(&S1Flux[index]); + CCTK_REAL const PDplus2S2Flux = PDplus2(&S2Flux[index]); + CCTK_REAL const PDplus2S3Flux = PDplus2(&S3Flux[index]); + CCTK_REAL const PDplus2tauFlux = PDplus2(&tauFlux[index]); + + /* Calculate temporaries and grid functions */ + DenrhsL = DenrhsL - PDplus2DenFlux; + + S1rhsL = -PDplus2S1Flux + S1rhsL; + + S2rhsL = -PDplus2S2Flux + S2rhsL; + + S3rhsL = -PDplus2S3Flux + S3rhsL; + + taurhsL = -PDplus2tauFlux + taurhsL; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; + taurhs[index] = taurhsL; + } + } + } +} + +extern "C" void eulersr_cons_calc_rhs_2(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_rhs_2_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_rhs_3.cc b/Examples/EulerSR/src/eulersr_cons_calc_rhs_3.cc new file mode 100644 index 0000000..2b33c05 --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_rhs_3.cc @@ -0,0 +1,156 @@ +/* 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 eulersr_cons_calc_rhs_3_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 */, "EulerSR::Den_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::Den_grouprhs."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::S_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::S_grouprhs."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EulerSR::tau_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EulerSR::tau_grouprhs."); + return; +} + +static void eulersr_cons_calc_rhs_3_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 eulersr_cons_calc_rhs_3_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_rhs_3_calc_every != eulersr_cons_calc_rhs_3_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_flux_group","EulerSR::Den_grouprhs","EulerSR::S1_flux_group","EulerSR::S2_flux_group","EulerSR::S3_flux_group","EulerSR::S_grouprhs","EulerSR::tau_flux_group","EulerSR::tau_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_rhs_3", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulersr_cons_calc_rhs_3", 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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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 DenFluxL = DenFlux[index]; + CCTK_REAL DenrhsL = Denrhs[index]; + CCTK_REAL S1FluxL = S1Flux[index]; + CCTK_REAL S1rhsL = S1rhs[index]; + CCTK_REAL S2FluxL = S2Flux[index]; + CCTK_REAL S2rhsL = S2rhs[index]; + CCTK_REAL S3FluxL = S3Flux[index]; + CCTK_REAL S3rhsL = S3rhs[index]; + CCTK_REAL tauFluxL = tauFlux[index]; + CCTK_REAL taurhsL = taurhs[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDplus3DenFlux = PDplus3(&DenFlux[index]); + CCTK_REAL const PDplus3S1Flux = PDplus3(&S1Flux[index]); + CCTK_REAL const PDplus3S2Flux = PDplus3(&S2Flux[index]); + CCTK_REAL const PDplus3S3Flux = PDplus3(&S3Flux[index]); + CCTK_REAL const PDplus3tauFlux = PDplus3(&tauFlux[index]); + + /* Calculate temporaries and grid functions */ + DenrhsL = DenrhsL - PDplus3DenFlux; + + S1rhsL = -PDplus3S1Flux + S1rhsL; + + S2rhsL = -PDplus3S2Flux + S2rhsL; + + S3rhsL = -PDplus3S3Flux + S3rhsL; + + taurhsL = -PDplus3tauFlux + taurhsL; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; + taurhs[index] = taurhsL; + } + } + } +} + +extern "C" void eulersr_cons_calc_rhs_3(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_rhs_3_Body); +} diff --git a/Examples/EulerSR/src/eulersr_cons_calc_zero_rhs.cc b/Examples/EulerSR/src/eulersr_cons_calc_zero_rhs.cc new file mode 100644 index 0000000..1919515 --- /dev/null +++ b/Examples/EulerSR/src/eulersr_cons_calc_zero_rhs.cc @@ -0,0 +1,142 @@ +/* File produced by Kranc */ + +#define KRANC_C + +#include <assert.h> +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" +#include "GenericFD.h" +#include "Differencing.h" + +/* Define macros used in calculations */ +#define INITVALUE (42) +#define QAD(x) (SQR(SQR(x))) +#define INV(x) ((1.0) / (x)) +#define SQR(x) ((x) * (x)) +#define CUB(x) ((x) * (x) * (x)) + +static void eulersr_cons_calc_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 eulersr_cons_calc_zero_rhs_Body"); + } + + if (cctk_iteration % eulersr_cons_calc_zero_rhs_calc_every != eulersr_cons_calc_zero_rhs_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::Den_grouprhs","EulerSR::S_grouprhs","EulerSR::tau_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_cons_calc_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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = 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; + + DenrhsL = 0; + + DenrhsL = 0; + + CCTK_REAL S1rhsL = 0; + + S1rhsL = 0; + + S1rhsL = 0; + + CCTK_REAL S2rhsL = 0; + + S2rhsL = 0; + + S2rhsL = 0; + + CCTK_REAL S3rhsL = 0; + + S3rhsL = 0; + + S3rhsL = 0; + + CCTK_REAL taurhsL = 0; + + taurhsL = 0; + + taurhsL = 0; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; + taurhs[index] = taurhsL; + } + } + } +} + +extern "C" void eulersr_cons_calc_zero_rhs(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_zero_rhs_Body); +} diff --git a/Examples/EulerSR/src/eulersr_initial_shock.cc b/Examples/EulerSR/src/eulersr_initial_shock.cc new file mode 100644 index 0000000..29575c9 --- /dev/null +++ b/Examples/EulerSR/src/eulersr_initial_shock.cc @@ -0,0 +1,131 @@ +/* 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 eulersr_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 eulersr_initial_shock_Body"); + } + + if (cctk_iteration % eulersr_initial_shock_calc_every != eulersr_initial_shock_calc_offset) + { + return; + } + + const char *groups[] = {"EulerSR::epsi_group","grid::coordinates","EulerSR::rho_group","EulerSR::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulersr_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 p1odx = INV(dx); + CCTK_REAL const p1ody = INV(dy); + CCTK_REAL const p1odz = INV(dz); + + /* Loop over the grid points */ + for (k = min[2]; k < max[2]; k++) + { + for (j = min[1]; j < max[1]; j++) + { + for (i = min[0]; i < max[0]; i++) + { + int const index = CCTK_GFINDEX3D(cctkGH,i,j,k) ; + + /* Assign local copies of grid functions */ + + CCTK_REAL xL = x[index]; + CCTK_REAL yL = y[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL X = xL + yL; + + CCTK_REAL rhoL = ToReal(rhoL0) + StepFunction(X)*(-ToReal(rhoL0) + + ToReal(rhoR0)); + + CCTK_REAL v1L = ToReal(vL0) + StepFunction(X)*(-ToReal(vL0) + + ToReal(vR0)); + + CCTK_REAL v2L = ToReal(vL0) + StepFunction(X)*(-ToReal(vL0) + + ToReal(vR0)); + + CCTK_REAL v3L = ToReal(vL0) + StepFunction(X)*(-ToReal(vL0) + + ToReal(vR0)); + + CCTK_REAL epsiL = ToReal(epsiL0) + StepFunction(X)*(-ToReal(epsiL0) + + ToReal(epsiR0)); + + /* Copy local copies back to grid functions */ + epsi[index] = epsiL; + rho[index] = rhoL; + v1[index] = v1L; + v2[index] = v2L; + v3[index] = v3L; + } + } + } +} + +extern "C" void eulersr_initial_shock(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + GenericFD_LoopOverEverything(cctkGH, &eulersr_initial_shock_Body); +} diff --git a/Examples/EulerSR/src/make.code.defn b/Examples/EulerSR/src/make.code.defn new file mode 100644 index 0000000..ec747ad --- /dev/null +++ b/Examples/EulerSR/src/make.code.defn @@ -0,0 +1,3 @@ +# File produced by Kranc + +SRCS = Startup.cc RegisterMoL.cc RegisterSymmetries.cc eulersr_initial_shock.cc eulersr_cons_calc_zero_rhs.cc eulersr_cons_calc_conserved.cc eulersr_cons_calc_primitives.cc eulersr_cons_calc_reconstruct_1.cc eulersr_cons_calc_intercell_conserved_1.cc eulersr_cons_calc_flux_1.cc eulersr_cons_calc_rhs_1.cc eulersr_cons_calc_reconstruct_2.cc eulersr_cons_calc_intercell_conserved_2.cc eulersr_cons_calc_flux_2.cc eulersr_cons_calc_rhs_2.cc eulersr_cons_calc_reconstruct_3.cc eulersr_cons_calc_intercell_conserved_3.cc eulersr_cons_calc_flux_3.cc eulersr_cons_calc_rhs_3.cc Boundaries.cc |