Task: Implement Local.cc for Carpet/CarpetIntegrateTest thorn

thorn_name: Carpet/CarpetIntegrateTest
src_filename: Local.cc
interface: implements: CarpetIntegrateTest

inherits: Reduce Grid Driver

CCTK_REAL integrand TYPE=GF TIMELEVELS=3

schedule: STORAGE: integrand[3]

schedule CarpetIntegrate_Local AT CCTK_INITIAL
{
  LANG: C
} "Setup integrand function"

schedule CarpetIntegrate_Local AT CCTK_EVOL
{
  LANG: C
} "Setup integrand function"

schedule CarpetIntegrate_Global AT CCTK_ANALYSIS 
{
  LANG: C
  OPTIONS: global
} "Global integration by reduction"

param: REAL constant "Integrand constant"
{
  *:* :: ""
} 1.0

REAL timefact "Time dependence of integrand"
{
  *:* :: ""
} 0.0

configuration: REQUIRES Carpet

context: make.code.defn:
```
# Source files in this directory
SRCS = Local.cc Global.cc

# Subdirectories containing source files
SUBDIRS = 

```

Global.cc:
```
#include <assert.h>
#include <stdio.h>

#include "cctk.h"
#include "cctk_Parameters.h"
#include "cctk_Arguments.h"

#include "carpet.hh"
#include "defs.hh"
#include "vect.hh"

#include "util_Table.h"

extern "C" void CarpetIntegrate_Global(CCTK_ARGUMENTS);

void CarpetIntegrate_Global(CCTK_ARGUMENTS) {
  DECLARE_CCTK_ARGUMENTS;
  DECLARE_CCTK_PARAMETERS;

  using namespace std;
  using namespace Carpet;

  int varindex = -1;
  int ierr = 0;

  CCTK_REAL integral;

  int reduction_handle = CCTK_ReductionHandle("sum");

  varindex = CCTK_VarIndex("CarpetIntegrateTest::integrand");
  assert(varindex >= 0);
  ierr = CCTK_Reduce(cctkGH, -1, reduction_handle, 1, CCTK_VARIABLE_REAL,
                     &integral, 1, varindex);
  assert(!ierr);

  CCTK_REAL d3x =
      cctk_delta_space[0] * cctk_delta_space[1] * cctk_delta_space[2];
  integral *= d3x;

  printf("Integral: %g\n", (double)integral);
}

```


combined_doc_context: ## README (README):
```
Cactus Code Thorn CarpetIntegrateTest
Thorn Author(s)     : Burkhard Zink <bzink@mpa-garching.mpg.de>
Thorn Maintainer(s) : Erik Schnetter <schnetter@aei.mpg.de>
--------------------------------------------------------------------------

Purpose of the thorn:

Test integration in Carpet.

```



Reference solution:
src_code: #include "cctk.h"
#include "cctk_Parameters.h"
#include "cctk_Arguments.h"

extern "C" void CarpetIntegrate_Local(CCTK_ARGUMENTS);

void CarpetIntegrate_Local(CCTK_ARGUMENTS) {
  DECLARE_CCTK_ARGUMENTS;
  DECLARE_CCTK_PARAMETERS;

  int nx = cctk_lsh[0];
  int ny = cctk_lsh[1];
  int nz = cctk_lsh[2];

  for (int k = 0; k < nz; k++) {
    for (int j = 0; j < ny; j++) {
      for (int i = 0; i < nx; i++) {
        int index = CCTK_GFINDEX3D(cctkGH, i, j, k);

        integrand[index] = constant + timefact * cctk_time;
      }
    }
  }
}