Repository: einsteintoolkit/Cactus — pull request #40 (cpp)
Title: Add missing WT_Standing.cc in McLachlan/ML_WaveToy

This PR adds the missing source file WT_Standing.cc to complete the McLachlan/ML_WaveToy thorn implementation.

Resolved issues:
title: Implement the full functionality of ML_WaveToy
body: Please implement the full functionality of `ML_WaveToy` by finishing the code in `WT_Standing.cc`.

## Thorn Information:
- Name: ML_WaveToy
- Target file: WT_Standing.cc

## Interface Definition in interface.ccl:

## Schedule Definition in schedule.ccl:

## Parameters Definition in param.ccl:

## Configuration Definition in configuration.ccl:

## Documentation Context in readme.md and doc/documentation.tex

## Related Code Context in src folder



Hints:

Fix patch:
diff --git a/arrangements/McLachlan/ML_WaveToy/src/WT_Standing.cc b/arrangements/McLachlan/ML_WaveToy/src/WT_Standing.cc
new file mode 100644
index 0000000..0000000
--- /dev/null
+++ b/arrangements/McLachlan/ML_WaveToy/src/WT_Standing.cc
@@ -0,0 +1,155 @@
+/*  File produced by Kranc */
+
+#define KRANC_C
+
+#include <algorithm>
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "Kranc.hh"
+#include "Differencing.h"
+#include "loopcontrol.h"
+#include "vectors.h"
+
+namespace ML_WaveToy {
+
+
+static void WT_Standing_Body(const cGH* restrict const cctkGH, const int dir, const int face, const CCTK_REAL normal[3], const CCTK_REAL tangentA[3], const CCTK_REAL tangentB[3], const int imin[3], const int imax[3], const int n_subblock_gfs, CCTK_REAL* restrict const subblock_gfs[])
+{
+  DECLARE_CCTK_ARGUMENTS;
+  DECLARE_CCTK_PARAMETERS;
+  
+  /* Include user-supplied include files */
+  /* Initialise finite differencing variables */
+  const ptrdiff_t di CCTK_ATTRIBUTE_UNUSED = 1;
+  const ptrdiff_t dj CCTK_ATTRIBUTE_UNUSED = 
+    CCTK_GFINDEX3D(cctkGH,0,1,0) - CCTK_GFINDEX3D(cctkGH,0,0,0);
+  const ptrdiff_t dk CCTK_ATTRIBUTE_UNUSED = 
+    CCTK_GFINDEX3D(cctkGH,0,0,1) - CCTK_GFINDEX3D(cctkGH,0,0,0);
+  const ptrdiff_t cdi CCTK_ATTRIBUTE_UNUSED = sizeof(CCTK_REAL) * di;
+  const ptrdiff_t cdj CCTK_ATTRIBUTE_UNUSED = sizeof(CCTK_REAL) * dj;
+  const ptrdiff_t cdk CCTK_ATTRIBUTE_UNUSED = sizeof(CCTK_REAL) * dk;
+  const ptrdiff_t cctkLbnd1 CCTK_ATTRIBUTE_UNUSED = cctk_lbnd[0];
+  const ptrdiff_t cctkLbnd2 CCTK_ATTRIBUTE_UNUSED = cctk_lbnd[1];
+  const ptrdiff_t cctkLbnd3 CCTK_ATTRIBUTE_UNUSED = cctk_lbnd[2];
+  const CCTK_REAL_VEC t CCTK_ATTRIBUTE_UNUSED = ToReal(cctk_time);
+  const CCTK_REAL_VEC cctkOriginSpace1 CCTK_ATTRIBUTE_UNUSED = 
+    ToReal(CCTK_ORIGIN_SPACE(0));
+  const CCTK_REAL_VEC cctkOriginSpace2 CCTK_ATTRIBUTE_UNUSED = 
+    ToReal(CCTK_ORIGIN_SPACE(1));
+  const CCTK_REAL_VEC cctkOriginSpace3 CCTK_ATTRIBUTE_UNUSED = 
+    ToReal(CCTK_ORIGIN_SPACE(2));
+  const CCTK_REAL_VEC dt CCTK_ATTRIBUTE_UNUSED = 
+    ToReal(CCTK_DELTA_TIME);
+  const CCTK_REAL_VEC dx CCTK_ATTRIBUTE_UNUSED = 
+    ToReal(CCTK_DELTA_SPACE(0));
+  const CCTK_REAL_VEC dy CCTK_ATTRIBUTE_UNUSED = 
+    ToReal(CCTK_DELTA_SPACE(1));
+  const CCTK_REAL_VEC dz CCTK_ATTRIBUTE_UNUSED = 
+    ToReal(CCTK_DELTA_SPACE(2));
+  const CCTK_REAL_VEC dxi CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(1),dx);
+  const CCTK_REAL_VEC dyi CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(1),dy);
+  const CCTK_REAL_VEC dzi CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(1),dz);
+  const CCTK_REAL_VEC khalf CCTK_ATTRIBUTE_UNUSED = ToReal(0.5);
+  const CCTK_REAL_VEC kthird CCTK_ATTRIBUTE_UNUSED = 
+    ToReal(0.333333333333333333333333333333);
+  const CCTK_REAL_VEC ktwothird CCTK_ATTRIBUTE_UNUSED = 
+    ToReal(0.666666666666666666666666666667);
+  const CCTK_REAL_VEC kfourthird CCTK_ATTRIBUTE_UNUSED = 
+    ToReal(1.33333333333333333333333333333);
+  const CCTK_REAL_VEC hdxi CCTK_ATTRIBUTE_UNUSED = 
+    kmul(dxi,ToReal(0.5));
+  const CCTK_REAL_VEC hdyi CCTK_ATTRIBUTE_UNUSED = 
+    kmul(dyi,ToReal(0.5));
+  const CCTK_REAL_VEC hdzi CCTK_ATTRIBUTE_UNUSED = 
+    kmul(dzi,ToReal(0.5));
+  /* Initialize predefined quantities */
+  const CCTK_REAL_VEC p1o12dx CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(0.0833333333333333333333333333333),dx);
+  const CCTK_REAL_VEC p1o12dy CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(0.0833333333333333333333333333333),dy);
+  const CCTK_REAL_VEC p1o12dz CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(0.0833333333333333333333333333333),dz);
+  const CCTK_REAL_VEC p1o144dxdy CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(0.00694444444444444444444444444444),kmul(dx,dy));
+  const CCTK_REAL_VEC p1o144dxdz CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(0.00694444444444444444444444444444),kmul(dx,dz));
+  const CCTK_REAL_VEC p1o144dydz CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(0.00694444444444444444444444444444),kmul(dy,dz));
+  const CCTK_REAL_VEC pm1o12dx2 CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(-0.0833333333333333333333333333333),kmul(dx,dx));
+  const CCTK_REAL_VEC pm1o12dy2 CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(-0.0833333333333333333333333333333),kmul(dy,dy));
+  const CCTK_REAL_VEC pm1o12dz2 CCTK_ATTRIBUTE_UNUSED = kdiv(ToReal(-0.0833333333333333333333333333333),kmul(dz,dz));
+  /* Assign local copies of arrays functions */
+  
+  
+  /* Calculate temporaries and arrays functions */
+  /* Copy local copies back to grid functions */
+  /* Loop over the grid points */
+  const int imin0=imin[0];
+  const int imin1=imin[1];
+  const int imin2=imin[2];
+  const int imax0=imax[0];
+  const int imax1=imax[1];
+  const int imax2=imax[2];
+  #pragma omp parallel
+  CCTK_LOOP3STR(WT_Standing,
+    i,j,k, imin0,imin1,imin2, imax0,imax1,imax2,
+    cctk_ash[0],cctk_ash[1],cctk_ash[2],
+    vecimin,vecimax, CCTK_REAL_VEC_SIZE)
+  {
+    const ptrdiff_t index CCTK_ATTRIBUTE_UNUSED = di*i + dj*j + dk*k;
+    /* Assign local copies of grid functions */
+    
+    CCTK_REAL_VEC xL CCTK_ATTRIBUTE_UNUSED = vec_load(x[index]);
+    CCTK_REAL_VEC yL CCTK_ATTRIBUTE_UNUSED = vec_load(y[index]);
+    CCTK_REAL_VEC zL CCTK_ATTRIBUTE_UNUSED = vec_load(z[index]);
+    
+    /* Include user supplied include files */
+    /* Precompute derivatives */
+    /* Calculate temporaries and grid functions */
+    CCTK_REAL_VEC kvec CCTK_ATTRIBUTE_UNUSED = 
+      ToReal(3.14159265358979323846264338328*pow(width,-1));
+    
+    CCTK_REAL_VEC omega CCTK_ATTRIBUTE_UNUSED = 
+      kmul(kpow(kmul(kvec,kvec),0.5),ToReal(1.73205080756887729352744634151));
+    
+    CCTK_REAL_VEC uL CCTK_ATTRIBUTE_UNUSED = 
+      kmul(kmul(kcos(kmul(xL,kvec)),kmul(kcos(kmul(yL,kvec)),kmul(kcos(kmul(zL,kvec)),kcos(kmul(omega,t))))),ToReal(amplitude));
+    
+    CCTK_REAL_VEC rhoL CCTK_ATTRIBUTE_UNUSED = 
+      kneg(kmul(kmul(omega,kmul(kcos(kmul(xL,kvec)),kmul(kcos(kmul(yL,kvec)),kmul(kcos(kmul(zL,kvec)),ksin(kmul(omega,t)))))),ToReal(amplitude)));
+    /* Copy local copies back to grid functions */
+    vec_store_partial_prepare(i,vecimin,vecimax);
+    vec_store_nta_partial(rho[index],rhoL);
+    vec_store_nta_partial(u[index],uL);
+  }
+  CCTK_ENDLOOP3STR(WT_Standing);
+}
+extern "C" void WT_Standing(CCTK_ARGUMENTS)
+{
+  DECLARE_CCTK_ARGUMENTS;
+  DECLARE_CCTK_PARAMETERS;
+  
+  if (verbose > 1)
+  {
+    CCTK_VInfo(CCTK_THORNSTRING,"Entering WT_Standing_Body");
+  }
+  if (cctk_iteration % WT_Standing_calc_every != WT_Standing_calc_offset)
+  {
+    return;
+  }
+  
+  const char* const groups[] = {
+    "grid::coordinates",
+    "ML_WaveToy::WT_rho",
+    "ML_WaveToy::WT_u"};
+  AssertGroupStorage(cctkGH, "WT_Standing", 3, groups);
+  
+  
+  LoopOverEverything(cctkGH, WT_Standing_Body);
+  if (verbose > 1)
+  {
+    CCTK_VInfo(CCTK_THORNSTRING,"Leaving WT_Standing_Body");
+  }
+}
+
+} // namespace ML_WaveToy

Test patch:
diff --git a/all_tests.txt b/all_tests.txt
new file mode 100644
index 0000000..0000000
--- /dev/null
+++ b/all_tests.txt
@@ -0,0 +1,3 @@
+gaussian-RK4
+gaussian-RK45
+gaussian-RK45-adaptive