diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2012-01-23 13:17:26 -0600 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2012-01-23 13:17:26 -0600 |
commit | a65586203c3cb4bb4d16811bcc48715b31911e81 (patch) | |
tree | 97be7fa125aabb84144f404df421c6401fe763bc | |
parent | d4a911e37e7302ad4414bf3824f0b73712705539 (diff) |
Regenerate examples (except Advect)
Advect doesn't work at the moment due to a problem with TensorTools.
100 files changed, 8225 insertions, 4872 deletions
diff --git a/Examples/Burgers/configuration.ccl b/Examples/Burgers/configuration.ccl index 023aac7..0a66ec2 100644 --- a/Examples/Burgers/configuration.ccl +++ b/Examples/Burgers/configuration.ccl @@ -1,3 +1,6 @@ # File produced by Kranc REQUIRES GenericFD +OPTIONAL LoopControl +{ +} diff --git a/Examples/Burgers/interface.ccl b/Examples/Burgers/interface.ccl index 873ed69..fadd7cc 100644 --- a/Examples/Burgers/interface.ccl +++ b/Examples/Burgers/interface.ccl @@ -10,6 +10,7 @@ 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 diff --git a/Examples/Burgers/param.ccl b/Examples/Burgers/param.ccl index a94fb3d..0b3226d 100644 --- a/Examples/Burgers/param.ccl +++ b/Examples/Burgers/param.ccl @@ -8,6 +8,7 @@ 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 @@ -71,6 +72,12 @@ CCTK_INT Burgers_MaxNumEvolvedVars "Number of evolved variables used by this tho } 1 restricted: +CCTK_INT Burgers_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:3 :: "" @@ -83,6 +90,12 @@ CCTK_INT rhs_timelevels "Number of active RHS timelevels" STEERABLE=RECOVER } 1 restricted: +CCTK_INT other_timelevels "Number of active timelevels for non-evolved grid functions" STEERABLE=RECOVER +{ + 0:3 :: "" +} 1 + +restricted: CCTK_INT burgers_initial_sine_calc_every "burgers_initial_sine_calc_every" STEERABLE=ALWAYS { *:* :: "" diff --git a/Examples/Burgers/schedule.ccl b/Examples/Burgers/schedule.ccl index 73893b1..2384e1a 100644 --- a/Examples/Burgers/schedule.ccl +++ b/Examples/Burgers/schedule.ccl @@ -1,11 +1,20 @@ # File produced by Kranc -STORAGE: uF_group[1] +if (other_timelevels == 1) +{ + STORAGE: uF_group[1] +} -STORAGE: uLeft_group[1] +if (other_timelevels == 1) +{ + STORAGE: uLeft_group[1] +} -STORAGE: uR_group[1] +if (other_timelevels == 1) +{ + STORAGE: uR_group[1] +} if (timelevels == 1) { @@ -102,12 +111,7 @@ schedule group burgers_reconstruct_1_bc_group in burgers_reconstruct_1_group aft # no language specified } "burgers_reconstruct_1" -schedule group burgers_reconstruct_1_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "burgers_reconstruct_1" - -schedule group burgers_reconstruct_1_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group burgers_reconstruct_1_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "burgers_reconstruct_1" @@ -139,12 +143,7 @@ schedule group burgers_flux_1_bc_group in burgers_flux_1_group after burgers_flu # no language specified } "burgers_flux_1" -schedule group burgers_flux_1_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "burgers_flux_1" - -schedule group burgers_flux_1_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group burgers_flux_1_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "burgers_flux_1" diff --git a/Examples/Burgers/src/Differencing.h b/Examples/Burgers/src/Differencing.h index 94f5300..dec7ce7 100644 --- a/Examples/Burgers/src/Differencing.h +++ b/Examples/Burgers/src/Differencing.h @@ -1,12 +1,144 @@ -#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)])) -#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)]) +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx) +#else +# define PDplus1(u) (PDplus1_impl(u,p1odx,cdj,cdk)) +static CCTK_REAL PDplus1_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 PDplus1_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 + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody) +#else +# define PDplus2(u) (PDplus2_impl(u,p1ody,cdj,cdk)) +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, 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,0,1,0))*p1ody; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz) +#else +# define PDplus3(u) (PDplus3_impl(u,p1odz,cdj,cdk)) +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, 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,0,0,1))*p1odz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o1) +#else +# define DiffPlus1(u) (DiffPlus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o1) +#else +# define DiffPlus2(u) (DiffPlus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1o1) +#else +# define DiffPlus3(u) (DiffPlus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus1(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,-1,0,0))*p1o1) +#else +# define DiffMinus1(u) (DiffMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus2(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,-1,0))*p1o1) +#else +# define DiffMinus2(u) (DiffMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,-1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus3(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,0,-1))*p1o1) +#else +# define DiffMinus3(u) (DiffMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,-1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus1(u) (KRANC_GFOFFSET3D(u,-1,0,0)*p1o1) +#else +# define ShiftMinus1(u) (ShiftMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,-1,0,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus2(u) (KRANC_GFOFFSET3D(u,0,-1,0)*p1o1) +#else +# define ShiftMinus2(u) (ShiftMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,-1,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus3(u) (KRANC_GFOFFSET3D(u,0,0,-1)*p1o1) +#else +# define ShiftMinus3(u) (ShiftMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,0,-1)*p1o1; +} +#endif + diff --git a/Examples/Burgers/src/RegisterMoL.cc b/Examples/Burgers/src/RegisterMoL.cc index d29d0eb..3863790 100644 --- a/Examples/Burgers/src/RegisterMoL.cc +++ b/Examples/Burgers/src/RegisterMoL.cc @@ -13,5 +13,7 @@ extern "C" void Burgers_RegisterVars(CCTK_ARGUMENTS) /* Register all the evolved grid functions with MoL */ ierr += MoLRegisterEvolved(CCTK_VarIndex("Burgers::u"), CCTK_VarIndex("Burgers::urhs")); + + /* Register all the evolved Array functions with MoL */ return; } diff --git a/Examples/Burgers/src/burgers_flux_1.cc b/Examples/Burgers/src/burgers_flux_1.cc index 827bbd6..947110f 100644 --- a/Examples/Burgers/src/burgers_flux_1.cc +++ b/Examples/Burgers/src/burgers_flux_1.cc @@ -12,6 +12,8 @@ #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) @@ -32,43 +34,28 @@ extern "C" void burgers_flux_1_SelectBCs(CCTK_ARGUMENTS) return; } -static void burgers_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[]) +static void burgers_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 imin[3], int const imax[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 burgers_flux_1_Body"); - } - - if (cctk_iteration % burgers_flux_1_calc_every != burgers_flux_1_calc_offset) - { - return; - } - - const char *groups[] = {"Burgers::uF_group","Burgers::uLeft_group","Burgers::uR_group"}; - GenericFD_AssertGroupStorage(cctkGH, "burgers_flux_1", 3, groups); - - GenericFD_EnsureStencilFits(cctkGH, "burgers_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); + 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); @@ -87,35 +74,41 @@ static void burgers_flux_1_Body(cGH const * restrict const cctkGH, int const dir CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (burgers_flux_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 uLeftL = uLeft[index]; - CCTK_REAL uRL = uR[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const ShiftMinus1uR = ShiftMinus1(&uR[index]); - - /* Calculate temporaries and grid functions */ - CCTK_REAL uFL = 0.25*(SQR(ShiftMinus1uR) + uLeftL*(uLeftL - - 2*ToReal(alpha)) + 2*ShiftMinus1uR*ToReal(alpha)); - - /* Copy local copies back to grid functions */ - uF[index] = uFL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL uLeftL = uLeft[index]; + CCTK_REAL uRL = uR[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const ShiftMinus1uR = ShiftMinus1(&uR[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL uFL = 0.25*(SQR(ShiftMinus1uR) + uLeftL*(uLeftL - + 2*ToReal(alpha)) + 2*ShiftMinus1uR*ToReal(alpha)); + + /* Copy local copies back to grid functions */ + uF[index] = uFL; } + CCTK_ENDLOOP3 (burgers_flux_1); } extern "C" void burgers_flux_1(CCTK_ARGUMENTS) @@ -123,5 +116,26 @@ extern "C" void burgers_flux_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering burgers_flux_1_Body"); + } + + if (cctk_iteration % burgers_flux_1_calc_every != burgers_flux_1_calc_offset) + { + return; + } + + const char *groups[] = {"Burgers::uF_group","Burgers::uLeft_group","Burgers::uR_group"}; + GenericFD_AssertGroupStorage(cctkGH, "burgers_flux_1", 3, groups); + + GenericFD_EnsureStencilFits(cctkGH, "burgers_flux_1", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &burgers_flux_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving burgers_flux_1_Body"); + } } diff --git a/Examples/Burgers/src/burgers_initial_shock.cc b/Examples/Burgers/src/burgers_initial_shock.cc index 3baf23f..6aaa0fc 100644 --- a/Examples/Burgers/src/burgers_initial_shock.cc +++ b/Examples/Burgers/src/burgers_initial_shock.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void burgers_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[]) +static void burgers_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 imin[3], int const imax[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 burgers_initial_shock_Body"); - } - - if (cctk_iteration % burgers_initial_shock_calc_every != burgers_initial_shock_calc_offset) - { - return; - } - - const char *groups[] = {"grid::coordinates","Burgers::u_group"}; - GenericFD_AssertGroupStorage(cctkGH, "burgers_initial_shock", 2, 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); + 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); @@ -74,33 +62,39 @@ static void burgers_initial_shock_Body(cGH const * restrict const cctkGH, int co CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (burgers_initial_shock, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL uL = ToReal(uL0) + StepFunction(-0.5 + xL)*(-ToReal(uL0) + - ToReal(uR0)); - - /* Copy local copies back to grid functions */ - u[index] = uL; - } - } + 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 uL = ToReal(uL0) + StepFunction(-0.5 + xL)*(-ToReal(uL0) + + ToReal(uR0)); + + /* Copy local copies back to grid functions */ + u[index] = uL; } + CCTK_ENDLOOP3 (burgers_initial_shock); } extern "C" void burgers_initial_shock(CCTK_ARGUMENTS) @@ -108,5 +102,25 @@ extern "C" void burgers_initial_shock(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering burgers_initial_shock_Body"); + } + + if (cctk_iteration % burgers_initial_shock_calc_every != burgers_initial_shock_calc_offset) + { + return; + } + + const char *groups[] = {"grid::coordinates","Burgers::u_group"}; + GenericFD_AssertGroupStorage(cctkGH, "burgers_initial_shock", 2, groups); + + GenericFD_LoopOverEverything(cctkGH, &burgers_initial_shock_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving burgers_initial_shock_Body"); + } } diff --git a/Examples/Burgers/src/burgers_initial_sine.cc b/Examples/Burgers/src/burgers_initial_sine.cc index 2cc003f..d6aa092 100644 --- a/Examples/Burgers/src/burgers_initial_sine.cc +++ b/Examples/Burgers/src/burgers_initial_sine.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void burgers_initial_sine_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[]) +static void burgers_initial_sine_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; - /* 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 burgers_initial_sine_Body"); - } - - if (cctk_iteration % burgers_initial_sine_calc_every != burgers_initial_sine_calc_offset) - { - return; - } - - const char *groups[] = {"grid::coordinates","Burgers::u_group"}; - GenericFD_AssertGroupStorage(cctkGH, "burgers_initial_sine", 2, 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); + 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); @@ -74,32 +62,38 @@ static void burgers_initial_sine_Body(cGH const * restrict const cctkGH, int con CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (burgers_initial_sine, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL uL = 1 + Sin(2*Pi*xL)*ToReal(amp); - - /* Copy local copies back to grid functions */ - u[index] = uL; - } - } + 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 uL = 1 + Sin(2*xL*Pi)*ToReal(amp); + + /* Copy local copies back to grid functions */ + u[index] = uL; } + CCTK_ENDLOOP3 (burgers_initial_sine); } extern "C" void burgers_initial_sine(CCTK_ARGUMENTS) @@ -107,5 +101,25 @@ extern "C" void burgers_initial_sine(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering burgers_initial_sine_Body"); + } + + if (cctk_iteration % burgers_initial_sine_calc_every != burgers_initial_sine_calc_offset) + { + return; + } + + const char *groups[] = {"grid::coordinates","Burgers::u_group"}; + GenericFD_AssertGroupStorage(cctkGH, "burgers_initial_sine", 2, groups); + + GenericFD_LoopOverEverything(cctkGH, &burgers_initial_sine_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving burgers_initial_sine_Body"); + } } diff --git a/Examples/Burgers/src/burgers_reconstruct_1.cc b/Examples/Burgers/src/burgers_reconstruct_1.cc index 59622d8..4a79c1e 100644 --- a/Examples/Burgers/src/burgers_reconstruct_1.cc +++ b/Examples/Burgers/src/burgers_reconstruct_1.cc @@ -12,6 +12,8 @@ #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) @@ -35,43 +37,28 @@ extern "C" void burgers_reconstruct_1_SelectBCs(CCTK_ARGUMENTS) return; } -static void burgers_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[]) +static void burgers_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 imin[3], int const imax[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 burgers_reconstruct_1_Body"); - } - - if (cctk_iteration % burgers_reconstruct_1_calc_every != burgers_reconstruct_1_calc_offset) - { - return; - } - - const char *groups[] = {"Burgers::u_group","Burgers::uLeft_group","Burgers::uR_group"}; - GenericFD_AssertGroupStorage(cctkGH, "burgers_reconstruct_1", 3, groups); - - GenericFD_EnsureStencilFits(cctkGH, "burgers_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); + 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); @@ -90,44 +77,50 @@ static void burgers_reconstruct_1_Body(cGH const * restrict const cctkGH, int co CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (burgers_reconstruct_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 uL = u[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const DiffPlus1u = DiffPlus1(&u[index]); - CCTK_REAL const DiffMinus1u = DiffMinus1(&u[index]); - - /* Calculate temporaries and grid functions */ - CCTK_REAL slopeL = DiffMinus1u; - - CCTK_REAL slopeR = DiffPlus1u; - - CCTK_REAL slope = IfThen(slopeL*slopeR < 0,0,IfThen(Abs(slopeL) < - Abs(slopeR),slopeL,slopeR)); - - CCTK_REAL uLeftL = -0.5*slope + uL; - - CCTK_REAL uRL = 0.5*slope + uL; - - /* Copy local copies back to grid functions */ - uLeft[index] = uLeftL; - uR[index] = uRL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL uL = u[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const DiffPlus1u = DiffPlus1(&u[index]); + CCTK_REAL const DiffMinus1u = DiffMinus1(&u[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL slopeL = DiffMinus1u; + + CCTK_REAL slopeR = DiffPlus1u; + + CCTK_REAL slope = IfThen(slopeL*slopeR < 0,0,IfThen(Abs(slopeL) < + Abs(slopeR),slopeL,slopeR)); + + CCTK_REAL uLeftL = uL - 0.5*slope; + + CCTK_REAL uRL = uL + 0.5*slope; + + /* Copy local copies back to grid functions */ + uLeft[index] = uLeftL; + uR[index] = uRL; } + CCTK_ENDLOOP3 (burgers_reconstruct_1); } extern "C" void burgers_reconstruct_1(CCTK_ARGUMENTS) @@ -135,5 +128,26 @@ extern "C" void burgers_reconstruct_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering burgers_reconstruct_1_Body"); + } + + if (cctk_iteration % burgers_reconstruct_1_calc_every != burgers_reconstruct_1_calc_offset) + { + return; + } + + const char *groups[] = {"Burgers::u_group","Burgers::uLeft_group","Burgers::uR_group"}; + GenericFD_AssertGroupStorage(cctkGH, "burgers_reconstruct_1", 3, groups); + + GenericFD_EnsureStencilFits(cctkGH, "burgers_reconstruct_1", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &burgers_reconstruct_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving burgers_reconstruct_1_Body"); + } } diff --git a/Examples/Burgers/src/burgers_rhs_1.cc b/Examples/Burgers/src/burgers_rhs_1.cc index 375ad35..557e7a0 100644 --- a/Examples/Burgers/src/burgers_rhs_1.cc +++ b/Examples/Burgers/src/burgers_rhs_1.cc @@ -12,6 +12,8 @@ #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) @@ -32,43 +34,28 @@ extern "C" void burgers_rhs_1_SelectBCs(CCTK_ARGUMENTS) return; } -static void burgers_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[]) +static void burgers_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 imin[3], int const imax[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 burgers_rhs_1_Body"); - } - - if (cctk_iteration % burgers_rhs_1_calc_every != burgers_rhs_1_calc_offset) - { - return; - } - - const char *groups[] = {"Burgers::uF_group","Burgers::u_grouprhs"}; - GenericFD_AssertGroupStorage(cctkGH, "burgers_rhs_1", 2, groups); - - GenericFD_EnsureStencilFits(cctkGH, "burgers_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); + 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); @@ -87,34 +74,40 @@ static void burgers_rhs_1_Body(cGH const * restrict const cctkGH, int const dir, CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (burgers_rhs_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 uFL = uF[index]; - CCTK_REAL urhsL = urhs[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const PDplus1uF = PDplus1(&uF[index]); - - /* Calculate temporaries and grid functions */ - urhsL = -PDplus1uF + urhsL; - - /* Copy local copies back to grid functions */ - urhs[index] = urhsL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL uFL = uF[index]; + CCTK_REAL urhsL = urhs[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDplus1uF = PDplus1(&uF[index]); + + /* Calculate temporaries and grid functions */ + urhsL = urhsL - PDplus1uF; + + /* Copy local copies back to grid functions */ + urhs[index] = urhsL; } + CCTK_ENDLOOP3 (burgers_rhs_1); } extern "C" void burgers_rhs_1(CCTK_ARGUMENTS) @@ -122,5 +115,26 @@ extern "C" void burgers_rhs_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering burgers_rhs_1_Body"); + } + + if (cctk_iteration % burgers_rhs_1_calc_every != burgers_rhs_1_calc_offset) + { + return; + } + + const char *groups[] = {"Burgers::uF_group","Burgers::u_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "burgers_rhs_1", 2, groups); + + GenericFD_EnsureStencilFits(cctkGH, "burgers_rhs_1", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &burgers_rhs_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving burgers_rhs_1_Body"); + } } diff --git a/Examples/Burgers/src/burgers_zero_rhs.cc b/Examples/Burgers/src/burgers_zero_rhs.cc index 538d321..10f020f 100644 --- a/Examples/Burgers/src/burgers_zero_rhs.cc +++ b/Examples/Burgers/src/burgers_zero_rhs.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void burgers_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[]) +static void burgers_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 imin[3], int const imax[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 burgers_zero_rhs_Body"); - } - - if (cctk_iteration % burgers_zero_rhs_calc_every != burgers_zero_rhs_calc_offset) - { - return; - } - - const char *groups[] = {"Burgers::u_grouprhs"}; - GenericFD_AssertGroupStorage(cctkGH, "burgers_zero_rhs", 1, 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); + 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); @@ -74,31 +62,37 @@ static void burgers_zero_rhs_Body(cGH const * restrict const cctkGH, int const d CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (burgers_zero_rhs, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 urhsL = 0; - - /* Copy local copies back to grid functions */ - urhs[index] = urhsL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL urhsL = 0; + + /* Copy local copies back to grid functions */ + urhs[index] = urhsL; } + CCTK_ENDLOOP3 (burgers_zero_rhs); } extern "C" void burgers_zero_rhs(CCTK_ARGUMENTS) @@ -106,5 +100,25 @@ extern "C" void burgers_zero_rhs(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering burgers_zero_rhs_Body"); + } + + if (cctk_iteration % burgers_zero_rhs_calc_every != burgers_zero_rhs_calc_offset) + { + return; + } + + const char *groups[] = {"Burgers::u_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "burgers_zero_rhs", 1, groups); + + GenericFD_LoopOverEverything(cctkGH, &burgers_zero_rhs_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving burgers_zero_rhs_Body"); + } } diff --git a/Examples/EM/configuration.ccl b/Examples/EM/configuration.ccl index 023aac7..0a66ec2 100644 --- a/Examples/EM/configuration.ccl +++ b/Examples/EM/configuration.ccl @@ -1,3 +1,6 @@ # File produced by Kranc REQUIRES GenericFD +OPTIONAL LoopControl +{ +} diff --git a/Examples/EM/interface.ccl b/Examples/EM/interface.ccl index 58b38f2..46d63e1 100644 --- a/Examples/EM/interface.ccl +++ b/Examples/EM/interface.ccl @@ -10,6 +10,7 @@ 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 diff --git a/Examples/EM/param.ccl b/Examples/EM/param.ccl index fad7962..4d95cbd 100644 --- a/Examples/EM/param.ccl +++ b/Examples/EM/param.ccl @@ -8,6 +8,7 @@ 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 @@ -34,6 +35,12 @@ CCTK_INT EM_MaxNumEvolvedVars "Number of evolved variables used by this thorn" A } 6 restricted: +CCTK_INT EM_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:3 :: "" @@ -46,6 +53,12 @@ CCTK_INT rhs_timelevels "Number of active RHS timelevels" STEERABLE=RECOVER } 1 restricted: +CCTK_INT other_timelevels "Number of active timelevels for non-evolved grid functions" STEERABLE=RECOVER +{ + 0:3 :: "" +} 1 + +restricted: CCTK_INT EM_initial_calc_every "EM_initial_calc_every" STEERABLE=ALWAYS { *:* :: "" diff --git a/Examples/EM/schedule.ccl b/Examples/EM/schedule.ccl index fea3ede..3dfb80d 100644 --- a/Examples/EM/schedule.ccl +++ b/Examples/EM/schedule.ccl @@ -1,9 +1,15 @@ # File produced by Kranc -STORAGE: constraints[1] +if (other_timelevels == 1) +{ + STORAGE: constraints[1] +} -STORAGE: endens[1] +if (other_timelevels == 1) +{ + STORAGE: endens[1] +} if (timelevels == 1) { @@ -95,6 +101,28 @@ schedule EM_constraints in EM_constraints_group LANG: C } "EM_constraints" +schedule EM_constraints_SelectBCs in EM_constraints_bc_group +{ + LANG: C + OPTIONS: level + SYNC: constraints +} "EM_constraints_SelectBCs" + +schedule group ApplyBCs as EM_constraints_ApplyBCs in EM_constraints_bc_group after EM_constraints_SelectBCs +{ + # no language specified +} "Apply BCs for groups set in EM_constraints" + +schedule group EM_constraints_bc_group in EM_constraints_group after EM_constraints +{ + # no language specified +} "EM_constraints" + +schedule group EM_constraints_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep +{ + # no language specified +} "EM_constraints" + schedule group EM_energy_group in MoL_PseudoEvolution { # no language specified diff --git a/Examples/EM/src/Differencing.h b/Examples/EM/src/Differencing.h index 7740e61..e6b9ac7 100644 --- a/Examples/EM/src/Differencing.h +++ b/Examples/EM/src/Differencing.h @@ -1,36 +1,432 @@ -#define PDstandard2nd1(u) (p1o2dx*(-(u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) -#define PDstandard2nd2(u) (p1o2dy*(-(u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) -#define PDstandard2nd3(u) (p1o2dz*(-(u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) -#define PDstandard2nd11(u) (p1odx2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) -#define PDstandard2nd22(u) (p1ody2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) -#define PDstandard2nd33(u) (p1odz2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) -#define PDstandard2nd12(u) (p1o4dxdy*((u)[di*(-1)+dj*(-1)+dk*(0)] - (u)[di*(-1)+dj*(1)+dk*(0)] - (u)[di*(1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)])) -#define PDstandard2nd13(u) (p1o4dxdz*((u)[di*(-1)+dj*(0)+dk*(-1)] - (u)[di*(-1)+dj*(0)+dk*(1)] - (u)[di*(1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)])) -#define PDstandard2nd21(u) (p1o4dxdy*((u)[di*(-1)+dj*(-1)+dk*(0)] - (u)[di*(-1)+dj*(1)+dk*(0)] - (u)[di*(1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)])) -#define PDstandard2nd23(u) (p1o4dydz*((u)[di*(0)+dj*(-1)+dk*(-1)] - (u)[di*(0)+dj*(-1)+dk*(1)] - (u)[di*(0)+dj*(1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)])) -#define PDstandard2nd31(u) (p1o4dxdz*((u)[di*(-1)+dj*(0)+dk*(-1)] - (u)[di*(-1)+dj*(0)+dk*(1)] - (u)[di*(1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)])) -#define PDstandard2nd32(u) (p1o4dydz*((u)[di*(0)+dj*(-1)+dk*(-1)] - (u)[di*(0)+dj*(-1)+dk*(1)] - (u)[di*(0)+dj*(1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)])) -#define PDstandard4th1(u) (p1o12dx*(-8*(u)[di*(-1)+dj*(0)+dk*(0)] + 8*(u)[di*(1)+dj*(0)+dk*(0)] + (u)[di*(-2)+dj*(0)+dk*(0)] - (u)[di*(2)+dj*(0)+dk*(0)])) -#define PDstandard4th2(u) (p1o12dy*(-8*(u)[di*(0)+dj*(-1)+dk*(0)] + 8*(u)[di*(0)+dj*(1)+dk*(0)] + (u)[di*(0)+dj*(-2)+dk*(0)] - (u)[di*(0)+dj*(2)+dk*(0)])) -#define PDstandard4th3(u) (p1o12dz*(-8*(u)[di*(0)+dj*(0)+dk*(-1)] + 8*(u)[di*(0)+dj*(0)+dk*(1)] + (u)[di*(0)+dj*(0)+dk*(-2)] - (u)[di*(0)+dj*(0)+dk*(2)])) -#define PDstandard4th11(u) (pm1o12dx2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)]) + (u)[di*(-2)+dj*(0)+dk*(0)] + (u)[di*(2)+dj*(0)+dk*(0)])) -#define PDstandard4th22(u) (pm1o12dy2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)]) + (u)[di*(0)+dj*(-2)+dk*(0)] + (u)[di*(0)+dj*(2)+dk*(0)])) -#define PDstandard4th33(u) (pm1o12dz2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)]) + (u)[di*(0)+dj*(0)+dk*(-2)] + (u)[di*(0)+dj*(0)+dk*(2)])) -#define PDstandard4th12(u) (p1o144dxdy*(-64*((u)[di*(-1)+dj*(1)+dk*(0)] + (u)[di*(1)+dj*(-1)+dk*(0)]) + 64*((u)[di*(-1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)]) + 8*((u)[di*(-1)+dj*(2)+dk*(0)] + (u)[di*(1)+dj*(-2)+dk*(0)] + (u)[di*(-2)+dj*(1)+dk*(0)] + (u)[di*(2)+dj*(-1)+dk*(0)]) - 8*((u)[di*(-1)+dj*(-2)+dk*(0)] + (u)[di*(1)+dj*(2)+dk*(0)] + (u)[di*(-2)+dj*(-1)+dk*(0)] + (u)[di*(2)+dj*(1)+dk*(0)]) + (u)[di*(-2)+dj*(-2)+dk*(0)] - (u)[di*(-2)+dj*(2)+dk*(0)] - (u)[di*(2)+dj*(-2)+dk*(0)] + (u)[di*(2)+dj*(2)+dk*(0)])) -#define PDstandard4th13(u) (p1o144dxdz*(-64*((u)[di*(-1)+dj*(0)+dk*(1)] + (u)[di*(1)+dj*(0)+dk*(-1)]) + 64*((u)[di*(-1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)]) + 8*((u)[di*(-1)+dj*(0)+dk*(2)] + (u)[di*(1)+dj*(0)+dk*(-2)] + (u)[di*(-2)+dj*(0)+dk*(1)] + (u)[di*(2)+dj*(0)+dk*(-1)]) - 8*((u)[di*(-1)+dj*(0)+dk*(-2)] + (u)[di*(1)+dj*(0)+dk*(2)] + (u)[di*(-2)+dj*(0)+dk*(-1)] + (u)[di*(2)+dj*(0)+dk*(1)]) + (u)[di*(-2)+dj*(0)+dk*(-2)] - (u)[di*(-2)+dj*(0)+dk*(2)] - (u)[di*(2)+dj*(0)+dk*(-2)] + (u)[di*(2)+dj*(0)+dk*(2)])) -#define PDstandard4th21(u) (p1o144dxdy*(-64*((u)[di*(-1)+dj*(1)+dk*(0)] + (u)[di*(1)+dj*(-1)+dk*(0)]) + 64*((u)[di*(-1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)]) + 8*((u)[di*(-1)+dj*(2)+dk*(0)] + (u)[di*(1)+dj*(-2)+dk*(0)] + (u)[di*(-2)+dj*(1)+dk*(0)] + (u)[di*(2)+dj*(-1)+dk*(0)]) - 8*((u)[di*(-1)+dj*(-2)+dk*(0)] + (u)[di*(1)+dj*(2)+dk*(0)] + (u)[di*(-2)+dj*(-1)+dk*(0)] + (u)[di*(2)+dj*(1)+dk*(0)]) + (u)[di*(-2)+dj*(-2)+dk*(0)] - (u)[di*(-2)+dj*(2)+dk*(0)] - (u)[di*(2)+dj*(-2)+dk*(0)] + (u)[di*(2)+dj*(2)+dk*(0)])) -#define PDstandard4th23(u) (p1o144dydz*(-64*((u)[di*(0)+dj*(-1)+dk*(1)] + (u)[di*(0)+dj*(1)+dk*(-1)]) + 64*((u)[di*(0)+dj*(-1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)]) + 8*((u)[di*(0)+dj*(-1)+dk*(2)] + (u)[di*(0)+dj*(1)+dk*(-2)] + (u)[di*(0)+dj*(-2)+dk*(1)] + (u)[di*(0)+dj*(2)+dk*(-1)]) - 8*((u)[di*(0)+dj*(-1)+dk*(-2)] + (u)[di*(0)+dj*(1)+dk*(2)] + (u)[di*(0)+dj*(-2)+dk*(-1)] + (u)[di*(0)+dj*(2)+dk*(1)]) + (u)[di*(0)+dj*(-2)+dk*(-2)] - (u)[di*(0)+dj*(-2)+dk*(2)] - (u)[di*(0)+dj*(2)+dk*(-2)] + (u)[di*(0)+dj*(2)+dk*(2)])) -#define PDstandard4th31(u) (p1o144dxdz*(-64*((u)[di*(-1)+dj*(0)+dk*(1)] + (u)[di*(1)+dj*(0)+dk*(-1)]) + 64*((u)[di*(-1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)]) + 8*((u)[di*(-1)+dj*(0)+dk*(2)] + (u)[di*(1)+dj*(0)+dk*(-2)] + (u)[di*(-2)+dj*(0)+dk*(1)] + (u)[di*(2)+dj*(0)+dk*(-1)]) - 8*((u)[di*(-1)+dj*(0)+dk*(-2)] + (u)[di*(1)+dj*(0)+dk*(2)] + (u)[di*(-2)+dj*(0)+dk*(-1)] + (u)[di*(2)+dj*(0)+dk*(1)]) + (u)[di*(-2)+dj*(0)+dk*(-2)] - (u)[di*(-2)+dj*(0)+dk*(2)] - (u)[di*(2)+dj*(0)+dk*(-2)] + (u)[di*(2)+dj*(0)+dk*(2)])) -#define PDstandard4th32(u) (p1o144dydz*(-64*((u)[di*(0)+dj*(-1)+dk*(1)] + (u)[di*(0)+dj*(1)+dk*(-1)]) + 64*((u)[di*(0)+dj*(-1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)]) + 8*((u)[di*(0)+dj*(-1)+dk*(2)] + (u)[di*(0)+dj*(1)+dk*(-2)] + (u)[di*(0)+dj*(-2)+dk*(1)] + (u)[di*(0)+dj*(2)+dk*(-1)]) - 8*((u)[di*(0)+dj*(-1)+dk*(-2)] + (u)[di*(0)+dj*(1)+dk*(2)] + (u)[di*(0)+dj*(-2)+dk*(-1)] + (u)[di*(0)+dj*(2)+dk*(1)]) + (u)[di*(0)+dj*(-2)+dk*(-2)] - (u)[di*(0)+dj*(-2)+dk*(2)] - (u)[di*(0)+dj*(2)+dk*(-2)] + (u)[di*(0)+dj*(2)+dk*(2)])) -#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)])) +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd1(u) ((-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx) +#else +# define PDstandard2nd1(u) (PDstandard2nd1_impl(u,p1o2dx,cdj,cdk)) +static CCTK_REAL PDstandard2nd1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd2(u) ((-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy) +#else +# define PDstandard2nd2(u) (PDstandard2nd2_impl(u,p1o2dy,cdj,cdk)) +static CCTK_REAL PDstandard2nd2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd3(u) ((-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz) +#else +# define PDstandard2nd3(u) (PDstandard2nd3_impl(u,p1o2dz,cdj,cdk)) +static CCTK_REAL PDstandard2nd3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd11(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx2) +#else +# define PDstandard2nd11(u) (PDstandard2nd11_impl(u,p1odx2,cdj,cdk)) +static CCTK_REAL PDstandard2nd11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd22(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody2) +#else +# define PDstandard2nd22(u) (PDstandard2nd22_impl(u,p1ody2,cdj,cdk)) +static CCTK_REAL PDstandard2nd22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd33(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz2) +#else +# define PDstandard2nd33(u) (PDstandard2nd33_impl(u,p1odz2,cdj,cdk)) +static CCTK_REAL PDstandard2nd33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd12(u) ((KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy) +#else +# define PDstandard2nd12(u) (PDstandard2nd12_impl(u,p1o4dxdy,cdj,cdk)) +static CCTK_REAL PDstandard2nd12_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd12_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd13(u) ((KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz) +#else +# define PDstandard2nd13(u) (PDstandard2nd13_impl(u,p1o4dxdz,cdj,cdk)) +static CCTK_REAL PDstandard2nd13_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd13_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd21(u) ((KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy) +#else +# define PDstandard2nd21(u) (PDstandard2nd21_impl(u,p1o4dxdy,cdj,cdk)) +static CCTK_REAL PDstandard2nd21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd23(u) ((KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz) +#else +# define PDstandard2nd23(u) (PDstandard2nd23_impl(u,p1o4dydz,cdj,cdk)) +static CCTK_REAL PDstandard2nd23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd31(u) ((KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz) +#else +# define PDstandard2nd31(u) (PDstandard2nd31_impl(u,p1o4dxdz,cdj,cdk)) +static CCTK_REAL PDstandard2nd31_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd31_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd32(u) ((KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz) +#else +# define PDstandard2nd32(u) (PDstandard2nd32_impl(u,p1o4dydz,cdj,cdk)) +static CCTK_REAL PDstandard2nd32_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd32_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th1(u) ((-8*KRANC_GFOFFSET3D(u,-1,0,0) + 8*KRANC_GFOFFSET3D(u,1,0,0) + KRANC_GFOFFSET3D(u,-2,0,0) - KRANC_GFOFFSET3D(u,2,0,0))*p1o12dx) +#else +# define PDstandard4th1(u) (PDstandard4th1_impl(u,p1o12dx,cdj,cdk)) +static CCTK_REAL PDstandard4th1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dx, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-8*KRANC_GFOFFSET3D(u,-1,0,0) + 8*KRANC_GFOFFSET3D(u,1,0,0) + KRANC_GFOFFSET3D(u,-2,0,0) - KRANC_GFOFFSET3D(u,2,0,0))*p1o12dx; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th2(u) ((-8*KRANC_GFOFFSET3D(u,0,-1,0) + 8*KRANC_GFOFFSET3D(u,0,1,0) + KRANC_GFOFFSET3D(u,0,-2,0) - KRANC_GFOFFSET3D(u,0,2,0))*p1o12dy) +#else +# define PDstandard4th2(u) (PDstandard4th2_impl(u,p1o12dy,cdj,cdk)) +static CCTK_REAL PDstandard4th2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-8*KRANC_GFOFFSET3D(u,0,-1,0) + 8*KRANC_GFOFFSET3D(u,0,1,0) + KRANC_GFOFFSET3D(u,0,-2,0) - KRANC_GFOFFSET3D(u,0,2,0))*p1o12dy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th3(u) ((-8*KRANC_GFOFFSET3D(u,0,0,-1) + 8*KRANC_GFOFFSET3D(u,0,0,1) + KRANC_GFOFFSET3D(u,0,0,-2) - KRANC_GFOFFSET3D(u,0,0,2))*p1o12dz) +#else +# define PDstandard4th3(u) (PDstandard4th3_impl(u,p1o12dz,cdj,cdk)) +static CCTK_REAL PDstandard4th3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-8*KRANC_GFOFFSET3D(u,0,0,-1) + 8*KRANC_GFOFFSET3D(u,0,0,1) + KRANC_GFOFFSET3D(u,0,0,-2) - KRANC_GFOFFSET3D(u,0,0,2))*p1o12dz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th11(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*pm1o12dx2) +#else +# define PDstandard4th11(u) (PDstandard4th11_impl(u,pm1o12dx2,cdj,cdk)) +static CCTK_REAL PDstandard4th11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dx2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*pm1o12dx2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th22(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*pm1o12dy2) +#else +# define PDstandard4th22(u) (PDstandard4th22_impl(u,pm1o12dy2,cdj,cdk)) +static CCTK_REAL PDstandard4th22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dy2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dy2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*pm1o12dy2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th33(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*pm1o12dz2) +#else +# define PDstandard4th33(u) (PDstandard4th33_impl(u,pm1o12dz2,cdj,cdk)) +static CCTK_REAL PDstandard4th33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dz2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*pm1o12dz2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th12(u) ((-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy) +#else +# define PDstandard4th12(u) (PDstandard4th12_impl(u,p1o144dxdy,cdj,cdk)) +static CCTK_REAL PDstandard4th12_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th12_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th13(u) ((-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz) +#else +# define PDstandard4th13(u) (PDstandard4th13_impl(u,p1o144dxdz,cdj,cdk)) +static CCTK_REAL PDstandard4th13_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th13_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th21(u) ((-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy) +#else +# define PDstandard4th21(u) (PDstandard4th21_impl(u,p1o144dxdy,cdj,cdk)) +static CCTK_REAL PDstandard4th21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th23(u) ((-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz) +#else +# define PDstandard4th23(u) (PDstandard4th23_impl(u,p1o144dydz,cdj,cdk)) +static CCTK_REAL PDstandard4th23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th31(u) ((-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz) +#else +# define PDstandard4th31(u) (PDstandard4th31_impl(u,p1o144dxdz,cdj,cdk)) +static CCTK_REAL PDstandard4th31_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th31_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th32(u) ((-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz) +#else +# define PDstandard4th32(u) (PDstandard4th32_impl(u,p1o144dydz,cdj,cdk)) +static CCTK_REAL PDstandard4th32_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th32_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o1) +#else +# define DiffPlus1(u) (DiffPlus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o1) +#else +# define DiffPlus2(u) (DiffPlus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1o1) +#else +# define DiffPlus3(u) (DiffPlus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus1(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,-1,0,0))*p1o1) +#else +# define DiffMinus1(u) (DiffMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus2(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,-1,0))*p1o1) +#else +# define DiffMinus2(u) (DiffMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,-1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus3(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,0,-1))*p1o1) +#else +# define DiffMinus3(u) (DiffMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,-1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus1(u) (KRANC_GFOFFSET3D(u,-1,0,0)*p1o1) +#else +# define ShiftMinus1(u) (ShiftMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,-1,0,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus2(u) (KRANC_GFOFFSET3D(u,0,-1,0)*p1o1) +#else +# define ShiftMinus2(u) (ShiftMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,-1,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus3(u) (KRANC_GFOFFSET3D(u,0,0,-1)*p1o1) +#else +# define ShiftMinus3(u) (ShiftMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,0,-1)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx) +#else +# define PDplus1(u) (PDplus1_impl(u,p1odx,cdj,cdk)) +static CCTK_REAL PDplus1_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 PDplus1_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 + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody) +#else +# define PDplus2(u) (PDplus2_impl(u,p1ody,cdj,cdk)) +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, 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,0,1,0))*p1ody; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz) +#else +# define PDplus3(u) (PDplus3_impl(u,p1odz,cdj,cdk)) +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, 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,0,0,1))*p1odz; +} +#endif + diff --git a/Examples/EM/src/EM_constraints.cc b/Examples/EM/src/EM_constraints.cc index d26cb66..dc40783 100644 --- a/Examples/EM/src/EM_constraints.cc +++ b/Examples/EM/src/EM_constraints.cc @@ -12,6 +12,8 @@ #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) @@ -20,43 +22,40 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void EM_constraints_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[]) +extern "C" void EM_constraints_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 */, "EM::constraints","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EM::constraints."); + return; +} + +static void EM_constraints_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; - /* 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 EM_constraints_Body"); - } - - if (cctk_iteration % EM_constraints_calc_every != EM_constraints_calc_offset) - { - return; - } - - const char *groups[] = {"EM::B_group","EM::constraints","EM::El_group"}; - GenericFD_AssertGroupStorage(cctkGH, "EM_constraints", 3, groups); - - GenericFD_EnsureStencilFits(cctkGH, "EM_constraints", 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); + 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); @@ -93,48 +92,54 @@ static void EM_constraints_Body(cGH const * restrict const cctkGH, int const dir CCTK_REAL const pm1o12dy2 = -0.0833333333333333333333333333333*INV(SQR(dy)); CCTK_REAL const pm1o12dz2 = -0.0833333333333333333333333333333*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 */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (EM_constraints, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 B1L = B1[index]; - CCTK_REAL B2L = B2[index]; - CCTK_REAL B3L = B3[index]; - CCTK_REAL El1L = El1[index]; - CCTK_REAL El2L = El2[index]; - CCTK_REAL El3L = El3[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const PDstandard2nd1B1 = PDstandard2nd1(&B1[index]); - CCTK_REAL const PDstandard2nd2B2 = PDstandard2nd2(&B2[index]); - CCTK_REAL const PDstandard2nd3B3 = PDstandard2nd3(&B3[index]); - CCTK_REAL const PDstandard2nd1El1 = PDstandard2nd1(&El1[index]); - CCTK_REAL const PDstandard2nd2El2 = PDstandard2nd2(&El2[index]); - CCTK_REAL const PDstandard2nd3El3 = PDstandard2nd3(&El3[index]); - - /* Calculate temporaries and grid functions */ - CCTK_REAL CElL = PDstandard2nd1El1 + PDstandard2nd2El2 + - PDstandard2nd3El3; - - CCTK_REAL CBL = PDstandard2nd1B1 + PDstandard2nd2B2 + - PDstandard2nd3B3; - - /* Copy local copies back to grid functions */ - CB[index] = CBL; - CEl[index] = CElL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL B1L = B1[index]; + CCTK_REAL B2L = B2[index]; + CCTK_REAL B3L = B3[index]; + CCTK_REAL El1L = El1[index]; + CCTK_REAL El2L = El2[index]; + CCTK_REAL El3L = El3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDstandard2nd1B1 = PDstandard2nd1(&B1[index]); + CCTK_REAL const PDstandard2nd2B2 = PDstandard2nd2(&B2[index]); + CCTK_REAL const PDstandard2nd3B3 = PDstandard2nd3(&B3[index]); + CCTK_REAL const PDstandard2nd1El1 = PDstandard2nd1(&El1[index]); + CCTK_REAL const PDstandard2nd2El2 = PDstandard2nd2(&El2[index]); + CCTK_REAL const PDstandard2nd3El3 = PDstandard2nd3(&El3[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL CElL = PDstandard2nd1El1 + PDstandard2nd2El2 + + PDstandard2nd3El3; + + CCTK_REAL CBL = PDstandard2nd1B1 + PDstandard2nd2B2 + + PDstandard2nd3B3; + + /* Copy local copies back to grid functions */ + CB[index] = CBL; + CEl[index] = CElL; } + CCTK_ENDLOOP3 (EM_constraints); } extern "C" void EM_constraints(CCTK_ARGUMENTS) @@ -142,5 +147,26 @@ extern "C" void EM_constraints(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; - GenericFD_LoopOverEverything(cctkGH, &EM_constraints_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering EM_constraints_Body"); + } + + if (cctk_iteration % EM_constraints_calc_every != EM_constraints_calc_offset) + { + return; + } + + const char *groups[] = {"EM::B_group","EM::constraints","EM::El_group"}; + GenericFD_AssertGroupStorage(cctkGH, "EM_constraints", 3, groups); + + GenericFD_EnsureStencilFits(cctkGH, "EM_constraints", 1, 1, 1); + + GenericFD_LoopOverInterior(cctkGH, &EM_constraints_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving EM_constraints_Body"); + } } diff --git a/Examples/EM/src/EM_energy.cc b/Examples/EM/src/EM_energy.cc index 2318bd8..b8e1a17 100644 --- a/Examples/EM/src/EM_energy.cc +++ b/Examples/EM/src/EM_energy.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void EM_energy_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[]) +static void EM_energy_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; - /* 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 EM_energy_Body"); - } - - if (cctk_iteration % EM_energy_calc_every != EM_energy_calc_offset) - { - return; - } - - const char *groups[] = {"EM::B_group","EM::El_group","EM::endens"}; - GenericFD_AssertGroupStorage(cctkGH, "EM_energy", 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); + 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); @@ -92,38 +80,44 @@ static void EM_energy_Body(cGH const * restrict const cctkGH, int const dir, int CCTK_REAL const pm1o12dy2 = -0.0833333333333333333333333333333*INV(SQR(dy)); CCTK_REAL const pm1o12dz2 = -0.0833333333333333333333333333333*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 */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (EM_energy, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 B1L = B1[index]; - CCTK_REAL B2L = B2[index]; - CCTK_REAL B3L = B3[index]; - CCTK_REAL El1L = El1[index]; - CCTK_REAL El2L = El2[index]; - CCTK_REAL El3L = El3[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL rhoL = 0.5*(SQR(B1L) + SQR(B2L) + SQR(B3L) + SQR(El1L) + - SQR(El2L) + SQR(El3L)); - - /* Copy local copies back to grid functions */ - rho[index] = rhoL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL B1L = B1[index]; + CCTK_REAL B2L = B2[index]; + CCTK_REAL B3L = B3[index]; + CCTK_REAL El1L = El1[index]; + CCTK_REAL El2L = El2[index]; + CCTK_REAL El3L = El3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL rhoL = 0.5*(SQR(B1L) + SQR(B2L) + SQR(B3L) + + SQR(El1L) + SQR(El2L) + SQR(El3L)); + + /* Copy local copies back to grid functions */ + rho[index] = rhoL; } + CCTK_ENDLOOP3 (EM_energy); } extern "C" void EM_energy(CCTK_ARGUMENTS) @@ -131,5 +125,25 @@ extern "C" void EM_energy(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering EM_energy_Body"); + } + + if (cctk_iteration % EM_energy_calc_every != EM_energy_calc_offset) + { + return; + } + + const char *groups[] = {"EM::B_group","EM::El_group","EM::endens"}; + GenericFD_AssertGroupStorage(cctkGH, "EM_energy", 3, groups); + + GenericFD_LoopOverEverything(cctkGH, &EM_energy_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving EM_energy_Body"); + } } diff --git a/Examples/EM/src/EM_evol.cc b/Examples/EM/src/EM_evol.cc index 311d5ca..ad67af3 100644 --- a/Examples/EM/src/EM_evol.cc +++ b/Examples/EM/src/EM_evol.cc @@ -12,6 +12,8 @@ #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) @@ -20,43 +22,43 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void EM_evol_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[]) +extern "C" void EM_evol_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 */, "EM::B_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EM::B_grouprhs."); + ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GenericFD_GetBoundaryWidth(cctkGH), -1 /* no table */, "EM::El_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for EM::El_grouprhs."); + return; +} + +static void EM_evol_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; - /* 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 EM_evol_Body"); - } - - if (cctk_iteration % EM_evol_calc_every != EM_evol_calc_offset) - { - return; - } - - const char *groups[] = {"EM::B_group","EM::B_grouprhs","EM::El_group","EM::El_grouprhs"}; - GenericFD_AssertGroupStorage(cctkGH, "EM_evol", 4, groups); - - GenericFD_EnsureStencilFits(cctkGH, "EM_evol", 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); + 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); @@ -93,64 +95,70 @@ static void EM_evol_Body(cGH const * restrict const cctkGH, int const dir, int c CCTK_REAL const pm1o12dy2 = -0.0833333333333333333333333333333*INV(SQR(dy)); CCTK_REAL const pm1o12dz2 = -0.0833333333333333333333333333333*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 */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (EM_evol, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 B1L = B1[index]; - CCTK_REAL B2L = B2[index]; - CCTK_REAL B3L = B3[index]; - CCTK_REAL El1L = El1[index]; - CCTK_REAL El2L = El2[index]; - CCTK_REAL El3L = El3[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const PDstandard2nd2B1 = PDstandard2nd2(&B1[index]); - CCTK_REAL const PDstandard2nd3B1 = PDstandard2nd3(&B1[index]); - CCTK_REAL const PDstandard2nd1B2 = PDstandard2nd1(&B2[index]); - CCTK_REAL const PDstandard2nd3B2 = PDstandard2nd3(&B2[index]); - CCTK_REAL const PDstandard2nd1B3 = PDstandard2nd1(&B3[index]); - CCTK_REAL const PDstandard2nd2B3 = PDstandard2nd2(&B3[index]); - CCTK_REAL const PDstandard2nd2El1 = PDstandard2nd2(&El1[index]); - CCTK_REAL const PDstandard2nd3El1 = PDstandard2nd3(&El1[index]); - CCTK_REAL const PDstandard2nd1El2 = PDstandard2nd1(&El2[index]); - CCTK_REAL const PDstandard2nd3El2 = PDstandard2nd3(&El2[index]); - CCTK_REAL const PDstandard2nd1El3 = PDstandard2nd1(&El3[index]); - CCTK_REAL const PDstandard2nd2El3 = PDstandard2nd2(&El3[index]); - - /* Calculate temporaries and grid functions */ - CCTK_REAL El1rhsL = PDstandard2nd2B3 - PDstandard2nd3B2; - - CCTK_REAL El2rhsL = -PDstandard2nd1B3 + PDstandard2nd3B1; - - CCTK_REAL El3rhsL = PDstandard2nd1B2 - PDstandard2nd2B1; - - CCTK_REAL B1rhsL = -PDstandard2nd2El3 + PDstandard2nd3El2; - - CCTK_REAL B2rhsL = PDstandard2nd1El3 - PDstandard2nd3El1; - - CCTK_REAL B3rhsL = -PDstandard2nd1El2 + PDstandard2nd2El1; - - /* Copy local copies back to grid functions */ - B1rhs[index] = B1rhsL; - B2rhs[index] = B2rhsL; - B3rhs[index] = B3rhsL; - El1rhs[index] = El1rhsL; - El2rhs[index] = El2rhsL; - El3rhs[index] = El3rhsL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL B1L = B1[index]; + CCTK_REAL B2L = B2[index]; + CCTK_REAL B3L = B3[index]; + CCTK_REAL El1L = El1[index]; + CCTK_REAL El2L = El2[index]; + CCTK_REAL El3L = El3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDstandard2nd2B1 = PDstandard2nd2(&B1[index]); + CCTK_REAL const PDstandard2nd3B1 = PDstandard2nd3(&B1[index]); + CCTK_REAL const PDstandard2nd1B2 = PDstandard2nd1(&B2[index]); + CCTK_REAL const PDstandard2nd3B2 = PDstandard2nd3(&B2[index]); + CCTK_REAL const PDstandard2nd1B3 = PDstandard2nd1(&B3[index]); + CCTK_REAL const PDstandard2nd2B3 = PDstandard2nd2(&B3[index]); + CCTK_REAL const PDstandard2nd2El1 = PDstandard2nd2(&El1[index]); + CCTK_REAL const PDstandard2nd3El1 = PDstandard2nd3(&El1[index]); + CCTK_REAL const PDstandard2nd1El2 = PDstandard2nd1(&El2[index]); + CCTK_REAL const PDstandard2nd3El2 = PDstandard2nd3(&El2[index]); + CCTK_REAL const PDstandard2nd1El3 = PDstandard2nd1(&El3[index]); + CCTK_REAL const PDstandard2nd2El3 = PDstandard2nd2(&El3[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL El1rhsL = PDstandard2nd2B3 - PDstandard2nd3B2; + + CCTK_REAL El2rhsL = -PDstandard2nd1B3 + PDstandard2nd3B1; + + CCTK_REAL El3rhsL = PDstandard2nd1B2 - PDstandard2nd2B1; + + CCTK_REAL B1rhsL = -PDstandard2nd2El3 + PDstandard2nd3El2; + + CCTK_REAL B2rhsL = PDstandard2nd1El3 - PDstandard2nd3El1; + + CCTK_REAL B3rhsL = -PDstandard2nd1El2 + PDstandard2nd2El1; + + /* Copy local copies back to grid functions */ + B1rhs[index] = B1rhsL; + B2rhs[index] = B2rhsL; + B3rhs[index] = B3rhsL; + El1rhs[index] = El1rhsL; + El2rhs[index] = El2rhsL; + El3rhs[index] = El3rhsL; } + CCTK_ENDLOOP3 (EM_evol); } extern "C" void EM_evol(CCTK_ARGUMENTS) @@ -158,5 +166,26 @@ extern "C" void EM_evol(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; - GenericFD_LoopOverEverything(cctkGH, &EM_evol_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering EM_evol_Body"); + } + + if (cctk_iteration % EM_evol_calc_every != EM_evol_calc_offset) + { + return; + } + + const char *groups[] = {"EM::B_group","EM::B_grouprhs","EM::El_group","EM::El_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "EM_evol", 4, groups); + + GenericFD_EnsureStencilFits(cctkGH, "EM_evol", 1, 1, 1); + + GenericFD_LoopOverInterior(cctkGH, &EM_evol_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving EM_evol_Body"); + } } diff --git a/Examples/EM/src/EM_initial.cc b/Examples/EM/src/EM_initial.cc index 9b2f83e..8d0e0b0 100644 --- a/Examples/EM/src/EM_initial.cc +++ b/Examples/EM/src/EM_initial.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void EM_initial_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[]) +static void EM_initial_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; - /* 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 EM_initial_Body"); - } - - if (cctk_iteration % EM_initial_calc_every != EM_initial_calc_offset) - { - return; - } - - const char *groups[] = {"EM::B_group","EM::El_group","grid::coordinates"}; - GenericFD_AssertGroupStorage(cctkGH, "EM_initial", 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); + 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); @@ -92,50 +80,56 @@ static void EM_initial_Body(cGH const * restrict const cctkGH, int const dir, in CCTK_REAL const pm1o12dy2 = -0.0833333333333333333333333333333*INV(SQR(dy)); CCTK_REAL const pm1o12dz2 = -0.0833333333333333333333333333333*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 */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (EM_initial, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 El1L = Cos(2*Pi*(xL + yL))*ToReal(sigma); - - CCTK_REAL El2L = Cos(2*Pi*xL)*(-1 + ToReal(sigma)) - Cos(2*Pi*(xL + - yL))*ToReal(sigma); - - CCTK_REAL El3L = 0; - - CCTK_REAL B1L = 0; - - CCTK_REAL B2L = 0; - - CCTK_REAL B3L = -(Cos(2*Pi*xL)*(-1 + ToReal(sigma))) + Cos(2*Pi*(xL + - yL))*ToReal(sigma); - - /* Copy local copies back to grid functions */ - B1[index] = B1L; - B2[index] = B2L; - B3[index] = B3L; - El1[index] = El1L; - El2[index] = El2L; - El3[index] = El3L; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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 El1L = Cos(2*(xL + yL)*Pi)*ToReal(sigma); + + CCTK_REAL El2L = Cos(2*xL*Pi)*(-1 + ToReal(sigma)) - Cos(2*(xL + + yL)*Pi)*ToReal(sigma); + + CCTK_REAL El3L = 0; + + CCTK_REAL B1L = 0; + + CCTK_REAL B2L = 0; + + CCTK_REAL B3L = -(Cos(2*xL*Pi)*(-1 + ToReal(sigma))) + Cos(2*(xL + + yL)*Pi)*ToReal(sigma); + + /* Copy local copies back to grid functions */ + B1[index] = B1L; + B2[index] = B2L; + B3[index] = B3L; + El1[index] = El1L; + El2[index] = El2L; + El3[index] = El3L; } + CCTK_ENDLOOP3 (EM_initial); } extern "C" void EM_initial(CCTK_ARGUMENTS) @@ -143,5 +137,25 @@ extern "C" void EM_initial(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering EM_initial_Body"); + } + + if (cctk_iteration % EM_initial_calc_every != EM_initial_calc_offset) + { + return; + } + + const char *groups[] = {"EM::B_group","EM::El_group","grid::coordinates"}; + GenericFD_AssertGroupStorage(cctkGH, "EM_initial", 3, groups); + + GenericFD_LoopOverEverything(cctkGH, &EM_initial_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving EM_initial_Body"); + } } diff --git a/Examples/EM/src/RegisterMoL.cc b/Examples/EM/src/RegisterMoL.cc index 34583ae..02f967a 100644 --- a/Examples/EM/src/RegisterMoL.cc +++ b/Examples/EM/src/RegisterMoL.cc @@ -18,5 +18,7 @@ extern "C" void EM_RegisterVars(CCTK_ARGUMENTS) ierr += MoLRegisterEvolved(CCTK_VarIndex("EM::El1"), CCTK_VarIndex("EM::El1rhs")); ierr += MoLRegisterEvolved(CCTK_VarIndex("EM::El2"), CCTK_VarIndex("EM::El2rhs")); ierr += MoLRegisterEvolved(CCTK_VarIndex("EM::El3"), CCTK_VarIndex("EM::El3rhs")); + + /* Register all the evolved Array functions with MoL */ return; } diff --git a/Examples/Euler/configuration.ccl b/Examples/Euler/configuration.ccl index 023aac7..0a66ec2 100644 --- a/Examples/Euler/configuration.ccl +++ b/Examples/Euler/configuration.ccl @@ -1,3 +1,6 @@ # File produced by Kranc REQUIRES GenericFD +OPTIONAL LoopControl +{ +} diff --git a/Examples/Euler/interface.ccl b/Examples/Euler/interface.ccl index 14f077c..15f32e0 100644 --- a/Examples/Euler/interface.ccl +++ b/Examples/Euler/interface.ccl @@ -10,6 +10,7 @@ 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 diff --git a/Examples/Euler/param.ccl b/Examples/Euler/param.ccl index 7475248..96ee289 100644 --- a/Examples/Euler/param.ccl +++ b/Examples/Euler/param.ccl @@ -8,6 +8,7 @@ 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 @@ -100,6 +101,12 @@ CCTK_INT Euler_MaxNumEvolvedVars "Number of evolved variables used by this thorn } 5 restricted: +CCTK_INT Euler_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:3 :: "" @@ -112,6 +119,12 @@ CCTK_INT rhs_timelevels "Number of active RHS timelevels" STEERABLE=RECOVER } 1 restricted: +CCTK_INT other_timelevels "Number of active timelevels for non-evolved grid functions" STEERABLE=RECOVER +{ + 0:3 :: "" +} 1 + +restricted: CCTK_INT euler_initial_shock_calc_every "euler_initial_shock_calc_every" STEERABLE=ALWAYS { *:* :: "" diff --git a/Examples/Euler/schedule.ccl b/Examples/Euler/schedule.ccl index d65c9f2..0e5da74 100644 --- a/Examples/Euler/schedule.ccl +++ b/Examples/Euler/schedule.ccl @@ -1,41 +1,95 @@ # File produced by Kranc -STORAGE: DenF_group[1] +if (other_timelevels == 1) +{ + STORAGE: DenF_group[1] +} -STORAGE: DenLeft_group[1] +if (other_timelevels == 1) +{ + STORAGE: DenLeft_group[1] +} -STORAGE: DenRight_group[1] +if (other_timelevels == 1) +{ + STORAGE: DenRight_group[1] +} -STORAGE: EnF_group[1] +if (other_timelevels == 1) +{ + STORAGE: EnF_group[1] +} -STORAGE: EnLeft_group[1] +if (other_timelevels == 1) +{ + STORAGE: EnLeft_group[1] +} -STORAGE: EnRight_group[1] +if (other_timelevels == 1) +{ + STORAGE: EnRight_group[1] +} -STORAGE: p_group[1] +if (other_timelevels == 1) +{ + STORAGE: p_group[1] +} -STORAGE: pLeft_group[1] +if (other_timelevels == 1) +{ + STORAGE: pLeft_group[1] +} -STORAGE: pRight_group[1] +if (other_timelevels == 1) +{ + STORAGE: pRight_group[1] +} -STORAGE: rho_group[1] +if (other_timelevels == 1) +{ + STORAGE: rho_group[1] +} -STORAGE: rhoLeft_group[1] +if (other_timelevels == 1) +{ + STORAGE: rhoLeft_group[1] +} -STORAGE: rhoRight_group[1] +if (other_timelevels == 1) +{ + STORAGE: rhoRight_group[1] +} -STORAGE: SF_group[1] +if (other_timelevels == 1) +{ + STORAGE: SF_group[1] +} -STORAGE: SLeft_group[1] +if (other_timelevels == 1) +{ + STORAGE: SLeft_group[1] +} -STORAGE: SRight_group[1] +if (other_timelevels == 1) +{ + STORAGE: SRight_group[1] +} -STORAGE: v_group[1] +if (other_timelevels == 1) +{ + STORAGE: v_group[1] +} -STORAGE: vLeft_group[1] +if (other_timelevels == 1) +{ + STORAGE: vLeft_group[1] +} -STORAGE: vRight_group[1] +if (other_timelevels == 1) +{ + STORAGE: vRight_group[1] +} if (timelevels == 1) { @@ -189,12 +243,7 @@ schedule group euler_reconstruct_1_bc_group in euler_reconstruct_1_group after e # no language specified } "euler_reconstruct_1" -schedule group euler_reconstruct_1_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "euler_reconstruct_1" - -schedule group euler_reconstruct_1_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group euler_reconstruct_1_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "euler_reconstruct_1" @@ -233,12 +282,7 @@ schedule group euler_flux_1_bc_group in euler_flux_1_group after euler_flux_1 # no language specified } "euler_flux_1" -schedule group euler_flux_1_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "euler_flux_1" - -schedule group euler_flux_1_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group euler_flux_1_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "euler_flux_1" diff --git a/Examples/Euler/src/Differencing.h b/Examples/Euler/src/Differencing.h index 7129217..ab7f0b7 100644 --- a/Examples/Euler/src/Differencing.h +++ b/Examples/Euler/src/Differencing.h @@ -1,42 +1,504 @@ -#define PDstandard2nd1(u) (p1o2dx*(-(u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) -#define PDstandard2nd2(u) (p1o2dy*(-(u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) -#define PDstandard2nd3(u) (p1o2dz*(-(u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) -#define PDstandard2nd11(u) (p1odx2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) -#define PDstandard2nd22(u) (p1ody2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) -#define PDstandard2nd33(u) (p1odz2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) -#define PDstandard2nd12(u) (p1o4dxdy*((u)[di*(-1)+dj*(-1)+dk*(0)] - (u)[di*(-1)+dj*(1)+dk*(0)] - (u)[di*(1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)])) -#define PDstandard2nd13(u) (p1o4dxdz*((u)[di*(-1)+dj*(0)+dk*(-1)] - (u)[di*(-1)+dj*(0)+dk*(1)] - (u)[di*(1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)])) -#define PDstandard2nd21(u) (p1o4dxdy*((u)[di*(-1)+dj*(-1)+dk*(0)] - (u)[di*(-1)+dj*(1)+dk*(0)] - (u)[di*(1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)])) -#define PDstandard2nd23(u) (p1o4dydz*((u)[di*(0)+dj*(-1)+dk*(-1)] - (u)[di*(0)+dj*(-1)+dk*(1)] - (u)[di*(0)+dj*(1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)])) -#define PDstandard2nd31(u) (p1o4dxdz*((u)[di*(-1)+dj*(0)+dk*(-1)] - (u)[di*(-1)+dj*(0)+dk*(1)] - (u)[di*(1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)])) -#define PDstandard2nd32(u) (p1o4dydz*((u)[di*(0)+dj*(-1)+dk*(-1)] - (u)[di*(0)+dj*(-1)+dk*(1)] - (u)[di*(0)+dj*(1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)])) -#define PDstandard4th1(u) (p1o12dx*(-8*(u)[di*(-1)+dj*(0)+dk*(0)] + 8*(u)[di*(1)+dj*(0)+dk*(0)] + (u)[di*(-2)+dj*(0)+dk*(0)] - (u)[di*(2)+dj*(0)+dk*(0)])) -#define PDstandard4th2(u) (p1o12dy*(-8*(u)[di*(0)+dj*(-1)+dk*(0)] + 8*(u)[di*(0)+dj*(1)+dk*(0)] + (u)[di*(0)+dj*(-2)+dk*(0)] - (u)[di*(0)+dj*(2)+dk*(0)])) -#define PDstandard4th3(u) (p1o12dz*(-8*(u)[di*(0)+dj*(0)+dk*(-1)] + 8*(u)[di*(0)+dj*(0)+dk*(1)] + (u)[di*(0)+dj*(0)+dk*(-2)] - (u)[di*(0)+dj*(0)+dk*(2)])) -#define PDstandard4th11(u) (pm1o12dx2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)]) + (u)[di*(-2)+dj*(0)+dk*(0)] + (u)[di*(2)+dj*(0)+dk*(0)])) -#define PDstandard4th22(u) (pm1o12dy2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)]) + (u)[di*(0)+dj*(-2)+dk*(0)] + (u)[di*(0)+dj*(2)+dk*(0)])) -#define PDstandard4th33(u) (pm1o12dz2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)]) + (u)[di*(0)+dj*(0)+dk*(-2)] + (u)[di*(0)+dj*(0)+dk*(2)])) -#define PDstandard4th12(u) (p1o144dxdy*(-64*((u)[di*(-1)+dj*(1)+dk*(0)] + (u)[di*(1)+dj*(-1)+dk*(0)]) + 64*((u)[di*(-1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)]) + 8*((u)[di*(-1)+dj*(2)+dk*(0)] + (u)[di*(1)+dj*(-2)+dk*(0)] + (u)[di*(-2)+dj*(1)+dk*(0)] + (u)[di*(2)+dj*(-1)+dk*(0)]) - 8*((u)[di*(-1)+dj*(-2)+dk*(0)] + (u)[di*(1)+dj*(2)+dk*(0)] + (u)[di*(-2)+dj*(-1)+dk*(0)] + (u)[di*(2)+dj*(1)+dk*(0)]) + (u)[di*(-2)+dj*(-2)+dk*(0)] - (u)[di*(-2)+dj*(2)+dk*(0)] - (u)[di*(2)+dj*(-2)+dk*(0)] + (u)[di*(2)+dj*(2)+dk*(0)])) -#define PDstandard4th13(u) (p1o144dxdz*(-64*((u)[di*(-1)+dj*(0)+dk*(1)] + (u)[di*(1)+dj*(0)+dk*(-1)]) + 64*((u)[di*(-1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)]) + 8*((u)[di*(-1)+dj*(0)+dk*(2)] + (u)[di*(1)+dj*(0)+dk*(-2)] + (u)[di*(-2)+dj*(0)+dk*(1)] + (u)[di*(2)+dj*(0)+dk*(-1)]) - 8*((u)[di*(-1)+dj*(0)+dk*(-2)] + (u)[di*(1)+dj*(0)+dk*(2)] + (u)[di*(-2)+dj*(0)+dk*(-1)] + (u)[di*(2)+dj*(0)+dk*(1)]) + (u)[di*(-2)+dj*(0)+dk*(-2)] - (u)[di*(-2)+dj*(0)+dk*(2)] - (u)[di*(2)+dj*(0)+dk*(-2)] + (u)[di*(2)+dj*(0)+dk*(2)])) -#define PDstandard4th21(u) (p1o144dxdy*(-64*((u)[di*(-1)+dj*(1)+dk*(0)] + (u)[di*(1)+dj*(-1)+dk*(0)]) + 64*((u)[di*(-1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)]) + 8*((u)[di*(-1)+dj*(2)+dk*(0)] + (u)[di*(1)+dj*(-2)+dk*(0)] + (u)[di*(-2)+dj*(1)+dk*(0)] + (u)[di*(2)+dj*(-1)+dk*(0)]) - 8*((u)[di*(-1)+dj*(-2)+dk*(0)] + (u)[di*(1)+dj*(2)+dk*(0)] + (u)[di*(-2)+dj*(-1)+dk*(0)] + (u)[di*(2)+dj*(1)+dk*(0)]) + (u)[di*(-2)+dj*(-2)+dk*(0)] - (u)[di*(-2)+dj*(2)+dk*(0)] - (u)[di*(2)+dj*(-2)+dk*(0)] + (u)[di*(2)+dj*(2)+dk*(0)])) -#define PDstandard4th23(u) (p1o144dydz*(-64*((u)[di*(0)+dj*(-1)+dk*(1)] + (u)[di*(0)+dj*(1)+dk*(-1)]) + 64*((u)[di*(0)+dj*(-1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)]) + 8*((u)[di*(0)+dj*(-1)+dk*(2)] + (u)[di*(0)+dj*(1)+dk*(-2)] + (u)[di*(0)+dj*(-2)+dk*(1)] + (u)[di*(0)+dj*(2)+dk*(-1)]) - 8*((u)[di*(0)+dj*(-1)+dk*(-2)] + (u)[di*(0)+dj*(1)+dk*(2)] + (u)[di*(0)+dj*(-2)+dk*(-1)] + (u)[di*(0)+dj*(2)+dk*(1)]) + (u)[di*(0)+dj*(-2)+dk*(-2)] - (u)[di*(0)+dj*(-2)+dk*(2)] - (u)[di*(0)+dj*(2)+dk*(-2)] + (u)[di*(0)+dj*(2)+dk*(2)])) -#define PDstandard4th31(u) (p1o144dxdz*(-64*((u)[di*(-1)+dj*(0)+dk*(1)] + (u)[di*(1)+dj*(0)+dk*(-1)]) + 64*((u)[di*(-1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)]) + 8*((u)[di*(-1)+dj*(0)+dk*(2)] + (u)[di*(1)+dj*(0)+dk*(-2)] + (u)[di*(-2)+dj*(0)+dk*(1)] + (u)[di*(2)+dj*(0)+dk*(-1)]) - 8*((u)[di*(-1)+dj*(0)+dk*(-2)] + (u)[di*(1)+dj*(0)+dk*(2)] + (u)[di*(-2)+dj*(0)+dk*(-1)] + (u)[di*(2)+dj*(0)+dk*(1)]) + (u)[di*(-2)+dj*(0)+dk*(-2)] - (u)[di*(-2)+dj*(0)+dk*(2)] - (u)[di*(2)+dj*(0)+dk*(-2)] + (u)[di*(2)+dj*(0)+dk*(2)])) -#define PDstandard4th32(u) (p1o144dydz*(-64*((u)[di*(0)+dj*(-1)+dk*(1)] + (u)[di*(0)+dj*(1)+dk*(-1)]) + 64*((u)[di*(0)+dj*(-1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)]) + 8*((u)[di*(0)+dj*(-1)+dk*(2)] + (u)[di*(0)+dj*(1)+dk*(-2)] + (u)[di*(0)+dj*(-2)+dk*(1)] + (u)[di*(0)+dj*(2)+dk*(-1)]) - 8*((u)[di*(0)+dj*(-1)+dk*(-2)] + (u)[di*(0)+dj*(1)+dk*(2)] + (u)[di*(0)+dj*(-2)+dk*(-1)] + (u)[di*(0)+dj*(2)+dk*(1)]) + (u)[di*(0)+dj*(-2)+dk*(-2)] - (u)[di*(0)+dj*(-2)+dk*(2)] - (u)[di*(0)+dj*(2)+dk*(-2)] + (u)[di*(0)+dj*(2)+dk*(2)])) -#define PDonesided2nd1(u) (pm1o2dx*(3*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(2*dir(1))+dj*(0)+dk*(0)] - 4*(u)[di*(dir(1))+dj*(0)+dk*(0)])*dir(1)) -#define PDonesided2nd2(u) (pm1o2dy*(3*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(2*dir(2))+dk*(0)] - 4*(u)[di*(0)+dj*(dir(2))+dk*(0)])*dir(2)) -#define PDonesided2nd3(u) (pm1o2dz*(3*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(2*dir(3))] - 4*(u)[di*(0)+dj*(0)+dk*(dir(3))])*dir(3)) -#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)])) -#define PDminus1(u) (p1odx*((u)[di*(0)+dj*(0)+dk*(0)] - (u)[di*(-1)+dj*(0)+dk*(0)])) -#define PDminus2(u) (p1ody*((u)[di*(0)+dj*(0)+dk*(0)] - (u)[di*(0)+dj*(-1)+dk*(0)])) -#define PDminus3(u) (p1odz*((u)[di*(0)+dj*(0)+dk*(0)] - (u)[di*(0)+dj*(0)+dk*(-1)])) -#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)]) +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd1(u) ((-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx) +#else +# define PDstandard2nd1(u) (PDstandard2nd1_impl(u,p1o2dx,cdj,cdk)) +static CCTK_REAL PDstandard2nd1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd2(u) ((-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy) +#else +# define PDstandard2nd2(u) (PDstandard2nd2_impl(u,p1o2dy,cdj,cdk)) +static CCTK_REAL PDstandard2nd2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd3(u) ((-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz) +#else +# define PDstandard2nd3(u) (PDstandard2nd3_impl(u,p1o2dz,cdj,cdk)) +static CCTK_REAL PDstandard2nd3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd11(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx2) +#else +# define PDstandard2nd11(u) (PDstandard2nd11_impl(u,p1odx2,cdj,cdk)) +static CCTK_REAL PDstandard2nd11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd22(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody2) +#else +# define PDstandard2nd22(u) (PDstandard2nd22_impl(u,p1ody2,cdj,cdk)) +static CCTK_REAL PDstandard2nd22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd33(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz2) +#else +# define PDstandard2nd33(u) (PDstandard2nd33_impl(u,p1odz2,cdj,cdk)) +static CCTK_REAL PDstandard2nd33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd12(u) ((KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy) +#else +# define PDstandard2nd12(u) (PDstandard2nd12_impl(u,p1o4dxdy,cdj,cdk)) +static CCTK_REAL PDstandard2nd12_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd12_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd13(u) ((KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz) +#else +# define PDstandard2nd13(u) (PDstandard2nd13_impl(u,p1o4dxdz,cdj,cdk)) +static CCTK_REAL PDstandard2nd13_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd13_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd21(u) ((KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy) +#else +# define PDstandard2nd21(u) (PDstandard2nd21_impl(u,p1o4dxdy,cdj,cdk)) +static CCTK_REAL PDstandard2nd21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd23(u) ((KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz) +#else +# define PDstandard2nd23(u) (PDstandard2nd23_impl(u,p1o4dydz,cdj,cdk)) +static CCTK_REAL PDstandard2nd23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd31(u) ((KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz) +#else +# define PDstandard2nd31(u) (PDstandard2nd31_impl(u,p1o4dxdz,cdj,cdk)) +static CCTK_REAL PDstandard2nd31_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd31_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd32(u) ((KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz) +#else +# define PDstandard2nd32(u) (PDstandard2nd32_impl(u,p1o4dydz,cdj,cdk)) +static CCTK_REAL PDstandard2nd32_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd32_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th1(u) ((-8*KRANC_GFOFFSET3D(u,-1,0,0) + 8*KRANC_GFOFFSET3D(u,1,0,0) + KRANC_GFOFFSET3D(u,-2,0,0) - KRANC_GFOFFSET3D(u,2,0,0))*p1o12dx) +#else +# define PDstandard4th1(u) (PDstandard4th1_impl(u,p1o12dx,cdj,cdk)) +static CCTK_REAL PDstandard4th1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dx, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-8*KRANC_GFOFFSET3D(u,-1,0,0) + 8*KRANC_GFOFFSET3D(u,1,0,0) + KRANC_GFOFFSET3D(u,-2,0,0) - KRANC_GFOFFSET3D(u,2,0,0))*p1o12dx; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th2(u) ((-8*KRANC_GFOFFSET3D(u,0,-1,0) + 8*KRANC_GFOFFSET3D(u,0,1,0) + KRANC_GFOFFSET3D(u,0,-2,0) - KRANC_GFOFFSET3D(u,0,2,0))*p1o12dy) +#else +# define PDstandard4th2(u) (PDstandard4th2_impl(u,p1o12dy,cdj,cdk)) +static CCTK_REAL PDstandard4th2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-8*KRANC_GFOFFSET3D(u,0,-1,0) + 8*KRANC_GFOFFSET3D(u,0,1,0) + KRANC_GFOFFSET3D(u,0,-2,0) - KRANC_GFOFFSET3D(u,0,2,0))*p1o12dy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th3(u) ((-8*KRANC_GFOFFSET3D(u,0,0,-1) + 8*KRANC_GFOFFSET3D(u,0,0,1) + KRANC_GFOFFSET3D(u,0,0,-2) - KRANC_GFOFFSET3D(u,0,0,2))*p1o12dz) +#else +# define PDstandard4th3(u) (PDstandard4th3_impl(u,p1o12dz,cdj,cdk)) +static CCTK_REAL PDstandard4th3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-8*KRANC_GFOFFSET3D(u,0,0,-1) + 8*KRANC_GFOFFSET3D(u,0,0,1) + KRANC_GFOFFSET3D(u,0,0,-2) - KRANC_GFOFFSET3D(u,0,0,2))*p1o12dz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th11(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*pm1o12dx2) +#else +# define PDstandard4th11(u) (PDstandard4th11_impl(u,pm1o12dx2,cdj,cdk)) +static CCTK_REAL PDstandard4th11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dx2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*pm1o12dx2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th22(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*pm1o12dy2) +#else +# define PDstandard4th22(u) (PDstandard4th22_impl(u,pm1o12dy2,cdj,cdk)) +static CCTK_REAL PDstandard4th22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dy2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dy2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*pm1o12dy2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th33(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*pm1o12dz2) +#else +# define PDstandard4th33(u) (PDstandard4th33_impl(u,pm1o12dz2,cdj,cdk)) +static CCTK_REAL PDstandard4th33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dz2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*pm1o12dz2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th12(u) ((-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy) +#else +# define PDstandard4th12(u) (PDstandard4th12_impl(u,p1o144dxdy,cdj,cdk)) +static CCTK_REAL PDstandard4th12_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th12_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th13(u) ((-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz) +#else +# define PDstandard4th13(u) (PDstandard4th13_impl(u,p1o144dxdz,cdj,cdk)) +static CCTK_REAL PDstandard4th13_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th13_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th21(u) ((-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy) +#else +# define PDstandard4th21(u) (PDstandard4th21_impl(u,p1o144dxdy,cdj,cdk)) +static CCTK_REAL PDstandard4th21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th23(u) ((-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz) +#else +# define PDstandard4th23(u) (PDstandard4th23_impl(u,p1o144dydz,cdj,cdk)) +static CCTK_REAL PDstandard4th23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th31(u) ((-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz) +#else +# define PDstandard4th31(u) (PDstandard4th31_impl(u,p1o144dxdz,cdj,cdk)) +static CCTK_REAL PDstandard4th31_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th31_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard4th32(u) ((-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz) +#else +# define PDstandard4th32(u) (PDstandard4th32_impl(u,p1o144dydz,cdj,cdk)) +static CCTK_REAL PDstandard4th32_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard4th32_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDonesided2nd1(u) ((3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,2*dir(1),0,0) - 4*KRANC_GFOFFSET3D(u,dir(1),0,0))*pm1o2dx*dir(1)) +#else +# define PDonesided2nd1(u) (PDonesided2nd1_impl(u,pm1o2dx,cdj,cdk)) +static CCTK_REAL PDonesided2nd1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDonesided2nd1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,2*dir(1),0,0) - 4*KRANC_GFOFFSET3D(u,dir(1),0,0))*pm1o2dx*dir(1); +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDonesided2nd2(u) ((3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,2*dir(2),0) - 4*KRANC_GFOFFSET3D(u,0,dir(2),0))*pm1o2dy*dir(2)) +#else +# define PDonesided2nd2(u) (PDonesided2nd2_impl(u,pm1o2dy,cdj,cdk)) +static CCTK_REAL PDonesided2nd2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDonesided2nd2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,2*dir(2),0) - 4*KRANC_GFOFFSET3D(u,0,dir(2),0))*pm1o2dy*dir(2); +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDonesided2nd3(u) ((3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,2*dir(3)) - 4*KRANC_GFOFFSET3D(u,0,0,dir(3)))*pm1o2dz*dir(3)) +#else +# define PDonesided2nd3(u) (PDonesided2nd3_impl(u,pm1o2dz,cdj,cdk)) +static CCTK_REAL PDonesided2nd3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDonesided2nd3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,2*dir(3)) - 4*KRANC_GFOFFSET3D(u,0,0,dir(3)))*pm1o2dz*dir(3); +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx) +#else +# define PDplus1(u) (PDplus1_impl(u,p1odx,cdj,cdk)) +static CCTK_REAL PDplus1_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 PDplus1_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 + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody) +#else +# define PDplus2(u) (PDplus2_impl(u,p1ody,cdj,cdk)) +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, 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,0,1,0))*p1ody; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz) +#else +# define PDplus3(u) (PDplus3_impl(u,p1odz,cdj,cdk)) +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, 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,0,0,1))*p1odz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDminus1(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,-1,0,0))*p1odx) +#else +# define PDminus1(u) (PDminus1_impl(u,p1odx,cdj,cdk)) +static CCTK_REAL PDminus1_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 PDminus1_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 + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDminus2(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,-1,0))*p1ody) +#else +# define PDminus2(u) (PDminus2_impl(u,p1ody,cdj,cdk)) +static CCTK_REAL PDminus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDminus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, 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,0,-1,0))*p1ody; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDminus3(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,0,-1))*p1odz) +#else +# define PDminus3(u) (PDminus3_impl(u,p1odz,cdj,cdk)) +static CCTK_REAL PDminus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDminus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, 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,0,0,-1))*p1odz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o1) +#else +# define DiffPlus1(u) (DiffPlus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o1) +#else +# define DiffPlus2(u) (DiffPlus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1o1) +#else +# define DiffPlus3(u) (DiffPlus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus1(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,-1,0,0))*p1o1) +#else +# define DiffMinus1(u) (DiffMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus2(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,-1,0))*p1o1) +#else +# define DiffMinus2(u) (DiffMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,-1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus3(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,0,-1))*p1o1) +#else +# define DiffMinus3(u) (DiffMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,-1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus1(u) (KRANC_GFOFFSET3D(u,-1,0,0)*p1o1) +#else +# define ShiftMinus1(u) (ShiftMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,-1,0,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus2(u) (KRANC_GFOFFSET3D(u,0,-1,0)*p1o1) +#else +# define ShiftMinus2(u) (ShiftMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,-1,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus3(u) (KRANC_GFOFFSET3D(u,0,0,-1)*p1o1) +#else +# define ShiftMinus3(u) (ShiftMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,0,-1)*p1o1; +} +#endif + diff --git a/Examples/Euler/src/RegisterMoL.cc b/Examples/Euler/src/RegisterMoL.cc index c6bc9a5..1b63de8 100644 --- a/Examples/Euler/src/RegisterMoL.cc +++ b/Examples/Euler/src/RegisterMoL.cc @@ -17,5 +17,7 @@ extern "C" void Euler_RegisterVars(CCTK_ARGUMENTS) ierr += MoLRegisterEvolved(CCTK_VarIndex("Euler::S1"), CCTK_VarIndex("Euler::S1rhs")); ierr += MoLRegisterEvolved(CCTK_VarIndex("Euler::S2"), CCTK_VarIndex("Euler::S2rhs")); ierr += MoLRegisterEvolved(CCTK_VarIndex("Euler::S3"), CCTK_VarIndex("Euler::S3rhs")); + + /* Register all the evolved Array functions with MoL */ return; } diff --git a/Examples/Euler/src/euler_conserved.cc b/Examples/Euler/src/euler_conserved.cc index 4b8252e..bfa9113 100644 --- a/Examples/Euler/src/euler_conserved.cc +++ b/Examples/Euler/src/euler_conserved.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void euler_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[]) +static void euler_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 imin[3], int const imax[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 euler_conserved_Body"); - } - - if (cctk_iteration % euler_conserved_calc_every != euler_conserved_calc_offset) - { - return; - } - - const char *groups[] = {"Euler::Den_group","Euler::En_group","Euler::p_group","Euler::rho_group","Euler::S_group","Euler::v_group"}; - GenericFD_AssertGroupStorage(cctkGH, "euler_conserved", 6, 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); + 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); @@ -95,49 +83,55 @@ static void euler_conserved_Body(cGH const * restrict const cctkGH, int const di CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (euler_conserved, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 pL = p[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 */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL DenL = rhoL; - - CCTK_REAL S1L = rhoL*v1L; - - CCTK_REAL S2L = rhoL*v2L; - - CCTK_REAL S3L = rhoL*v3L; - - CCTK_REAL EnL = pL*INV(-1 + ToReal(gamma)) + 0.5*rhoL*(SQR(v1L) + - SQR(v2L) + SQR(v3L)); - - /* Copy local copies back to grid functions */ - Den[index] = DenL; - En[index] = EnL; - S1[index] = S1L; - S2[index] = S2L; - S3[index] = S3L; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + 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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenL = rhoL; + + CCTK_REAL S1L = rhoL*v1L; + + CCTK_REAL S2L = rhoL*v2L; + + CCTK_REAL S3L = rhoL*v3L; + + CCTK_REAL EnL = 0.5*INV(-1 + ToReal(gamma))*(2*pL + + rhoL*(SQR(v1L) + SQR(v2L) + SQR(v3L))*(-1 + ToReal(gamma))); + + /* Copy local copies back to grid functions */ + Den[index] = DenL; + En[index] = EnL; + S1[index] = S1L; + S2[index] = S2L; + S3[index] = S3L; } + CCTK_ENDLOOP3 (euler_conserved); } extern "C" void euler_conserved(CCTK_ARGUMENTS) @@ -145,5 +139,25 @@ extern "C" void euler_conserved(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering euler_conserved_Body"); + } + + if (cctk_iteration % euler_conserved_calc_every != euler_conserved_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::Den_group","Euler::En_group","Euler::p_group","Euler::rho_group","Euler::S_group","Euler::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_conserved", 6, groups); + + GenericFD_LoopOverEverything(cctkGH, &euler_conserved_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving euler_conserved_Body"); + } } diff --git a/Examples/Euler/src/euler_conserved_flux_1.cc b/Examples/Euler/src/euler_conserved_flux_1.cc index c6ab4b0..13cf71b 100644 --- a/Examples/Euler/src/euler_conserved_flux_1.cc +++ b/Examples/Euler/src/euler_conserved_flux_1.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void euler_conserved_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[]) +static void euler_conserved_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 imin[3], int const imax[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 euler_conserved_flux_1_Body"); - } - - if (cctk_iteration % euler_conserved_flux_1_calc_every != euler_conserved_flux_1_calc_offset) - { - return; - } - - const char *groups[] = {"Euler::DenLeft_group","Euler::DenRight_group","Euler::EnLeft_group","Euler::EnRight_group","Euler::pLeft_group","Euler::pRight_group","Euler::rhoLeft_group","Euler::rhoRight_group","Euler::SLeft_group","Euler::SRight_group","Euler::vLeft_group","Euler::vRight_group"}; - GenericFD_AssertGroupStorage(cctkGH, "euler_conserved_flux_1", 12, 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); + 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); @@ -95,70 +83,78 @@ static void euler_conserved_flux_1_Body(cGH const * restrict const cctkGH, int c CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (euler_conserved_flux_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 pLeftL = pLeft[index]; - CCTK_REAL pRightL = pRight[index]; - CCTK_REAL rhoLeftL = rhoLeft[index]; - CCTK_REAL rhoRightL = rhoRight[index]; - CCTK_REAL vLeft1L = vLeft1[index]; - CCTK_REAL vLeft2L = vLeft2[index]; - CCTK_REAL vLeft3L = vLeft3[index]; - CCTK_REAL vRight1L = vRight1[index]; - CCTK_REAL vRight2L = vRight2[index]; - CCTK_REAL vRight3L = vRight3[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL DenLeftL = rhoLeftL; - - CCTK_REAL DenRightL = rhoRightL; - - CCTK_REAL SLeft1L = rhoLeftL*vLeft1L; - - CCTK_REAL SLeft2L = rhoLeftL*vLeft2L; - - CCTK_REAL SLeft3L = rhoLeftL*vLeft3L; - - CCTK_REAL SRight1L = rhoRightL*vRight1L; - - CCTK_REAL SRight2L = rhoRightL*vRight2L; - - CCTK_REAL SRight3L = rhoRightL*vRight3L; - - CCTK_REAL EnLeftL = pLeftL*INV(-1 + ToReal(gamma)) + - 0.5*rhoLeftL*(SQR(vLeft1L) + SQR(vLeft2L) + SQR(vLeft3L)); - - CCTK_REAL EnRightL = pRightL*INV(-1 + ToReal(gamma)) + - 0.5*rhoRightL*(SQR(vRight1L) + SQR(vRight2L) + SQR(vRight3L)); - - /* Copy local copies back to grid functions */ - DenLeft[index] = DenLeftL; - DenRight[index] = DenRightL; - EnLeft[index] = EnLeftL; - EnRight[index] = EnRightL; - SLeft1[index] = SLeft1L; - SLeft2[index] = SLeft2L; - SLeft3[index] = SLeft3L; - SRight1[index] = SRight1L; - SRight2[index] = SRight2L; - SRight3[index] = SRight3L; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL pLeftL = pLeft[index]; + CCTK_REAL pRightL = pRight[index]; + CCTK_REAL rhoLeftL = rhoLeft[index]; + CCTK_REAL rhoRightL = rhoRight[index]; + CCTK_REAL vLeft1L = vLeft1[index]; + CCTK_REAL vLeft2L = vLeft2[index]; + CCTK_REAL vLeft3L = vLeft3[index]; + CCTK_REAL vRight1L = vRight1[index]; + CCTK_REAL vRight2L = vRight2[index]; + CCTK_REAL vRight3L = vRight3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenLeftL = rhoLeftL; + + CCTK_REAL DenRightL = rhoRightL; + + CCTK_REAL SLeft1L = rhoLeftL*vLeft1L; + + CCTK_REAL SLeft2L = rhoLeftL*vLeft2L; + + CCTK_REAL SLeft3L = rhoLeftL*vLeft3L; + + CCTK_REAL SRight1L = rhoRightL*vRight1L; + + CCTK_REAL SRight2L = rhoRightL*vRight2L; + + CCTK_REAL SRight3L = rhoRightL*vRight3L; + + CCTK_REAL EnLeftL = 0.5*INV(-1 + ToReal(gamma))*(2*pLeftL + + rhoLeftL*(SQR(vLeft1L) + SQR(vLeft2L) + SQR(vLeft3L))*(-1 + + ToReal(gamma))); + + CCTK_REAL EnRightL = 0.5*INV(-1 + ToReal(gamma))*(2*pRightL + + rhoRightL*(SQR(vRight1L) + SQR(vRight2L) + SQR(vRight3L))*(-1 + + ToReal(gamma))); + + /* Copy local copies back to grid functions */ + DenLeft[index] = DenLeftL; + DenRight[index] = DenRightL; + EnLeft[index] = EnLeftL; + EnRight[index] = EnRightL; + SLeft1[index] = SLeft1L; + SLeft2[index] = SLeft2L; + SLeft3[index] = SLeft3L; + SRight1[index] = SRight1L; + SRight2[index] = SRight2L; + SRight3[index] = SRight3L; } + CCTK_ENDLOOP3 (euler_conserved_flux_1); } extern "C" void euler_conserved_flux_1(CCTK_ARGUMENTS) @@ -166,5 +162,25 @@ extern "C" void euler_conserved_flux_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering euler_conserved_flux_1_Body"); + } + + if (cctk_iteration % euler_conserved_flux_1_calc_every != euler_conserved_flux_1_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::DenLeft_group","Euler::DenRight_group","Euler::EnLeft_group","Euler::EnRight_group","Euler::pLeft_group","Euler::pRight_group","Euler::rhoLeft_group","Euler::rhoRight_group","Euler::SLeft_group","Euler::SRight_group","Euler::vLeft_group","Euler::vRight_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_conserved_flux_1", 12, groups); + + GenericFD_LoopOverEverything(cctkGH, &euler_conserved_flux_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving euler_conserved_flux_1_Body"); + } } diff --git a/Examples/Euler/src/euler_flux_1.cc b/Examples/Euler/src/euler_flux_1.cc index 59f4eee..4786a56 100644 --- a/Examples/Euler/src/euler_flux_1.cc +++ b/Examples/Euler/src/euler_flux_1.cc @@ -12,6 +12,8 @@ #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) @@ -38,43 +40,28 @@ extern "C" void euler_flux_1_SelectBCs(CCTK_ARGUMENTS) return; } -static void euler_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[]) +static void euler_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 imin[3], int const imax[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 euler_flux_1_Body"); - } - - if (cctk_iteration % euler_flux_1_calc_every != euler_flux_1_calc_offset) - { - return; - } - - const char *groups[] = {"Euler::DenF_group","Euler::DenLeft_group","Euler::DenRight_group","Euler::EnF_group","Euler::EnLeft_group","Euler::EnRight_group","Euler::pLeft_group","Euler::pRight_group","Euler::rhoLeft_group","Euler::rhoRight_group","Euler::SF_group","Euler::SLeft_group","Euler::SRight_group","Euler::vLeft_group","Euler::vRight_group"}; - GenericFD_AssertGroupStorage(cctkGH, "euler_flux_1", 15, groups); - - GenericFD_EnsureStencilFits(cctkGH, "euler_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); + 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); @@ -114,89 +101,95 @@ static void euler_flux_1_Body(cGH const * restrict const cctkGH, int const dir, CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (euler_flux_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 EnLeftL = EnLeft[index]; - CCTK_REAL EnRightL = EnRight[index]; - CCTK_REAL pLeftL = pLeft[index]; - CCTK_REAL pRightL = pRight[index]; - CCTK_REAL rhoLeftL = rhoLeft[index]; - CCTK_REAL rhoRightL = rhoRight[index]; - CCTK_REAL SLeft1L = SLeft1[index]; - CCTK_REAL SLeft2L = SLeft2[index]; - CCTK_REAL SLeft3L = SLeft3[index]; - CCTK_REAL SRight1L = SRight1[index]; - CCTK_REAL SRight2L = SRight2[index]; - CCTK_REAL SRight3L = SRight3[index]; - CCTK_REAL vLeft1L = vLeft1[index]; - CCTK_REAL vLeft2L = vLeft2[index]; - CCTK_REAL vLeft3L = vLeft3[index]; - CCTK_REAL vRight1L = vRight1[index]; - CCTK_REAL vRight2L = vRight2[index]; - CCTK_REAL vRight3L = vRight3[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const ShiftMinus1DenRight = ShiftMinus1(&DenRight[index]); - CCTK_REAL const ShiftMinus1EnRight = ShiftMinus1(&EnRight[index]); - CCTK_REAL const ShiftMinus1pRight = ShiftMinus1(&pRight[index]); - CCTK_REAL const ShiftMinus1rhoRight = ShiftMinus1(&rhoRight[index]); - CCTK_REAL const ShiftMinus1SRight1 = ShiftMinus1(&SRight1[index]); - CCTK_REAL const ShiftMinus1SRight2 = ShiftMinus1(&SRight2[index]); - CCTK_REAL const ShiftMinus1SRight3 = ShiftMinus1(&SRight3[index]); - CCTK_REAL const ShiftMinus1vRight1 = ShiftMinus1(&vRight1[index]); - CCTK_REAL const ShiftMinus1vRight2 = ShiftMinus1(&vRight2[index]); - CCTK_REAL const ShiftMinus1vRight3 = ShiftMinus1(&vRight3[index]); - - /* Calculate temporaries and grid functions */ - CCTK_REAL vRightTemp1 = ShiftMinus1vRight1; - - CCTK_REAL vRightTemp2 = ShiftMinus1vRight2; - - CCTK_REAL vRightTemp3 = ShiftMinus1vRight3; - - CCTK_REAL DenFL = 0.5*(rhoLeftL*vLeft1L + - ShiftMinus1rhoRight*vRightTemp1 + (-DenLeftL + - ShiftMinus1DenRight)*ToReal(alpha)); - - CCTK_REAL SF1L = 0.5*(pLeftL + ShiftMinus1pRight + - rhoLeftL*SQR(vLeft1L) + ShiftMinus1rhoRight*SQR(vRightTemp1) + - (ShiftMinus1SRight1 - SLeft1L)*ToReal(alpha)); - - CCTK_REAL SF2L = 0.5*(rhoLeftL*vLeft1L*vLeft2L + - ShiftMinus1rhoRight*vRightTemp1*vRightTemp2 + (ShiftMinus1SRight2 - - SLeft2L)*ToReal(alpha)); - - CCTK_REAL SF3L = 0.5*(rhoLeftL*vLeft1L*vLeft3L + - ShiftMinus1rhoRight*vRightTemp1*vRightTemp3 + (ShiftMinus1SRight3 - - SLeft3L)*ToReal(alpha)); - - CCTK_REAL EnFL = 0.5*((EnLeftL + pLeftL)*vLeft1L + - ShiftMinus1pRight*vRightTemp1 - EnLeftL*ToReal(alpha) + - ShiftMinus1EnRight*(vRightTemp1 + ToReal(alpha))); - - /* Copy local copies back to grid functions */ - DenF[index] = DenFL; - EnF[index] = EnFL; - SF1[index] = SF1L; - SF2[index] = SF2L; - SF3[index] = SF3L; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL DenLeftL = DenLeft[index]; + CCTK_REAL DenRightL = DenRight[index]; + CCTK_REAL EnLeftL = EnLeft[index]; + CCTK_REAL EnRightL = EnRight[index]; + CCTK_REAL pLeftL = pLeft[index]; + CCTK_REAL pRightL = pRight[index]; + CCTK_REAL rhoLeftL = rhoLeft[index]; + CCTK_REAL rhoRightL = rhoRight[index]; + CCTK_REAL SLeft1L = SLeft1[index]; + CCTK_REAL SLeft2L = SLeft2[index]; + CCTK_REAL SLeft3L = SLeft3[index]; + CCTK_REAL SRight1L = SRight1[index]; + CCTK_REAL SRight2L = SRight2[index]; + CCTK_REAL SRight3L = SRight3[index]; + CCTK_REAL vLeft1L = vLeft1[index]; + CCTK_REAL vLeft2L = vLeft2[index]; + CCTK_REAL vLeft3L = vLeft3[index]; + CCTK_REAL vRight1L = vRight1[index]; + CCTK_REAL vRight2L = vRight2[index]; + CCTK_REAL vRight3L = vRight3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const ShiftMinus1DenRight = ShiftMinus1(&DenRight[index]); + CCTK_REAL const ShiftMinus1EnRight = ShiftMinus1(&EnRight[index]); + CCTK_REAL const ShiftMinus1pRight = ShiftMinus1(&pRight[index]); + CCTK_REAL const ShiftMinus1rhoRight = ShiftMinus1(&rhoRight[index]); + CCTK_REAL const ShiftMinus1SRight1 = ShiftMinus1(&SRight1[index]); + CCTK_REAL const ShiftMinus1SRight2 = ShiftMinus1(&SRight2[index]); + CCTK_REAL const ShiftMinus1SRight3 = ShiftMinus1(&SRight3[index]); + CCTK_REAL const ShiftMinus1vRight1 = ShiftMinus1(&vRight1[index]); + CCTK_REAL const ShiftMinus1vRight2 = ShiftMinus1(&vRight2[index]); + CCTK_REAL const ShiftMinus1vRight3 = ShiftMinus1(&vRight3[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL vRightTemp1 = ShiftMinus1vRight1; + + CCTK_REAL vRightTemp2 = ShiftMinus1vRight2; + + CCTK_REAL vRightTemp3 = ShiftMinus1vRight3; + + CCTK_REAL DenFL = 0.5*(rhoLeftL*vLeft1L + + ShiftMinus1rhoRight*vRightTemp1 + (-DenLeftL + + ShiftMinus1DenRight)*ToReal(alpha)); + + CCTK_REAL SF1L = 0.5*(pLeftL + ShiftMinus1pRight + + rhoLeftL*SQR(vLeft1L) + ShiftMinus1rhoRight*SQR(vRightTemp1) + + (-SLeft1L + ShiftMinus1SRight1)*ToReal(alpha)); + + CCTK_REAL SF2L = 0.5*(rhoLeftL*vLeft1L*vLeft2L + + ShiftMinus1rhoRight*vRightTemp1*vRightTemp2 + (-SLeft2L + + ShiftMinus1SRight2)*ToReal(alpha)); + + CCTK_REAL SF3L = 0.5*(rhoLeftL*vLeft1L*vLeft3L + + ShiftMinus1rhoRight*vRightTemp1*vRightTemp3 + (-SLeft3L + + ShiftMinus1SRight3)*ToReal(alpha)); + + CCTK_REAL EnFL = 0.5*((EnLeftL + pLeftL)*vLeft1L + + ShiftMinus1pRight*vRightTemp1 - EnLeftL*ToReal(alpha) + + ShiftMinus1EnRight*(vRightTemp1 + ToReal(alpha))); + + /* Copy local copies back to grid functions */ + DenF[index] = DenFL; + EnF[index] = EnFL; + SF1[index] = SF1L; + SF2[index] = SF2L; + SF3[index] = SF3L; } + CCTK_ENDLOOP3 (euler_flux_1); } extern "C" void euler_flux_1(CCTK_ARGUMENTS) @@ -204,5 +197,26 @@ extern "C" void euler_flux_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering euler_flux_1_Body"); + } + + if (cctk_iteration % euler_flux_1_calc_every != euler_flux_1_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::DenF_group","Euler::DenLeft_group","Euler::DenRight_group","Euler::EnF_group","Euler::EnLeft_group","Euler::EnRight_group","Euler::pLeft_group","Euler::pRight_group","Euler::rhoLeft_group","Euler::rhoRight_group","Euler::SF_group","Euler::SLeft_group","Euler::SRight_group","Euler::vLeft_group","Euler::vRight_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_flux_1", 15, groups); + + GenericFD_EnsureStencilFits(cctkGH, "euler_flux_1", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &euler_flux_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving euler_flux_1_Body"); + } } diff --git a/Examples/Euler/src/euler_initial_shock.cc b/Examples/Euler/src/euler_initial_shock.cc index d20ce9a..e1350f0 100644 --- a/Examples/Euler/src/euler_initial_shock.cc +++ b/Examples/Euler/src/euler_initial_shock.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void euler_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[]) +static void euler_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 imin[3], int const imax[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 euler_initial_shock_Body"); - } - - if (cctk_iteration % euler_initial_shock_calc_every != euler_initial_shock_calc_offset) - { - return; - } - - const char *groups[] = {"grid::coordinates","Euler::p_group","Euler::rho_group","Euler::v_group"}; - GenericFD_AssertGroupStorage(cctkGH, "euler_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); + 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); @@ -95,47 +83,53 @@ static void euler_initial_shock_Body(cGH const * restrict const cctkGH, int cons CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (euler_initial_shock, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL rhoL = ToReal(rhoL0) + StepFunction(-0.5 + - xL)*(-ToReal(rhoL0) + ToReal(rhoR0)); - - CCTK_REAL v1L = ToReal(vL0) + StepFunction(-0.5 + xL)*(-ToReal(vL0) + - ToReal(vR0)); - - CCTK_REAL v2L = 0; - - CCTK_REAL v3L = 0; - - CCTK_REAL pL = ToReal(pL0) + StepFunction(-0.5 + xL)*(-ToReal(pL0) + - ToReal(pR0)); - - /* Copy local copies back to grid functions */ - p[index] = pL; - rho[index] = rhoL; - v1[index] = v1L; - v2[index] = v2L; - v3[index] = v3L; - } - } + 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 rhoL = ToReal(rhoL0) + StepFunction(-0.5 + + xL)*(-ToReal(rhoL0) + ToReal(rhoR0)); + + CCTK_REAL v1L = ToReal(vL0) + StepFunction(-0.5 + xL)*(-ToReal(vL0) + + ToReal(vR0)); + + CCTK_REAL v2L = 0; + + CCTK_REAL v3L = 0; + + CCTK_REAL pL = ToReal(pL0) + StepFunction(-0.5 + xL)*(-ToReal(pL0) + + ToReal(pR0)); + + /* Copy local copies back to grid functions */ + p[index] = pL; + rho[index] = rhoL; + v1[index] = v1L; + v2[index] = v2L; + v3[index] = v3L; } + CCTK_ENDLOOP3 (euler_initial_shock); } extern "C" void euler_initial_shock(CCTK_ARGUMENTS) @@ -143,5 +137,25 @@ extern "C" void euler_initial_shock(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering euler_initial_shock_Body"); + } + + if (cctk_iteration % euler_initial_shock_calc_every != euler_initial_shock_calc_offset) + { + return; + } + + const char *groups[] = {"grid::coordinates","Euler::p_group","Euler::rho_group","Euler::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_initial_shock", 4, groups); + + GenericFD_LoopOverEverything(cctkGH, &euler_initial_shock_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving euler_initial_shock_Body"); + } } diff --git a/Examples/Euler/src/euler_primitives.cc b/Examples/Euler/src/euler_primitives.cc index 27d26b9..6f28417 100644 --- a/Examples/Euler/src/euler_primitives.cc +++ b/Examples/Euler/src/euler_primitives.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void euler_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[]) +static void euler_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 imin[3], int const imax[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 euler_primitives_Body"); - } - - if (cctk_iteration % euler_primitives_calc_every != euler_primitives_calc_offset) - { - return; - } - - const char *groups[] = {"Euler::Den_group","Euler::En_group","Euler::p_group","Euler::rho_group","Euler::S_group","Euler::v_group"}; - GenericFD_AssertGroupStorage(cctkGH, "euler_primitives", 6, 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); + 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); @@ -95,49 +83,55 @@ static void euler_primitives_Body(cGH const * restrict const cctkGH, int const d CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (euler_primitives, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 EnL = En[index]; - CCTK_REAL S1L = S1[index]; - CCTK_REAL S2L = S2[index]; - CCTK_REAL S3L = S3[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL rhoL = DenL; - - CCTK_REAL v1L = S1L*INV(DenL); - - CCTK_REAL v2L = S2L*INV(DenL); - - CCTK_REAL v3L = S3L*INV(DenL); - - CCTK_REAL pL = (EnL - 0.5*INV(DenL)*(SQR(S1L) + SQR(S2L) + - SQR(S3L)))*(-1 + ToReal(gamma)); - - /* Copy local copies back to grid functions */ - p[index] = pL; - rho[index] = rhoL; - v1[index] = v1L; - v2[index] = v2L; - v3[index] = v3L; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL DenL = Den[index]; + CCTK_REAL EnL = En[index]; + CCTK_REAL S1L = S1[index]; + CCTK_REAL S2L = S2[index]; + CCTK_REAL S3L = S3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL rhoL = DenL; + + CCTK_REAL v1L = S1L*INV(DenL); + + CCTK_REAL v2L = S2L*INV(DenL); + + CCTK_REAL v3L = S3L*INV(DenL); + + CCTK_REAL pL = 0.5*INV(DenL)*(2*DenL*EnL - SQR(S1L) - + SQR(S2L) - SQR(S3L))*(-1 + ToReal(gamma)); + + /* Copy local copies back to grid functions */ + p[index] = pL; + rho[index] = rhoL; + v1[index] = v1L; + v2[index] = v2L; + v3[index] = v3L; } + CCTK_ENDLOOP3 (euler_primitives); } extern "C" void euler_primitives(CCTK_ARGUMENTS) @@ -145,5 +139,25 @@ extern "C" void euler_primitives(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering euler_primitives_Body"); + } + + if (cctk_iteration % euler_primitives_calc_every != euler_primitives_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::Den_group","Euler::En_group","Euler::p_group","Euler::rho_group","Euler::S_group","Euler::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_primitives", 6, groups); + + GenericFD_LoopOverEverything(cctkGH, &euler_primitives_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving euler_primitives_Body"); + } } diff --git a/Examples/Euler/src/euler_reconstruct_1.cc b/Examples/Euler/src/euler_reconstruct_1.cc index 6fa5f9a..976472d 100644 --- a/Examples/Euler/src/euler_reconstruct_1.cc +++ b/Examples/Euler/src/euler_reconstruct_1.cc @@ -12,6 +12,8 @@ #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) @@ -47,43 +49,28 @@ extern "C" void euler_reconstruct_1_SelectBCs(CCTK_ARGUMENTS) return; } -static void euler_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[]) +static void euler_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 imin[3], int const imax[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 euler_reconstruct_1_Body"); - } - - if (cctk_iteration % euler_reconstruct_1_calc_every != euler_reconstruct_1_calc_offset) - { - return; - } - - const char *groups[] = {"Euler::p_group","Euler::pLeft_group","Euler::pRight_group","Euler::rho_group","Euler::rhoLeft_group","Euler::rhoRight_group","Euler::v_group","Euler::vLeft_group","Euler::vRight_group"}; - GenericFD_AssertGroupStorage(cctkGH, "euler_reconstruct_1", 9, groups); - - GenericFD_EnsureStencilFits(cctkGH, "euler_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); + 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); @@ -123,103 +110,109 @@ static void euler_reconstruct_1_Body(cGH const * restrict const cctkGH, int cons CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (euler_reconstruct_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 pL = p[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 DiffPlus1p = DiffPlus1(&p[index]); - CCTK_REAL const DiffMinus1p = DiffMinus1(&p[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 vLeft1L = -0.5*slope + v1L; - - CCTK_REAL vRight1L = 0.5*slope + v1L; - - slopeL = DiffMinus1v2; - - slopeR = DiffPlus1v2; - - slope = VanLeer(slopeL,slopeR); - - CCTK_REAL vLeft2L = -0.5*slope + v2L; - - CCTK_REAL vRight2L = 0.5*slope + v2L; - - slopeL = DiffMinus1v3; - - slopeR = DiffPlus1v3; - - slope = VanLeer(slopeL,slopeR); - - CCTK_REAL vLeft3L = -0.5*slope + v3L; - - CCTK_REAL vRight3L = 0.5*slope + v3L; - - slopeL = DiffMinus1p; - - slopeR = DiffPlus1p; - - slope = VanLeer(slopeL,slopeR); - - CCTK_REAL pLeftL = pL - 0.5*slope; - - CCTK_REAL pRightL = pL + 0.5*slope; - - /* Copy local copies back to grid functions */ - pLeft[index] = pLeftL; - pRight[index] = pRightL; - rhoLeft[index] = rhoLeftL; - rhoRight[index] = rhoRightL; - vLeft1[index] = vLeft1L; - vLeft2[index] = vLeft2L; - vLeft3[index] = vLeft3L; - vRight1[index] = vRight1L; - vRight2[index] = vRight2L; - vRight3[index] = vRight3L; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + 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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const DiffPlus1p = DiffPlus1(&p[index]); + CCTK_REAL const DiffMinus1p = DiffMinus1(&p[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 vLeft1L = v1L - 0.5*slope; + + CCTK_REAL vRight1L = v1L + 0.5*slope; + + slopeL = DiffMinus1v2; + + slopeR = DiffPlus1v2; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL vLeft2L = v2L - 0.5*slope; + + CCTK_REAL vRight2L = v2L + 0.5*slope; + + slopeL = DiffMinus1v3; + + slopeR = DiffPlus1v3; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL vLeft3L = v3L - 0.5*slope; + + CCTK_REAL vRight3L = v3L + 0.5*slope; + + slopeL = DiffMinus1p; + + slopeR = DiffPlus1p; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL pLeftL = pL - 0.5*slope; + + CCTK_REAL pRightL = pL + 0.5*slope; + + /* Copy local copies back to grid functions */ + pLeft[index] = pLeftL; + pRight[index] = pRightL; + rhoLeft[index] = rhoLeftL; + rhoRight[index] = rhoRightL; + vLeft1[index] = vLeft1L; + vLeft2[index] = vLeft2L; + vLeft3[index] = vLeft3L; + vRight1[index] = vRight1L; + vRight2[index] = vRight2L; + vRight3[index] = vRight3L; } + CCTK_ENDLOOP3 (euler_reconstruct_1); } extern "C" void euler_reconstruct_1(CCTK_ARGUMENTS) @@ -227,5 +220,26 @@ extern "C" void euler_reconstruct_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering euler_reconstruct_1_Body"); + } + + if (cctk_iteration % euler_reconstruct_1_calc_every != euler_reconstruct_1_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::p_group","Euler::pLeft_group","Euler::pRight_group","Euler::rho_group","Euler::rhoLeft_group","Euler::rhoRight_group","Euler::v_group","Euler::vLeft_group","Euler::vRight_group"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_reconstruct_1", 9, groups); + + GenericFD_EnsureStencilFits(cctkGH, "euler_reconstruct_1", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &euler_reconstruct_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving euler_reconstruct_1_Body"); + } } diff --git a/Examples/Euler/src/euler_rhs_1.cc b/Examples/Euler/src/euler_rhs_1.cc index 2467cbb..fa611a2 100644 --- a/Examples/Euler/src/euler_rhs_1.cc +++ b/Examples/Euler/src/euler_rhs_1.cc @@ -12,6 +12,8 @@ #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) @@ -38,43 +40,28 @@ extern "C" void euler_rhs_1_SelectBCs(CCTK_ARGUMENTS) return; } -static void euler_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[]) +static void euler_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 imin[3], int const imax[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 euler_rhs_1_Body"); - } - - if (cctk_iteration % euler_rhs_1_calc_every != euler_rhs_1_calc_offset) - { - return; - } - - const char *groups[] = {"Euler::DenF_group","Euler::Den_grouprhs","Euler::EnF_group","Euler::En_grouprhs","Euler::SF_group","Euler::S_grouprhs"}; - GenericFD_AssertGroupStorage(cctkGH, "euler_rhs_1", 6, groups); - - GenericFD_EnsureStencilFits(cctkGH, "euler_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); + 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); @@ -114,58 +101,64 @@ static void euler_rhs_1_Body(cGH const * restrict const cctkGH, int const dir, i CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (euler_rhs_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 DenFL = DenF[index]; - CCTK_REAL DenrhsL = Denrhs[index]; - CCTK_REAL EnFL = EnF[index]; - CCTK_REAL EnrhsL = Enrhs[index]; - CCTK_REAL S1rhsL = S1rhs[index]; - CCTK_REAL S2rhsL = S2rhs[index]; - CCTK_REAL S3rhsL = S3rhs[index]; - CCTK_REAL SF1L = SF1[index]; - CCTK_REAL SF2L = SF2[index]; - CCTK_REAL SF3L = SF3[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const PDplus1DenF = PDplus1(&DenF[index]); - CCTK_REAL const PDplus1EnF = PDplus1(&EnF[index]); - CCTK_REAL const PDplus1SF1 = PDplus1(&SF1[index]); - CCTK_REAL const PDplus1SF2 = PDplus1(&SF2[index]); - CCTK_REAL const PDplus1SF3 = PDplus1(&SF3[index]); - - /* Calculate temporaries and grid functions */ - DenrhsL = DenrhsL - PDplus1DenF; - - S1rhsL = -PDplus1SF1 + S1rhsL; - - S2rhsL = -PDplus1SF2 + S2rhsL; - - S3rhsL = -PDplus1SF3 + S3rhsL; - - EnrhsL = EnrhsL - PDplus1EnF; - - /* Copy local copies back to grid functions */ - Denrhs[index] = DenrhsL; - Enrhs[index] = EnrhsL; - S1rhs[index] = S1rhsL; - S2rhs[index] = S2rhsL; - S3rhs[index] = S3rhsL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL DenFL = DenF[index]; + CCTK_REAL DenrhsL = Denrhs[index]; + CCTK_REAL EnFL = EnF[index]; + CCTK_REAL EnrhsL = Enrhs[index]; + CCTK_REAL S1rhsL = S1rhs[index]; + CCTK_REAL S2rhsL = S2rhs[index]; + CCTK_REAL S3rhsL = S3rhs[index]; + CCTK_REAL SF1L = SF1[index]; + CCTK_REAL SF2L = SF2[index]; + CCTK_REAL SF3L = SF3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDplus1DenF = PDplus1(&DenF[index]); + CCTK_REAL const PDplus1EnF = PDplus1(&EnF[index]); + CCTK_REAL const PDplus1SF1 = PDplus1(&SF1[index]); + CCTK_REAL const PDplus1SF2 = PDplus1(&SF2[index]); + CCTK_REAL const PDplus1SF3 = PDplus1(&SF3[index]); + + /* Calculate temporaries and grid functions */ + DenrhsL = DenrhsL - PDplus1DenF; + + S1rhsL = S1rhsL - PDplus1SF1; + + S2rhsL = S2rhsL - PDplus1SF2; + + S3rhsL = S3rhsL - PDplus1SF3; + + EnrhsL = EnrhsL - PDplus1EnF; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + Enrhs[index] = EnrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; } + CCTK_ENDLOOP3 (euler_rhs_1); } extern "C" void euler_rhs_1(CCTK_ARGUMENTS) @@ -173,5 +166,26 @@ extern "C" void euler_rhs_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering euler_rhs_1_Body"); + } + + if (cctk_iteration % euler_rhs_1_calc_every != euler_rhs_1_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::DenF_group","Euler::Den_grouprhs","Euler::EnF_group","Euler::En_grouprhs","Euler::SF_group","Euler::S_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_rhs_1", 6, groups); + + GenericFD_EnsureStencilFits(cctkGH, "euler_rhs_1", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &euler_rhs_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving euler_rhs_1_Body"); + } } diff --git a/Examples/Euler/src/euler_zero_rhs.cc b/Examples/Euler/src/euler_zero_rhs.cc index 62157f2..b5371b0 100644 --- a/Examples/Euler/src/euler_zero_rhs.cc +++ b/Examples/Euler/src/euler_zero_rhs.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void euler_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[]) +static void euler_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 imin[3], int const imax[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 euler_zero_rhs_Body"); - } - - if (cctk_iteration % euler_zero_rhs_calc_every != euler_zero_rhs_calc_offset) - { - return; - } - - const char *groups[] = {"Euler::Den_grouprhs","Euler::En_grouprhs","Euler::S_grouprhs"}; - GenericFD_AssertGroupStorage(cctkGH, "euler_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); + 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); @@ -95,43 +83,49 @@ static void euler_zero_rhs_Body(cGH const * restrict const cctkGH, int const dir CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (euler_zero_rhs, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - - CCTK_REAL S1rhsL = 0; - - CCTK_REAL S2rhsL = 0; - - CCTK_REAL S3rhsL = 0; - - CCTK_REAL EnrhsL = 0; - - /* Copy local copies back to grid functions */ - Denrhs[index] = DenrhsL; - Enrhs[index] = EnrhsL; - S1rhs[index] = S1rhsL; - S2rhs[index] = S2rhsL; - S3rhs[index] = S3rhsL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenrhsL = 0; + + CCTK_REAL S1rhsL = 0; + + CCTK_REAL S2rhsL = 0; + + CCTK_REAL S3rhsL = 0; + + CCTK_REAL EnrhsL = 0; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + Enrhs[index] = EnrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; } + CCTK_ENDLOOP3 (euler_zero_rhs); } extern "C" void euler_zero_rhs(CCTK_ARGUMENTS) @@ -139,5 +133,25 @@ extern "C" void euler_zero_rhs(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering euler_zero_rhs_Body"); + } + + if (cctk_iteration % euler_zero_rhs_calc_every != euler_zero_rhs_calc_offset) + { + return; + } + + const char *groups[] = {"Euler::Den_grouprhs","Euler::En_grouprhs","Euler::S_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "euler_zero_rhs", 3, groups); + + GenericFD_LoopOverEverything(cctkGH, &euler_zero_rhs_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving euler_zero_rhs_Body"); + } } diff --git a/Examples/EulerAuto/configuration.ccl b/Examples/EulerAuto/configuration.ccl index 023aac7..0a66ec2 100644 --- a/Examples/EulerAuto/configuration.ccl +++ b/Examples/EulerAuto/configuration.ccl @@ -1,3 +1,6 @@ # File produced by Kranc REQUIRES GenericFD +OPTIONAL LoopControl +{ +} diff --git a/Examples/EulerAuto/interface.ccl b/Examples/EulerAuto/interface.ccl index 409ad9e..0323809 100644 --- a/Examples/EulerAuto/interface.ccl +++ b/Examples/EulerAuto/interface.ccl @@ -10,6 +10,7 @@ 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 diff --git a/Examples/EulerAuto/param.ccl b/Examples/EulerAuto/param.ccl index e36bd21..06e8caf 100644 --- a/Examples/EulerAuto/param.ccl +++ b/Examples/EulerAuto/param.ccl @@ -8,6 +8,7 @@ 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 @@ -94,6 +95,12 @@ CCTK_INT EulerAuto_MaxNumEvolvedVars "Number of evolved variables used by this t } 5 restricted: +CCTK_INT EulerAuto_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:3 :: "" @@ -106,6 +113,12 @@ CCTK_INT rhs_timelevels "Number of active RHS timelevels" STEERABLE=RECOVER } 1 restricted: +CCTK_INT other_timelevels "Number of active timelevels for non-evolved grid functions" STEERABLE=RECOVER +{ + 0:3 :: "" +} 1 + +restricted: CCTK_INT eulerauto_initial_shock_calc_every "eulerauto_initial_shock_calc_every" STEERABLE=ALWAYS { *:* :: "" diff --git a/Examples/EulerAuto/schedule.ccl b/Examples/EulerAuto/schedule.ccl index 4f5faa0..2911d7b 100644 --- a/Examples/EulerAuto/schedule.ccl +++ b/Examples/EulerAuto/schedule.ccl @@ -1,41 +1,95 @@ # File produced by Kranc -STORAGE: Den_flux_group[1] +if (other_timelevels == 1) +{ + STORAGE: Den_flux_group[1] +} -STORAGE: Den_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: Den_lr_group[1] +} -STORAGE: En_flux_group[1] +if (other_timelevels == 1) +{ + STORAGE: En_flux_group[1] +} -STORAGE: En_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: En_lr_group[1] +} -STORAGE: p_group[1] +if (other_timelevels == 1) +{ + STORAGE: p_group[1] +} -STORAGE: p_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: p_lr_group[1] +} -STORAGE: rho_group[1] +if (other_timelevels == 1) +{ + STORAGE: rho_group[1] +} -STORAGE: rho_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: rho_lr_group[1] +} -STORAGE: S1_flux_group[1] +if (other_timelevels == 1) +{ + STORAGE: S1_flux_group[1] +} -STORAGE: S1_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: S1_lr_group[1] +} -STORAGE: S2_flux_group[1] +if (other_timelevels == 1) +{ + STORAGE: S2_flux_group[1] +} -STORAGE: S2_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: S2_lr_group[1] +} -STORAGE: S3_flux_group[1] +if (other_timelevels == 1) +{ + STORAGE: S3_flux_group[1] +} -STORAGE: S3_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: S3_lr_group[1] +} -STORAGE: v1_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: v1_lr_group[1] +} -STORAGE: v2_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: v2_lr_group[1] +} -STORAGE: v3_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: v3_lr_group[1] +} -STORAGE: v_group[1] +if (other_timelevels == 1) +{ + STORAGE: v_group[1] +} if (timelevels == 1) { @@ -188,12 +242,7 @@ schedule group eulerauto_cons_calc_reconstruct_1_bc_group in eulerauto_cons_calc # no language specified } "eulerauto_cons_calc_reconstruct_1" -schedule group eulerauto_cons_calc_reconstruct_1_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulerauto_cons_calc_reconstruct_1" - -schedule group eulerauto_cons_calc_reconstruct_1_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulerauto_cons_calc_reconstruct_1_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulerauto_cons_calc_reconstruct_1" @@ -234,12 +283,7 @@ schedule group eulerauto_cons_calc_flux_1_bc_group in eulerauto_cons_calc_flux_1 # no language specified } "eulerauto_cons_calc_flux_1" -schedule group eulerauto_cons_calc_flux_1_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulerauto_cons_calc_flux_1" - -schedule group eulerauto_cons_calc_flux_1_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulerauto_cons_calc_flux_1_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulerauto_cons_calc_flux_1" @@ -280,12 +324,7 @@ schedule group eulerauto_cons_calc_reconstruct_2_bc_group in eulerauto_cons_calc # no language specified } "eulerauto_cons_calc_reconstruct_2" -schedule group eulerauto_cons_calc_reconstruct_2_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulerauto_cons_calc_reconstruct_2" - -schedule group eulerauto_cons_calc_reconstruct_2_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulerauto_cons_calc_reconstruct_2_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulerauto_cons_calc_reconstruct_2" @@ -326,12 +365,7 @@ schedule group eulerauto_cons_calc_flux_2_bc_group in eulerauto_cons_calc_flux_2 # no language specified } "eulerauto_cons_calc_flux_2" -schedule group eulerauto_cons_calc_flux_2_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulerauto_cons_calc_flux_2" - -schedule group eulerauto_cons_calc_flux_2_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulerauto_cons_calc_flux_2_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulerauto_cons_calc_flux_2" @@ -372,12 +406,7 @@ schedule group eulerauto_cons_calc_reconstruct_3_bc_group in eulerauto_cons_calc # no language specified } "eulerauto_cons_calc_reconstruct_3" -schedule group eulerauto_cons_calc_reconstruct_3_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulerauto_cons_calc_reconstruct_3" - -schedule group eulerauto_cons_calc_reconstruct_3_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulerauto_cons_calc_reconstruct_3_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulerauto_cons_calc_reconstruct_3" @@ -418,12 +447,7 @@ schedule group eulerauto_cons_calc_flux_3_bc_group in eulerauto_cons_calc_flux_3 # no language specified } "eulerauto_cons_calc_flux_3" -schedule group eulerauto_cons_calc_flux_3_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulerauto_cons_calc_flux_3" - -schedule group eulerauto_cons_calc_flux_3_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulerauto_cons_calc_flux_3_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulerauto_cons_calc_flux_3" diff --git a/Examples/EulerAuto/src/Differencing.h b/Examples/EulerAuto/src/Differencing.h index 0908172..913cfa8 100644 --- a/Examples/EulerAuto/src/Differencing.h +++ b/Examples/EulerAuto/src/Differencing.h @@ -1,12 +1,144 @@ -#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)])) +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o1) +#else +# define DiffPlus1(u) (DiffPlus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o1) +#else +# define DiffPlus2(u) (DiffPlus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1o1) +#else +# define DiffPlus3(u) (DiffPlus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus1(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,-1,0,0))*p1o1) +#else +# define DiffMinus1(u) (DiffMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus2(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,-1,0))*p1o1) +#else +# define DiffMinus2(u) (DiffMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,-1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus3(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,0,-1))*p1o1) +#else +# define DiffMinus3(u) (DiffMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,-1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus1(u) (KRANC_GFOFFSET3D(u,-1,0,0)*p1o1) +#else +# define ShiftMinus1(u) (ShiftMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,-1,0,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus2(u) (KRANC_GFOFFSET3D(u,0,-1,0)*p1o1) +#else +# define ShiftMinus2(u) (ShiftMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,-1,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus3(u) (KRANC_GFOFFSET3D(u,0,0,-1)*p1o1) +#else +# define ShiftMinus3(u) (ShiftMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,0,-1)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx) +#else +# define PDplus1(u) (PDplus1_impl(u,p1odx,cdj,cdk)) +static CCTK_REAL PDplus1_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 PDplus1_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 + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody) +#else +# define PDplus2(u) (PDplus2_impl(u,p1ody,cdj,cdk)) +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, 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,0,1,0))*p1ody; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz) +#else +# define PDplus3(u) (PDplus3_impl(u,p1odz,cdj,cdk)) +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, 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,0,0,1))*p1odz; +} +#endif + diff --git a/Examples/EulerAuto/src/RegisterMoL.cc b/Examples/EulerAuto/src/RegisterMoL.cc index c01d0fd..76554bb 100644 --- a/Examples/EulerAuto/src/RegisterMoL.cc +++ b/Examples/EulerAuto/src/RegisterMoL.cc @@ -17,5 +17,7 @@ extern "C" void EulerAuto_RegisterVars(CCTK_ARGUMENTS) ierr += MoLRegisterEvolved(CCTK_VarIndex("EulerAuto::S1"), CCTK_VarIndex("EulerAuto::S1rhs")); ierr += MoLRegisterEvolved(CCTK_VarIndex("EulerAuto::S2"), CCTK_VarIndex("EulerAuto::S2rhs")); ierr += MoLRegisterEvolved(CCTK_VarIndex("EulerAuto::S3"), CCTK_VarIndex("EulerAuto::S3rhs")); + + /* Register all the evolved Array functions with MoL */ return; } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_conserved.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_conserved.cc index 9f483da..b41803a 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_conserved.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_conserved.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_conserved_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_conserved_calc_every != eulerauto_cons_calc_conserved_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_group","EulerAuto::En_group","EulerAuto::p_group","EulerAuto::rho_group","EulerAuto::S_group","EulerAuto::v_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_conserved", 6, 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); + 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); @@ -74,49 +62,55 @@ static void eulerauto_cons_calc_conserved_Body(cGH const * restrict const cctkGH CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_conserved, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 pL = p[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 */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL DenL = rhoL; - - CCTK_REAL S1L = rhoL*v1L; - - CCTK_REAL S2L = rhoL*v2L; - - CCTK_REAL S3L = rhoL*v3L; - - CCTK_REAL EnL = pL*INV(-1 + ToReal(gamma)) + 0.5*rhoL*(SQR(v1L) + - SQR(v2L) + SQR(v3L)); - - /* Copy local copies back to grid functions */ - Den[index] = DenL; - En[index] = EnL; - S1[index] = S1L; - S2[index] = S2L; - S3[index] = S3L; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + 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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenL = rhoL; + + CCTK_REAL S1L = rhoL*v1L; + + CCTK_REAL S2L = rhoL*v2L; + + CCTK_REAL S3L = rhoL*v3L; + + CCTK_REAL EnL = 0.5*INV(-1 + ToReal(gamma))*(2*pL + + rhoL*(SQR(v1L) + SQR(v2L) + SQR(v3L))*(-1 + ToReal(gamma))); + + /* Copy local copies back to grid functions */ + Den[index] = DenL; + En[index] = EnL; + S1[index] = S1L; + S2[index] = S2L; + S3[index] = S3L; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_conserved); } extern "C" void eulerauto_cons_calc_conserved(CCTK_ARGUMENTS) @@ -124,5 +118,25 @@ extern "C" void eulerauto_cons_calc_conserved(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_conserved_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_conserved_calc_every != eulerauto_cons_calc_conserved_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_group","EulerAuto::En_group","EulerAuto::p_group","EulerAuto::rho_group","EulerAuto::S_group","EulerAuto::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_conserved", 6, groups); + + GenericFD_LoopOverEverything(cctkGH, &eulerauto_cons_calc_conserved_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_conserved_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_flux_1.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_flux_1.cc index 579c9dc..02eec61 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_flux_1.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_flux_1.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulerauto_cons_calc_flux_1_SelectBCs(CCTK_ARGUMENTS) return; } -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_flux_1_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_flux_1_calc_every != eulerauto_cons_calc_flux_1_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_lr_group","EulerAuto::En_flux_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_flux_group","EulerAuto::S1_lr_group","EulerAuto::S2_flux_group","EulerAuto::S2_lr_group","EulerAuto::S3_flux_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_flux_1", 15, groups); - - GenericFD_EnsureStencilFits(cctkGH, "eulerauto_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); + 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); @@ -99,102 +86,108 @@ static void eulerauto_cons_calc_flux_1_Body(cGH const * restrict const cctkGH, i CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_flux_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 EnLeftL = EnLeft[index]; - CCTK_REAL EnRightL = EnRight[index]; - CCTK_REAL pLeftL = pLeft[index]; - CCTK_REAL pRightL = pRight[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 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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const ShiftMinus1DenRight = ShiftMinus1(&DenRight[index]); - CCTK_REAL const ShiftMinus1EnRight = ShiftMinus1(&EnRight[index]); - CCTK_REAL const ShiftMinus1pRight = ShiftMinus1(&pRight[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 ShiftMinus1v1Right = ShiftMinus1(&v1Right[index]); - CCTK_REAL const ShiftMinus1v2Right = ShiftMinus1(&v2Right[index]); - CCTK_REAL const ShiftMinus1v3Right = ShiftMinus1(&v3Right[index]); - - /* Calculate temporaries and grid functions */ - CCTK_REAL DenFluxLeft = rhoLeftL*v1LeftL; - - CCTK_REAL DenFluxRight = ShiftMinus1rhoRight*ShiftMinus1v1Right; - - CCTK_REAL DenFluxL = 0.5*(DenFluxLeft + DenFluxRight + (-DenLeftL + - ShiftMinus1DenRight)*ToReal(hlleAlpha)); - - CCTK_REAL S1FluxLeft = pLeftL + rhoLeftL*SQR(v1LeftL); - - CCTK_REAL S1FluxRight = ShiftMinus1pRight + - ShiftMinus1rhoRight*SQR(ShiftMinus1v1Right); - - CCTK_REAL S1FluxL = 0.5*(S1FluxLeft + S1FluxRight + (-S1LeftL + - ShiftMinus1S1Right)*ToReal(hlleAlpha)); - - CCTK_REAL S2FluxLeft = rhoLeftL*v1LeftL*v2LeftL; - - CCTK_REAL S2FluxRight = - ShiftMinus1rhoRight*ShiftMinus1v1Right*ShiftMinus1v2Right; - - CCTK_REAL S2FluxL = 0.5*(S2FluxLeft + S2FluxRight + (-S2LeftL + - ShiftMinus1S2Right)*ToReal(hlleAlpha)); - - CCTK_REAL S3FluxLeft = rhoLeftL*v1LeftL*v3LeftL; - - CCTK_REAL S3FluxRight = - ShiftMinus1rhoRight*ShiftMinus1v1Right*ShiftMinus1v3Right; - - CCTK_REAL S3FluxL = 0.5*(S3FluxLeft + S3FluxRight + (-S3LeftL + - ShiftMinus1S3Right)*ToReal(hlleAlpha)); - - CCTK_REAL EnFluxLeft = (EnLeftL + pLeftL)*v1LeftL; - - CCTK_REAL EnFluxRight = (ShiftMinus1EnRight + - ShiftMinus1pRight)*ShiftMinus1v1Right; - - CCTK_REAL EnFluxL = 0.5*(EnFluxLeft + EnFluxRight + (-EnLeftL + - ShiftMinus1EnRight)*ToReal(hlleAlpha)); - - /* Copy local copies back to grid functions */ - DenFlux[index] = DenFluxL; - EnFlux[index] = EnFluxL; - S1Flux[index] = S1FluxL; - S2Flux[index] = S2FluxL; - S3Flux[index] = S3FluxL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL DenLeftL = DenLeft[index]; + CCTK_REAL DenRightL = DenRight[index]; + CCTK_REAL EnLeftL = EnLeft[index]; + CCTK_REAL EnRightL = EnRight[index]; + CCTK_REAL pLeftL = pLeft[index]; + CCTK_REAL pRightL = pRight[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 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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const ShiftMinus1DenRight = ShiftMinus1(&DenRight[index]); + CCTK_REAL const ShiftMinus1EnRight = ShiftMinus1(&EnRight[index]); + CCTK_REAL const ShiftMinus1pRight = ShiftMinus1(&pRight[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 ShiftMinus1v1Right = ShiftMinus1(&v1Right[index]); + CCTK_REAL const ShiftMinus1v2Right = ShiftMinus1(&v2Right[index]); + CCTK_REAL const ShiftMinus1v3Right = ShiftMinus1(&v3Right[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenFluxLeft = rhoLeftL*v1LeftL; + + CCTK_REAL DenFluxRight = ShiftMinus1rhoRight*ShiftMinus1v1Right; + + CCTK_REAL DenFluxL = 0.5*(DenFluxLeft + DenFluxRight + (-DenLeftL + + ShiftMinus1DenRight)*ToReal(hlleAlpha)); + + CCTK_REAL S1FluxLeft = pLeftL + rhoLeftL*SQR(v1LeftL); + + CCTK_REAL S1FluxRight = ShiftMinus1pRight + + ShiftMinus1rhoRight*SQR(ShiftMinus1v1Right); + + CCTK_REAL S1FluxL = 0.5*(S1FluxLeft + S1FluxRight + (-S1LeftL + + ShiftMinus1S1Right)*ToReal(hlleAlpha)); + + CCTK_REAL S2FluxLeft = rhoLeftL*v1LeftL*v2LeftL; + + CCTK_REAL S2FluxRight = + ShiftMinus1rhoRight*ShiftMinus1v1Right*ShiftMinus1v2Right; + + CCTK_REAL S2FluxL = 0.5*(S2FluxLeft + S2FluxRight + (-S2LeftL + + ShiftMinus1S2Right)*ToReal(hlleAlpha)); + + CCTK_REAL S3FluxLeft = rhoLeftL*v1LeftL*v3LeftL; + + CCTK_REAL S3FluxRight = + ShiftMinus1rhoRight*ShiftMinus1v1Right*ShiftMinus1v3Right; + + CCTK_REAL S3FluxL = 0.5*(S3FluxLeft + S3FluxRight + (-S3LeftL + + ShiftMinus1S3Right)*ToReal(hlleAlpha)); + + CCTK_REAL EnFluxLeft = (EnLeftL + pLeftL)*v1LeftL; + + CCTK_REAL EnFluxRight = (ShiftMinus1EnRight + + ShiftMinus1pRight)*ShiftMinus1v1Right; + + CCTK_REAL EnFluxL = 0.5*(EnFluxLeft + EnFluxRight + (-EnLeftL + + ShiftMinus1EnRight)*ToReal(hlleAlpha)); + + /* Copy local copies back to grid functions */ + DenFlux[index] = DenFluxL; + EnFlux[index] = EnFluxL; + S1Flux[index] = S1FluxL; + S2Flux[index] = S2FluxL; + S3Flux[index] = S3FluxL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_flux_1); } extern "C" void eulerauto_cons_calc_flux_1(CCTK_ARGUMENTS) @@ -202,5 +195,26 @@ extern "C" void eulerauto_cons_calc_flux_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_flux_1_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_flux_1_calc_every != eulerauto_cons_calc_flux_1_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_lr_group","EulerAuto::En_flux_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_flux_group","EulerAuto::S1_lr_group","EulerAuto::S2_flux_group","EulerAuto::S2_lr_group","EulerAuto::S3_flux_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_flux_1", 15, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulerauto_cons_calc_flux_1", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &eulerauto_cons_calc_flux_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_flux_1_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_flux_2.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_flux_2.cc index cf67145..eb6fac5 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_flux_2.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_flux_2.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulerauto_cons_calc_flux_2_SelectBCs(CCTK_ARGUMENTS) return; } -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_flux_2_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_flux_2_calc_every != eulerauto_cons_calc_flux_2_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_lr_group","EulerAuto::En_flux_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_flux_group","EulerAuto::S1_lr_group","EulerAuto::S2_flux_group","EulerAuto::S2_lr_group","EulerAuto::S3_flux_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_flux_2", 15, groups); - - GenericFD_EnsureStencilFits(cctkGH, "eulerauto_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); + 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); @@ -99,102 +86,108 @@ static void eulerauto_cons_calc_flux_2_Body(cGH const * restrict const cctkGH, i CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_flux_2, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 EnLeftL = EnLeft[index]; - CCTK_REAL EnRightL = EnRight[index]; - CCTK_REAL pLeftL = pLeft[index]; - CCTK_REAL pRightL = pRight[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 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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const ShiftMinus2DenRight = ShiftMinus2(&DenRight[index]); - CCTK_REAL const ShiftMinus2EnRight = ShiftMinus2(&EnRight[index]); - CCTK_REAL const ShiftMinus2pRight = ShiftMinus2(&pRight[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 ShiftMinus2v1Right = ShiftMinus2(&v1Right[index]); - CCTK_REAL const ShiftMinus2v2Right = ShiftMinus2(&v2Right[index]); - CCTK_REAL const ShiftMinus2v3Right = ShiftMinus2(&v3Right[index]); - - /* Calculate temporaries and grid functions */ - CCTK_REAL DenFluxLeft = rhoLeftL*v2LeftL; - - CCTK_REAL DenFluxRight = ShiftMinus2rhoRight*ShiftMinus2v2Right; - - CCTK_REAL DenFluxL = 0.5*(DenFluxLeft + DenFluxRight + (-DenLeftL + - ShiftMinus2DenRight)*ToReal(hlleAlpha)); - - CCTK_REAL S1FluxLeft = rhoLeftL*v1LeftL*v2LeftL; - - CCTK_REAL S1FluxRight = - ShiftMinus2rhoRight*ShiftMinus2v1Right*ShiftMinus2v2Right; - - CCTK_REAL S1FluxL = 0.5*(S1FluxLeft + S1FluxRight + (-S1LeftL + - ShiftMinus2S1Right)*ToReal(hlleAlpha)); - - CCTK_REAL S2FluxLeft = pLeftL + rhoLeftL*SQR(v2LeftL); - - CCTK_REAL S2FluxRight = ShiftMinus2pRight + - ShiftMinus2rhoRight*SQR(ShiftMinus2v2Right); - - CCTK_REAL S2FluxL = 0.5*(S2FluxLeft + S2FluxRight + (-S2LeftL + - ShiftMinus2S2Right)*ToReal(hlleAlpha)); - - CCTK_REAL S3FluxLeft = rhoLeftL*v2LeftL*v3LeftL; - - CCTK_REAL S3FluxRight = - ShiftMinus2rhoRight*ShiftMinus2v2Right*ShiftMinus2v3Right; - - CCTK_REAL S3FluxL = 0.5*(S3FluxLeft + S3FluxRight + (-S3LeftL + - ShiftMinus2S3Right)*ToReal(hlleAlpha)); - - CCTK_REAL EnFluxLeft = (EnLeftL + pLeftL)*v2LeftL; - - CCTK_REAL EnFluxRight = (ShiftMinus2EnRight + - ShiftMinus2pRight)*ShiftMinus2v2Right; - - CCTK_REAL EnFluxL = 0.5*(EnFluxLeft + EnFluxRight + (-EnLeftL + - ShiftMinus2EnRight)*ToReal(hlleAlpha)); - - /* Copy local copies back to grid functions */ - DenFlux[index] = DenFluxL; - EnFlux[index] = EnFluxL; - S1Flux[index] = S1FluxL; - S2Flux[index] = S2FluxL; - S3Flux[index] = S3FluxL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL DenLeftL = DenLeft[index]; + CCTK_REAL DenRightL = DenRight[index]; + CCTK_REAL EnLeftL = EnLeft[index]; + CCTK_REAL EnRightL = EnRight[index]; + CCTK_REAL pLeftL = pLeft[index]; + CCTK_REAL pRightL = pRight[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 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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const ShiftMinus2DenRight = ShiftMinus2(&DenRight[index]); + CCTK_REAL const ShiftMinus2EnRight = ShiftMinus2(&EnRight[index]); + CCTK_REAL const ShiftMinus2pRight = ShiftMinus2(&pRight[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 ShiftMinus2v1Right = ShiftMinus2(&v1Right[index]); + CCTK_REAL const ShiftMinus2v2Right = ShiftMinus2(&v2Right[index]); + CCTK_REAL const ShiftMinus2v3Right = ShiftMinus2(&v3Right[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenFluxLeft = rhoLeftL*v2LeftL; + + CCTK_REAL DenFluxRight = ShiftMinus2rhoRight*ShiftMinus2v2Right; + + CCTK_REAL DenFluxL = 0.5*(DenFluxLeft + DenFluxRight + (-DenLeftL + + ShiftMinus2DenRight)*ToReal(hlleAlpha)); + + CCTK_REAL S1FluxLeft = rhoLeftL*v1LeftL*v2LeftL; + + CCTK_REAL S1FluxRight = + ShiftMinus2rhoRight*ShiftMinus2v1Right*ShiftMinus2v2Right; + + CCTK_REAL S1FluxL = 0.5*(S1FluxLeft + S1FluxRight + (-S1LeftL + + ShiftMinus2S1Right)*ToReal(hlleAlpha)); + + CCTK_REAL S2FluxLeft = pLeftL + rhoLeftL*SQR(v2LeftL); + + CCTK_REAL S2FluxRight = ShiftMinus2pRight + + ShiftMinus2rhoRight*SQR(ShiftMinus2v2Right); + + CCTK_REAL S2FluxL = 0.5*(S2FluxLeft + S2FluxRight + (-S2LeftL + + ShiftMinus2S2Right)*ToReal(hlleAlpha)); + + CCTK_REAL S3FluxLeft = rhoLeftL*v2LeftL*v3LeftL; + + CCTK_REAL S3FluxRight = + ShiftMinus2rhoRight*ShiftMinus2v2Right*ShiftMinus2v3Right; + + CCTK_REAL S3FluxL = 0.5*(S3FluxLeft + S3FluxRight + (-S3LeftL + + ShiftMinus2S3Right)*ToReal(hlleAlpha)); + + CCTK_REAL EnFluxLeft = (EnLeftL + pLeftL)*v2LeftL; + + CCTK_REAL EnFluxRight = (ShiftMinus2EnRight + + ShiftMinus2pRight)*ShiftMinus2v2Right; + + CCTK_REAL EnFluxL = 0.5*(EnFluxLeft + EnFluxRight + (-EnLeftL + + ShiftMinus2EnRight)*ToReal(hlleAlpha)); + + /* Copy local copies back to grid functions */ + DenFlux[index] = DenFluxL; + EnFlux[index] = EnFluxL; + S1Flux[index] = S1FluxL; + S2Flux[index] = S2FluxL; + S3Flux[index] = S3FluxL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_flux_2); } extern "C" void eulerauto_cons_calc_flux_2(CCTK_ARGUMENTS) @@ -202,5 +195,26 @@ extern "C" void eulerauto_cons_calc_flux_2(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_flux_2_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_flux_2_calc_every != eulerauto_cons_calc_flux_2_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_lr_group","EulerAuto::En_flux_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_flux_group","EulerAuto::S1_lr_group","EulerAuto::S2_flux_group","EulerAuto::S2_lr_group","EulerAuto::S3_flux_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_flux_2", 15, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulerauto_cons_calc_flux_2", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &eulerauto_cons_calc_flux_2_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_flux_2_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_flux_3.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_flux_3.cc index 797da55..140cd47 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_flux_3.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_flux_3.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulerauto_cons_calc_flux_3_SelectBCs(CCTK_ARGUMENTS) return; } -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_flux_3_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_flux_3_calc_every != eulerauto_cons_calc_flux_3_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_lr_group","EulerAuto::En_flux_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_flux_group","EulerAuto::S1_lr_group","EulerAuto::S2_flux_group","EulerAuto::S2_lr_group","EulerAuto::S3_flux_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_flux_3", 15, groups); - - GenericFD_EnsureStencilFits(cctkGH, "eulerauto_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); + 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); @@ -99,102 +86,108 @@ static void eulerauto_cons_calc_flux_3_Body(cGH const * restrict const cctkGH, i CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_flux_3, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 EnLeftL = EnLeft[index]; - CCTK_REAL EnRightL = EnRight[index]; - CCTK_REAL pLeftL = pLeft[index]; - CCTK_REAL pRightL = pRight[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 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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const ShiftMinus3DenRight = ShiftMinus3(&DenRight[index]); - CCTK_REAL const ShiftMinus3EnRight = ShiftMinus3(&EnRight[index]); - CCTK_REAL const ShiftMinus3pRight = ShiftMinus3(&pRight[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 ShiftMinus3v1Right = ShiftMinus3(&v1Right[index]); - CCTK_REAL const ShiftMinus3v2Right = ShiftMinus3(&v2Right[index]); - CCTK_REAL const ShiftMinus3v3Right = ShiftMinus3(&v3Right[index]); - - /* Calculate temporaries and grid functions */ - CCTK_REAL DenFluxLeft = rhoLeftL*v3LeftL; - - CCTK_REAL DenFluxRight = ShiftMinus3rhoRight*ShiftMinus3v3Right; - - CCTK_REAL DenFluxL = 0.5*(DenFluxLeft + DenFluxRight + (-DenLeftL + - ShiftMinus3DenRight)*ToReal(hlleAlpha)); - - CCTK_REAL S1FluxLeft = rhoLeftL*v1LeftL*v3LeftL; - - CCTK_REAL S1FluxRight = - ShiftMinus3rhoRight*ShiftMinus3v1Right*ShiftMinus3v3Right; - - CCTK_REAL S1FluxL = 0.5*(S1FluxLeft + S1FluxRight + (-S1LeftL + - ShiftMinus3S1Right)*ToReal(hlleAlpha)); - - CCTK_REAL S2FluxLeft = rhoLeftL*v2LeftL*v3LeftL; - - CCTK_REAL S2FluxRight = - ShiftMinus3rhoRight*ShiftMinus3v2Right*ShiftMinus3v3Right; - - CCTK_REAL S2FluxL = 0.5*(S2FluxLeft + S2FluxRight + (-S2LeftL + - ShiftMinus3S2Right)*ToReal(hlleAlpha)); - - CCTK_REAL S3FluxLeft = pLeftL + rhoLeftL*SQR(v3LeftL); - - CCTK_REAL S3FluxRight = ShiftMinus3pRight + - ShiftMinus3rhoRight*SQR(ShiftMinus3v3Right); - - CCTK_REAL S3FluxL = 0.5*(S3FluxLeft + S3FluxRight + (-S3LeftL + - ShiftMinus3S3Right)*ToReal(hlleAlpha)); - - CCTK_REAL EnFluxLeft = (EnLeftL + pLeftL)*v3LeftL; - - CCTK_REAL EnFluxRight = (ShiftMinus3EnRight + - ShiftMinus3pRight)*ShiftMinus3v3Right; - - CCTK_REAL EnFluxL = 0.5*(EnFluxLeft + EnFluxRight + (-EnLeftL + - ShiftMinus3EnRight)*ToReal(hlleAlpha)); - - /* Copy local copies back to grid functions */ - DenFlux[index] = DenFluxL; - EnFlux[index] = EnFluxL; - S1Flux[index] = S1FluxL; - S2Flux[index] = S2FluxL; - S3Flux[index] = S3FluxL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL DenLeftL = DenLeft[index]; + CCTK_REAL DenRightL = DenRight[index]; + CCTK_REAL EnLeftL = EnLeft[index]; + CCTK_REAL EnRightL = EnRight[index]; + CCTK_REAL pLeftL = pLeft[index]; + CCTK_REAL pRightL = pRight[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 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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const ShiftMinus3DenRight = ShiftMinus3(&DenRight[index]); + CCTK_REAL const ShiftMinus3EnRight = ShiftMinus3(&EnRight[index]); + CCTK_REAL const ShiftMinus3pRight = ShiftMinus3(&pRight[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 ShiftMinus3v1Right = ShiftMinus3(&v1Right[index]); + CCTK_REAL const ShiftMinus3v2Right = ShiftMinus3(&v2Right[index]); + CCTK_REAL const ShiftMinus3v3Right = ShiftMinus3(&v3Right[index]); + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenFluxLeft = rhoLeftL*v3LeftL; + + CCTK_REAL DenFluxRight = ShiftMinus3rhoRight*ShiftMinus3v3Right; + + CCTK_REAL DenFluxL = 0.5*(DenFluxLeft + DenFluxRight + (-DenLeftL + + ShiftMinus3DenRight)*ToReal(hlleAlpha)); + + CCTK_REAL S1FluxLeft = rhoLeftL*v1LeftL*v3LeftL; + + CCTK_REAL S1FluxRight = + ShiftMinus3rhoRight*ShiftMinus3v1Right*ShiftMinus3v3Right; + + CCTK_REAL S1FluxL = 0.5*(S1FluxLeft + S1FluxRight + (-S1LeftL + + ShiftMinus3S1Right)*ToReal(hlleAlpha)); + + CCTK_REAL S2FluxLeft = rhoLeftL*v2LeftL*v3LeftL; + + CCTK_REAL S2FluxRight = + ShiftMinus3rhoRight*ShiftMinus3v2Right*ShiftMinus3v3Right; + + CCTK_REAL S2FluxL = 0.5*(S2FluxLeft + S2FluxRight + (-S2LeftL + + ShiftMinus3S2Right)*ToReal(hlleAlpha)); + + CCTK_REAL S3FluxLeft = pLeftL + rhoLeftL*SQR(v3LeftL); + + CCTK_REAL S3FluxRight = ShiftMinus3pRight + + ShiftMinus3rhoRight*SQR(ShiftMinus3v3Right); + + CCTK_REAL S3FluxL = 0.5*(S3FluxLeft + S3FluxRight + (-S3LeftL + + ShiftMinus3S3Right)*ToReal(hlleAlpha)); + + CCTK_REAL EnFluxLeft = (EnLeftL + pLeftL)*v3LeftL; + + CCTK_REAL EnFluxRight = (ShiftMinus3EnRight + + ShiftMinus3pRight)*ShiftMinus3v3Right; + + CCTK_REAL EnFluxL = 0.5*(EnFluxLeft + EnFluxRight + (-EnLeftL + + ShiftMinus3EnRight)*ToReal(hlleAlpha)); + + /* Copy local copies back to grid functions */ + DenFlux[index] = DenFluxL; + EnFlux[index] = EnFluxL; + S1Flux[index] = S1FluxL; + S2Flux[index] = S2FluxL; + S3Flux[index] = S3FluxL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_flux_3); } extern "C" void eulerauto_cons_calc_flux_3(CCTK_ARGUMENTS) @@ -202,5 +195,26 @@ extern "C" void eulerauto_cons_calc_flux_3(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_flux_3_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_flux_3_calc_every != eulerauto_cons_calc_flux_3_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_lr_group","EulerAuto::En_flux_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_flux_group","EulerAuto::S1_lr_group","EulerAuto::S2_flux_group","EulerAuto::S2_lr_group","EulerAuto::S3_flux_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_flux_3", 15, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulerauto_cons_calc_flux_3", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &eulerauto_cons_calc_flux_3_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_flux_3_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_1.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_1.cc index 3f91fa6..fdcd6f7 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_1.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_1.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_intercell_conserved_1_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_intercell_conserved_1_calc_every != eulerauto_cons_calc_intercell_conserved_1_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_lr_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_lr_group","EulerAuto::S2_lr_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_intercell_conserved_1", 10, 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); + 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); @@ -74,70 +62,78 @@ static void eulerauto_cons_calc_intercell_conserved_1_Body(cGH const * restrict CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_intercell_conserved_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 pLeftL = pLeft[index]; - CCTK_REAL pRightL = pRight[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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL DenLeftL = rhoLeftL; - - CCTK_REAL S1LeftL = rhoLeftL*v1LeftL; - - CCTK_REAL S2LeftL = rhoLeftL*v2LeftL; - - CCTK_REAL S3LeftL = rhoLeftL*v3LeftL; - - CCTK_REAL EnLeftL = pLeftL*INV(-1 + ToReal(gamma)) + - 0.5*rhoLeftL*(SQR(v1LeftL) + SQR(v2LeftL) + SQR(v3LeftL)); - - CCTK_REAL DenRightL = rhoRightL; - - CCTK_REAL S1RightL = rhoRightL*v1RightL; - - CCTK_REAL S2RightL = rhoRightL*v2RightL; - - CCTK_REAL S3RightL = rhoRightL*v3RightL; - - CCTK_REAL EnRightL = pRightL*INV(-1 + ToReal(gamma)) + - 0.5*rhoRightL*(SQR(v1RightL) + SQR(v2RightL) + SQR(v3RightL)); - - /* Copy local copies back to grid functions */ - DenLeft[index] = DenLeftL; - DenRight[index] = DenRightL; - EnLeft[index] = EnLeftL; - EnRight[index] = EnRightL; - S1Left[index] = S1LeftL; - S1Right[index] = S1RightL; - S2Left[index] = S2LeftL; - S2Right[index] = S2RightL; - S3Left[index] = S3LeftL; - S3Right[index] = S3RightL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL pLeftL = pLeft[index]; + CCTK_REAL pRightL = pRight[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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenLeftL = rhoLeftL; + + CCTK_REAL S1LeftL = rhoLeftL*v1LeftL; + + CCTK_REAL S2LeftL = rhoLeftL*v2LeftL; + + CCTK_REAL S3LeftL = rhoLeftL*v3LeftL; + + CCTK_REAL EnLeftL = 0.5*INV(-1 + ToReal(gamma))*(2*pLeftL + + rhoLeftL*(SQR(v1LeftL) + SQR(v2LeftL) + SQR(v3LeftL))*(-1 + + ToReal(gamma))); + + CCTK_REAL DenRightL = rhoRightL; + + CCTK_REAL S1RightL = rhoRightL*v1RightL; + + CCTK_REAL S2RightL = rhoRightL*v2RightL; + + CCTK_REAL S3RightL = rhoRightL*v3RightL; + + CCTK_REAL EnRightL = 0.5*INV(-1 + ToReal(gamma))*(2*pRightL + + rhoRightL*(SQR(v1RightL) + SQR(v2RightL) + SQR(v3RightL))*(-1 + + ToReal(gamma))); + + /* Copy local copies back to grid functions */ + DenLeft[index] = DenLeftL; + DenRight[index] = DenRightL; + EnLeft[index] = EnLeftL; + EnRight[index] = EnRightL; + S1Left[index] = S1LeftL; + S1Right[index] = S1RightL; + S2Left[index] = S2LeftL; + S2Right[index] = S2RightL; + S3Left[index] = S3LeftL; + S3Right[index] = S3RightL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_intercell_conserved_1); } extern "C" void eulerauto_cons_calc_intercell_conserved_1(CCTK_ARGUMENTS) @@ -145,5 +141,25 @@ extern "C" void eulerauto_cons_calc_intercell_conserved_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_intercell_conserved_1_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_intercell_conserved_1_calc_every != eulerauto_cons_calc_intercell_conserved_1_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_lr_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_lr_group","EulerAuto::S2_lr_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_intercell_conserved_1", 10, groups); + + GenericFD_LoopOverEverything(cctkGH, &eulerauto_cons_calc_intercell_conserved_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_intercell_conserved_1_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_2.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_2.cc index 209949e..9a8709d 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_2.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_2.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_intercell_conserved_2_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_intercell_conserved_2_calc_every != eulerauto_cons_calc_intercell_conserved_2_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_lr_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_lr_group","EulerAuto::S2_lr_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_intercell_conserved_2", 10, 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); + 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); @@ -74,70 +62,78 @@ static void eulerauto_cons_calc_intercell_conserved_2_Body(cGH const * restrict CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_intercell_conserved_2, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 pLeftL = pLeft[index]; - CCTK_REAL pRightL = pRight[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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL DenLeftL = rhoLeftL; - - CCTK_REAL S1LeftL = rhoLeftL*v1LeftL; - - CCTK_REAL S2LeftL = rhoLeftL*v2LeftL; - - CCTK_REAL S3LeftL = rhoLeftL*v3LeftL; - - CCTK_REAL EnLeftL = pLeftL*INV(-1 + ToReal(gamma)) + - 0.5*rhoLeftL*(SQR(v1LeftL) + SQR(v2LeftL) + SQR(v3LeftL)); - - CCTK_REAL DenRightL = rhoRightL; - - CCTK_REAL S1RightL = rhoRightL*v1RightL; - - CCTK_REAL S2RightL = rhoRightL*v2RightL; - - CCTK_REAL S3RightL = rhoRightL*v3RightL; - - CCTK_REAL EnRightL = pRightL*INV(-1 + ToReal(gamma)) + - 0.5*rhoRightL*(SQR(v1RightL) + SQR(v2RightL) + SQR(v3RightL)); - - /* Copy local copies back to grid functions */ - DenLeft[index] = DenLeftL; - DenRight[index] = DenRightL; - EnLeft[index] = EnLeftL; - EnRight[index] = EnRightL; - S1Left[index] = S1LeftL; - S1Right[index] = S1RightL; - S2Left[index] = S2LeftL; - S2Right[index] = S2RightL; - S3Left[index] = S3LeftL; - S3Right[index] = S3RightL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL pLeftL = pLeft[index]; + CCTK_REAL pRightL = pRight[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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenLeftL = rhoLeftL; + + CCTK_REAL S1LeftL = rhoLeftL*v1LeftL; + + CCTK_REAL S2LeftL = rhoLeftL*v2LeftL; + + CCTK_REAL S3LeftL = rhoLeftL*v3LeftL; + + CCTK_REAL EnLeftL = 0.5*INV(-1 + ToReal(gamma))*(2*pLeftL + + rhoLeftL*(SQR(v1LeftL) + SQR(v2LeftL) + SQR(v3LeftL))*(-1 + + ToReal(gamma))); + + CCTK_REAL DenRightL = rhoRightL; + + CCTK_REAL S1RightL = rhoRightL*v1RightL; + + CCTK_REAL S2RightL = rhoRightL*v2RightL; + + CCTK_REAL S3RightL = rhoRightL*v3RightL; + + CCTK_REAL EnRightL = 0.5*INV(-1 + ToReal(gamma))*(2*pRightL + + rhoRightL*(SQR(v1RightL) + SQR(v2RightL) + SQR(v3RightL))*(-1 + + ToReal(gamma))); + + /* Copy local copies back to grid functions */ + DenLeft[index] = DenLeftL; + DenRight[index] = DenRightL; + EnLeft[index] = EnLeftL; + EnRight[index] = EnRightL; + S1Left[index] = S1LeftL; + S1Right[index] = S1RightL; + S2Left[index] = S2LeftL; + S2Right[index] = S2RightL; + S3Left[index] = S3LeftL; + S3Right[index] = S3RightL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_intercell_conserved_2); } extern "C" void eulerauto_cons_calc_intercell_conserved_2(CCTK_ARGUMENTS) @@ -145,5 +141,25 @@ extern "C" void eulerauto_cons_calc_intercell_conserved_2(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_intercell_conserved_2_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_intercell_conserved_2_calc_every != eulerauto_cons_calc_intercell_conserved_2_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_lr_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_lr_group","EulerAuto::S2_lr_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_intercell_conserved_2", 10, groups); + + GenericFD_LoopOverEverything(cctkGH, &eulerauto_cons_calc_intercell_conserved_2_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_intercell_conserved_2_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_3.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_3.cc index 9398982..2c4f3a1 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_3.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_intercell_conserved_3.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_intercell_conserved_3_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_intercell_conserved_3_calc_every != eulerauto_cons_calc_intercell_conserved_3_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_lr_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_lr_group","EulerAuto::S2_lr_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_intercell_conserved_3", 10, 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); + 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); @@ -74,70 +62,78 @@ static void eulerauto_cons_calc_intercell_conserved_3_Body(cGH const * restrict CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_intercell_conserved_3, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 pLeftL = pLeft[index]; - CCTK_REAL pRightL = pRight[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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL DenLeftL = rhoLeftL; - - CCTK_REAL S1LeftL = rhoLeftL*v1LeftL; - - CCTK_REAL S2LeftL = rhoLeftL*v2LeftL; - - CCTK_REAL S3LeftL = rhoLeftL*v3LeftL; - - CCTK_REAL EnLeftL = pLeftL*INV(-1 + ToReal(gamma)) + - 0.5*rhoLeftL*(SQR(v1LeftL) + SQR(v2LeftL) + SQR(v3LeftL)); - - CCTK_REAL DenRightL = rhoRightL; - - CCTK_REAL S1RightL = rhoRightL*v1RightL; - - CCTK_REAL S2RightL = rhoRightL*v2RightL; - - CCTK_REAL S3RightL = rhoRightL*v3RightL; - - CCTK_REAL EnRightL = pRightL*INV(-1 + ToReal(gamma)) + - 0.5*rhoRightL*(SQR(v1RightL) + SQR(v2RightL) + SQR(v3RightL)); - - /* Copy local copies back to grid functions */ - DenLeft[index] = DenLeftL; - DenRight[index] = DenRightL; - EnLeft[index] = EnLeftL; - EnRight[index] = EnRightL; - S1Left[index] = S1LeftL; - S1Right[index] = S1RightL; - S2Left[index] = S2LeftL; - S2Right[index] = S2RightL; - S3Left[index] = S3LeftL; - S3Right[index] = S3RightL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL pLeftL = pLeft[index]; + CCTK_REAL pRightL = pRight[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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL DenLeftL = rhoLeftL; + + CCTK_REAL S1LeftL = rhoLeftL*v1LeftL; + + CCTK_REAL S2LeftL = rhoLeftL*v2LeftL; + + CCTK_REAL S3LeftL = rhoLeftL*v3LeftL; + + CCTK_REAL EnLeftL = 0.5*INV(-1 + ToReal(gamma))*(2*pLeftL + + rhoLeftL*(SQR(v1LeftL) + SQR(v2LeftL) + SQR(v3LeftL))*(-1 + + ToReal(gamma))); + + CCTK_REAL DenRightL = rhoRightL; + + CCTK_REAL S1RightL = rhoRightL*v1RightL; + + CCTK_REAL S2RightL = rhoRightL*v2RightL; + + CCTK_REAL S3RightL = rhoRightL*v3RightL; + + CCTK_REAL EnRightL = 0.5*INV(-1 + ToReal(gamma))*(2*pRightL + + rhoRightL*(SQR(v1RightL) + SQR(v2RightL) + SQR(v3RightL))*(-1 + + ToReal(gamma))); + + /* Copy local copies back to grid functions */ + DenLeft[index] = DenLeftL; + DenRight[index] = DenRightL; + EnLeft[index] = EnLeftL; + EnRight[index] = EnRightL; + S1Left[index] = S1LeftL; + S1Right[index] = S1RightL; + S2Left[index] = S2LeftL; + S2Right[index] = S2RightL; + S3Left[index] = S3LeftL; + S3Right[index] = S3RightL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_intercell_conserved_3); } extern "C" void eulerauto_cons_calc_intercell_conserved_3(CCTK_ARGUMENTS) @@ -145,5 +141,25 @@ extern "C" void eulerauto_cons_calc_intercell_conserved_3(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_intercell_conserved_3_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_intercell_conserved_3_calc_every != eulerauto_cons_calc_intercell_conserved_3_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_lr_group","EulerAuto::En_lr_group","EulerAuto::p_lr_group","EulerAuto::rho_lr_group","EulerAuto::S1_lr_group","EulerAuto::S2_lr_group","EulerAuto::S3_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_intercell_conserved_3", 10, groups); + + GenericFD_LoopOverEverything(cctkGH, &eulerauto_cons_calc_intercell_conserved_3_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_intercell_conserved_3_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_primitives.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_primitives.cc index 0a7228a..1b16069 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_primitives.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_primitives.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_primitives_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_primitives_calc_every != eulerauto_cons_calc_primitives_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_group","EulerAuto::En_group","EulerAuto::p_group","EulerAuto::rho_group","EulerAuto::S_group","EulerAuto::v_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_primitives", 6, 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); + 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); @@ -74,49 +62,55 @@ static void eulerauto_cons_calc_primitives_Body(cGH const * restrict const cctkG CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_primitives, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 EnL = En[index]; - CCTK_REAL S1L = S1[index]; - CCTK_REAL S2L = S2[index]; - CCTK_REAL S3L = S3[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL rhoL = DenL; - - CCTK_REAL v1L = S1L*INV(DenL); - - CCTK_REAL v2L = S2L*INV(DenL); - - CCTK_REAL v3L = S3L*INV(DenL); - - CCTK_REAL pL = (EnL - 0.5*INV(DenL)*(SQR(S1L) + SQR(S2L) + - SQR(S3L)))*(-1 + ToReal(gamma)); - - /* Copy local copies back to grid functions */ - p[index] = pL; - rho[index] = rhoL; - v1[index] = v1L; - v2[index] = v2L; - v3[index] = v3L; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL DenL = Den[index]; + CCTK_REAL EnL = En[index]; + CCTK_REAL S1L = S1[index]; + CCTK_REAL S2L = S2[index]; + CCTK_REAL S3L = S3[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + /* Calculate temporaries and grid functions */ + CCTK_REAL rhoL = DenL; + + CCTK_REAL v1L = S1L*INV(DenL); + + CCTK_REAL v2L = S2L*INV(DenL); + + CCTK_REAL v3L = S3L*INV(DenL); + + CCTK_REAL pL = 0.5*INV(DenL)*(2*DenL*EnL - SQR(S1L) - + SQR(S2L) - SQR(S3L))*(-1 + ToReal(gamma)); + + /* Copy local copies back to grid functions */ + p[index] = pL; + rho[index] = rhoL; + v1[index] = v1L; + v2[index] = v2L; + v3[index] = v3L; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_primitives); } extern "C" void eulerauto_cons_calc_primitives(CCTK_ARGUMENTS) @@ -124,5 +118,25 @@ extern "C" void eulerauto_cons_calc_primitives(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_primitives_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_primitives_calc_every != eulerauto_cons_calc_primitives_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_group","EulerAuto::En_group","EulerAuto::p_group","EulerAuto::rho_group","EulerAuto::S_group","EulerAuto::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_primitives", 6, groups); + + GenericFD_LoopOverEverything(cctkGH, &eulerauto_cons_calc_primitives_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_primitives_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_1.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_1.cc index 0506ef0..be96c9f 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_1.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_1.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulerauto_cons_calc_reconstruct_1_SelectBCs(CCTK_ARGUMENTS) return; } -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_reconstruct_1_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_reconstruct_1_calc_every != eulerauto_cons_calc_reconstruct_1_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::p_group","EulerAuto::p_lr_group","EulerAuto::rho_group","EulerAuto::rho_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group","EulerAuto::v_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_reconstruct_1", 8, groups); - - GenericFD_EnsureStencilFits(cctkGH, "eulerauto_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); + 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); @@ -99,103 +86,109 @@ static void eulerauto_cons_calc_reconstruct_1_Body(cGH const * restrict const cc CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_reconstruct_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 pL = p[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 DiffPlus1p = DiffPlus1(&p[index]); - CCTK_REAL const DiffMinus1p = DiffMinus1(&p[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 = DiffMinus1p; - - slopeR = DiffPlus1p; - - slope = VanLeer(slopeL,slopeR); - - CCTK_REAL pLeftL = pL - 0.5*slope; - - CCTK_REAL pRightL = pL + 0.5*slope; - - /* Copy local copies back to grid functions */ - pLeft[index] = pLeftL; - pRight[index] = pRightL; - rhoLeft[index] = rhoLeftL; - rhoRight[index] = rhoRightL; - v1Left[index] = v1LeftL; - v1Right[index] = v1RightL; - v2Left[index] = v2LeftL; - v2Right[index] = v2RightL; - v3Left[index] = v3LeftL; - v3Right[index] = v3RightL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + 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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const DiffPlus1p = DiffPlus1(&p[index]); + CCTK_REAL const DiffMinus1p = DiffMinus1(&p[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 = v1L - 0.5*slope; + + CCTK_REAL v1RightL = v1L + 0.5*slope; + + slopeL = DiffMinus1v2; + + slopeR = DiffPlus1v2; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v2LeftL = v2L - 0.5*slope; + + CCTK_REAL v2RightL = v2L + 0.5*slope; + + slopeL = DiffMinus1v3; + + slopeR = DiffPlus1v3; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v3LeftL = v3L - 0.5*slope; + + CCTK_REAL v3RightL = v3L + 0.5*slope; + + slopeL = DiffMinus1p; + + slopeR = DiffPlus1p; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL pLeftL = pL - 0.5*slope; + + CCTK_REAL pRightL = pL + 0.5*slope; + + /* Copy local copies back to grid functions */ + pLeft[index] = pLeftL; + pRight[index] = pRightL; + rhoLeft[index] = rhoLeftL; + rhoRight[index] = rhoRightL; + v1Left[index] = v1LeftL; + v1Right[index] = v1RightL; + v2Left[index] = v2LeftL; + v2Right[index] = v2RightL; + v3Left[index] = v3LeftL; + v3Right[index] = v3RightL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_reconstruct_1); } extern "C" void eulerauto_cons_calc_reconstruct_1(CCTK_ARGUMENTS) @@ -203,5 +196,26 @@ extern "C" void eulerauto_cons_calc_reconstruct_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_reconstruct_1_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_reconstruct_1_calc_every != eulerauto_cons_calc_reconstruct_1_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::p_group","EulerAuto::p_lr_group","EulerAuto::rho_group","EulerAuto::rho_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group","EulerAuto::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_reconstruct_1", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulerauto_cons_calc_reconstruct_1", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &eulerauto_cons_calc_reconstruct_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_reconstruct_1_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_2.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_2.cc index f71f106..34b7f55 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_2.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_2.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulerauto_cons_calc_reconstruct_2_SelectBCs(CCTK_ARGUMENTS) return; } -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_reconstruct_2_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_reconstruct_2_calc_every != eulerauto_cons_calc_reconstruct_2_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::p_group","EulerAuto::p_lr_group","EulerAuto::rho_group","EulerAuto::rho_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group","EulerAuto::v_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_reconstruct_2", 8, groups); - - GenericFD_EnsureStencilFits(cctkGH, "eulerauto_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); + 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); @@ -99,103 +86,109 @@ static void eulerauto_cons_calc_reconstruct_2_Body(cGH const * restrict const cc CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_reconstruct_2, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 pL = p[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 DiffPlus2p = DiffPlus2(&p[index]); - CCTK_REAL const DiffMinus2p = DiffMinus2(&p[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 = DiffMinus2p; - - slopeR = DiffPlus2p; - - slope = VanLeer(slopeL,slopeR); - - CCTK_REAL pLeftL = pL - 0.5*slope; - - CCTK_REAL pRightL = pL + 0.5*slope; - - /* Copy local copies back to grid functions */ - pLeft[index] = pLeftL; - pRight[index] = pRightL; - rhoLeft[index] = rhoLeftL; - rhoRight[index] = rhoRightL; - v1Left[index] = v1LeftL; - v1Right[index] = v1RightL; - v2Left[index] = v2LeftL; - v2Right[index] = v2RightL; - v3Left[index] = v3LeftL; - v3Right[index] = v3RightL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + 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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const DiffPlus2p = DiffPlus2(&p[index]); + CCTK_REAL const DiffMinus2p = DiffMinus2(&p[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 = v1L - 0.5*slope; + + CCTK_REAL v1RightL = v1L + 0.5*slope; + + slopeL = DiffMinus2v2; + + slopeR = DiffPlus2v2; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v2LeftL = v2L - 0.5*slope; + + CCTK_REAL v2RightL = v2L + 0.5*slope; + + slopeL = DiffMinus2v3; + + slopeR = DiffPlus2v3; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v3LeftL = v3L - 0.5*slope; + + CCTK_REAL v3RightL = v3L + 0.5*slope; + + slopeL = DiffMinus2p; + + slopeR = DiffPlus2p; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL pLeftL = pL - 0.5*slope; + + CCTK_REAL pRightL = pL + 0.5*slope; + + /* Copy local copies back to grid functions */ + pLeft[index] = pLeftL; + pRight[index] = pRightL; + rhoLeft[index] = rhoLeftL; + rhoRight[index] = rhoRightL; + v1Left[index] = v1LeftL; + v1Right[index] = v1RightL; + v2Left[index] = v2LeftL; + v2Right[index] = v2RightL; + v3Left[index] = v3LeftL; + v3Right[index] = v3RightL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_reconstruct_2); } extern "C" void eulerauto_cons_calc_reconstruct_2(CCTK_ARGUMENTS) @@ -203,5 +196,26 @@ extern "C" void eulerauto_cons_calc_reconstruct_2(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_reconstruct_2_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_reconstruct_2_calc_every != eulerauto_cons_calc_reconstruct_2_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::p_group","EulerAuto::p_lr_group","EulerAuto::rho_group","EulerAuto::rho_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group","EulerAuto::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_reconstruct_2", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulerauto_cons_calc_reconstruct_2", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &eulerauto_cons_calc_reconstruct_2_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_reconstruct_2_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_3.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_3.cc index 5204483..5481fba 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_3.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_reconstruct_3.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulerauto_cons_calc_reconstruct_3_SelectBCs(CCTK_ARGUMENTS) return; } -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_reconstruct_3_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_reconstruct_3_calc_every != eulerauto_cons_calc_reconstruct_3_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::p_group","EulerAuto::p_lr_group","EulerAuto::rho_group","EulerAuto::rho_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group","EulerAuto::v_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_reconstruct_3", 8, groups); - - GenericFD_EnsureStencilFits(cctkGH, "eulerauto_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); + 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); @@ -99,103 +86,109 @@ static void eulerauto_cons_calc_reconstruct_3_Body(cGH const * restrict const cc CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_reconstruct_3, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 pL = p[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 DiffPlus3p = DiffPlus3(&p[index]); - CCTK_REAL const DiffMinus3p = DiffMinus3(&p[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 = DiffMinus3p; - - slopeR = DiffPlus3p; - - slope = VanLeer(slopeL,slopeR); - - CCTK_REAL pLeftL = pL - 0.5*slope; - - CCTK_REAL pRightL = pL + 0.5*slope; - - /* Copy local copies back to grid functions */ - pLeft[index] = pLeftL; - pRight[index] = pRightL; - rhoLeft[index] = rhoLeftL; - rhoRight[index] = rhoRightL; - v1Left[index] = v1LeftL; - v1Right[index] = v1RightL; - v2Left[index] = v2LeftL; - v2Right[index] = v2RightL; - v3Left[index] = v3LeftL; - v3Right[index] = v3RightL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + 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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const DiffPlus3p = DiffPlus3(&p[index]); + CCTK_REAL const DiffMinus3p = DiffMinus3(&p[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 = v1L - 0.5*slope; + + CCTK_REAL v1RightL = v1L + 0.5*slope; + + slopeL = DiffMinus3v2; + + slopeR = DiffPlus3v2; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v2LeftL = v2L - 0.5*slope; + + CCTK_REAL v2RightL = v2L + 0.5*slope; + + slopeL = DiffMinus3v3; + + slopeR = DiffPlus3v3; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v3LeftL = v3L - 0.5*slope; + + CCTK_REAL v3RightL = v3L + 0.5*slope; + + slopeL = DiffMinus3p; + + slopeR = DiffPlus3p; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL pLeftL = pL - 0.5*slope; + + CCTK_REAL pRightL = pL + 0.5*slope; + + /* Copy local copies back to grid functions */ + pLeft[index] = pLeftL; + pRight[index] = pRightL; + rhoLeft[index] = rhoLeftL; + rhoRight[index] = rhoRightL; + v1Left[index] = v1LeftL; + v1Right[index] = v1RightL; + v2Left[index] = v2LeftL; + v2Right[index] = v2RightL; + v3Left[index] = v3LeftL; + v3Right[index] = v3RightL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_reconstruct_3); } extern "C" void eulerauto_cons_calc_reconstruct_3(CCTK_ARGUMENTS) @@ -203,5 +196,26 @@ extern "C" void eulerauto_cons_calc_reconstruct_3(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_reconstruct_3_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_reconstruct_3_calc_every != eulerauto_cons_calc_reconstruct_3_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::p_group","EulerAuto::p_lr_group","EulerAuto::rho_group","EulerAuto::rho_lr_group","EulerAuto::v1_lr_group","EulerAuto::v2_lr_group","EulerAuto::v3_lr_group","EulerAuto::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_reconstruct_3", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulerauto_cons_calc_reconstruct_3", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &eulerauto_cons_calc_reconstruct_3_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_reconstruct_3_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_1.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_1.cc index 24e51d4..5f38d60 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_1.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_1.cc @@ -12,6 +12,8 @@ #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) @@ -38,43 +40,28 @@ extern "C" void eulerauto_cons_calc_rhs_1_SelectBCs(CCTK_ARGUMENTS) return; } -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_rhs_1_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_rhs_1_calc_every != eulerauto_cons_calc_rhs_1_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_grouprhs","EulerAuto::En_flux_group","EulerAuto::En_grouprhs","EulerAuto::S1_flux_group","EulerAuto::S2_flux_group","EulerAuto::S3_flux_group","EulerAuto::S_grouprhs"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_rhs_1", 8, groups); - - GenericFD_EnsureStencilFits(cctkGH, "eulerauto_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); + 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); @@ -93,58 +80,64 @@ static void eulerauto_cons_calc_rhs_1_Body(cGH const * restrict const cctkGH, in CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_rhs_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 EnFluxL = EnFlux[index]; - CCTK_REAL EnrhsL = Enrhs[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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const PDplus1DenFlux = PDplus1(&DenFlux[index]); - CCTK_REAL const PDplus1EnFlux = PDplus1(&EnFlux[index]); - CCTK_REAL const PDplus1S1Flux = PDplus1(&S1Flux[index]); - CCTK_REAL const PDplus1S2Flux = PDplus1(&S2Flux[index]); - CCTK_REAL const PDplus1S3Flux = PDplus1(&S3Flux[index]); - - /* Calculate temporaries and grid functions */ - DenrhsL = DenrhsL - PDplus1DenFlux; - - EnrhsL = EnrhsL - PDplus1EnFlux; - - S1rhsL = -PDplus1S1Flux + S1rhsL; - - S2rhsL = -PDplus1S2Flux + S2rhsL; - - S3rhsL = -PDplus1S3Flux + S3rhsL; - - /* Copy local copies back to grid functions */ - Denrhs[index] = DenrhsL; - Enrhs[index] = EnrhsL; - S1rhs[index] = S1rhsL; - S2rhs[index] = S2rhsL; - S3rhs[index] = S3rhsL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL DenFluxL = DenFlux[index]; + CCTK_REAL DenrhsL = Denrhs[index]; + CCTK_REAL EnFluxL = EnFlux[index]; + CCTK_REAL EnrhsL = Enrhs[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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDplus1DenFlux = PDplus1(&DenFlux[index]); + CCTK_REAL const PDplus1EnFlux = PDplus1(&EnFlux[index]); + CCTK_REAL const PDplus1S1Flux = PDplus1(&S1Flux[index]); + CCTK_REAL const PDplus1S2Flux = PDplus1(&S2Flux[index]); + CCTK_REAL const PDplus1S3Flux = PDplus1(&S3Flux[index]); + + /* Calculate temporaries and grid functions */ + DenrhsL = DenrhsL - PDplus1DenFlux; + + EnrhsL = EnrhsL - PDplus1EnFlux; + + S1rhsL = S1rhsL - PDplus1S1Flux; + + S2rhsL = S2rhsL - PDplus1S2Flux; + + S3rhsL = S3rhsL - PDplus1S3Flux; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + Enrhs[index] = EnrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_rhs_1); } extern "C" void eulerauto_cons_calc_rhs_1(CCTK_ARGUMENTS) @@ -152,5 +145,26 @@ extern "C" void eulerauto_cons_calc_rhs_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_rhs_1_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_rhs_1_calc_every != eulerauto_cons_calc_rhs_1_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_grouprhs","EulerAuto::En_flux_group","EulerAuto::En_grouprhs","EulerAuto::S1_flux_group","EulerAuto::S2_flux_group","EulerAuto::S3_flux_group","EulerAuto::S_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_rhs_1", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulerauto_cons_calc_rhs_1", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &eulerauto_cons_calc_rhs_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_rhs_1_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_2.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_2.cc index caee229..c4859bc 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_2.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_2.cc @@ -12,6 +12,8 @@ #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) @@ -38,43 +40,28 @@ extern "C" void eulerauto_cons_calc_rhs_2_SelectBCs(CCTK_ARGUMENTS) return; } -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_rhs_2_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_rhs_2_calc_every != eulerauto_cons_calc_rhs_2_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_grouprhs","EulerAuto::En_flux_group","EulerAuto::En_grouprhs","EulerAuto::S1_flux_group","EulerAuto::S2_flux_group","EulerAuto::S3_flux_group","EulerAuto::S_grouprhs"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_rhs_2", 8, groups); - - GenericFD_EnsureStencilFits(cctkGH, "eulerauto_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); + 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); @@ -93,58 +80,64 @@ static void eulerauto_cons_calc_rhs_2_Body(cGH const * restrict const cctkGH, in CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_rhs_2, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 EnFluxL = EnFlux[index]; - CCTK_REAL EnrhsL = Enrhs[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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const PDplus2DenFlux = PDplus2(&DenFlux[index]); - CCTK_REAL const PDplus2EnFlux = PDplus2(&EnFlux[index]); - CCTK_REAL const PDplus2S1Flux = PDplus2(&S1Flux[index]); - CCTK_REAL const PDplus2S2Flux = PDplus2(&S2Flux[index]); - CCTK_REAL const PDplus2S3Flux = PDplus2(&S3Flux[index]); - - /* Calculate temporaries and grid functions */ - DenrhsL = DenrhsL - PDplus2DenFlux; - - EnrhsL = EnrhsL - PDplus2EnFlux; - - S1rhsL = -PDplus2S1Flux + S1rhsL; - - S2rhsL = -PDplus2S2Flux + S2rhsL; - - S3rhsL = -PDplus2S3Flux + S3rhsL; - - /* Copy local copies back to grid functions */ - Denrhs[index] = DenrhsL; - Enrhs[index] = EnrhsL; - S1rhs[index] = S1rhsL; - S2rhs[index] = S2rhsL; - S3rhs[index] = S3rhsL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL DenFluxL = DenFlux[index]; + CCTK_REAL DenrhsL = Denrhs[index]; + CCTK_REAL EnFluxL = EnFlux[index]; + CCTK_REAL EnrhsL = Enrhs[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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDplus2DenFlux = PDplus2(&DenFlux[index]); + CCTK_REAL const PDplus2EnFlux = PDplus2(&EnFlux[index]); + CCTK_REAL const PDplus2S1Flux = PDplus2(&S1Flux[index]); + CCTK_REAL const PDplus2S2Flux = PDplus2(&S2Flux[index]); + CCTK_REAL const PDplus2S3Flux = PDplus2(&S3Flux[index]); + + /* Calculate temporaries and grid functions */ + DenrhsL = DenrhsL - PDplus2DenFlux; + + EnrhsL = EnrhsL - PDplus2EnFlux; + + S1rhsL = S1rhsL - PDplus2S1Flux; + + S2rhsL = S2rhsL - PDplus2S2Flux; + + S3rhsL = S3rhsL - PDplus2S3Flux; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + Enrhs[index] = EnrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_rhs_2); } extern "C" void eulerauto_cons_calc_rhs_2(CCTK_ARGUMENTS) @@ -152,5 +145,26 @@ extern "C" void eulerauto_cons_calc_rhs_2(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_rhs_2_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_rhs_2_calc_every != eulerauto_cons_calc_rhs_2_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_grouprhs","EulerAuto::En_flux_group","EulerAuto::En_grouprhs","EulerAuto::S1_flux_group","EulerAuto::S2_flux_group","EulerAuto::S3_flux_group","EulerAuto::S_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_rhs_2", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulerauto_cons_calc_rhs_2", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &eulerauto_cons_calc_rhs_2_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_rhs_2_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_3.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_3.cc index f485670..0ce65f6 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_3.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_rhs_3.cc @@ -12,6 +12,8 @@ #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) @@ -38,43 +40,28 @@ extern "C" void eulerauto_cons_calc_rhs_3_SelectBCs(CCTK_ARGUMENTS) return; } -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_rhs_3_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_rhs_3_calc_every != eulerauto_cons_calc_rhs_3_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_grouprhs","EulerAuto::En_flux_group","EulerAuto::En_grouprhs","EulerAuto::S1_flux_group","EulerAuto::S2_flux_group","EulerAuto::S3_flux_group","EulerAuto::S_grouprhs"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_rhs_3", 8, groups); - - GenericFD_EnsureStencilFits(cctkGH, "eulerauto_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); + 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); @@ -93,58 +80,64 @@ static void eulerauto_cons_calc_rhs_3_Body(cGH const * restrict const cctkGH, in CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_rhs_3, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 EnFluxL = EnFlux[index]; - CCTK_REAL EnrhsL = Enrhs[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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const PDplus3DenFlux = PDplus3(&DenFlux[index]); - CCTK_REAL const PDplus3EnFlux = PDplus3(&EnFlux[index]); - CCTK_REAL const PDplus3S1Flux = PDplus3(&S1Flux[index]); - CCTK_REAL const PDplus3S2Flux = PDplus3(&S2Flux[index]); - CCTK_REAL const PDplus3S3Flux = PDplus3(&S3Flux[index]); - - /* Calculate temporaries and grid functions */ - DenrhsL = DenrhsL - PDplus3DenFlux; - - EnrhsL = EnrhsL - PDplus3EnFlux; - - S1rhsL = -PDplus3S1Flux + S1rhsL; - - S2rhsL = -PDplus3S2Flux + S2rhsL; - - S3rhsL = -PDplus3S3Flux + S3rhsL; - - /* Copy local copies back to grid functions */ - Denrhs[index] = DenrhsL; - Enrhs[index] = EnrhsL; - S1rhs[index] = S1rhsL; - S2rhs[index] = S2rhsL; - S3rhs[index] = S3rhsL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL DenFluxL = DenFlux[index]; + CCTK_REAL DenrhsL = Denrhs[index]; + CCTK_REAL EnFluxL = EnFlux[index]; + CCTK_REAL EnrhsL = Enrhs[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]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL const PDplus3DenFlux = PDplus3(&DenFlux[index]); + CCTK_REAL const PDplus3EnFlux = PDplus3(&EnFlux[index]); + CCTK_REAL const PDplus3S1Flux = PDplus3(&S1Flux[index]); + CCTK_REAL const PDplus3S2Flux = PDplus3(&S2Flux[index]); + CCTK_REAL const PDplus3S3Flux = PDplus3(&S3Flux[index]); + + /* Calculate temporaries and grid functions */ + DenrhsL = DenrhsL - PDplus3DenFlux; + + EnrhsL = EnrhsL - PDplus3EnFlux; + + S1rhsL = S1rhsL - PDplus3S1Flux; + + S2rhsL = S2rhsL - PDplus3S2Flux; + + S3rhsL = S3rhsL - PDplus3S3Flux; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + Enrhs[index] = EnrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_rhs_3); } extern "C" void eulerauto_cons_calc_rhs_3(CCTK_ARGUMENTS) @@ -152,5 +145,26 @@ extern "C" void eulerauto_cons_calc_rhs_3(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_rhs_3_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_rhs_3_calc_every != eulerauto_cons_calc_rhs_3_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_flux_group","EulerAuto::Den_grouprhs","EulerAuto::En_flux_group","EulerAuto::En_grouprhs","EulerAuto::S1_flux_group","EulerAuto::S2_flux_group","EulerAuto::S3_flux_group","EulerAuto::S_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_rhs_3", 8, groups); + + GenericFD_EnsureStencilFits(cctkGH, "eulerauto_cons_calc_rhs_3", 1, 1, 1); + GenericFD_LoopOverInterior(cctkGH, &eulerauto_cons_calc_rhs_3_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_rhs_3_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_cons_calc_zero_rhs.cc b/Examples/EulerAuto/src/eulerauto_cons_calc_zero_rhs.cc index ba14718..5418435 100644 --- a/Examples/EulerAuto/src/eulerauto_cons_calc_zero_rhs.cc +++ b/Examples/EulerAuto/src/eulerauto_cons_calc_zero_rhs.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_cons_calc_zero_rhs_Body"); - } - - if (cctk_iteration % eulerauto_cons_calc_zero_rhs_calc_every != eulerauto_cons_calc_zero_rhs_calc_offset) - { - return; - } - - const char *groups[] = {"EulerAuto::Den_grouprhs","EulerAuto::En_grouprhs","EulerAuto::S_grouprhs"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_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); + 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); @@ -74,63 +62,69 @@ static void eulerauto_cons_calc_zero_rhs_Body(cGH const * restrict const cctkGH, CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_cons_calc_zero_rhs, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - - CCTK_REAL S2rhsL = 0; - - CCTK_REAL S3rhsL = 0; - - S1rhsL = 0; - - S2rhsL = 0; - - S3rhsL = 0; - - S1rhsL = 0; - - S2rhsL = 0; - - S3rhsL = 0; - - CCTK_REAL EnrhsL = 0; - - EnrhsL = 0; - - EnrhsL = 0; - - /* Copy local copies back to grid functions */ - Denrhs[index] = DenrhsL; - Enrhs[index] = EnrhsL; - S1rhs[index] = S1rhsL; - S2rhs[index] = S2rhsL; - S3rhs[index] = S3rhsL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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; + + CCTK_REAL S2rhsL = 0; + + CCTK_REAL S3rhsL = 0; + + S1rhsL = 0; + + S2rhsL = 0; + + S3rhsL = 0; + + S1rhsL = 0; + + S2rhsL = 0; + + S3rhsL = 0; + + CCTK_REAL EnrhsL = 0; + + EnrhsL = 0; + + EnrhsL = 0; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + Enrhs[index] = EnrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; } + CCTK_ENDLOOP3 (eulerauto_cons_calc_zero_rhs); } extern "C" void eulerauto_cons_calc_zero_rhs(CCTK_ARGUMENTS) @@ -138,5 +132,25 @@ extern "C" void eulerauto_cons_calc_zero_rhs(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_cons_calc_zero_rhs_Body"); + } + + if (cctk_iteration % eulerauto_cons_calc_zero_rhs_calc_every != eulerauto_cons_calc_zero_rhs_calc_offset) + { + return; + } + + const char *groups[] = {"EulerAuto::Den_grouprhs","EulerAuto::En_grouprhs","EulerAuto::S_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_cons_calc_zero_rhs", 3, groups); + + GenericFD_LoopOverEverything(cctkGH, &eulerauto_cons_calc_zero_rhs_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_cons_calc_zero_rhs_Body"); + } } diff --git a/Examples/EulerAuto/src/eulerauto_initial_shock.cc b/Examples/EulerAuto/src/eulerauto_initial_shock.cc index f6893b7..ea1b342 100644 --- a/Examples/EulerAuto/src/eulerauto_initial_shock.cc +++ b/Examples/EulerAuto/src/eulerauto_initial_shock.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void eulerauto_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[]) +static void eulerauto_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 imin[3], int const imax[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 eulerauto_initial_shock_Body"); - } - - if (cctk_iteration % eulerauto_initial_shock_calc_every != eulerauto_initial_shock_calc_offset) - { - return; - } - - const char *groups[] = {"grid::coordinates","EulerAuto::p_group","EulerAuto::rho_group","EulerAuto::v_group"}; - GenericFD_AssertGroupStorage(cctkGH, "eulerauto_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); + 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); @@ -74,47 +62,53 @@ static void eulerauto_initial_shock_Body(cGH const * restrict const cctkGH, int CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulerauto_initial_shock, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL rhoL = ToReal(rhoL0) + StepFunction(-0.5 + - xL)*(-ToReal(rhoL0) + ToReal(rhoR0)); - - CCTK_REAL v1L = ToReal(vL0) + StepFunction(-0.5 + xL)*(-ToReal(vL0) + - ToReal(vR0)); - - CCTK_REAL v2L = 0; - - CCTK_REAL v3L = 0; - - CCTK_REAL pL = ToReal(pL0) + StepFunction(-0.5 + xL)*(-ToReal(pL0) + - ToReal(pR0)); - - /* Copy local copies back to grid functions */ - p[index] = pL; - rho[index] = rhoL; - v1[index] = v1L; - v2[index] = v2L; - v3[index] = v3L; - } - } + 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 rhoL = ToReal(rhoL0) + StepFunction(-0.5 + + xL)*(-ToReal(rhoL0) + ToReal(rhoR0)); + + CCTK_REAL v1L = ToReal(vL0) + StepFunction(-0.5 + xL)*(-ToReal(vL0) + + ToReal(vR0)); + + CCTK_REAL v2L = 0; + + CCTK_REAL v3L = 0; + + CCTK_REAL pL = ToReal(pL0) + StepFunction(-0.5 + xL)*(-ToReal(pL0) + + ToReal(pR0)); + + /* Copy local copies back to grid functions */ + p[index] = pL; + rho[index] = rhoL; + v1[index] = v1L; + v2[index] = v2L; + v3[index] = v3L; } + CCTK_ENDLOOP3 (eulerauto_initial_shock); } extern "C" void eulerauto_initial_shock(CCTK_ARGUMENTS) @@ -122,5 +116,25 @@ extern "C" void eulerauto_initial_shock(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering eulerauto_initial_shock_Body"); + } + + if (cctk_iteration % eulerauto_initial_shock_calc_every != eulerauto_initial_shock_calc_offset) + { + return; + } + + const char *groups[] = {"grid::coordinates","EulerAuto::p_group","EulerAuto::rho_group","EulerAuto::v_group"}; + GenericFD_AssertGroupStorage(cctkGH, "eulerauto_initial_shock", 4, groups); + + GenericFD_LoopOverEverything(cctkGH, &eulerauto_initial_shock_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulerauto_initial_shock_Body"); + } } diff --git a/Examples/EulerSR/configuration.ccl b/Examples/EulerSR/configuration.ccl index 023aac7..0a66ec2 100644 --- a/Examples/EulerSR/configuration.ccl +++ b/Examples/EulerSR/configuration.ccl @@ -1,3 +1,6 @@ # File produced by Kranc REQUIRES GenericFD +OPTIONAL LoopControl +{ +} diff --git a/Examples/EulerSR/interface.ccl b/Examples/EulerSR/interface.ccl index eb300ee..41c6ab6 100644 --- a/Examples/EulerSR/interface.ccl +++ b/Examples/EulerSR/interface.ccl @@ -10,6 +10,7 @@ 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 diff --git a/Examples/EulerSR/param.ccl b/Examples/EulerSR/param.ccl index 211a7e7..87f07c5 100644 --- a/Examples/EulerSR/param.ccl +++ b/Examples/EulerSR/param.ccl @@ -8,6 +8,7 @@ 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 @@ -94,6 +95,12 @@ CCTK_INT EulerSR_MaxNumEvolvedVars "Number of evolved variables used by this tho } 5 restricted: +CCTK_INT EulerSR_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:3 :: "" @@ -106,6 +113,12 @@ CCTK_INT rhs_timelevels "Number of active RHS timelevels" STEERABLE=RECOVER } 1 restricted: +CCTK_INT other_timelevels "Number of active timelevels for non-evolved grid functions" STEERABLE=RECOVER +{ + 0:3 :: "" +} 1 + +restricted: CCTK_INT eulersr_initial_shock_calc_every "eulersr_initial_shock_calc_every" STEERABLE=ALWAYS { *:* :: "" diff --git a/Examples/EulerSR/schedule.ccl b/Examples/EulerSR/schedule.ccl index ffeaf07..d6b29e0 100644 --- a/Examples/EulerSR/schedule.ccl +++ b/Examples/EulerSR/schedule.ccl @@ -1,47 +1,110 @@ # File produced by Kranc -STORAGE: Den_flux_group[1] +if (other_timelevels == 1) +{ + STORAGE: Den_flux_group[1] +} -STORAGE: Den_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: Den_lr_group[1] +} -STORAGE: epsi_group[1] +if (other_timelevels == 1) +{ + STORAGE: epsi_group[1] +} -STORAGE: epsi_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: epsi_lr_group[1] +} -STORAGE: h_group[1] +if (other_timelevels == 1) +{ + STORAGE: h_group[1] +} -STORAGE: p_group[1] +if (other_timelevels == 1) +{ + STORAGE: p_group[1] +} -STORAGE: rho_group[1] +if (other_timelevels == 1) +{ + STORAGE: rho_group[1] +} -STORAGE: rho_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: rho_lr_group[1] +} -STORAGE: S1_flux_group[1] +if (other_timelevels == 1) +{ + STORAGE: S1_flux_group[1] +} -STORAGE: S1_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: S1_lr_group[1] +} -STORAGE: S2_flux_group[1] +if (other_timelevels == 1) +{ + STORAGE: S2_flux_group[1] +} -STORAGE: S2_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: S2_lr_group[1] +} -STORAGE: S3_flux_group[1] +if (other_timelevels == 1) +{ + STORAGE: S3_flux_group[1] +} -STORAGE: S3_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: S3_lr_group[1] +} -STORAGE: tau_flux_group[1] +if (other_timelevels == 1) +{ + STORAGE: tau_flux_group[1] +} -STORAGE: tau_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: tau_lr_group[1] +} -STORAGE: v1_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: v1_lr_group[1] +} -STORAGE: v2_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: v2_lr_group[1] +} -STORAGE: v3_lr_group[1] +if (other_timelevels == 1) +{ + STORAGE: v3_lr_group[1] +} -STORAGE: v_group[1] +if (other_timelevels == 1) +{ + STORAGE: v_group[1] +} -STORAGE: W_group[1] +if (other_timelevels == 1) +{ + STORAGE: W_group[1] +} if (timelevels == 1) { @@ -194,12 +257,7 @@ schedule group eulersr_cons_calc_reconstruct_1_bc_group in eulersr_cons_calc_rec # no language specified } "eulersr_cons_calc_reconstruct_1" -schedule group eulersr_cons_calc_reconstruct_1_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulersr_cons_calc_reconstruct_1" - -schedule group eulersr_cons_calc_reconstruct_1_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulersr_cons_calc_reconstruct_1_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulersr_cons_calc_reconstruct_1" @@ -240,12 +298,7 @@ schedule group eulersr_cons_calc_flux_1_bc_group in eulersr_cons_calc_flux_1_gro # no language specified } "eulersr_cons_calc_flux_1" -schedule group eulersr_cons_calc_flux_1_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulersr_cons_calc_flux_1" - -schedule group eulersr_cons_calc_flux_1_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulersr_cons_calc_flux_1_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulersr_cons_calc_flux_1" @@ -286,12 +339,7 @@ schedule group eulersr_cons_calc_reconstruct_2_bc_group in eulersr_cons_calc_rec # no language specified } "eulersr_cons_calc_reconstruct_2" -schedule group eulersr_cons_calc_reconstruct_2_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulersr_cons_calc_reconstruct_2" - -schedule group eulersr_cons_calc_reconstruct_2_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulersr_cons_calc_reconstruct_2_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulersr_cons_calc_reconstruct_2" @@ -332,12 +380,7 @@ schedule group eulersr_cons_calc_flux_2_bc_group in eulersr_cons_calc_flux_2_gro # no language specified } "eulersr_cons_calc_flux_2" -schedule group eulersr_cons_calc_flux_2_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulersr_cons_calc_flux_2" - -schedule group eulersr_cons_calc_flux_2_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulersr_cons_calc_flux_2_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulersr_cons_calc_flux_2" @@ -378,12 +421,7 @@ schedule group eulersr_cons_calc_reconstruct_3_bc_group in eulersr_cons_calc_rec # no language specified } "eulersr_cons_calc_reconstruct_3" -schedule group eulersr_cons_calc_reconstruct_3_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulersr_cons_calc_reconstruct_3" - -schedule group eulersr_cons_calc_reconstruct_3_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulersr_cons_calc_reconstruct_3_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulersr_cons_calc_reconstruct_3" @@ -424,12 +462,7 @@ schedule group eulersr_cons_calc_flux_3_bc_group in eulersr_cons_calc_flux_3_gro # no language specified } "eulersr_cons_calc_flux_3" -schedule group eulersr_cons_calc_flux_3_bc_group at CCTK_POSTRESTRICT -{ - # no language specified -} "eulersr_cons_calc_flux_3" - -schedule group eulersr_cons_calc_flux_3_bc_group at CCTK_POSTRESTRICTINITIAL +schedule group eulersr_cons_calc_flux_3_bc_group in MoL_PseudoEvolutionBoundaries after MoL_PostStep { # no language specified } "eulersr_cons_calc_flux_3" diff --git a/Examples/EulerSR/src/Differencing.h b/Examples/EulerSR/src/Differencing.h index 0908172..913cfa8 100644 --- a/Examples/EulerSR/src/Differencing.h +++ b/Examples/EulerSR/src/Differencing.h @@ -1,12 +1,144 @@ -#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)])) +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o1) +#else +# define DiffPlus1(u) (DiffPlus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o1) +#else +# define DiffPlus2(u) (DiffPlus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1o1) +#else +# define DiffPlus3(u) (DiffPlus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus1(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,-1,0,0))*p1o1) +#else +# define DiffMinus1(u) (DiffMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus2(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,-1,0))*p1o1) +#else +# define DiffMinus2(u) (DiffMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,-1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus3(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,0,-1))*p1o1) +#else +# define DiffMinus3(u) (DiffMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,-1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus1(u) (KRANC_GFOFFSET3D(u,-1,0,0)*p1o1) +#else +# define ShiftMinus1(u) (ShiftMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,-1,0,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus2(u) (KRANC_GFOFFSET3D(u,0,-1,0)*p1o1) +#else +# define ShiftMinus2(u) (ShiftMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,-1,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus3(u) (KRANC_GFOFFSET3D(u,0,0,-1)*p1o1) +#else +# define ShiftMinus3(u) (ShiftMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,0,-1)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx) +#else +# define PDplus1(u) (PDplus1_impl(u,p1odx,cdj,cdk)) +static CCTK_REAL PDplus1_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 PDplus1_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 + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody) +#else +# define PDplus2(u) (PDplus2_impl(u,p1ody,cdj,cdk)) +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, 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,0,1,0))*p1ody; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz) +#else +# define PDplus3(u) (PDplus3_impl(u,p1odz,cdj,cdk)) +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, 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,0,0,1))*p1odz; +} +#endif + diff --git a/Examples/EulerSR/src/RegisterMoL.cc b/Examples/EulerSR/src/RegisterMoL.cc index 5f77b35..9ef9a4d 100644 --- a/Examples/EulerSR/src/RegisterMoL.cc +++ b/Examples/EulerSR/src/RegisterMoL.cc @@ -17,5 +17,7 @@ extern "C" void EulerSR_RegisterVars(CCTK_ARGUMENTS) 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")); + + /* Register all the evolved Array functions with MoL */ return; } diff --git a/Examples/EulerSR/src/eulersr_cons_calc_conserved.cc b/Examples/EulerSR/src/eulersr_cons_calc_conserved.cc index 788478c..673ff99 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_conserved.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_conserved.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #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[]) +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 imin[3], int const imax[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); + 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); @@ -74,63 +62,69 @@ static void eulersr_cons_calc_conserved_Body(cGH const * restrict const cctkGH, CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_conserved, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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; } + CCTK_ENDLOOP3 (eulersr_cons_calc_conserved); } extern "C" void eulersr_cons_calc_conserved(CCTK_ARGUMENTS) @@ -138,5 +132,25 @@ extern "C" void eulersr_cons_calc_conserved(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_conserved_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index eefd139..843de50 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_flux_1.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_flux_1.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulersr_cons_calc_flux_1_SelectBCs(CCTK_ARGUMENTS) 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[]) +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 imin[3], int const imax[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); + 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); @@ -99,96 +86,102 @@ static void eulersr_cons_calc_flux_1_Body(cGH const * restrict const cctkGH, int CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_flux_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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 + (-tauLeftL + + ShiftMinus1tauRight)*ToReal(hlleAlpha)); + + /* Copy local copies back to grid functions */ + DenFlux[index] = DenFluxL; + S1Flux[index] = S1FluxL; + S2Flux[index] = S2FluxL; + S3Flux[index] = S3FluxL; + tauFlux[index] = tauFluxL; } + CCTK_ENDLOOP3 (eulersr_cons_calc_flux_1); } extern "C" void eulersr_cons_calc_flux_1(CCTK_ARGUMENTS) @@ -196,5 +189,26 @@ extern "C" void eulersr_cons_calc_flux_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_flux_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index b650410..fb8553c 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_flux_2.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_flux_2.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulersr_cons_calc_flux_2_SelectBCs(CCTK_ARGUMENTS) 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[]) +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 imin[3], int const imax[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); + 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); @@ -99,96 +86,102 @@ static void eulersr_cons_calc_flux_2_Body(cGH const * restrict const cctkGH, int CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_flux_2, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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 + (-tauLeftL + + ShiftMinus2tauRight)*ToReal(hlleAlpha)); + + /* Copy local copies back to grid functions */ + DenFlux[index] = DenFluxL; + S1Flux[index] = S1FluxL; + S2Flux[index] = S2FluxL; + S3Flux[index] = S3FluxL; + tauFlux[index] = tauFluxL; } + CCTK_ENDLOOP3 (eulersr_cons_calc_flux_2); } extern "C" void eulersr_cons_calc_flux_2(CCTK_ARGUMENTS) @@ -196,5 +189,26 @@ extern "C" void eulersr_cons_calc_flux_2(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_flux_2_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index 7f4dbea..90fc2b7 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_flux_3.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_flux_3.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulersr_cons_calc_flux_3_SelectBCs(CCTK_ARGUMENTS) 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[]) +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 imin[3], int const imax[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); + 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); @@ -99,96 +86,102 @@ static void eulersr_cons_calc_flux_3_Body(cGH const * restrict const cctkGH, int CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_flux_3, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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 + (-tauLeftL + + ShiftMinus3tauRight)*ToReal(hlleAlpha)); + + /* Copy local copies back to grid functions */ + DenFlux[index] = DenFluxL; + S1Flux[index] = S1FluxL; + S2Flux[index] = S2FluxL; + S3Flux[index] = S3FluxL; + tauFlux[index] = tauFluxL; } + CCTK_ENDLOOP3 (eulersr_cons_calc_flux_3); } extern "C" void eulersr_cons_calc_flux_3(CCTK_ARGUMENTS) @@ -196,5 +189,26 @@ extern "C" void eulersr_cons_calc_flux_3(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_flux_3_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index 6885845..df163c1 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_1.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_1.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #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[]) +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 imin[3], int const imax[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); + 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); @@ -74,92 +62,99 @@ static void eulersr_cons_calc_intercell_conserved_1_Body(cGH const * restrict co CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_intercell_conserved_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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; } + CCTK_ENDLOOP3 (eulersr_cons_calc_intercell_conserved_1); } extern "C" void eulersr_cons_calc_intercell_conserved_1(CCTK_ARGUMENTS) @@ -167,5 +162,25 @@ extern "C" void eulersr_cons_calc_intercell_conserved_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_intercell_conserved_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index 2263c6a..83616ac 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_2.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_2.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #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[]) +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 imin[3], int const imax[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); + 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); @@ -74,92 +62,99 @@ static void eulersr_cons_calc_intercell_conserved_2_Body(cGH const * restrict co CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_intercell_conserved_2, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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; } + CCTK_ENDLOOP3 (eulersr_cons_calc_intercell_conserved_2); } extern "C" void eulersr_cons_calc_intercell_conserved_2(CCTK_ARGUMENTS) @@ -167,5 +162,25 @@ extern "C" void eulersr_cons_calc_intercell_conserved_2(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_intercell_conserved_2_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index f636073..4cc9ef2 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_3.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_intercell_conserved_3.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #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[]) +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 imin[3], int const imax[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); + 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); @@ -74,92 +62,99 @@ static void eulersr_cons_calc_intercell_conserved_3_Body(cGH const * restrict co CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_intercell_conserved_3, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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; } + CCTK_ENDLOOP3 (eulersr_cons_calc_intercell_conserved_3); } extern "C" void eulersr_cons_calc_intercell_conserved_3(CCTK_ARGUMENTS) @@ -167,5 +162,25 @@ extern "C" void eulersr_cons_calc_intercell_conserved_3(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_intercell_conserved_3_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index c1ca939..b43f41a 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_primitives.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_primitives.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #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[]) +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 imin[3], int const imax[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); + 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); @@ -74,178 +62,185 @@ static void eulersr_cons_calc_primitives_Body(cGH const * restrict const cctkGH, CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_primitives, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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 + tauL + pBar; + + 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 - (rhoL + pBar)*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 + tauL + pBar; + + 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 - (rhoL + pBar)*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 + tauL + pBar; + + 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 - (rhoL + pBar)*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 + tauL + pBar; + + 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 - (rhoL + pBar)*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 + tauL + pBar; + + 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 - (rhoL + pBar)*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; } + CCTK_ENDLOOP3 (eulersr_cons_calc_primitives); } extern "C" void eulersr_cons_calc_primitives(CCTK_ARGUMENTS) @@ -253,5 +248,25 @@ extern "C" void eulersr_cons_calc_primitives(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_primitives_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index fd2111a..347fb53 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_1.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_1.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulersr_cons_calc_reconstruct_1_SelectBCs(CCTK_ARGUMENTS) 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[]) +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 imin[3], int const imax[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); + 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); @@ -99,103 +86,109 @@ static void eulersr_cons_calc_reconstruct_1_Body(cGH const * restrict const cctk CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_reconstruct_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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 = v1L - 0.5*slope; + + CCTK_REAL v1RightL = v1L + 0.5*slope; + + slopeL = DiffMinus1v2; + + slopeR = DiffPlus1v2; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v2LeftL = v2L - 0.5*slope; + + CCTK_REAL v2RightL = v2L + 0.5*slope; + + slopeL = DiffMinus1v3; + + slopeR = DiffPlus1v3; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v3LeftL = v3L - 0.5*slope; + + CCTK_REAL v3RightL = v3L + 0.5*slope; + + 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; } + CCTK_ENDLOOP3 (eulersr_cons_calc_reconstruct_1); } extern "C" void eulersr_cons_calc_reconstruct_1(CCTK_ARGUMENTS) @@ -203,5 +196,26 @@ extern "C" void eulersr_cons_calc_reconstruct_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_reconstruct_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index 6725583..420741b 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_2.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_2.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulersr_cons_calc_reconstruct_2_SelectBCs(CCTK_ARGUMENTS) 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[]) +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 imin[3], int const imax[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); + 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); @@ -99,103 +86,109 @@ static void eulersr_cons_calc_reconstruct_2_Body(cGH const * restrict const cctk CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_reconstruct_2, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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 = v1L - 0.5*slope; + + CCTK_REAL v1RightL = v1L + 0.5*slope; + + slopeL = DiffMinus2v2; + + slopeR = DiffPlus2v2; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v2LeftL = v2L - 0.5*slope; + + CCTK_REAL v2RightL = v2L + 0.5*slope; + + slopeL = DiffMinus2v3; + + slopeR = DiffPlus2v3; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v3LeftL = v3L - 0.5*slope; + + CCTK_REAL v3RightL = v3L + 0.5*slope; + + 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; } + CCTK_ENDLOOP3 (eulersr_cons_calc_reconstruct_2); } extern "C" void eulersr_cons_calc_reconstruct_2(CCTK_ARGUMENTS) @@ -203,5 +196,26 @@ extern "C" void eulersr_cons_calc_reconstruct_2(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_reconstruct_2_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index 7a913d0..d0d6b42 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_3.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_reconstruct_3.cc @@ -12,6 +12,8 @@ #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) @@ -44,43 +46,28 @@ extern "C" void eulersr_cons_calc_reconstruct_3_SelectBCs(CCTK_ARGUMENTS) 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[]) +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 imin[3], int const imax[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); + 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); @@ -99,103 +86,109 @@ static void eulersr_cons_calc_reconstruct_3_Body(cGH const * restrict const cctk CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_reconstruct_3, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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 = v1L - 0.5*slope; + + CCTK_REAL v1RightL = v1L + 0.5*slope; + + slopeL = DiffMinus3v2; + + slopeR = DiffPlus3v2; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v2LeftL = v2L - 0.5*slope; + + CCTK_REAL v2RightL = v2L + 0.5*slope; + + slopeL = DiffMinus3v3; + + slopeR = DiffPlus3v3; + + slope = VanLeer(slopeL,slopeR); + + CCTK_REAL v3LeftL = v3L - 0.5*slope; + + CCTK_REAL v3RightL = v3L + 0.5*slope; + + 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; } + CCTK_ENDLOOP3 (eulersr_cons_calc_reconstruct_3); } extern "C" void eulersr_cons_calc_reconstruct_3(CCTK_ARGUMENTS) @@ -203,5 +196,26 @@ extern "C" void eulersr_cons_calc_reconstruct_3(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_reconstruct_3_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index 0dee465..f5ca0d1 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_rhs_1.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_rhs_1.cc @@ -12,6 +12,8 @@ #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) @@ -38,43 +40,28 @@ extern "C" void eulersr_cons_calc_rhs_1_SelectBCs(CCTK_ARGUMENTS) 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[]) +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 imin[3], int const imax[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); + 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); @@ -93,58 +80,64 @@ static void eulersr_cons_calc_rhs_1_Body(cGH const * restrict const cctkGH, int CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_rhs_1, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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 = S1rhsL - PDplus1S1Flux; + + S2rhsL = S2rhsL - PDplus1S2Flux; + + S3rhsL = S3rhsL - PDplus1S3Flux; + + taurhsL = taurhsL - PDplus1tauFlux; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; + taurhs[index] = taurhsL; } + CCTK_ENDLOOP3 (eulersr_cons_calc_rhs_1); } extern "C" void eulersr_cons_calc_rhs_1(CCTK_ARGUMENTS) @@ -152,5 +145,26 @@ extern "C" void eulersr_cons_calc_rhs_1(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_rhs_1_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index f8a470b..33d6d0e 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_rhs_2.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_rhs_2.cc @@ -12,6 +12,8 @@ #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) @@ -38,43 +40,28 @@ extern "C" void eulersr_cons_calc_rhs_2_SelectBCs(CCTK_ARGUMENTS) 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[]) +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 imin[3], int const imax[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); + 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); @@ -93,58 +80,64 @@ static void eulersr_cons_calc_rhs_2_Body(cGH const * restrict const cctkGH, int CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_rhs_2, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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 = S1rhsL - PDplus2S1Flux; + + S2rhsL = S2rhsL - PDplus2S2Flux; + + S3rhsL = S3rhsL - PDplus2S3Flux; + + taurhsL = taurhsL - PDplus2tauFlux; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; + taurhs[index] = taurhsL; } + CCTK_ENDLOOP3 (eulersr_cons_calc_rhs_2); } extern "C" void eulersr_cons_calc_rhs_2(CCTK_ARGUMENTS) @@ -152,5 +145,26 @@ extern "C" void eulersr_cons_calc_rhs_2(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_rhs_2_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index 2b33c05..6a288fe 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_rhs_3.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_rhs_3.cc @@ -12,6 +12,8 @@ #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) @@ -38,43 +40,28 @@ extern "C" void eulersr_cons_calc_rhs_3_SelectBCs(CCTK_ARGUMENTS) 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[]) +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 imin[3], int const imax[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); + 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); @@ -93,58 +80,64 @@ static void eulersr_cons_calc_rhs_3_Body(cGH const * restrict const cctkGH, int CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_rhs_3, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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 = S1rhsL - PDplus3S1Flux; + + S2rhsL = S2rhsL - PDplus3S2Flux; + + S3rhsL = S3rhsL - PDplus3S3Flux; + + taurhsL = taurhsL - PDplus3tauFlux; + + /* Copy local copies back to grid functions */ + Denrhs[index] = DenrhsL; + S1rhs[index] = S1rhsL; + S2rhs[index] = S2rhsL; + S3rhs[index] = S3rhsL; + taurhs[index] = taurhsL; } + CCTK_ENDLOOP3 (eulersr_cons_calc_rhs_3); } extern "C" void eulersr_cons_calc_rhs_3(CCTK_ARGUMENTS) @@ -152,5 +145,26 @@ extern "C" void eulersr_cons_calc_rhs_3(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + GenericFD_LoopOverInterior(cctkGH, &eulersr_cons_calc_rhs_3_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving 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 index 1919515..6a93d61 100644 --- a/Examples/EulerSR/src/eulersr_cons_calc_zero_rhs.cc +++ b/Examples/EulerSR/src/eulersr_cons_calc_zero_rhs.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #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[]) +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 imin[3], int const imax[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); + 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); @@ -74,63 +62,69 @@ static void eulersr_cons_calc_zero_rhs_Body(cGH const * restrict const cctkGH, i CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_cons_calc_zero_rhs, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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; - } - } + ptrdiff_t const index = di*i + dj*j + dk*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; } + CCTK_ENDLOOP3 (eulersr_cons_calc_zero_rhs); } extern "C" void eulersr_cons_calc_zero_rhs(CCTK_ARGUMENTS) @@ -138,5 +132,25 @@ extern "C" void eulersr_cons_calc_zero_rhs(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + + GenericFD_LoopOverEverything(cctkGH, &eulersr_cons_calc_zero_rhs_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulersr_cons_calc_zero_rhs_Body"); + } } diff --git a/Examples/EulerSR/src/eulersr_initial_shock.cc b/Examples/EulerSR/src/eulersr_initial_shock.cc index 2881056..73eb475 100644 --- a/Examples/EulerSR/src/eulersr_initial_shock.cc +++ b/Examples/EulerSR/src/eulersr_initial_shock.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #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[]) +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 imin[3], int const imax[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); + 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); @@ -74,51 +62,57 @@ static void eulersr_initial_shock_Body(cGH const * restrict const cctkGH, int co CCTK_REAL const p1ody = INV(dy); CCTK_REAL const p1odz = INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (eulersr_initial_shock, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL X = xL; - - 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; - } - } + 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 X = xL; + + 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; } + CCTK_ENDLOOP3 (eulersr_initial_shock); } extern "C" void eulersr_initial_shock(CCTK_ARGUMENTS) @@ -126,5 +120,25 @@ extern "C" void eulersr_initial_shock(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + 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); + + GenericFD_LoopOverEverything(cctkGH, &eulersr_initial_shock_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving eulersr_initial_shock_Body"); + } } diff --git a/Examples/SimpleWave/configuration.ccl b/Examples/SimpleWave/configuration.ccl index 023aac7..0a66ec2 100644 --- a/Examples/SimpleWave/configuration.ccl +++ b/Examples/SimpleWave/configuration.ccl @@ -1,3 +1,6 @@ # File produced by Kranc REQUIRES GenericFD +OPTIONAL LoopControl +{ +} diff --git a/Examples/SimpleWave/interface.ccl b/Examples/SimpleWave/interface.ccl index 67c3c69..48ce002 100644 --- a/Examples/SimpleWave/interface.ccl +++ b/Examples/SimpleWave/interface.ccl @@ -10,6 +10,7 @@ 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 diff --git a/Examples/SimpleWave/param.ccl b/Examples/SimpleWave/param.ccl index 8f36068..41f8cd6 100644 --- a/Examples/SimpleWave/param.ccl +++ b/Examples/SimpleWave/param.ccl @@ -8,6 +8,7 @@ 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 @@ -28,6 +29,12 @@ CCTK_INT SimpleWave_MaxNumEvolvedVars "Number of evolved variables used by this } 2 restricted: +CCTK_INT SimpleWave_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:3 :: "" @@ -40,6 +47,12 @@ CCTK_INT rhs_timelevels "Number of active RHS timelevels" STEERABLE=RECOVER } 1 restricted: +CCTK_INT other_timelevels "Number of active timelevels for non-evolved grid functions" STEERABLE=RECOVER +{ + 0:3 :: "" +} 1 + +restricted: CCTK_INT initial_sine_calc_every "initial_sine_calc_every" STEERABLE=ALWAYS { *:* :: "" diff --git a/Examples/SimpleWave/src/Differencing.h b/Examples/SimpleWave/src/Differencing.h index 84d7298..fc6d45d 100644 --- a/Examples/SimpleWave/src/Differencing.h +++ b/Examples/SimpleWave/src/Differencing.h @@ -1,18 +1,216 @@ -#define PDstandard2nd1(u) (p1o2dx*(-(u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) -#define PDstandard2nd2(u) (p1o2dy*(-(u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) -#define PDstandard2nd3(u) (p1o2dz*(-(u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) -#define PDstandard2nd11(u) (p1odx2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) -#define PDstandard2nd22(u) (p1ody2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) -#define PDstandard2nd33(u) (p1odz2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) -#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)])) +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd1(u) ((-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx) +#else +# define PDstandard2nd1(u) (PDstandard2nd1_impl(u,p1o2dx,cdj,cdk)) +static CCTK_REAL PDstandard2nd1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd2(u) ((-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy) +#else +# define PDstandard2nd2(u) (PDstandard2nd2_impl(u,p1o2dy,cdj,cdk)) +static CCTK_REAL PDstandard2nd2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd3(u) ((-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz) +#else +# define PDstandard2nd3(u) (PDstandard2nd3_impl(u,p1o2dz,cdj,cdk)) +static CCTK_REAL PDstandard2nd3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd11(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx2) +#else +# define PDstandard2nd11(u) (PDstandard2nd11_impl(u,p1odx2,cdj,cdk)) +static CCTK_REAL PDstandard2nd11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd22(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody2) +#else +# define PDstandard2nd22(u) (PDstandard2nd22_impl(u,p1ody2,cdj,cdk)) +static CCTK_REAL PDstandard2nd22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandard2nd33(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz2) +#else +# define PDstandard2nd33(u) (PDstandard2nd33_impl(u,p1odz2,cdj,cdk)) +static CCTK_REAL PDstandard2nd33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandard2nd33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o1) +#else +# define DiffPlus1(u) (DiffPlus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o1) +#else +# define DiffPlus2(u) (DiffPlus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1o1) +#else +# define DiffPlus3(u) (DiffPlus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus1(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,-1,0,0))*p1o1) +#else +# define DiffMinus1(u) (DiffMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus2(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,-1,0))*p1o1) +#else +# define DiffMinus2(u) (DiffMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,-1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus3(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,0,-1))*p1o1) +#else +# define DiffMinus3(u) (DiffMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,-1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus1(u) (KRANC_GFOFFSET3D(u,-1,0,0)*p1o1) +#else +# define ShiftMinus1(u) (ShiftMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,-1,0,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus2(u) (KRANC_GFOFFSET3D(u,0,-1,0)*p1o1) +#else +# define ShiftMinus2(u) (ShiftMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,-1,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus3(u) (KRANC_GFOFFSET3D(u,0,0,-1)*p1o1) +#else +# define ShiftMinus3(u) (ShiftMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,0,-1)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx) +#else +# define PDplus1(u) (PDplus1_impl(u,p1odx,cdj,cdk)) +static CCTK_REAL PDplus1_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 PDplus1_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 + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody) +#else +# define PDplus2(u) (PDplus2_impl(u,p1ody,cdj,cdk)) +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, 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,0,1,0))*p1ody; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz) +#else +# define PDplus3(u) (PDplus3_impl(u,p1odz,cdj,cdk)) +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, 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,0,0,1))*p1odz; +} +#endif + diff --git a/Examples/SimpleWave/src/RegisterMoL.cc b/Examples/SimpleWave/src/RegisterMoL.cc index c1d917d..6386c7f 100644 --- a/Examples/SimpleWave/src/RegisterMoL.cc +++ b/Examples/SimpleWave/src/RegisterMoL.cc @@ -14,5 +14,7 @@ extern "C" void SimpleWave_RegisterVars(CCTK_ARGUMENTS) /* Register all the evolved grid functions with MoL */ ierr += MoLRegisterEvolved(CCTK_VarIndex("SimpleWave::phi"), CCTK_VarIndex("SimpleWave::phirhs")); ierr += MoLRegisterEvolved(CCTK_VarIndex("SimpleWave::pi"), CCTK_VarIndex("SimpleWave::pirhs")); + + /* Register all the evolved Array functions with MoL */ return; } diff --git a/Examples/SimpleWave/src/calc_rhs.cc b/Examples/SimpleWave/src/calc_rhs.cc index 4dfe490..b742e82 100644 --- a/Examples/SimpleWave/src/calc_rhs.cc +++ b/Examples/SimpleWave/src/calc_rhs.cc @@ -12,6 +12,8 @@ #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) @@ -20,43 +22,40 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void calc_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[]) +extern "C" void calc_rhs_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 */, "SimpleWave::evolved_grouprhs","flat"); + if (ierr < 0) + CCTK_WARN(1, "Failed to register flat BC for SimpleWave::evolved_grouprhs."); + return; +} + +static void calc_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 imin[3], int const imax[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 calc_rhs_Body"); - } - - if (cctk_iteration % calc_rhs_calc_every != calc_rhs_calc_offset) - { - return; - } - - const char *groups[] = {"SimpleWave::evolved_group","SimpleWave::evolved_grouprhs"}; - GenericFD_AssertGroupStorage(cctkGH, "calc_rhs", 2, groups); - - GenericFD_EnsureStencilFits(cctkGH, "calc_rhs", 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); + 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); @@ -81,40 +80,46 @@ static void calc_rhs_Body(cGH const * restrict const cctkGH, int const dir, int CCTK_REAL const p1odz = INV(dz); 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 */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (calc_rhs, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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 phiL = phi[index]; - CCTK_REAL piL = pi[index]; - - - /* 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 */ - phirhs[index] = phirhsL; - pirhs[index] = pirhsL; - } - } + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL phiL = phi[index]; + CCTK_REAL piL = pi[index]; + + + /* 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 */ + phirhs[index] = phirhsL; + pirhs[index] = pirhsL; } + CCTK_ENDLOOP3 (calc_rhs); } extern "C" void calc_rhs(CCTK_ARGUMENTS) @@ -122,5 +127,26 @@ extern "C" void calc_rhs(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; - GenericFD_LoopOverEverything(cctkGH, &calc_rhs_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering calc_rhs_Body"); + } + + if (cctk_iteration % calc_rhs_calc_every != calc_rhs_calc_offset) + { + return; + } + + const char *groups[] = {"SimpleWave::evolved_group","SimpleWave::evolved_grouprhs"}; + GenericFD_AssertGroupStorage(cctkGH, "calc_rhs", 2, groups); + + GenericFD_EnsureStencilFits(cctkGH, "calc_rhs", 1, 1, 1); + + GenericFD_LoopOverInterior(cctkGH, &calc_rhs_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving calc_rhs_Body"); + } } diff --git a/Examples/SimpleWave/src/initial_sine.cc b/Examples/SimpleWave/src/initial_sine.cc index 0a450d2..a37a221 100644 --- a/Examples/SimpleWave/src/initial_sine.cc +++ b/Examples/SimpleWave/src/initial_sine.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void initial_sine_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[]) +static void initial_sine_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; - /* 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 initial_sine_Body"); - } - - if (cctk_iteration % initial_sine_calc_every != initial_sine_calc_offset) - { - return; - } - - const char *groups[] = {"SimpleWave::evolved_group","grid::coordinates"}; - GenericFD_AssertGroupStorage(cctkGH, "initial_sine", 2, 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); + 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); @@ -80,35 +68,41 @@ static void initial_sine_Body(cGH const * restrict const cctkGH, int const dir, CCTK_REAL const p1odz = INV(dz); 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 */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (initial_sine, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - 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]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL phiL = Sin(2*Pi*(xL - cctk_time)); - - CCTK_REAL piL = -2*Pi*Cos(2*Pi*(xL - cctk_time)); - - /* Copy local copies back to grid functions */ - phi[index] = phiL; - pi[index] = piL; - } - } + 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 = Sin(2*Pi*(xL - cctk_time)); + + CCTK_REAL piL = -2*Pi*Cos(2*Pi*(xL - cctk_time)); + + /* Copy local copies back to grid functions */ + phi[index] = phiL; + pi[index] = piL; } + CCTK_ENDLOOP3 (initial_sine); } extern "C" void initial_sine(CCTK_ARGUMENTS) @@ -116,5 +110,25 @@ extern "C" void initial_sine(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering initial_sine_Body"); + } + + if (cctk_iteration % initial_sine_calc_every != initial_sine_calc_offset) + { + return; + } + + const char *groups[] = {"SimpleWave::evolved_group","grid::coordinates"}; + GenericFD_AssertGroupStorage(cctkGH, "initial_sine", 2, groups); + + GenericFD_LoopOverEverything(cctkGH, &initial_sine_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving initial_sine_Body"); + } } diff --git a/Examples/Wave/configuration.ccl b/Examples/Wave/configuration.ccl index 023aac7..0a66ec2 100644 --- a/Examples/Wave/configuration.ccl +++ b/Examples/Wave/configuration.ccl @@ -1,3 +1,6 @@ # File produced by Kranc REQUIRES GenericFD +OPTIONAL LoopControl +{ +} diff --git a/Examples/Wave/interface.ccl b/Examples/Wave/interface.ccl index ab486ea..89fef10 100644 --- a/Examples/Wave/interface.ccl +++ b/Examples/Wave/interface.ccl @@ -10,6 +10,7 @@ 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 diff --git a/Examples/Wave/param.ccl b/Examples/Wave/param.ccl index 3b37c58..ae83072 100644 --- a/Examples/Wave/param.ccl +++ b/Examples/Wave/param.ccl @@ -8,6 +8,7 @@ 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 @@ -70,11 +71,23 @@ CCTK_REAL x0 "x0" } 0 restricted: +CCTK_REAL diss "diss" +{ + "*:*" :: "" +} 0 + +restricted: CCTK_REAL hlleAlpha "hlleAlpha" { "*:*" :: "" } 0 +restricted: +CCTK_INT fdOrder "fdOrder" +{ + *:* :: "" +} 2 + private: KEYWORD initial_data "initial_data" { @@ -96,6 +109,12 @@ CCTK_INT Wave_MaxNumEvolvedVars "Number of evolved variables used by this thorn" } 2 restricted: +CCTK_INT Wave_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:3 :: "" @@ -108,6 +127,12 @@ CCTK_INT rhs_timelevels "Number of active RHS timelevels" STEERABLE=RECOVER } 1 restricted: +CCTK_INT other_timelevels "Number of active timelevels for non-evolved grid functions" STEERABLE=RECOVER +{ + 0:3 :: "" +} 1 + +restricted: CCTK_INT wave_exact_sine_calc_every "wave_exact_sine_calc_every" STEERABLE=ALWAYS { *:* :: "" diff --git a/Examples/Wave/schedule.ccl b/Examples/Wave/schedule.ccl index ea09733..e9e28e0 100644 --- a/Examples/Wave/schedule.ccl +++ b/Examples/Wave/schedule.ccl @@ -1,11 +1,44 @@ # File produced by Kranc -STORAGE: errors[3] +if (timelevels == 1) +{ + STORAGE: errors[1] +} +if (timelevels == 2) +{ + STORAGE: errors[2] +} +if (timelevels == 3) +{ + STORAGE: errors[3] +} -STORAGE: exact[3] +if (timelevels == 1) +{ + STORAGE: exact[1] +} +if (timelevels == 2) +{ + STORAGE: exact[2] +} +if (timelevels == 3) +{ + STORAGE: exact[3] +} -STORAGE: norms[3] +if (timelevels == 1) +{ + STORAGE: norms[1] +} +if (timelevels == 2) +{ + STORAGE: norms[2] +} +if (timelevels == 3) +{ + STORAGE: norms[3] +} if (timelevels == 1) { @@ -54,7 +87,7 @@ schedule Wave_RegisterSymmetries in SymmetryRegister if (CCTK_EQUALS(initial_data, "sine")) { - schedule wave_exact_sine AT INITIAL before import_exact + schedule wave_exact_sine AT INITIAL before import_exact before import_exact { LANG: C } "wave_exact_sine" @@ -63,7 +96,7 @@ if (CCTK_EQUALS(initial_data, "sine")) if (CCTK_EQUALS(initial_data, "sine")) { - schedule wave_exact_sine AT POSTSTEP before calc_errors + schedule wave_exact_sine AT POSTSTEP before calc_errors before import_exact { LANG: C } "wave_exact_sine" @@ -72,7 +105,7 @@ if (CCTK_EQUALS(initial_data, "sine")) if (CCTK_EQUALS(initial_data, "gaussian")) { - schedule wave_exact_gaussian AT INITIAL before import_exact + schedule wave_exact_gaussian AT INITIAL before import_exact before import_exact { LANG: C } "wave_exact_gaussian" @@ -81,7 +114,7 @@ if (CCTK_EQUALS(initial_data, "gaussian")) if (CCTK_EQUALS(initial_data, "gaussian")) { - schedule wave_exact_gaussian AT POSTSTEP before calc_errors + schedule wave_exact_gaussian AT POSTSTEP before calc_errors before import_exact { LANG: C } "wave_exact_gaussian" diff --git a/Examples/Wave/src/Differencing.h b/Examples/Wave/src/Differencing.h index e7810c7..c809b72 100644 --- a/Examples/Wave/src/Differencing.h +++ b/Examples/Wave/src/Differencing.h @@ -1,53 +1,636 @@ -#define PDstandard2nd1(u) (p1o2dx*(-(u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) -#define PDstandard2nd2(u) (p1o2dy*(-(u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) -#define PDstandard2nd3(u) (p1o2dz*(-(u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) -#define PDstandard2nd11(u) (p1odx2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) -#define PDstandard2nd22(u) (p1ody2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) -#define PDstandard2nd33(u) (p1odz2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) -#define PDstandard2nd12(u) (p1o4dxdy*((u)[di*(-1)+dj*(-1)+dk*(0)] - (u)[di*(-1)+dj*(1)+dk*(0)] - (u)[di*(1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)])) -#define PDstandard2nd13(u) (p1o4dxdz*((u)[di*(-1)+dj*(0)+dk*(-1)] - (u)[di*(-1)+dj*(0)+dk*(1)] - (u)[di*(1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)])) -#define PDstandard2nd21(u) (p1o4dxdy*((u)[di*(-1)+dj*(-1)+dk*(0)] - (u)[di*(-1)+dj*(1)+dk*(0)] - (u)[di*(1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)])) -#define PDstandard2nd23(u) (p1o4dydz*((u)[di*(0)+dj*(-1)+dk*(-1)] - (u)[di*(0)+dj*(-1)+dk*(1)] - (u)[di*(0)+dj*(1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)])) -#define PDstandard2nd31(u) (p1o4dxdz*((u)[di*(-1)+dj*(0)+dk*(-1)] - (u)[di*(-1)+dj*(0)+dk*(1)] - (u)[di*(1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)])) -#define PDstandard2nd32(u) (p1o4dydz*((u)[di*(0)+dj*(-1)+dk*(-1)] - (u)[di*(0)+dj*(-1)+dk*(1)] - (u)[di*(0)+dj*(1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)])) -#define PDstandard4th1(u) (p1o12dx*(-8*(u)[di*(-1)+dj*(0)+dk*(0)] + 8*(u)[di*(1)+dj*(0)+dk*(0)] + (u)[di*(-2)+dj*(0)+dk*(0)] - (u)[di*(2)+dj*(0)+dk*(0)])) -#define PDstandard4th2(u) (p1o12dy*(-8*(u)[di*(0)+dj*(-1)+dk*(0)] + 8*(u)[di*(0)+dj*(1)+dk*(0)] + (u)[di*(0)+dj*(-2)+dk*(0)] - (u)[di*(0)+dj*(2)+dk*(0)])) -#define PDstandard4th3(u) (p1o12dz*(-8*(u)[di*(0)+dj*(0)+dk*(-1)] + 8*(u)[di*(0)+dj*(0)+dk*(1)] + (u)[di*(0)+dj*(0)+dk*(-2)] - (u)[di*(0)+dj*(0)+dk*(2)])) -#define PDstandard4th11(u) (pm1o12dx2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)]) + (u)[di*(-2)+dj*(0)+dk*(0)] + (u)[di*(2)+dj*(0)+dk*(0)])) -#define PDstandard4th22(u) (pm1o12dy2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)]) + (u)[di*(0)+dj*(-2)+dk*(0)] + (u)[di*(0)+dj*(2)+dk*(0)])) -#define PDstandard4th33(u) (pm1o12dz2*(30*(u)[di*(0)+dj*(0)+dk*(0)] - 16*((u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)]) + (u)[di*(0)+dj*(0)+dk*(-2)] + (u)[di*(0)+dj*(0)+dk*(2)])) -#define PDstandard4th12(u) (p1o144dxdy*(-64*((u)[di*(-1)+dj*(1)+dk*(0)] + (u)[di*(1)+dj*(-1)+dk*(0)]) + 64*((u)[di*(-1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)]) + 8*((u)[di*(-1)+dj*(2)+dk*(0)] + (u)[di*(1)+dj*(-2)+dk*(0)] + (u)[di*(-2)+dj*(1)+dk*(0)] + (u)[di*(2)+dj*(-1)+dk*(0)]) - 8*((u)[di*(-1)+dj*(-2)+dk*(0)] + (u)[di*(1)+dj*(2)+dk*(0)] + (u)[di*(-2)+dj*(-1)+dk*(0)] + (u)[di*(2)+dj*(1)+dk*(0)]) + (u)[di*(-2)+dj*(-2)+dk*(0)] - (u)[di*(-2)+dj*(2)+dk*(0)] - (u)[di*(2)+dj*(-2)+dk*(0)] + (u)[di*(2)+dj*(2)+dk*(0)])) -#define PDstandard4th13(u) (p1o144dxdz*(-64*((u)[di*(-1)+dj*(0)+dk*(1)] + (u)[di*(1)+dj*(0)+dk*(-1)]) + 64*((u)[di*(-1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)]) + 8*((u)[di*(-1)+dj*(0)+dk*(2)] + (u)[di*(1)+dj*(0)+dk*(-2)] + (u)[di*(-2)+dj*(0)+dk*(1)] + (u)[di*(2)+dj*(0)+dk*(-1)]) - 8*((u)[di*(-1)+dj*(0)+dk*(-2)] + (u)[di*(1)+dj*(0)+dk*(2)] + (u)[di*(-2)+dj*(0)+dk*(-1)] + (u)[di*(2)+dj*(0)+dk*(1)]) + (u)[di*(-2)+dj*(0)+dk*(-2)] - (u)[di*(-2)+dj*(0)+dk*(2)] - (u)[di*(2)+dj*(0)+dk*(-2)] + (u)[di*(2)+dj*(0)+dk*(2)])) -#define PDstandard4th21(u) (p1o144dxdy*(-64*((u)[di*(-1)+dj*(1)+dk*(0)] + (u)[di*(1)+dj*(-1)+dk*(0)]) + 64*((u)[di*(-1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)]) + 8*((u)[di*(-1)+dj*(2)+dk*(0)] + (u)[di*(1)+dj*(-2)+dk*(0)] + (u)[di*(-2)+dj*(1)+dk*(0)] + (u)[di*(2)+dj*(-1)+dk*(0)]) - 8*((u)[di*(-1)+dj*(-2)+dk*(0)] + (u)[di*(1)+dj*(2)+dk*(0)] + (u)[di*(-2)+dj*(-1)+dk*(0)] + (u)[di*(2)+dj*(1)+dk*(0)]) + (u)[di*(-2)+dj*(-2)+dk*(0)] - (u)[di*(-2)+dj*(2)+dk*(0)] - (u)[di*(2)+dj*(-2)+dk*(0)] + (u)[di*(2)+dj*(2)+dk*(0)])) -#define PDstandard4th23(u) (p1o144dydz*(-64*((u)[di*(0)+dj*(-1)+dk*(1)] + (u)[di*(0)+dj*(1)+dk*(-1)]) + 64*((u)[di*(0)+dj*(-1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)]) + 8*((u)[di*(0)+dj*(-1)+dk*(2)] + (u)[di*(0)+dj*(1)+dk*(-2)] + (u)[di*(0)+dj*(-2)+dk*(1)] + (u)[di*(0)+dj*(2)+dk*(-1)]) - 8*((u)[di*(0)+dj*(-1)+dk*(-2)] + (u)[di*(0)+dj*(1)+dk*(2)] + (u)[di*(0)+dj*(-2)+dk*(-1)] + (u)[di*(0)+dj*(2)+dk*(1)]) + (u)[di*(0)+dj*(-2)+dk*(-2)] - (u)[di*(0)+dj*(-2)+dk*(2)] - (u)[di*(0)+dj*(2)+dk*(-2)] + (u)[di*(0)+dj*(2)+dk*(2)])) -#define PDstandard4th31(u) (p1o144dxdz*(-64*((u)[di*(-1)+dj*(0)+dk*(1)] + (u)[di*(1)+dj*(0)+dk*(-1)]) + 64*((u)[di*(-1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)]) + 8*((u)[di*(-1)+dj*(0)+dk*(2)] + (u)[di*(1)+dj*(0)+dk*(-2)] + (u)[di*(-2)+dj*(0)+dk*(1)] + (u)[di*(2)+dj*(0)+dk*(-1)]) - 8*((u)[di*(-1)+dj*(0)+dk*(-2)] + (u)[di*(1)+dj*(0)+dk*(2)] + (u)[di*(-2)+dj*(0)+dk*(-1)] + (u)[di*(2)+dj*(0)+dk*(1)]) + (u)[di*(-2)+dj*(0)+dk*(-2)] - (u)[di*(-2)+dj*(0)+dk*(2)] - (u)[di*(2)+dj*(0)+dk*(-2)] + (u)[di*(2)+dj*(0)+dk*(2)])) -#define PDstandard4th32(u) (p1o144dydz*(-64*((u)[di*(0)+dj*(-1)+dk*(1)] + (u)[di*(0)+dj*(1)+dk*(-1)]) + 64*((u)[di*(0)+dj*(-1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)]) + 8*((u)[di*(0)+dj*(-1)+dk*(2)] + (u)[di*(0)+dj*(1)+dk*(-2)] + (u)[di*(0)+dj*(-2)+dk*(1)] + (u)[di*(0)+dj*(2)+dk*(-1)]) - 8*((u)[di*(0)+dj*(-1)+dk*(-2)] + (u)[di*(0)+dj*(1)+dk*(2)] + (u)[di*(0)+dj*(-2)+dk*(-1)] + (u)[di*(0)+dj*(2)+dk*(1)]) + (u)[di*(0)+dj*(-2)+dk*(-2)] - (u)[di*(0)+dj*(-2)+dk*(2)] - (u)[di*(0)+dj*(2)+dk*(-2)] + (u)[di*(0)+dj*(2)+dk*(2)])) -#define PDonesided2nd1(u) (pm1o2dx*(3*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(2*dir1)+dj*(0)+dk*(0)] - 4*(u)[di*(dir1)+dj*(0)+dk*(0)])*dir1) -#define PDonesided2nd2(u) (pm1o2dy*(3*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(2*dir2)+dk*(0)] - 4*(u)[di*(0)+dj*(dir2)+dk*(0)])*dir2) -#define PDonesided2nd3(u) (pm1o2dz*(3*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(2*dir3)] - 4*(u)[di*(0)+dj*(0)+dk*(dir3)])*dir3) -#define Diss2nd(u) (-(p1odxdydz*diss*((6*(u)[di*(0)+dj*(0)+dk*(0)] - 4*((u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)]) + (u)[di*(0)+dj*(0)+dk*(-2)] + (u)[di*(0)+dj*(0)+dk*(2)])*INV(dxi)*INV(dyi) + ((6*(u)[di*(0)+dj*(0)+dk*(0)] - 4*((u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)]) + (u)[di*(0)+dj*(-2)+dk*(0)] + (u)[di*(0)+dj*(2)+dk*(0)])*INV(dxi) + (6*(u)[di*(0)+dj*(0)+dk*(0)] - 4*((u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)]) + (u)[di*(-2)+dj*(0)+dk*(0)] + (u)[di*(2)+dj*(0)+dk*(0)])*INV(dyi))*INV(dzi)))) -#define Diss4th(u) (p1odxdydz*diss*((-20*(u)[di*(0)+dj*(0)+dk*(0)] + 15*((u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)]) - 6*((u)[di*(0)+dj*(0)+dk*(-2)] + (u)[di*(0)+dj*(0)+dk*(2)]) + (u)[di*(0)+dj*(0)+dk*(-3)] + (u)[di*(0)+dj*(0)+dk*(3)])*INV(dxi)*INV(dyi) + ((15*((u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)]) - 6*((u)[di*(0)+dj*(-2)+dk*(0)] + (u)[di*(0)+dj*(2)+dk*(0)]) + (u)[di*(0)+dj*(-3)+dk*(0)] + (u)[di*(0)+dj*(3)+dk*(0)])*INV(dxi) + (15*((u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)]) - 6*((u)[di*(-2)+dj*(0)+dk*(0)] + (u)[di*(2)+dj*(0)+dk*(0)]) + (u)[di*(-3)+dj*(0)+dk*(0)] + (u)[di*(3)+dj*(0)+dk*(0)])*INV(dyi) - 20*(u)[di*(0)+dj*(0)+dk*(0)]*(INV(dxi) + INV(dyi)))*INV(dzi))) -#define PDzero1(u) (p1o2dx*(-(u)[di*(-1)+dj*(0)+dk*(0)] + (u)[di*(1)+dj*(0)+dk*(0)])) -#define PDzero2(u) (p1o2dy*(-(u)[di*(0)+dj*(-1)+dk*(0)] + (u)[di*(0)+dj*(1)+dk*(0)])) -#define PDzero3(u) (p1o2dz*(-(u)[di*(0)+dj*(0)+dk*(-1)] + (u)[di*(0)+dj*(0)+dk*(1)])) -#define PDzero11(u) (p1o4dx2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(-2)+dj*(0)+dk*(0)] + (u)[di*(2)+dj*(0)+dk*(0)])) -#define PDzero12(u) (p1o4dxdy*((u)[di*(-1)+dj*(-1)+dk*(0)] - (u)[di*(-1)+dj*(1)+dk*(0)] - (u)[di*(1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)])) -#define PDzero13(u) (p1o4dxdz*((u)[di*(-1)+dj*(0)+dk*(-1)] - (u)[di*(-1)+dj*(0)+dk*(1)] - (u)[di*(1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)])) -#define PDzero21(u) (p1o4dxdy*((u)[di*(-1)+dj*(-1)+dk*(0)] - (u)[di*(-1)+dj*(1)+dk*(0)] - (u)[di*(1)+dj*(-1)+dk*(0)] + (u)[di*(1)+dj*(1)+dk*(0)])) -#define PDzero22(u) (p1o4dy2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(-2)+dk*(0)] + (u)[di*(0)+dj*(2)+dk*(0)])) -#define PDzero23(u) (p1o4dydz*((u)[di*(0)+dj*(-1)+dk*(-1)] - (u)[di*(0)+dj*(-1)+dk*(1)] - (u)[di*(0)+dj*(1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)])) -#define PDzero31(u) (p1o4dxdz*((u)[di*(-1)+dj*(0)+dk*(-1)] - (u)[di*(-1)+dj*(0)+dk*(1)] - (u)[di*(1)+dj*(0)+dk*(-1)] + (u)[di*(1)+dj*(0)+dk*(1)])) -#define PDzero32(u) (p1o4dydz*((u)[di*(0)+dj*(-1)+dk*(-1)] - (u)[di*(0)+dj*(-1)+dk*(1)] - (u)[di*(0)+dj*(1)+dk*(-1)] + (u)[di*(0)+dj*(1)+dk*(1)])) -#define PDzero33(u) (p1o4dz2*(-2*(u)[di*(0)+dj*(0)+dk*(0)] + (u)[di*(0)+dj*(0)+dk*(-2)] + (u)[di*(0)+dj*(0)+dk*(2)])) -#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)])) -#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)]) +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder21(u) ((-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx) +#else +# define PDstandardfdOrder21(u) (PDstandardfdOrder21_impl(u,p1o2dx,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder22(u) ((-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy) +#else +# define PDstandardfdOrder22(u) (PDstandardfdOrder22_impl(u,p1o2dy,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder23(u) ((-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz) +#else +# define PDstandardfdOrder23(u) (PDstandardfdOrder23_impl(u,p1o2dz,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder41(u) ((-8*KRANC_GFOFFSET3D(u,-1,0,0) + 8*KRANC_GFOFFSET3D(u,1,0,0) + KRANC_GFOFFSET3D(u,-2,0,0) - KRANC_GFOFFSET3D(u,2,0,0))*p1o12dx) +#else +# define PDstandardfdOrder41(u) (PDstandardfdOrder41_impl(u,p1o12dx,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder41_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder41_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dx, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-8*KRANC_GFOFFSET3D(u,-1,0,0) + 8*KRANC_GFOFFSET3D(u,1,0,0) + KRANC_GFOFFSET3D(u,-2,0,0) - KRANC_GFOFFSET3D(u,2,0,0))*p1o12dx; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder42(u) ((-8*KRANC_GFOFFSET3D(u,0,-1,0) + 8*KRANC_GFOFFSET3D(u,0,1,0) + KRANC_GFOFFSET3D(u,0,-2,0) - KRANC_GFOFFSET3D(u,0,2,0))*p1o12dy) +#else +# define PDstandardfdOrder42(u) (PDstandardfdOrder42_impl(u,p1o12dy,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder42_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder42_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-8*KRANC_GFOFFSET3D(u,0,-1,0) + 8*KRANC_GFOFFSET3D(u,0,1,0) + KRANC_GFOFFSET3D(u,0,-2,0) - KRANC_GFOFFSET3D(u,0,2,0))*p1o12dy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder43(u) ((-8*KRANC_GFOFFSET3D(u,0,0,-1) + 8*KRANC_GFOFFSET3D(u,0,0,1) + KRANC_GFOFFSET3D(u,0,0,-2) - KRANC_GFOFFSET3D(u,0,0,2))*p1o12dz) +#else +# define PDstandardfdOrder43(u) (PDstandardfdOrder43_impl(u,p1o12dz,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder43_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder43_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o12dz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-8*KRANC_GFOFFSET3D(u,0,0,-1) + 8*KRANC_GFOFFSET3D(u,0,0,1) + KRANC_GFOFFSET3D(u,0,0,-2) - KRANC_GFOFFSET3D(u,0,0,2))*p1o12dz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder211(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx2) +#else +# define PDstandardfdOrder211(u) (PDstandardfdOrder211_impl(u,p1odx2,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder211_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder211_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odx2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder222(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody2) +#else +# define PDstandardfdOrder222(u) (PDstandardfdOrder222_impl(u,p1ody2,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder222_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder222_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder233(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz2) +#else +# define PDstandardfdOrder233(u) (PDstandardfdOrder233_impl(u,p1odz2,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder233_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder233_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder411(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*pm1o12dx2) +#else +# define PDstandardfdOrder411(u) (PDstandardfdOrder411_impl(u,pm1o12dx2,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder411_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder411_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dx2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*pm1o12dx2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder422(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*pm1o12dy2) +#else +# define PDstandardfdOrder422(u) (PDstandardfdOrder422_impl(u,pm1o12dy2,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder422_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dy2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder422_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dy2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*pm1o12dy2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder433(u) ((30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*pm1o12dz2) +#else +# define PDstandardfdOrder433(u) (PDstandardfdOrder433_impl(u,pm1o12dz2,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder433_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder433_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o12dz2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (30*KRANC_GFOFFSET3D(u,0,0,0) - 16*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*pm1o12dz2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder212(u) ((KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy) +#else +# define PDstandardfdOrder212(u) (PDstandardfdOrder212_impl(u,p1o4dxdy,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder212_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder212_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder213(u) ((KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz) +#else +# define PDstandardfdOrder213(u) (PDstandardfdOrder213_impl(u,p1o4dxdz,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder213_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder213_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder221(u) ((KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy) +#else +# define PDstandardfdOrder221(u) (PDstandardfdOrder221_impl(u,p1o4dxdy,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder221_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder221_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder223(u) ((KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz) +#else +# define PDstandardfdOrder223(u) (PDstandardfdOrder223_impl(u,p1o4dydz,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder223_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder223_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder231(u) ((KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz) +#else +# define PDstandardfdOrder231(u) (PDstandardfdOrder231_impl(u,p1o4dxdz,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder231_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder231_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder232(u) ((KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz) +#else +# define PDstandardfdOrder232(u) (PDstandardfdOrder232_impl(u,p1o4dydz,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder232_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder232_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder412(u) ((-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy) +#else +# define PDstandardfdOrder412(u) (PDstandardfdOrder412_impl(u,p1o144dxdy,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder412_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder412_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder413(u) ((-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz) +#else +# define PDstandardfdOrder413(u) (PDstandardfdOrder413_impl(u,p1o144dxdz,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder413_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder413_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder421(u) ((-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy) +#else +# define PDstandardfdOrder421(u) (PDstandardfdOrder421_impl(u,p1o144dxdy,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder421_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder421_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,1,0) + KRANC_GFOFFSET3D(u,1,-1,0)) + 64*(KRANC_GFOFFSET3D(u,-1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0)) + 8*(KRANC_GFOFFSET3D(u,-1,2,0) + KRANC_GFOFFSET3D(u,1,-2,0) + KRANC_GFOFFSET3D(u,-2,1,0) + KRANC_GFOFFSET3D(u,2,-1,0)) - 8*(KRANC_GFOFFSET3D(u,-1,-2,0) + KRANC_GFOFFSET3D(u,1,2,0) + KRANC_GFOFFSET3D(u,-2,-1,0) + KRANC_GFOFFSET3D(u,2,1,0)) + KRANC_GFOFFSET3D(u,-2,-2,0) - KRANC_GFOFFSET3D(u,-2,2,0) - KRANC_GFOFFSET3D(u,2,-2,0) + KRANC_GFOFFSET3D(u,2,2,0))*p1o144dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder423(u) ((-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz) +#else +# define PDstandardfdOrder423(u) (PDstandardfdOrder423_impl(u,p1o144dydz,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder423_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder423_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder431(u) ((-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz) +#else +# define PDstandardfdOrder431(u) (PDstandardfdOrder431_impl(u,p1o144dxdz,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder431_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder431_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,-1,0,1) + KRANC_GFOFFSET3D(u,1,0,-1)) + 64*(KRANC_GFOFFSET3D(u,-1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1)) + 8*(KRANC_GFOFFSET3D(u,-1,0,2) + KRANC_GFOFFSET3D(u,1,0,-2) + KRANC_GFOFFSET3D(u,-2,0,1) + KRANC_GFOFFSET3D(u,2,0,-1)) - 8*(KRANC_GFOFFSET3D(u,-1,0,-2) + KRANC_GFOFFSET3D(u,1,0,2) + KRANC_GFOFFSET3D(u,-2,0,-1) + KRANC_GFOFFSET3D(u,2,0,1)) + KRANC_GFOFFSET3D(u,-2,0,-2) - KRANC_GFOFFSET3D(u,-2,0,2) - KRANC_GFOFFSET3D(u,2,0,-2) + KRANC_GFOFFSET3D(u,2,0,2))*p1o144dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDstandardfdOrder432(u) ((-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz) +#else +# define PDstandardfdOrder432(u) (PDstandardfdOrder432_impl(u,p1o144dydz,cdj,cdk)) +static CCTK_REAL PDstandardfdOrder432_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDstandardfdOrder432_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o144dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-64*(KRANC_GFOFFSET3D(u,0,-1,1) + KRANC_GFOFFSET3D(u,0,1,-1)) + 64*(KRANC_GFOFFSET3D(u,0,-1,-1) + KRANC_GFOFFSET3D(u,0,1,1)) + 8*(KRANC_GFOFFSET3D(u,0,-1,2) + KRANC_GFOFFSET3D(u,0,1,-2) + KRANC_GFOFFSET3D(u,0,-2,1) + KRANC_GFOFFSET3D(u,0,2,-1)) - 8*(KRANC_GFOFFSET3D(u,0,-1,-2) + KRANC_GFOFFSET3D(u,0,1,2) + KRANC_GFOFFSET3D(u,0,-2,-1) + KRANC_GFOFFSET3D(u,0,2,1)) + KRANC_GFOFFSET3D(u,0,-2,-2) - KRANC_GFOFFSET3D(u,0,-2,2) - KRANC_GFOFFSET3D(u,0,2,-2) + KRANC_GFOFFSET3D(u,0,2,2))*p1o144dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDonesided2nd1(u) ((3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,2*dir1,0,0) - 4*KRANC_GFOFFSET3D(u,dir1,0,0))*pm1o2dx*dir1) +#else +# define PDonesided2nd1(u) (PDonesided2nd1_impl(u,pm1o2dx,cdj,cdk,dir1,dir2,dir3)) +static CCTK_REAL PDonesided2nd1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk, ptrdiff_t const dir1, ptrdiff_t const dir2, ptrdiff_t const dir3) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDonesided2nd1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk, ptrdiff_t const dir1, ptrdiff_t const dir2, ptrdiff_t const dir3) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,2*dir1,0,0) - 4*KRANC_GFOFFSET3D(u,dir1,0,0))*pm1o2dx*dir1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDonesided2nd2(u) ((3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,2*dir2,0) - 4*KRANC_GFOFFSET3D(u,0,dir2,0))*pm1o2dy*dir2) +#else +# define PDonesided2nd2(u) (PDonesided2nd2_impl(u,pm1o2dy,cdj,cdk,dir1,dir2,dir3)) +static CCTK_REAL PDonesided2nd2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk, ptrdiff_t const dir1, ptrdiff_t const dir2, ptrdiff_t const dir3) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDonesided2nd2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk, ptrdiff_t const dir1, ptrdiff_t const dir2, ptrdiff_t const dir3) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,2*dir2,0) - 4*KRANC_GFOFFSET3D(u,0,dir2,0))*pm1o2dy*dir2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDonesided2nd3(u) ((3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,2*dir3) - 4*KRANC_GFOFFSET3D(u,0,0,dir3))*pm1o2dz*dir3) +#else +# define PDonesided2nd3(u) (PDonesided2nd3_impl(u,pm1o2dz,cdj,cdk,dir1,dir2,dir3)) +static CCTK_REAL PDonesided2nd3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk, ptrdiff_t const dir1, ptrdiff_t const dir2, ptrdiff_t const dir3) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDonesided2nd3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const pm1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk, ptrdiff_t const dir1, ptrdiff_t const dir2, ptrdiff_t const dir3) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (3*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,2*dir3) - 4*KRANC_GFOFFSET3D(u,0,0,dir3))*pm1o2dz*dir3; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DissfdOrder2(u) (-(p1odxdydz*diss*((6*KRANC_GFOFFSET3D(u,0,0,0) - 4*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*INV(dxi)*INV(dyi) + ((6*KRANC_GFOFFSET3D(u,0,0,0) - 4*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*INV(dxi) + (6*KRANC_GFOFFSET3D(u,0,0,0) - 4*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*INV(dyi))*INV(dzi)))) +#else +# define DissfdOrder2(u) (DissfdOrder2_impl(u,p1odxdydz,cdj,cdk)) +static CCTK_REAL DissfdOrder2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odxdydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DissfdOrder2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odxdydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return -(p1odxdydz*diss*((6*KRANC_GFOFFSET3D(u,0,0,0) - 4*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*INV(dxi)*INV(dyi) + ((6*KRANC_GFOFFSET3D(u,0,0,0) - 4*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*INV(dxi) + (6*KRANC_GFOFFSET3D(u,0,0,0) - 4*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*INV(dyi))*INV(dzi))); +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DissfdOrder4(u) (p1odxdydz*diss*((-20*KRANC_GFOFFSET3D(u,0,0,0) + 15*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) - 6*(KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2)) + KRANC_GFOFFSET3D(u,0,0,-3) + KRANC_GFOFFSET3D(u,0,0,3))*INV(dxi)*INV(dyi) + ((15*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) - 6*(KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0)) + KRANC_GFOFFSET3D(u,0,-3,0) + KRANC_GFOFFSET3D(u,0,3,0))*INV(dxi) + (15*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) - 6*(KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0)) + KRANC_GFOFFSET3D(u,-3,0,0) + KRANC_GFOFFSET3D(u,3,0,0))*INV(dyi) - 20*KRANC_GFOFFSET3D(u,0,0,0)*(INV(dxi) + INV(dyi)))*INV(dzi))) +#else +# define DissfdOrder4(u) (DissfdOrder4_impl(u,p1odxdydz,cdj,cdk)) +static CCTK_REAL DissfdOrder4_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odxdydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DissfdOrder4_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odxdydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return p1odxdydz*diss*((-20*KRANC_GFOFFSET3D(u,0,0,0) + 15*(KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1)) - 6*(KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2)) + KRANC_GFOFFSET3D(u,0,0,-3) + KRANC_GFOFFSET3D(u,0,0,3))*INV(dxi)*INV(dyi) + ((15*(KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0)) - 6*(KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0)) + KRANC_GFOFFSET3D(u,0,-3,0) + KRANC_GFOFFSET3D(u,0,3,0))*INV(dxi) + (15*(KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0)) - 6*(KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0)) + KRANC_GFOFFSET3D(u,-3,0,0) + KRANC_GFOFFSET3D(u,3,0,0))*INV(dyi) - 20*KRANC_GFOFFSET3D(u,0,0,0)*(INV(dxi) + INV(dyi)))*INV(dzi)); +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero1(u) ((-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx) +#else +# define PDzero1(u) (PDzero1_impl(u,p1o2dx,cdj,cdk)) +static CCTK_REAL PDzero1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dx, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,-1,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o2dx; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero2(u) ((-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy) +#else +# define PDzero2(u) (PDzero2_impl(u,p1o2dy,cdj,cdk)) +static CCTK_REAL PDzero2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,0,-1,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o2dy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero3(u) ((-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz) +#else +# define PDzero3(u) (PDzero3_impl(u,p1o2dz,cdj,cdk)) +static CCTK_REAL PDzero3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o2dz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-KRANC_GFOFFSET3D(u,0,0,-1) + KRANC_GFOFFSET3D(u,0,0,1))*p1o2dz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero11(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*p1o4dx2) +#else +# define PDzero11(u) (PDzero11_impl(u,p1o4dx2,cdj,cdk)) +static CCTK_REAL PDzero11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dx2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero11_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dx2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,-2,0,0) + KRANC_GFOFFSET3D(u,2,0,0))*p1o4dx2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero12(u) ((KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy) +#else +# define PDzero12(u) (PDzero12_impl(u,p1o4dxdy,cdj,cdk)) +static CCTK_REAL PDzero12_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero12_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero13(u) ((KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz) +#else +# define PDzero13(u) (PDzero13_impl(u,p1o4dxdz,cdj,cdk)) +static CCTK_REAL PDzero13_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero13_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero21(u) ((KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy) +#else +# define PDzero21(u) (PDzero21_impl(u,p1o4dxdy,cdj,cdk)) +static CCTK_REAL PDzero21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero21_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdy, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,-1,0) - KRANC_GFOFFSET3D(u,-1,1,0) - KRANC_GFOFFSET3D(u,1,-1,0) + KRANC_GFOFFSET3D(u,1,1,0))*p1o4dxdy; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero22(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*p1o4dy2) +#else +# define PDzero22(u) (PDzero22_impl(u,p1o4dy2,cdj,cdk)) +static CCTK_REAL PDzero22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dy2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero22_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dy2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,-2,0) + KRANC_GFOFFSET3D(u,0,2,0))*p1o4dy2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero23(u) ((KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz) +#else +# define PDzero23(u) (PDzero23_impl(u,p1o4dydz,cdj,cdk)) +static CCTK_REAL PDzero23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero23_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero31(u) ((KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz) +#else +# define PDzero31(u) (PDzero31_impl(u,p1o4dxdz,cdj,cdk)) +static CCTK_REAL PDzero31_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero31_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dxdz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,-1,0,-1) - KRANC_GFOFFSET3D(u,-1,0,1) - KRANC_GFOFFSET3D(u,1,0,-1) + KRANC_GFOFFSET3D(u,1,0,1))*p1o4dxdz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero32(u) ((KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz) +#else +# define PDzero32(u) (PDzero32_impl(u,p1o4dydz,cdj,cdk)) +static CCTK_REAL PDzero32_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero32_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dydz, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (KRANC_GFOFFSET3D(u,0,-1,-1) - KRANC_GFOFFSET3D(u,0,-1,1) - KRANC_GFOFFSET3D(u,0,1,-1) + KRANC_GFOFFSET3D(u,0,1,1))*p1o4dydz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDzero33(u) ((-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*p1o4dz2) +#else +# define PDzero33(u) (PDzero33_impl(u,p1o4dz2,cdj,cdk)) +static CCTK_REAL PDzero33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dz2, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDzero33_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o4dz2, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return (-2*KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,-2) + KRANC_GFOFFSET3D(u,0,0,2))*p1o4dz2; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1odx) +#else +# define PDplus1(u) (PDplus1_impl(u,p1odx,cdj,cdk)) +static CCTK_REAL PDplus1_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 PDplus1_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 + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1ody) +#else +# define PDplus2(u) (PDplus2_impl(u,p1ody,cdj,cdk)) +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1ody, 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,0,1,0))*p1ody; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define PDplus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1odz) +#else +# define PDplus3(u) (PDplus3_impl(u,p1odz,cdj,cdk)) +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL PDplus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1odz, 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,0,0,1))*p1odz; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus1(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,1,0,0))*p1o1) +#else +# define DiffPlus1(u) (DiffPlus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus2(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,1,0))*p1o1) +#else +# define DiffPlus2(u) (DiffPlus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffPlus3(u) ((-KRANC_GFOFFSET3D(u,0,0,0) + KRANC_GFOFFSET3D(u,0,0,1))*p1o1) +#else +# define DiffPlus3(u) (DiffPlus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffPlus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus1(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,-1,0,0))*p1o1) +#else +# define DiffMinus1(u) (DiffMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus2(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,-1,0))*p1o1) +#else +# define DiffMinus2(u) (DiffMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,-1,0))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define DiffMinus3(u) ((KRANC_GFOFFSET3D(u,0,0,0) - KRANC_GFOFFSET3D(u,0,0,-1))*p1o1) +#else +# define DiffMinus3(u) (DiffMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL DiffMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, 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,0,0,-1))*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus1(u) (KRANC_GFOFFSET3D(u,-1,0,0)*p1o1) +#else +# define ShiftMinus1(u) (ShiftMinus1_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus1_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,-1,0,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus2(u) (KRANC_GFOFFSET3D(u,0,-1,0)*p1o1) +#else +# define ShiftMinus2(u) (ShiftMinus2_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus2_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,-1,0)*p1o1; +} +#endif + +#ifndef KRANC_DIFF_FUNCTIONS +# define ShiftMinus3(u) (KRANC_GFOFFSET3D(u,0,0,-1)*p1o1) +#else +# define ShiftMinus3(u) (ShiftMinus3_impl(u,p1o1,cdj,cdk)) +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) CCTK_ATTRIBUTE_NOINLINE CCTK_ATTRIBUTE_UNUSED; +static CCTK_REAL ShiftMinus3_impl(CCTK_REAL const* restrict const u, CCTK_REAL const p1o1, ptrdiff_t const cdj, ptrdiff_t const cdk) +{ + ptrdiff_t const cdi=sizeof(CCTK_REAL); + return KRANC_GFOFFSET3D(u,0,0,-1)*p1o1; +} +#endif + diff --git a/Examples/Wave/src/RegisterMoL.cc b/Examples/Wave/src/RegisterMoL.cc index 2d73922..623b8e3 100644 --- a/Examples/Wave/src/RegisterMoL.cc +++ b/Examples/Wave/src/RegisterMoL.cc @@ -14,5 +14,7 @@ extern "C" void Wave_RegisterVars(CCTK_ARGUMENTS) /* Register all the evolved grid functions with MoL */ ierr += MoLRegisterEvolved(CCTK_VarIndex("Wave::phi"), CCTK_VarIndex("Wave::phirhs")); ierr += MoLRegisterEvolved(CCTK_VarIndex("Wave::pi"), CCTK_VarIndex("Wave::pirhs")); + + /* Register all the evolved Array functions with MoL */ return; } diff --git a/Examples/Wave/src/wave_boundary.cc b/Examples/Wave/src/wave_boundary.cc index 0341182..2ec1e2c 100644 --- a/Examples/Wave/src/wave_boundary.cc +++ b/Examples/Wave/src/wave_boundary.cc @@ -12,6 +12,8 @@ #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) @@ -32,43 +34,28 @@ extern "C" void wave_boundary_SelectBCs(CCTK_ARGUMENTS) return; } -static void wave_boundary_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[]) +static void wave_boundary_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; - /* 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 wave_boundary_Body"); - } - - if (cctk_iteration % wave_boundary_calc_every != wave_boundary_calc_offset) - { - return; - } - - const char *groups[] = {"Wave::evolved","Wave::evolvedrhs","grid::coordinates"}; - GenericFD_AssertGroupStorage(cctkGH, "wave_boundary", 3, groups); - - GenericFD_EnsureStencilFits(cctkGH, "wave_boundary", 2, 2, 2); - /* 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); @@ -112,56 +99,71 @@ static void wave_boundary_Body(cGH const * restrict const cctkGH, int const dir, CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (wave_boundary, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - for (j = min[1]; j < max[1]; j++) + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL phiL = phi[index]; + CCTK_REAL piL = pi[index]; + CCTK_REAL rL = r[index]; + CCTK_REAL xL = x[index]; + CCTK_REAL yL = y[index]; + CCTK_REAL zL = z[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + switch(fdOrder) { - 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 phiL = phi[index]; - CCTK_REAL piL = pi[index]; - CCTK_REAL rL = r[index]; - CCTK_REAL xL = x[index]; - CCTK_REAL yL = y[index]; - CCTK_REAL zL = z[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL norm1 = -(xL*INV(rL)); - - CCTK_REAL norm2 = -(yL*INV(rL)); - - CCTK_REAL norm3 = -(zL*INV(rL)); - - ptrdiff_t dir1 = Sign(norm1); - - ptrdiff_t dir2 = Sign(norm2); - - ptrdiff_t dir3 = Sign(norm3); - - CCTK_REAL phirhsL = PDonesided2nd1(&phi[index])*norm1 + - PDonesided2nd2(&phi[index])*norm2 + - PDonesided2nd3(&phi[index])*norm3 - phiL*INV(rL); - - CCTK_REAL pirhsL = PDonesided2nd1(&pi[index])*norm1 + - PDonesided2nd2(&pi[index])*norm2 + PDonesided2nd3(&pi[index])*norm3 - - piL*INV(rL); - - /* Copy local copies back to grid functions */ - phirhs[index] = phirhsL; - pirhs[index] = pirhsL; - } + case 2: + break; + + case 4: + break; } + + /* Calculate temporaries and grid functions */ + CCTK_REAL norm1 = -(xL*INV(rL)); + + CCTK_REAL norm2 = -(yL*INV(rL)); + + CCTK_REAL norm3 = -(zL*INV(rL)); + + ptrdiff_t dir1 = Sign(norm1); + + ptrdiff_t dir2 = Sign(norm2); + + ptrdiff_t dir3 = Sign(norm3); + + CCTK_REAL phirhsL = PDonesided2nd1(&phi[index])*norm1 + + PDonesided2nd2(&phi[index])*norm2 + + PDonesided2nd3(&phi[index])*norm3 - phiL*INV(rL); + + CCTK_REAL pirhsL = PDonesided2nd1(&pi[index])*norm1 + + PDonesided2nd2(&pi[index])*norm2 + PDonesided2nd3(&pi[index])*norm3 + - piL*INV(rL); + + /* Copy local copies back to grid functions */ + phirhs[index] = phirhsL; + pirhs[index] = pirhsL; } + CCTK_ENDLOOP3 (wave_boundary); } extern "C" void wave_boundary(CCTK_ARGUMENTS) @@ -169,5 +171,35 @@ extern "C" void wave_boundary(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering wave_boundary_Body"); + } + + if (cctk_iteration % wave_boundary_calc_every != wave_boundary_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::evolved","Wave::evolvedrhs","grid::coordinates"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_boundary", 3, groups); + + switch(fdOrder) + { + case 2: + GenericFD_EnsureStencilFits(cctkGH, "wave_boundary", 2, 2, 2); + break; + + case 4: + GenericFD_EnsureStencilFits(cctkGH, "wave_boundary", 2, 2, 2); + break; + } + GenericFD_LoopOverBoundary(cctkGH, &wave_boundary_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving wave_boundary_Body"); + } } diff --git a/Examples/Wave/src/wave_calc_errors.cc b/Examples/Wave/src/wave_calc_errors.cc index 395f33a..a133c1a 100644 --- a/Examples/Wave/src/wave_calc_errors.cc +++ b/Examples/Wave/src/wave_calc_errors.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void wave_calc_errors_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[]) +static void wave_calc_errors_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; - /* 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 wave_calc_errors_Body"); - } - - if (cctk_iteration % wave_calc_errors_calc_every != wave_calc_errors_calc_offset) - { - return; - } - - const char *groups[] = {"Wave::errors","Wave::evolved","Wave::exact"}; - GenericFD_AssertGroupStorage(cctkGH, "wave_calc_errors", 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); + 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); @@ -99,38 +87,53 @@ static void wave_calc_errors_Body(cGH const * restrict const cctkGH, int const d CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (wave_calc_errors, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - for (j = min[1]; j < max[1]; j++) + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL phiL = phi[index]; + CCTK_REAL phiExactL = phiExact[index]; + CCTK_REAL piL = pi[index]; + CCTK_REAL piExactL = piExact[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + switch(fdOrder) { - 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 phiL = phi[index]; - CCTK_REAL phiExactL = phiExact[index]; - CCTK_REAL piL = pi[index]; - CCTK_REAL piExactL = piExact[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL phiErrorL = -phiExactL + phiL; - - CCTK_REAL piErrorL = -piExactL + piL; - - /* Copy local copies back to grid functions */ - phiError[index] = phiErrorL; - piError[index] = piErrorL; - } + case 2: + break; + + case 4: + break; } + + /* Calculate temporaries and grid functions */ + CCTK_REAL phiErrorL = -phiExactL + phiL; + + CCTK_REAL piErrorL = -piExactL + piL; + + /* Copy local copies back to grid functions */ + phiError[index] = phiErrorL; + piError[index] = piErrorL; } + CCTK_ENDLOOP3 (wave_calc_errors); } extern "C" void wave_calc_errors(CCTK_ARGUMENTS) @@ -138,5 +141,33 @@ extern "C" void wave_calc_errors(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering wave_calc_errors_Body"); + } + + if (cctk_iteration % wave_calc_errors_calc_every != wave_calc_errors_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::errors","Wave::evolved","Wave::exact"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_calc_errors", 3, groups); + + switch(fdOrder) + { + case 2: + break; + + case 4: + break; + } + GenericFD_LoopOverEverything(cctkGH, &wave_calc_errors_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving wave_calc_errors_Body"); + } } diff --git a/Examples/Wave/src/wave_calc_norm.cc b/Examples/Wave/src/wave_calc_norm.cc index 9546f10..7e15d73 100644 --- a/Examples/Wave/src/wave_calc_norm.cc +++ b/Examples/Wave/src/wave_calc_norm.cc @@ -12,6 +12,8 @@ #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) @@ -32,43 +34,28 @@ extern "C" void wave_calc_norm_SelectBCs(CCTK_ARGUMENTS) return; } -static void wave_calc_norm_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[]) +static void wave_calc_norm_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; - /* 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 wave_calc_norm_Body"); - } - - if (cctk_iteration % wave_calc_norm_calc_every != wave_calc_norm_calc_offset) - { - return; - } - - const char *groups[] = {"Wave::errors","Wave::evolved","Wave::norms"}; - GenericFD_AssertGroupStorage(cctkGH, "wave_calc_norm", 3, groups); - - GenericFD_EnsureStencilFits(cctkGH, "wave_calc_norm", 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); + 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); @@ -112,51 +99,72 @@ static void wave_calc_norm_Body(cGH const * restrict const cctkGH, int const dir CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (wave_calc_norm, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - for (j = min[1]; j < max[1]; j++) + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL phiL = phi[index]; + CCTK_REAL phiErrorL = phiError[index]; + CCTK_REAL piL = pi[index]; + CCTK_REAL piErrorL = piError[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL PDplus1phi; + CCTK_REAL PDplus2phi; + CCTK_REAL PDplus3phi; + + switch(fdOrder) { - 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 phiL = phi[index]; - CCTK_REAL phiErrorL = phiError[index]; - CCTK_REAL piL = pi[index]; - CCTK_REAL piErrorL = piError[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - CCTK_REAL const PDplus1phi = PDplus1(&phi[index]); - CCTK_REAL const PDplus2phi = PDplus2(&phi[index]); - CCTK_REAL const PDplus3phi = PDplus3(&phi[index]); - - /* Calculate temporaries and grid functions */ - CCTK_REAL VL2squared = SQR(phiL) + SQR(piL); - - CCTK_REAL VL2L = sqrt(VL2squared); - - CCTK_REAL VDPsquared = SQR(PDplus1phi) + SQR(PDplus2phi) + - SQR(PDplus3phi) + SQR(piL); - - CCTK_REAL VDPL = sqrt(VDPsquared); - - CCTK_REAL EL2squared = SQR(phiErrorL) + SQR(piErrorL); - - CCTK_REAL EL2L = sqrt(EL2squared); - - /* Copy local copies back to grid functions */ - EL2[index] = EL2L; - VDP[index] = VDPL; - VL2[index] = VL2L; - } + case 2: + PDplus1phi = PDplus1(&phi[index]); + PDplus2phi = PDplus2(&phi[index]); + PDplus3phi = PDplus3(&phi[index]); + break; + + case 4: + PDplus1phi = PDplus1(&phi[index]); + PDplus2phi = PDplus2(&phi[index]); + PDplus3phi = PDplus3(&phi[index]); + break; } + + /* Calculate temporaries and grid functions */ + CCTK_REAL VL2squared = SQR(phiL) + SQR(piL); + + CCTK_REAL VL2L = sqrt(VL2squared); + + CCTK_REAL VDPsquared = SQR(piL) + SQR(PDplus1phi) + SQR(PDplus2phi) + + SQR(PDplus3phi); + + CCTK_REAL VDPL = sqrt(VDPsquared); + + CCTK_REAL EL2squared = SQR(phiErrorL) + SQR(piErrorL); + + CCTK_REAL EL2L = sqrt(EL2squared); + + /* Copy local copies back to grid functions */ + EL2[index] = EL2L; + VDP[index] = VDPL; + VL2[index] = VL2L; } + CCTK_ENDLOOP3 (wave_calc_norm); } extern "C" void wave_calc_norm(CCTK_ARGUMENTS) @@ -164,5 +172,35 @@ extern "C" void wave_calc_norm(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering wave_calc_norm_Body"); + } + + if (cctk_iteration % wave_calc_norm_calc_every != wave_calc_norm_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::errors","Wave::evolved","Wave::norms"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_calc_norm", 3, groups); + + switch(fdOrder) + { + case 2: + GenericFD_EnsureStencilFits(cctkGH, "wave_calc_norm", 1, 1, 1); + break; + + case 4: + GenericFD_EnsureStencilFits(cctkGH, "wave_calc_norm", 1, 1, 1); + break; + } + GenericFD_LoopOverInterior(cctkGH, &wave_calc_norm_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving wave_calc_norm_Body"); + } } diff --git a/Examples/Wave/src/wave_evolve.cc b/Examples/Wave/src/wave_evolve.cc index b3d11e1..5c6314d 100644 --- a/Examples/Wave/src/wave_evolve.cc +++ b/Examples/Wave/src/wave_evolve.cc @@ -12,6 +12,8 @@ #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) @@ -32,43 +34,28 @@ extern "C" void wave_evolve_SelectBCs(CCTK_ARGUMENTS) return; } -static void wave_evolve_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[]) +static void wave_evolve_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; - /* 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 wave_evolve_Body"); - } - - if (cctk_iteration % wave_evolve_calc_every != wave_evolve_calc_offset) - { - return; - } - - const char *groups[] = {"Wave::evolved","Wave::evolvedrhs"}; - GenericFD_AssertGroupStorage(cctkGH, "wave_evolve", 2, groups); - - GenericFD_EnsureStencilFits(cctkGH, "wave_evolve", 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); + 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); @@ -112,40 +99,61 @@ static void wave_evolve_Body(cGH const * restrict const cctkGH, int const dir, i CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (wave_evolve, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - for (j = min[1]; j < max[1]; j++) + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL phiL = phi[index]; + CCTK_REAL piL = pi[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + CCTK_REAL PDstandard11phi; + CCTK_REAL PDstandard22phi; + CCTK_REAL PDstandard33phi; + + switch(fdOrder) { - 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 phiL = phi[index]; - CCTK_REAL piL = pi[index]; - - - /* 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 */ - phirhs[index] = phirhsL; - pirhs[index] = pirhsL; - } + case 2: + PDstandard11phi = PDstandardfdOrder211(&phi[index]); + PDstandard22phi = PDstandardfdOrder222(&phi[index]); + PDstandard33phi = PDstandardfdOrder233(&phi[index]); + break; + + case 4: + PDstandard11phi = PDstandardfdOrder411(&phi[index]); + PDstandard22phi = PDstandardfdOrder422(&phi[index]); + PDstandard33phi = PDstandardfdOrder433(&phi[index]); + break; } + + /* Calculate temporaries and grid functions */ + CCTK_REAL phirhsL = piL; + + CCTK_REAL pirhsL = PDstandard11phi + PDstandard22phi + + PDstandard33phi; + + /* Copy local copies back to grid functions */ + phirhs[index] = phirhsL; + pirhs[index] = pirhsL; } + CCTK_ENDLOOP3 (wave_evolve); } extern "C" void wave_evolve(CCTK_ARGUMENTS) @@ -153,5 +161,35 @@ extern "C" void wave_evolve(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering wave_evolve_Body"); + } + + if (cctk_iteration % wave_evolve_calc_every != wave_evolve_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::evolved","Wave::evolvedrhs"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_evolve", 2, groups); + + switch(fdOrder) + { + case 2: + GenericFD_EnsureStencilFits(cctkGH, "wave_evolve", 1, 1, 1); + break; + + case 4: + GenericFD_EnsureStencilFits(cctkGH, "wave_evolve", 2, 2, 2); + break; + } + GenericFD_LoopOverInterior(cctkGH, &wave_evolve_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving wave_evolve_Body"); + } } diff --git a/Examples/Wave/src/wave_exact_gaussian.cc b/Examples/Wave/src/wave_exact_gaussian.cc index 1efc9b5..ed37143 100644 --- a/Examples/Wave/src/wave_exact_gaussian.cc +++ b/Examples/Wave/src/wave_exact_gaussian.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void wave_exact_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 min[3], int const max[3], int const n_subblock_gfs, CCTK_REAL * restrict const subblock_gfs[]) +static void wave_exact_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; - /* 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 wave_exact_gaussian_Body"); - } - - if (cctk_iteration % wave_exact_gaussian_calc_every != wave_exact_gaussian_calc_offset) - { - return; - } - - const char *groups[] = {"Wave::exact","grid::coordinates"}; - GenericFD_AssertGroupStorage(cctkGH, "wave_exact_gaussian", 2, 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); + 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); @@ -99,48 +87,63 @@ static void wave_exact_gaussian_Body(cGH const * restrict const cctkGH, int cons CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (wave_exact_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]) { - for (j = min[1]; j < max[1]; j++) + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL rL = r[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + switch(fdOrder) { - 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 rL = r[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL rEps = pow(1.e-24 + QAD(rL),0.25); - - CCTK_REAL phiExactL = (-(CUB(-rL + cctk_time + - ToReal(t0))*exp(-(INV(SQR(ToReal(nSigma)))*SQR(-rL + cctk_time + - ToReal(t0))))) + CUB(rL + cctk_time + - ToReal(t0))*exp(-(INV(SQR(ToReal(nSigma)))*SQR(rL + cctk_time + - ToReal(t0)))))*INV(rEps); - - CCTK_REAL piExactL = - INV(rEps)*(INV(SQR(ToReal(nSigma)))*(2*exp(-(INV(SQR(ToReal(nSigma)))*SQR(-rL - + cctk_time + ToReal(t0))))*QAD(-rL + cctk_time + ToReal(t0)) - - 2*exp(-(INV(SQR(ToReal(nSigma)))*SQR(rL + cctk_time + ToReal(t0))))*QAD(rL + - cctk_time + ToReal(t0))) - 3*exp(-(INV(SQR(ToReal(nSigma)))*SQR(-rL + cctk_time + - ToReal(t0))))*SQR(-rL + cctk_time + ToReal(t0)) + - 3*exp(-(INV(SQR(ToReal(nSigma)))*SQR(rL + cctk_time + ToReal(t0))))*SQR(rL + - cctk_time + ToReal(t0))); - - /* Copy local copies back to grid functions */ - phiExact[index] = phiExactL; - piExact[index] = piExactL; - } + case 2: + break; + + case 4: + break; } + + /* Calculate temporaries and grid functions */ + CCTK_REAL rEps = pow(1.e-24 + QAD(rL),0.25); + + CCTK_REAL phiExactL = (-(CUB(-rL + cctk_time + + ToReal(t0))*exp(-(INV(SQR(ToReal(nSigma)))*SQR(-rL + cctk_time + + ToReal(t0))))) + CUB(rL + cctk_time + + ToReal(t0))*exp(-(INV(SQR(ToReal(nSigma)))*SQR(rL + cctk_time + + ToReal(t0)))))*INV(rEps); + + CCTK_REAL piExactL = + INV(rEps)*(INV(SQR(ToReal(nSigma)))*(2*exp(-(INV(SQR(ToReal(nSigma)))*SQR(-rL + + cctk_time + ToReal(t0))))*QAD(-rL + cctk_time + ToReal(t0)) - + 2*exp(-(INV(SQR(ToReal(nSigma)))*SQR(rL + cctk_time + ToReal(t0))))*QAD(rL + + cctk_time + ToReal(t0))) - 3*exp(-(INV(SQR(ToReal(nSigma)))*SQR(-rL + cctk_time + + ToReal(t0))))*SQR(-rL + cctk_time + ToReal(t0)) + + 3*exp(-(INV(SQR(ToReal(nSigma)))*SQR(rL + cctk_time + ToReal(t0))))*SQR(rL + + cctk_time + ToReal(t0))); + + /* Copy local copies back to grid functions */ + phiExact[index] = phiExactL; + piExact[index] = piExactL; } + CCTK_ENDLOOP3 (wave_exact_gaussian); } extern "C" void wave_exact_gaussian(CCTK_ARGUMENTS) @@ -148,5 +151,33 @@ extern "C" void wave_exact_gaussian(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering wave_exact_gaussian_Body"); + } + + if (cctk_iteration % wave_exact_gaussian_calc_every != wave_exact_gaussian_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::exact","grid::coordinates"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_exact_gaussian", 2, groups); + + switch(fdOrder) + { + case 2: + break; + + case 4: + break; + } + GenericFD_LoopOverEverything(cctkGH, &wave_exact_gaussian_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving wave_exact_gaussian_Body"); + } } diff --git a/Examples/Wave/src/wave_exact_sine.cc b/Examples/Wave/src/wave_exact_sine.cc index 96e788a..78c4251 100644 --- a/Examples/Wave/src/wave_exact_sine.cc +++ b/Examples/Wave/src/wave_exact_sine.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void wave_exact_sine_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[]) +static void wave_exact_sine_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; - /* 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 wave_exact_sine_Body"); - } - - if (cctk_iteration % wave_exact_sine_calc_every != wave_exact_sine_calc_offset) - { - return; - } - - const char *groups[] = {"Wave::exact","grid::coordinates"}; - GenericFD_AssertGroupStorage(cctkGH, "wave_exact_sine", 2, 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); + 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); @@ -99,46 +87,62 @@ static void wave_exact_sine_Body(cGH const * restrict const cctkGH, int const di CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (wave_exact_sine, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - for (j = min[1]; j < max[1]; j++) + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL xL = x[index]; + CCTK_REAL yL = y[index]; + CCTK_REAL zL = z[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + switch(fdOrder) { - 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]; - CCTK_REAL zL = z[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL piconst = 3.1415926535897932385; - - CCTK_REAL phiExactL = - Sin(2*piconst*INV(ToReal(periodicity))*(-(cctk_time*sqrt(SQR(ToReal(n1)) + - SQR(ToReal(n2)) + SQR(ToReal(n3)))) + xL*ToReal(n1) + yL*ToReal(n2) + - zL*ToReal(n3)))*ToReal(amplitude); - - CCTK_REAL piExactL = - -2*piconst*Cos(2*piconst*INV(ToReal(periodicity))*(-(cctk_time*sqrt(SQR(ToReal(n1)) - + SQR(ToReal(n2)) + SQR(ToReal(n3)))) + xL*ToReal(n1) + yL*ToReal(n2) + - zL*ToReal(n3)))*INV(ToReal(periodicity))*sqrt(SQR(ToReal(n1)) + - SQR(ToReal(n2)) + SQR(ToReal(n3)))*ToReal(amplitude); - - /* Copy local copies back to grid functions */ - phiExact[index] = phiExactL; - piExact[index] = piExactL; - } + case 2: + break; + + case 4: + break; } + + /* Calculate temporaries and grid functions */ + CCTK_REAL piconst = 3.1415926535897932385; + + CCTK_REAL phiExactL = + Sin(2*piconst*INV(ToReal(periodicity))*(-(cctk_time*sqrt(SQR(ToReal(n1)) + + SQR(ToReal(n2)) + SQR(ToReal(n3)))) + xL*ToReal(n1) + yL*ToReal(n2) + + zL*ToReal(n3)))*ToReal(amplitude); + + CCTK_REAL piExactL = + -2*piconst*Cos(2*piconst*INV(ToReal(periodicity))*(-(cctk_time*sqrt(SQR(ToReal(n1)) + + SQR(ToReal(n2)) + SQR(ToReal(n3)))) + xL*ToReal(n1) + + yL*ToReal(n2) + + zL*ToReal(n3)))*INV(ToReal(periodicity))*sqrt(SQR(ToReal(n1)) + + SQR(ToReal(n2)) + SQR(ToReal(n3)))*ToReal(amplitude); + + /* Copy local copies back to grid functions */ + phiExact[index] = phiExactL; + piExact[index] = piExactL; } + CCTK_ENDLOOP3 (wave_exact_sine); } extern "C" void wave_exact_sine(CCTK_ARGUMENTS) @@ -146,5 +150,33 @@ extern "C" void wave_exact_sine(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering wave_exact_sine_Body"); + } + + if (cctk_iteration % wave_exact_sine_calc_every != wave_exact_sine_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::exact","grid::coordinates"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_exact_sine", 2, groups); + + switch(fdOrder) + { + case 2: + break; + + case 4: + break; + } + GenericFD_LoopOverEverything(cctkGH, &wave_exact_sine_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving wave_exact_sine_Body"); + } } diff --git a/Examples/Wave/src/wave_import_exact.cc b/Examples/Wave/src/wave_import_exact.cc index 8263c88..840eef7 100644 --- a/Examples/Wave/src/wave_import_exact.cc +++ b/Examples/Wave/src/wave_import_exact.cc @@ -12,6 +12,8 @@ #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) @@ -20,42 +22,28 @@ #define SQR(x) ((x) * (x)) #define CUB(x) ((x) * (x) * (x)) -static void wave_import_exact_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[]) +static void wave_import_exact_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; - /* 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 wave_import_exact_Body"); - } - - if (cctk_iteration % wave_import_exact_calc_every != wave_import_exact_calc_offset) - { - return; - } - - const char *groups[] = {"Wave::evolved","Wave::exact"}; - GenericFD_AssertGroupStorage(cctkGH, "wave_import_exact", 2, 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); + 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); @@ -99,36 +87,51 @@ static void wave_import_exact_Body(cGH const * restrict const cctkGH, int const CCTK_REAL const pm1o2dy = -0.5*INV(dy); CCTK_REAL const pm1o2dz = -0.5*INV(dz); + /* Assign local copies of arrays functions */ + + + + /* Calculate temporaries and arrays functions */ + + /* Copy local copies back to grid functions */ + /* Loop over the grid points */ - for (k = min[2]; k < max[2]; k++) + #pragma omp parallel + CCTK_LOOP3 (wave_import_exact, + i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { - for (j = min[1]; j < max[1]; j++) + ptrdiff_t const index = di*i + dj*j + dk*k; + + /* Assign local copies of grid functions */ + + CCTK_REAL phiExactL = phiExact[index]; + CCTK_REAL piExactL = piExact[index]; + + + /* Include user supplied include files */ + + /* Precompute derivatives */ + + switch(fdOrder) { - 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 phiExactL = phiExact[index]; - CCTK_REAL piExactL = piExact[index]; - - - /* Include user supplied include files */ - - /* Precompute derivatives */ - - /* Calculate temporaries and grid functions */ - CCTK_REAL phiL = phiExactL; - - CCTK_REAL piL = piExactL; - - /* Copy local copies back to grid functions */ - phi[index] = phiL; - pi[index] = piL; - } + case 2: + break; + + case 4: + break; } + + /* Calculate temporaries and grid functions */ + CCTK_REAL phiL = phiExactL; + + CCTK_REAL piL = piExactL; + + /* Copy local copies back to grid functions */ + phi[index] = phiL; + pi[index] = piL; } + CCTK_ENDLOOP3 (wave_import_exact); } extern "C" void wave_import_exact(CCTK_ARGUMENTS) @@ -136,5 +139,33 @@ extern "C" void wave_import_exact(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Entering wave_import_exact_Body"); + } + + if (cctk_iteration % wave_import_exact_calc_every != wave_import_exact_calc_offset) + { + return; + } + + const char *groups[] = {"Wave::evolved","Wave::exact"}; + GenericFD_AssertGroupStorage(cctkGH, "wave_import_exact", 2, groups); + + switch(fdOrder) + { + case 2: + break; + + case 4: + break; + } + GenericFD_LoopOverEverything(cctkGH, &wave_import_exact_Body); + + if (verbose > 1) + { + CCTK_VInfo(CCTK_THORNSTRING,"Leaving wave_import_exact_Body"); + } } |