Skip to content

Commit

Permalink
Generate AdvectCaKernel
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhinder committed Jan 27, 2012
1 parent a0a05de commit d3c1d76
Show file tree
Hide file tree
Showing 12 changed files with 352 additions and 0 deletions.
15 changes: 15 additions & 0 deletions 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"
}

6 changes: 6 additions & 0 deletions Examples/AdvectCaKernel/configuration.ccl
@@ -0,0 +1,6 @@
# File produced by Kranc

REQUIRES GenericFD
OPTIONAL LoopControl
{
}
34 changes: 34 additions & 0 deletions 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"
60 changes: 60 additions & 0 deletions 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

57 changes: 57 additions & 0 deletions 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#
############################################################
41 changes: 41 additions & 0 deletions 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:
*/

67 changes: 67 additions & 0 deletions 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
12 changes: 12 additions & 0 deletions 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

18 changes: 18 additions & 0 deletions 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;
}
24 changes: 24 additions & 0 deletions 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");

}
10 changes: 10 additions & 0 deletions 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;
}
8 changes: 8 additions & 0 deletions 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#
############################################################

0 comments on commit d3c1d76

Please sign in to comment.