From d3c1d765b67c103f714a22d6d62d0465f1639c09 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Fri, 27 Jan 2012 15:29:53 -0600 Subject: Generate AdvectCaKernel --- Examples/AdvectCaKernel/cakernel.ccl | 15 +++++ Examples/AdvectCaKernel/configuration.ccl | 6 ++ Examples/AdvectCaKernel/interface.ccl | 34 +++++++++++ Examples/AdvectCaKernel/param.ccl | 60 +++++++++++++++++++ Examples/AdvectCaKernel/schedule.ccl | 57 ++++++++++++++++++ Examples/AdvectCaKernel/src/Boundaries.cc | 41 +++++++++++++ .../src/CaKernel__initial_gaussian.code | 67 ++++++++++++++++++++++ Examples/AdvectCaKernel/src/Differencing.h | 12 ++++ Examples/AdvectCaKernel/src/RegisterMoL.cc | 18 ++++++ Examples/AdvectCaKernel/src/RegisterSymmetries.cc | 24 ++++++++ Examples/AdvectCaKernel/src/Startup.cc | 10 ++++ Examples/AdvectCaKernel/src/make.code.defn | 8 +++ 12 files changed, 352 insertions(+) create mode 100644 Examples/AdvectCaKernel/cakernel.ccl create mode 100644 Examples/AdvectCaKernel/configuration.ccl create mode 100644 Examples/AdvectCaKernel/interface.ccl create mode 100644 Examples/AdvectCaKernel/param.ccl create mode 100644 Examples/AdvectCaKernel/schedule.ccl create mode 100644 Examples/AdvectCaKernel/src/Boundaries.cc create mode 100644 Examples/AdvectCaKernel/src/CaKernel__initial_gaussian.code create mode 100644 Examples/AdvectCaKernel/src/Differencing.h create mode 100644 Examples/AdvectCaKernel/src/RegisterMoL.cc create mode 100644 Examples/AdvectCaKernel/src/RegisterSymmetries.cc create mode 100644 Examples/AdvectCaKernel/src/Startup.cc create mode 100644 Examples/AdvectCaKernel/src/make.code.defn (limited to 'Examples') diff --git a/Examples/AdvectCaKernel/cakernel.ccl b/Examples/AdvectCaKernel/cakernel.ccl new file mode 100644 index 0000000..ddec99a --- /dev/null +++ b/Examples/AdvectCaKernel/cakernel.ccl @@ -0,0 +1,15 @@ +CCTK_CUDA_KERNEL initial_gaussian TYPE=gpu_cuda/3dblock STENCIL="0,0,0,0,0,0" TILE="8,8,8" SHARECODE=yes +{ + CCTK_CUDA_KERNEL_VARIABLE cached=yes intent=out + { + phi + } + "phi" + + CCTK_CUDA_KERNEL_VARIABLE cached=yes intent=in + { + x + } + "x" +} + diff --git a/Examples/AdvectCaKernel/configuration.ccl b/Examples/AdvectCaKernel/configuration.ccl new file mode 100644 index 0000000..0a66ec2 --- /dev/null +++ b/Examples/AdvectCaKernel/configuration.ccl @@ -0,0 +1,6 @@ +# File produced by Kranc + +REQUIRES GenericFD +OPTIONAL LoopControl +{ +} diff --git a/Examples/AdvectCaKernel/interface.ccl b/Examples/AdvectCaKernel/interface.ccl new file mode 100644 index 0000000..beec223 --- /dev/null +++ b/Examples/AdvectCaKernel/interface.ccl @@ -0,0 +1,34 @@ +# File produced by Kranc + +implements: AdvectCaKernel + +inherits: Grid GenericFD Boundary + + + +USES INCLUDE: GenericFD.h +USES INCLUDE: Symmetry.h +USES INCLUDE: sbp_calc_coeffs.h +USES INCLUDE: Boundary.h +USES INCLUDE: loopcontrol.h + +CCTK_INT FUNCTION MoLRegisterEvolved(CCTK_INT IN EvolvedIndex, CCTK_INT IN RHSIndex) +USES FUNCTION MoLRegisterEvolved + +SUBROUTINE Diff_coeff(CCTK_POINTER_TO_CONST IN cctkGH, CCTK_INT IN dir, CCTK_INT IN nsize, CCTK_INT OUT ARRAY imin, CCTK_INT OUT ARRAY imax, CCTK_REAL OUT ARRAY q, CCTK_INT IN table_handle) +USES FUNCTION Diff_coeff + +CCTK_INT FUNCTION MultiPatch_GetMap(CCTK_POINTER_TO_CONST IN cctkGH) +USES FUNCTION MultiPatch_GetMap + +CCTK_INT FUNCTION Boundary_SelectGroupForBC(CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN group_name, CCTK_STRING IN bc_name) +USES FUNCTION Boundary_SelectGroupForBC + +CCTK_INT FUNCTION Boundary_SelectVarForBC(CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN var_name, CCTK_STRING IN bc_name) +USES FUNCTION Boundary_SelectVarForBC + +public: +CCTK_REAL phi_g type=GF timelevels=1 tags='' +{ + phi +} "phi_g" diff --git a/Examples/AdvectCaKernel/param.ccl b/Examples/AdvectCaKernel/param.ccl new file mode 100644 index 0000000..d6f8566 --- /dev/null +++ b/Examples/AdvectCaKernel/param.ccl @@ -0,0 +1,60 @@ +# File produced by Kranc + + +shares: GenericFD + + + +shares: MethodOfLines + +USES CCTK_INT MoL_Num_Evolved_Vars +USES CCTK_INT MoL_Num_ArrayEvolved_Vars + +restricted: +CCTK_INT verbose "verbose" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + +restricted: +CCTK_INT AdvectCaKernel_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 + +restricted: +CCTK_INT AdvectCaKernel_MaxNumArrayEvolvedVars "Number of Array evolved variables used by this thorn" ACCUMULATOR-BASE=MethodofLines::MoL_Num_ArrayEvolved_Vars STEERABLE=RECOVER +{ + 0:0 :: "Number of Array evolved variables used by this thorn" +} 0 + +restricted: +CCTK_INT timelevels "Number of active timelevels" STEERABLE=RECOVER +{ + 0:1 :: "" +} 1 + +restricted: +CCTK_INT rhs_timelevels "Number of active RHS timelevels" STEERABLE=RECOVER +{ + 0:1 :: "" +} 1 + +restricted: +CCTK_INT other_timelevels "Number of active timelevels for non-evolved grid functions" STEERABLE=RECOVER +{ + 0:1 :: "" +} 1 + +restricted: +CCTK_INT initial_gaussian_calc_every "initial_gaussian_calc_every" STEERABLE=ALWAYS +{ + *:* :: "" +} 1 + +restricted: +CCTK_INT initial_gaussian_calc_offset "initial_gaussian_calc_offset" STEERABLE=ALWAYS +{ + *:* :: "" +} 0 + diff --git a/Examples/AdvectCaKernel/schedule.ccl b/Examples/AdvectCaKernel/schedule.ccl new file mode 100644 index 0000000..b83b7b8 --- /dev/null +++ b/Examples/AdvectCaKernel/schedule.ccl @@ -0,0 +1,57 @@ +# File produced by Kranc + + +if (other_timelevels == 1) +{ + STORAGE: phi_g[1] +} + +schedule AdvectCaKernel_Startup at STARTUP +{ + LANG: C + OPTIONS: meta +} "create banner" + +schedule AdvectCaKernel_RegisterVars in MoL_Register +{ + LANG: C + OPTIONS: meta +} "Register Variables for MoL" + +schedule AdvectCaKernel_RegisterSymmetries in SymmetryRegister +{ + LANG: C + OPTIONS: meta +} "register symmetries" + +schedule CAKERNEL_Launch_initial_gaussian AT INITIAL +{ + LANG: C +} "initial_gaussian" + +schedule AdvectCaKernel_SelectBoundConds in MoL_PostStep +{ + LANG: C + OPTIONS: level +} "select boundary conditions" + +schedule AdvectCaKernel_CheckBoundaries at BASEGRID +{ + LANG: C + OPTIONS: meta +} "check boundaries treatment" + +schedule CaKernel_CopyFromDev at ANALYSIS +{ + LANG: C +} "Copy variables from devices" + +schedule group ApplyBCs as AdvectCaKernel_ApplyBCs in MoL_PostStep after AdvectCaKernel_SelectBoundConds +{ + # no language specified +} "Apply boundary conditions controlled by thorn Boundary" + + +############################################################ +#CAKERNEL AUTO GENERATED PART. DO NOT EDIT BELOW THIS POINT# +############################################################ diff --git a/Examples/AdvectCaKernel/src/Boundaries.cc b/Examples/AdvectCaKernel/src/Boundaries.cc new file mode 100644 index 0000000..03d5618 --- /dev/null +++ b/Examples/AdvectCaKernel/src/Boundaries.cc @@ -0,0 +1,41 @@ +/* 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 AdvectCaKernel_CheckBoundaries(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + return; +} + +extern "C" void AdvectCaKernel_SelectBoundConds(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + CCTK_INT ierr = 0; + return; +} + + + +/* template for entries in parameter file: +*/ + diff --git a/Examples/AdvectCaKernel/src/CaKernel__initial_gaussian.code b/Examples/AdvectCaKernel/src/CaKernel__initial_gaussian.code new file mode 100644 index 0000000..19ecad8 --- /dev/null +++ b/Examples/AdvectCaKernel/src/CaKernel__initial_gaussian.code @@ -0,0 +1,67 @@ +#undef KRANC_DIFF_FUNCTIONS +#define KRANC_C +#include "Differencing.h" +#include "GenericFD.h" + +#define KRANC_GFOFFSET3D(u,i,j,k) I3D(u,i,j,k) + + +/* 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)) + +CAKERNEL_initial_gaussian_Begin + + /* Include user-supplied include files */ + + /* Initialise finite differencing variables */ + CCTK_REAL const dx = params.cagh_dx; + CCTK_REAL const dy = params.cagh_dy; + CCTK_REAL const dz = params.cagh_dz; + CCTK_REAL const dt = params.cagh_dt; + CCTK_REAL const t = params.cagh_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 p1odx = INV(dx); + + /* Assign local copies of arrays functions */ + + + + /* 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)); + + /* Copy local copies back to grid functions */ + I3D(phi,0,0,0) = phiL; + + CAKERNEL_initial_gaussian_Computations_End + +CAKERNEL_initial_gaussian_End diff --git a/Examples/AdvectCaKernel/src/Differencing.h b/Examples/AdvectCaKernel/src/Differencing.h new file mode 100644 index 0000000..2dc688d --- /dev/null +++ b/Examples/AdvectCaKernel/src/Differencing.h @@ -0,0 +1,12 @@ +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx) +#else +# define PDstandard1(u) (PDstandard1_impl(u,p1odx,cdj,cdk)) +static CCTK_REAL PDstandard1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx; +} +#endif + diff --git a/Examples/AdvectCaKernel/src/RegisterMoL.cc b/Examples/AdvectCaKernel/src/RegisterMoL.cc new file mode 100644 index 0000000..bce1435 --- /dev/null +++ b/Examples/AdvectCaKernel/src/RegisterMoL.cc @@ -0,0 +1,18 @@ +/* File produced by Kranc */ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +extern "C" void AdvectCaKernel_RegisterVars(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + CCTK_INT ierr = 0; + + /* Register all the evolved grid functions with MoL */ + + /* Register all the evolved Array functions with MoL */ + return; +} diff --git a/Examples/AdvectCaKernel/src/RegisterSymmetries.cc b/Examples/AdvectCaKernel/src/RegisterSymmetries.cc new file mode 100644 index 0000000..c1c48a5 --- /dev/null +++ b/Examples/AdvectCaKernel/src/RegisterSymmetries.cc @@ -0,0 +1,24 @@ +/* File produced by Kranc */ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" +#include "Symmetry.h" + +extern "C" void AdvectCaKernel_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, "AdvectCaKernel::phi"); + +} diff --git a/Examples/AdvectCaKernel/src/Startup.cc b/Examples/AdvectCaKernel/src/Startup.cc new file mode 100644 index 0000000..ba99b79 --- /dev/null +++ b/Examples/AdvectCaKernel/src/Startup.cc @@ -0,0 +1,10 @@ +/* File produced by Kranc */ + +#include "cctk.h" + +extern "C" int AdvectCaKernel_Startup(void) +{ + const char * banner = "AdvectCaKernel"; + CCTK_RegisterBanner(banner); + return 0; +} diff --git a/Examples/AdvectCaKernel/src/make.code.defn b/Examples/AdvectCaKernel/src/make.code.defn new file mode 100644 index 0000000..9f29474 --- /dev/null +++ b/Examples/AdvectCaKernel/src/make.code.defn @@ -0,0 +1,8 @@ +# File produced by Kranc + +SRCS = Startup.cc RegisterMoL.cc RegisterSymmetries.cc Boundaries.cc + + +############################################################ +#CAKERNEL AUTO GENERATED PART. DO NOT EDIT BELOW THIS POINT# +############################################################ -- cgit v1.2.3