diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2012-01-25 16:26:38 -0600 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2012-01-25 16:26:38 -0600 |
commit | 66351c0bf0cd499d942874e922c9bd658cc52752 (patch) | |
tree | b8aa94554ef7be6ad059eb4a74a15b23e58193d3 /Examples | |
parent | 967e562ad70137c50d31762df2b8e5c897c8fe24 (diff) |
Regenerate SimpleWaveCaKernel
Diffstat (limited to 'Examples')
-rw-r--r-- | Examples/SimpleWaveCaKernel/cakernel.ccl | 54 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/interface.ccl | 16 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/param.ccl | 148 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/schedule.ccl | 61 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/src/Boundaries.cc | 208 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/src/RegisterMoL.cc | 2 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/src/calc_rhs.code | 78 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/src/initial_sine.code | 68 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/src/rk1.code | 73 |
9 files changed, 698 insertions, 10 deletions
diff --git a/Examples/SimpleWaveCaKernel/cakernel.ccl b/Examples/SimpleWaveCaKernel/cakernel.ccl index 78dfad4..c4aa03c 100644 --- a/Examples/SimpleWaveCaKernel/cakernel.ccl +++ b/Examples/SimpleWaveCaKernel/cakernel.ccl @@ -13,3 +13,57 @@ CCTK_CUDA_KERNEL initial_sine TYPE=gpu_cuda/3dblock STENCIL=0,0,0,0,0,0 TILE=16, "pi" } +CCTK_CUDA_KERNEL calc_rhs TYPE=gpu_cuda/3dblock STENCIL=0,0,0,0,0,0 TILE=16,16,16 SHARECODE=yes +{ + CCTK_CUDA_KERNEL_VARIABLE cached=yes intent=in + { + phi + } + "phi" + + CCTK_CUDA_KERNEL_VARIABLE cached=yes intent=out + { + phirhs + } + "phirhs" + + CCTK_CUDA_KERNEL_VARIABLE cached=yes intent=in + { + pi + } + "pi" + + CCTK_CUDA_KERNEL_VARIABLE cached=yes intent=out + { + pirhs + } + "pirhs" +} + +CCTK_CUDA_KERNEL rk1 TYPE=gpu_cuda/3dblock STENCIL=0,0,0,0,0,0 TILE=16,16,16 SHARECODE=yes +{ + CCTK_CUDA_KERNEL_VARIABLE cached=yes intent=inout + { + phi + } + "phi" + + CCTK_CUDA_KERNEL_VARIABLE cached=yes intent=in + { + phirhs + } + "phirhs" + + CCTK_CUDA_KERNEL_VARIABLE cached=yes intent=in + { + pi + } + "pi" + + CCTK_CUDA_KERNEL_VARIABLE cached=yes intent=in + { + pirhs + } + "pirhs" +} + diff --git a/Examples/SimpleWaveCaKernel/interface.ccl b/Examples/SimpleWaveCaKernel/interface.ccl index 0dad3ec..c65ef50 100644 --- a/Examples/SimpleWaveCaKernel/interface.ccl +++ b/Examples/SimpleWaveCaKernel/interface.ccl @@ -28,13 +28,25 @@ CCTK_INT FUNCTION Boundary_SelectVarForBC(CCTK_POINTER_TO_CONST IN GH, CCTK_INT USES FUNCTION Boundary_SelectVarForBC public: -CCTK_REAL phi_g type=GF timelevels=1 tags='' +CCTK_REAL phi_g type=GF timelevels=3 tags='' { phi } "phi_g" public: -CCTK_REAL pi_g type=GF timelevels=1 tags='' +CCTK_REAL pi_g type=GF timelevels=3 tags='' { pi } "pi_g" + +public: +CCTK_REAL phi_grhs type=GF timelevels=3 tags='' +{ + phirhs +} "phi_grhs" + +public: +CCTK_REAL pi_grhs type=GF timelevels=3 tags='' +{ + pirhs +} "pi_grhs" diff --git a/Examples/SimpleWaveCaKernel/param.ccl b/Examples/SimpleWaveCaKernel/param.ccl index 0350b70..60327e0 100644 --- a/Examples/SimpleWaveCaKernel/param.ccl +++ b/Examples/SimpleWaveCaKernel/param.ccl @@ -19,8 +19,8 @@ CCTK_INT verbose "verbose" STEERABLE=ALWAYS restricted: CCTK_INT SimpleWaveCaKernel_MaxNumEvolvedVars "Number of evolved variables used by this thorn" ACCUMULATOR-BASE=MethodofLines::MoL_Num_Evolved_Vars STEERABLE=RECOVER { - 0:0 :: "Number of evolved variables used by this thorn" -} 0 + 2:2 :: "Number of evolved variables used by this thorn" +} 2 restricted: CCTK_INT SimpleWaveCaKernel_MaxNumArrayEvolvedVars "Number of Array evolved variables used by this thorn" ACCUMULATOR-BASE=MethodofLines::MoL_Num_ArrayEvolved_Vars STEERABLE=RECOVER @@ -53,8 +53,152 @@ CCTK_INT initial_sine_calc_every "initial_sine_calc_every" STEERABLE=ALWAYS } 1 restricted: +CCTK_INT calc_rhs_calc_every "calc_rhs_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT rk1_calc_every "rk1_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: CCTK_INT initial_sine_calc_offset "initial_sine_calc_offset" STEERABLE=ALWAYS { *:* :: "" } 0 +restricted: +CCTK_INT calc_rhs_calc_offset "calc_rhs_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT rk1_calc_offset "rk1_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +private: +KEYWORD phi_bound "Boundary condition to implement" STEERABLE=ALWAYS +{ + "flat" :: "Flat boundary condition" + "none" :: "No boundary condition" + "static" :: "Boundaries held fixed" + "radiative" :: "Radiation boundary condition" + "scalar" :: "Dirichlet boundary condition" + "newrad" :: "Improved radiative boundary condition" + "skip" :: "skip boundary condition code" +} "skip" + +private: +KEYWORD pi_bound "Boundary condition to implement" STEERABLE=ALWAYS +{ + "flat" :: "Flat boundary condition" + "none" :: "No boundary condition" + "static" :: "Boundaries held fixed" + "radiative" :: "Radiation boundary condition" + "scalar" :: "Dirichlet boundary condition" + "newrad" :: "Improved radiative boundary condition" + "skip" :: "skip boundary condition code" +} "skip" + +private: +KEYWORD phi_g_bound "Boundary condition to implement" STEERABLE=ALWAYS +{ + "flat" :: "Flat boundary condition" + "none" :: "No boundary condition" + "static" :: "Boundaries held fixed" + "radiative" :: "Radiation boundary condition" + "scalar" :: "Dirichlet boundary condition" + "newrad" :: "Improved radiative boundary condition" + "skip" :: "skip boundary condition code" +} "none" + +private: +KEYWORD pi_g_bound "Boundary condition to implement" STEERABLE=ALWAYS +{ + "flat" :: "Flat boundary condition" + "none" :: "No boundary condition" + "static" :: "Boundaries held fixed" + "radiative" :: "Radiation boundary condition" + "scalar" :: "Dirichlet boundary condition" + "newrad" :: "Improved radiative boundary condition" + "skip" :: "skip boundary condition code" +} "none" + +private: +CCTK_REAL phi_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL pi_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL phi_g_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL pi_g_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS +{ + "0:*" :: "outgoing characteristic speed > 0" +} 1. + +private: +CCTK_REAL phi_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL pi_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL phi_g_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL pi_g_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS +{ + "*:*" :: "value of limit value is unrestricted" +} 0. + +private: +CCTK_REAL phi_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + +private: +CCTK_REAL pi_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + +private: +CCTK_REAL phi_g_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + +private: +CCTK_REAL pi_g_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS +{ + "*:*" :: "unrestricted" +} 0. + diff --git a/Examples/SimpleWaveCaKernel/schedule.ccl b/Examples/SimpleWaveCaKernel/schedule.ccl index 35de27d..bd66804 100644 --- a/Examples/SimpleWaveCaKernel/schedule.ccl +++ b/Examples/SimpleWaveCaKernel/schedule.ccl @@ -1,15 +1,57 @@ # File produced by Kranc -if (other_timelevels == 1) +if (timelevels == 1) { STORAGE: phi_g[1] } +if (timelevels == 2) +{ + STORAGE: phi_g[2] +} +if (timelevels == 3) +{ + STORAGE: phi_g[3] +} -if (other_timelevels == 1) +if (timelevels == 1) { STORAGE: pi_g[1] } +if (timelevels == 2) +{ + STORAGE: pi_g[2] +} +if (timelevels == 3) +{ + STORAGE: pi_g[3] +} + +if (rhs_timelevels == 1) +{ + STORAGE: phi_grhs[1] +} +if (rhs_timelevels == 2) +{ + STORAGE: phi_grhs[2] +} +if (rhs_timelevels == 3) +{ + STORAGE: phi_grhs[3] +} + +if (rhs_timelevels == 1) +{ + STORAGE: pi_grhs[1] +} +if (rhs_timelevels == 2) +{ + STORAGE: pi_grhs[2] +} +if (rhs_timelevels == 3) +{ + STORAGE: pi_grhs[3] +} schedule SimpleWaveCaKernel_Startup at STARTUP { @@ -34,10 +76,25 @@ schedule CAKERNEL_Launch_initial_sine AT INITIAL LANG: C } "initial_sine" +schedule CAKERNEL_Launch_calc_rhs at EVOL +{ + LANG: C + SYNC: phi_grhs + SYNC: pi_grhs +} "calc_rhs" + +schedule CAKERNEL_Launch_rk1 at EVOL after calc_rhs +{ + LANG: C + SYNC: phi_g +} "rk1" + schedule SimpleWaveCaKernel_SelectBoundConds in MoL_PostStep { LANG: C OPTIONS: level + SYNC: phi_g + SYNC: pi_g } "select boundary conditions" schedule SimpleWaveCaKernel_CheckBoundaries at BASEGRID diff --git a/Examples/SimpleWaveCaKernel/src/Boundaries.cc b/Examples/SimpleWaveCaKernel/src/Boundaries.cc index 0417d10..11561bf 100644 --- a/Examples/SimpleWaveCaKernel/src/Boundaries.cc +++ b/Examples/SimpleWaveCaKernel/src/Boundaries.cc @@ -31,11 +31,219 @@ extern "C" void SimpleWaveCaKernel_SelectBoundConds(CCTK_ARGUMENTS) DECLARE_CCTK_PARAMETERS; CCTK_INT ierr = 0; + + if (CCTK_EQUALS(phi_g_bound, "none" ) || + CCTK_EQUALS(phi_g_bound, "static") || + CCTK_EQUALS(phi_g_bound, "flat" ) || + CCTK_EQUALS(phi_g_bound, "zero" ) ) + { + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "SimpleWaveCaKernel::phi_g", phi_g_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register phi_g_bound BC for SimpleWaveCaKernel::phi_g!"); + } + + if (CCTK_EQUALS(pi_g_bound, "none" ) || + CCTK_EQUALS(pi_g_bound, "static") || + CCTK_EQUALS(pi_g_bound, "flat" ) || + CCTK_EQUALS(pi_g_bound, "zero" ) ) + { + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "SimpleWaveCaKernel::pi_g", pi_g_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register pi_g_bound BC for SimpleWaveCaKernel::pi_g!"); + } + + if (CCTK_EQUALS(phi_bound, "none" ) || + CCTK_EQUALS(phi_bound, "static") || + CCTK_EQUALS(phi_bound, "flat" ) || + CCTK_EQUALS(phi_bound, "zero" ) ) + { + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "SimpleWaveCaKernel::phi", phi_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register phi_bound BC for SimpleWaveCaKernel::phi!"); + } + + if (CCTK_EQUALS(pi_bound, "none" ) || + CCTK_EQUALS(pi_bound, "static") || + CCTK_EQUALS(pi_bound, "flat" ) || + CCTK_EQUALS(pi_bound, "zero" ) ) + { + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1, + "SimpleWaveCaKernel::pi", pi_bound); + if (ierr < 0) + CCTK_WARN(0, "Failed to register pi_bound BC for SimpleWaveCaKernel::pi!"); + } + + if (CCTK_EQUALS(phi_g_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_phi_g_bound = -1; + if (handle_phi_g_bound < 0) handle_phi_g_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_phi_g_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_phi_g_bound , phi_g_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_phi_g_bound ,phi_g_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_phi_g_bound, + "SimpleWaveCaKernel::phi_g", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for SimpleWaveCaKernel::phi_g!"); + + } + + if (CCTK_EQUALS(pi_g_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_pi_g_bound = -1; + if (handle_pi_g_bound < 0) handle_pi_g_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_pi_g_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_pi_g_bound , pi_g_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_pi_g_bound ,pi_g_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_pi_g_bound, + "SimpleWaveCaKernel::pi_g", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for SimpleWaveCaKernel::pi_g!"); + + } + + if (CCTK_EQUALS(phi_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_phi_bound = -1; + if (handle_phi_bound < 0) handle_phi_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_phi_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_phi_bound , phi_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_phi_bound ,phi_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_phi_bound, + "SimpleWaveCaKernel::phi", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for SimpleWaveCaKernel::phi!"); + + } + + if (CCTK_EQUALS(pi_bound, "radiative")) + { + /* select radiation boundary condition */ + static CCTK_INT handle_pi_bound = -1; + if (handle_pi_bound < 0) handle_pi_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_pi_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_pi_bound , pi_bound_limit, "LIMIT") < 0) + CCTK_WARN(0, "could not set LIMIT value in table!"); + if (Util_TableSetReal(handle_pi_bound ,pi_bound_speed, "SPEED") < 0) + CCTK_WARN(0, "could not set SPEED value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_pi_bound, + "SimpleWaveCaKernel::pi", "Radiation"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Radiation BC for SimpleWaveCaKernel::pi!"); + + } + + if (CCTK_EQUALS(phi_g_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_phi_g_bound = -1; + if (handle_phi_g_bound < 0) handle_phi_g_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_phi_g_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_phi_g_bound ,phi_g_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_phi_g_bound, + "SimpleWaveCaKernel::phi_g", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Scalar BC for SimpleWaveCaKernel::phi_g!"); + + } + + if (CCTK_EQUALS(pi_g_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_pi_g_bound = -1; + if (handle_pi_g_bound < 0) handle_pi_g_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_pi_g_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_pi_g_bound ,pi_g_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, handle_pi_g_bound, + "SimpleWaveCaKernel::pi_g", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Failed to register Scalar BC for SimpleWaveCaKernel::pi_g!"); + + } + + if (CCTK_EQUALS(phi_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_phi_bound = -1; + if (handle_phi_bound < 0) handle_phi_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_phi_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_phi_bound ,phi_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_phi_bound, + "SimpleWaveCaKernel::phi", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for SimpleWaveCaKernel::phi!"); + + } + + if (CCTK_EQUALS(pi_bound, "scalar")) + { + /* select scalar boundary condition */ + static CCTK_INT handle_pi_bound = -1; + if (handle_pi_bound < 0) handle_pi_bound = Util_TableCreate(UTIL_TABLE_FLAGS_CASE_INSENSITIVE); + if (handle_pi_bound < 0) CCTK_WARN(0, "could not create table!"); + if (Util_TableSetReal(handle_pi_bound ,pi_bound_scalar, "SCALAR") < 0) + CCTK_WARN(0, "could not set SCALAR value in table!"); + + ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, handle_pi_bound, + "SimpleWaveCaKernel::pi", "scalar"); + + if (ierr < 0) + CCTK_WARN(0, "Error in registering Scalar BC for SimpleWaveCaKernel::pi!"); + + } return; } /* template for entries in parameter file: +#$bound$#SimpleWaveCaKernel::phi_g_bound = "skip" +#$bound$#SimpleWaveCaKernel::phi_g_bound_speed = 1.0 +#$bound$#SimpleWaveCaKernel::phi_g_bound_limit = 0.0 +#$bound$#SimpleWaveCaKernel::phi_g_bound_scalar = 0.0 + +#$bound$#SimpleWaveCaKernel::pi_g_bound = "skip" +#$bound$#SimpleWaveCaKernel::pi_g_bound_speed = 1.0 +#$bound$#SimpleWaveCaKernel::pi_g_bound_limit = 0.0 +#$bound$#SimpleWaveCaKernel::pi_g_bound_scalar = 0.0 + +#$bound$#SimpleWaveCaKernel::phi_bound = "skip" +#$bound$#SimpleWaveCaKernel::phi_bound_speed = 1.0 +#$bound$#SimpleWaveCaKernel::phi_bound_limit = 0.0 +#$bound$#SimpleWaveCaKernel::phi_bound_scalar = 0.0 + +#$bound$#SimpleWaveCaKernel::pi_bound = "skip" +#$bound$#SimpleWaveCaKernel::pi_bound_speed = 1.0 +#$bound$#SimpleWaveCaKernel::pi_bound_limit = 0.0 +#$bound$#SimpleWaveCaKernel::pi_bound_scalar = 0.0 + */ diff --git a/Examples/SimpleWaveCaKernel/src/RegisterMoL.cc b/Examples/SimpleWaveCaKernel/src/RegisterMoL.cc index 3e35f8d..ac8c57b 100644 --- a/Examples/SimpleWaveCaKernel/src/RegisterMoL.cc +++ b/Examples/SimpleWaveCaKernel/src/RegisterMoL.cc @@ -12,6 +12,8 @@ extern "C" void SimpleWaveCaKernel_RegisterVars(CCTK_ARGUMENTS) CCTK_INT ierr = 0; /* Register all the evolved grid functions with MoL */ + ierr += MoLRegisterEvolved(CCTK_VarIndex("SimpleWaveCaKernel::phi"), CCTK_VarIndex("SimpleWaveCaKernel::phirhs")); + ierr += MoLRegisterEvolved(CCTK_VarIndex("SimpleWaveCaKernel::pi"), CCTK_VarIndex("SimpleWaveCaKernel::pirhs")); /* Register all the evolved Array functions with MoL */ return; diff --git a/Examples/SimpleWaveCaKernel/src/calc_rhs.code b/Examples/SimpleWaveCaKernel/src/calc_rhs.code new file mode 100644 index 0000000..f21f507 --- /dev/null +++ b/Examples/SimpleWaveCaKernel/src/calc_rhs.code @@ -0,0 +1,78 @@ +#include "GenericFD.h" +#include "Differencing.h" + +#define CCTK_GFINDEX3D(u,i,j,k) I3D(u,i,j,k) + +CAKERNEL_calc_rhs_Begin_s + + /* Declare finite differencing variables */ + + /* Include user-supplied include files */ + + /* Initialise finite differencing variables */ + ptrdiff_t const di = 1; + ptrdiff_t const dj = CCTK_GFINDEX3D(cctkGH,0,1,0) - CCTK_GFINDEX3D(cctkGH,0,0,0); + ptrdiff_t const dk = CCTK_GFINDEX3D(cctkGH,0,0,1) - CCTK_GFINDEX3D(cctkGH,0,0,0); + ptrdiff_t const cdi = sizeof(CCTK_REAL) * di; + ptrdiff_t const cdj = sizeof(CCTK_REAL) * dj; + ptrdiff_t const cdk = sizeof(CCTK_REAL) * dk; + CCTK_REAL const dx = ToReal(CCTK_DELTA_SPACE(0)); + CCTK_REAL const dy = ToReal(CCTK_DELTA_SPACE(1)); + CCTK_REAL const dz = ToReal(CCTK_DELTA_SPACE(2)); + CCTK_REAL const dt = ToReal(CCTK_DELTA_TIME); + CCTK_REAL const t = ToReal(cctk_time); + CCTK_REAL const dxi = INV(dx); + CCTK_REAL const dyi = INV(dy); + CCTK_REAL const dzi = INV(dz); + CCTK_REAL const khalf = 0.5; + CCTK_REAL const kthird = 1/3.0; + CCTK_REAL const ktwothird = 2.0/3.0; + CCTK_REAL const kfourthird = 4.0/3.0; + CCTK_REAL const keightthird = 8.0/3.0; + CCTK_REAL const hdxi = 0.5 * dxi; + CCTK_REAL const hdyi = 0.5 * dyi; + CCTK_REAL const hdzi = 0.5 * dzi; + + /* Initialize predefined quantities */ + CCTK_REAL const p1o2dx = 0.5*INV(dx); + CCTK_REAL const p1o2dy = 0.5*INV(dy); + CCTK_REAL const p1o2dz = 0.5*INV(dz); + CCTK_REAL const p1odx2 = INV(SQR(dx)); + CCTK_REAL const p1ody2 = INV(SQR(dy)); + CCTK_REAL const p1odz2 = INV(SQR(dz)); + + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + CAKERNEL_calc_rhs_Computations_Begin_s + + /* Assign local copies of grid functions */ + + CCTK_REAL phiL = I3D(phi,0,0,0); + CCTK_REAL piL = I3D(pi,0,0,0); + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDstandard2nd11phi = PDstandard2nd11(&phi[index]); + CCTK_REAL const PDstandard2nd22phi = PDstandard2nd22(&phi[index]); + CCTK_REAL const PDstandard2nd33phi = PDstandard2nd33(&phi[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL phirhsL = piL; + + CCTK_REAL pirhsL = PDstandard2nd11phi + PDstandard2nd22phi + + PDstandard2nd33phi; + + /* Copy local copies back to grid functions */ + I3D(phirhs,0,0,0) = phirhsL; + I3D(pirhs,0,0,0) = pirhsL; + + CAKERNEL_calc_rhs_Computations_End_s + +CAKERNEL_calc_rhs_End_s diff --git a/Examples/SimpleWaveCaKernel/src/initial_sine.code b/Examples/SimpleWaveCaKernel/src/initial_sine.code index 41e6fcf..293d70a 100644 --- a/Examples/SimpleWaveCaKernel/src/initial_sine.code +++ b/Examples/SimpleWaveCaKernel/src/initial_sine.code @@ -1,11 +1,71 @@ +#include "GenericFD.h" +#include "Differencing.h" + +#define CCTK_GFINDEX3D(u,i,j,k) I3D(u,i,j,k) + CAKERNEL_initial_sine_Begin_s + + /* Declare finite differencing variables */ + + /* Include user-supplied include files */ + + /* Initialise finite differencing variables */ + ptrdiff_t const di = 1; + ptrdiff_t const dj = CCTK_GFINDEX3D(cctkGH,0,1,0) - CCTK_GFINDEX3D(cctkGH,0,0,0); + ptrdiff_t const dk = CCTK_GFINDEX3D(cctkGH,0,0,1) - CCTK_GFINDEX3D(cctkGH,0,0,0); + ptrdiff_t const cdi = sizeof(CCTK_REAL) * di; + ptrdiff_t const cdj = sizeof(CCTK_REAL) * dj; + ptrdiff_t const cdk = sizeof(CCTK_REAL) * dk; + CCTK_REAL const dx = ToReal(CCTK_DELTA_SPACE(0)); + CCTK_REAL const dy = ToReal(CCTK_DELTA_SPACE(1)); + CCTK_REAL const dz = ToReal(CCTK_DELTA_SPACE(2)); + CCTK_REAL const dt = ToReal(CCTK_DELTA_TIME); + CCTK_REAL const t = ToReal(cctk_time); + CCTK_REAL const dxi = INV(dx); + CCTK_REAL const dyi = INV(dy); + CCTK_REAL const dzi = INV(dz); + CCTK_REAL const khalf = 0.5; + CCTK_REAL const kthird = 1/3.0; + CCTK_REAL const ktwothird = 2.0/3.0; + CCTK_REAL const kfourthird = 4.0/3.0; + CCTK_REAL const keightthird = 8.0/3.0; + CCTK_REAL const hdxi = 0.5 * dxi; + CCTK_REAL const hdyi = 0.5 * dyi; + CCTK_REAL const hdzi = 0.5 * dzi; + + /* Initialize predefined quantities */ + CCTK_REAL const p1o2dx = 0.5*INV(dx); + CCTK_REAL const p1o2dy = 0.5*INV(dy); + CCTK_REAL const p1o2dz = 0.5*INV(dz); + CCTK_REAL const p1odx2 = INV(SQR(dx)); + CCTK_REAL const p1ody2 = INV(SQR(dy)); + CCTK_REAL const p1odz2 = INV(SQR(dz)); + + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ CAKERNEL_initial_sine_Computations_Begin_s - // phi -> 0 - phi(0,0,0) = 0 - // pi -> 0 - pi(0,0,0) = 0 + /* Assign local copies of grid functions */ + + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL phiL = 0; + + CCTK_REAL piL = 0; + /* Copy local copies back to grid functions */ + I3D(phi,0,0,0) = phiL; + I3D(pi,0,0,0) = piL; CAKERNEL_initial_sine_Computations_End_s diff --git a/Examples/SimpleWaveCaKernel/src/rk1.code b/Examples/SimpleWaveCaKernel/src/rk1.code new file mode 100644 index 0000000..ed4bb7a --- /dev/null +++ b/Examples/SimpleWaveCaKernel/src/rk1.code @@ -0,0 +1,73 @@ +#include "GenericFD.h" +#include "Differencing.h" + +#define CCTK_GFINDEX3D(u,i,j,k) I3D(u,i,j,k) + +CAKERNEL_rk1_Begin_s + + /* Declare finite differencing variables */ + + /* Include user-supplied include files */ + + /* Initialise finite differencing variables */ + ptrdiff_t const di = 1; + ptrdiff_t const dj = CCTK_GFINDEX3D(cctkGH,0,1,0) - CCTK_GFINDEX3D(cctkGH,0,0,0); + ptrdiff_t const dk = CCTK_GFINDEX3D(cctkGH,0,0,1) - CCTK_GFINDEX3D(cctkGH,0,0,0); + ptrdiff_t const cdi = sizeof(CCTK_REAL) * di; + ptrdiff_t const cdj = sizeof(CCTK_REAL) * dj; + ptrdiff_t const cdk = sizeof(CCTK_REAL) * dk; + CCTK_REAL const dx = ToReal(CCTK_DELTA_SPACE(0)); + CCTK_REAL const dy = ToReal(CCTK_DELTA_SPACE(1)); + CCTK_REAL const dz = ToReal(CCTK_DELTA_SPACE(2)); + CCTK_REAL const dt = ToReal(CCTK_DELTA_TIME); + CCTK_REAL const t = ToReal(cctk_time); + CCTK_REAL const dxi = INV(dx); + CCTK_REAL const dyi = INV(dy); + CCTK_REAL const dzi = INV(dz); + CCTK_REAL const khalf = 0.5; + CCTK_REAL const kthird = 1/3.0; + CCTK_REAL const ktwothird = 2.0/3.0; + CCTK_REAL const kfourthird = 4.0/3.0; + CCTK_REAL const keightthird = 8.0/3.0; + CCTK_REAL const hdxi = 0.5 * dxi; + CCTK_REAL const hdyi = 0.5 * dyi; + CCTK_REAL const hdzi = 0.5 * dzi; + + /* Initialize predefined quantities */ + CCTK_REAL const p1o2dx = 0.5*INV(dx); + CCTK_REAL const p1o2dy = 0.5*INV(dy); + CCTK_REAL const p1o2dz = 0.5*INV(dz); + CCTK_REAL const p1odx2 = INV(SQR(dx)); + CCTK_REAL const p1ody2 = INV(SQR(dy)); + CCTK_REAL const p1odz2 = INV(SQR(dz)); + + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + CAKERNEL_rk1_Computations_Begin_s + + /* Assign local copies of grid functions */ + + CCTK_REAL phiL = I3D(phi,0,0,0); + CCTK_REAL phirhsL = I3D(phirhs,0,0,0); + CCTK_REAL piL = I3D(pi,0,0,0); + CCTK_REAL pirhsL = I3D(pirhs,0,0,0); + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + phiL = Rule(phiL + phirhsL*piL*dt,piL + pirhsL*dt); + + /* Copy local copies back to grid functions */ + I3D(phi,0,0,0) = phiL; + + CAKERNEL_rk1_Computations_End_s + +CAKERNEL_rk1_End_s |