diff options
Diffstat (limited to 'Examples/SimpleWaveCaKernel/src')
-rw-r--r-- | Examples/SimpleWaveCaKernel/src/CaKernel__calc_bound_rhs.code (renamed from Examples/SimpleWaveCaKernel/src/CaKernel__initial_gaussian.code) | 46 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/src/CaKernel__copy_to_device.code (renamed from Examples/SimpleWaveCaKernel/src/CaKernel__rk1.code) | 14 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/src/RegisterSymmetries.cc | 5 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/src/initial_gaussian.cc | 131 | ||||
-rw-r--r-- | Examples/SimpleWaveCaKernel/src/make.code.defn | 2 |
5 files changed, 165 insertions, 33 deletions
diff --git a/Examples/SimpleWaveCaKernel/src/CaKernel__initial_gaussian.code b/Examples/SimpleWaveCaKernel/src/CaKernel__calc_bound_rhs.code index 40f6037..863ad4f 100644 --- a/Examples/SimpleWaveCaKernel/src/CaKernel__initial_gaussian.code +++ b/Examples/SimpleWaveCaKernel/src/CaKernel__calc_bound_rhs.code @@ -14,7 +14,7 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -CAKERNEL_initial_gaussian_Begin +CAKERNEL_calc_bound_rhs_Begin /* Include user-supplied include files */ @@ -51,26 +51,24 @@ CAKERNEL_initial_gaussian_Begin /* Calculate temporaries and arrays functions */ /* Copy local copies back to grid functions */ - CAKERNEL_initial_gaussian_Computations_Begin - - /* Assign local copies of grid functions */ - - CCTK_REAL xL = I3D(x,0,0,0); - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL phiL = exp(-100.*SQR(xL + t)); - - CCTK_REAL piL = -200.*(xL + t)*exp(-100.*SQR(xL + t)); - - /* Copy local copies back to grid functions */ - I3D(phi,0,0,0) = phiL; - I3D(pi,0,0,0) = piL; - - CAKERNEL_initial_gaussian_Computations_End - -CAKERNEL_initial_gaussian_End + + /* Assign local copies of grid functions */ + + CCTK_REAL xCopyL = I3D(xCopy,0,0,0); + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL phirhsL = -200.*(xCopyL + t)*exp(-100.*SQR(xCopyL + t)); + + CCTK_REAL pirhsL = exp(-100.*SQR(xCopyL + t))*(-200. + + 80000.*xCopyL*t + 40000.*(SQR(xCopyL) + SQR(t))); + + /* Copy local copies back to grid functions */ + I3D(phirhs,0,0,0) = phirhsL; + I3D(pirhs,0,0,0) = pirhsL; + +CAKERNEL_calc_bound_rhs_End diff --git a/Examples/SimpleWaveCaKernel/src/CaKernel__rk1.code b/Examples/SimpleWaveCaKernel/src/CaKernel__copy_to_device.code index e3feb54..24b4566 100644 --- a/Examples/SimpleWaveCaKernel/src/CaKernel__rk1.code +++ b/Examples/SimpleWaveCaKernel/src/CaKernel__copy_to_device.code @@ -14,7 +14,7 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -CAKERNEL_rk1_Begin +CAKERNEL_copy_to_device_Begin /* Include user-supplied include files */ @@ -51,14 +51,12 @@ CAKERNEL_rk1_Begin /* Calculate temporaries and arrays functions */ /* Copy local copies back to grid functions */ - CAKERNEL_rk1_Computations_Begin + CAKERNEL_copy_to_device_Computations_Begin /* 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 */ @@ -66,14 +64,14 @@ CAKERNEL_rk1_Begin /* Precompute derivatives */ /* Calculate temporaries and grid functions */ - phiL = phiL + phirhsL*dt; + phiL = phiL; - piL = piL + pirhsL*dt; + piL = piL; /* Copy local copies back to grid functions */ I3D(phi,0,0,0) = phiL; I3D(pi,0,0,0) = piL; - CAKERNEL_rk1_Computations_End + CAKERNEL_copy_to_device_Computations_End -CAKERNEL_rk1_End +CAKERNEL_copy_to_device_End diff --git a/Examples/SimpleWaveCaKernel/src/RegisterSymmetries.cc b/Examples/SimpleWaveCaKernel/src/RegisterSymmetries.cc index 128eb50..c099f5b 100644 --- a/Examples/SimpleWaveCaKernel/src/RegisterSymmetries.cc +++ b/Examples/SimpleWaveCaKernel/src/RegisterSymmetries.cc @@ -26,4 +26,9 @@ extern "C" void SimpleWaveCaKernel_RegisterSymmetries(CCTK_ARGUMENTS) sym[2] = 1; SetCartSymVN(cctkGH, sym, "SimpleWaveCaKernel::pi"); + sym[0] = 1; + sym[1] = 1; + sym[2] = 1; + SetCartSymVN(cctkGH, sym, "SimpleWaveCaKernel::xCopy"); + } diff --git a/Examples/SimpleWaveCaKernel/src/initial_gaussian.cc b/Examples/SimpleWaveCaKernel/src/initial_gaussian.cc new file mode 100644 index 0000000..55bd228 --- /dev/null +++ b/Examples/SimpleWaveCaKernel/src/initial_gaussian.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" +#include "cctk_Loop.h" +#include "loopcontrol.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 initial_gaussian_Body(cGH const * restrict const cctkGH, int const dir, int const face, CCTK_REAL const normal[3], CCTK_REAL const tangentA[3], CCTK_REAL const tangentB[3], int const imin[3], int const imax[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[]) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + + /* 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 */ + + /* Loop over the grid points */ + #pragma omp parallel + CCTK_LOOP3(initial_gaussian, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) + { + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL xL = x[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL phiL = exp(-100.*SQR(xL + t)); + + CCTK_REAL piL = -200.*(xL + t)*exp(-100.*SQR(xL + t)); + + CCTK_REAL xCopyL = xL; + + /* Copy local copies back to grid functions */ + phi[index] = phiL; + pi[index] = piL; + xCopy[index] = xCopyL; + } + CCTK_ENDLOOP3(initial_gaussian); +} + +extern "C" void initial_gaussian(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering initial_gaussian_Body"); + } + + if (cctk_iteration % initial_gaussian_calc_every != initial_gaussian_calc_offset) + { + return; + } + + const char *groups[] = {"grid::coordinates","SimpleWaveCaKernel::phi_g","SimpleWaveCaKernel::pi_g","SimpleWaveCaKernel::xCopy_g"}; + GenericFD_AssertGroupStorage(cctkGH, "initial_gaussian", 4, groups); + + + GenericFD_LoopOverEverything(cctkGH, &initial_gaussian_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving initial_gaussian_Body"); + } +} diff --git a/Examples/SimpleWaveCaKernel/src/make.code.defn b/Examples/SimpleWaveCaKernel/src/make.code.defn index 5e729f5..c43661b 100644 --- a/Examples/SimpleWaveCaKernel/src/make.code.defn +++ b/Examples/SimpleWaveCaKernel/src/make.code.defn @@ -1,3 +1,3 @@ # File produced by Kranc -SRCS = Startup.cc RegisterMoL.cc RegisterSymmetries.cc Boundaries.cc +SRCS = Startup.cc RegisterSymmetries.cc RegisterMoL.cc initial_gaussian.cc Boundaries.cc |