diff options
author | eschnett <> | 2001-03-01 11:40:00 +0000 |
---|---|---|
committer | eschnett <> | 2001-03-01 11:40:00 +0000 |
commit | 310f0ea48d18866b773136aed11200b6eda6378b (patch) | |
tree | 445d3e34ce8b89812994b6614f7bc9f4acbc7fe2 /CarpetExtra/CarpetIntegrateTest/src |
Initial revision
darcs-hash:20010301114010-f6438-12fb8a9ffcc80e86c0a97e37b5b0dae0dbc59b79.gz
Diffstat (limited to 'CarpetExtra/CarpetIntegrateTest/src')
-rw-r--r-- | CarpetExtra/CarpetIntegrateTest/src/Global.cc | 46 | ||||
-rw-r--r-- | CarpetExtra/CarpetIntegrateTest/src/Local.cc | 70 | ||||
-rw-r--r-- | CarpetExtra/CarpetIntegrateTest/src/make.code.defn | 7 |
3 files changed, 123 insertions, 0 deletions
diff --git a/CarpetExtra/CarpetIntegrateTest/src/Global.cc b/CarpetExtra/CarpetIntegrateTest/src/Global.cc new file mode 100644 index 000000000..9c36cc992 --- /dev/null +++ b/CarpetExtra/CarpetIntegrateTest/src/Global.cc @@ -0,0 +1,46 @@ +// $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/CarpetIntegrateTest/src/Global.cc,v 1.1 2004/09/01 17:47:53 schnetter Exp $ + +#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" { CCTK_INT CarpetIntegrate_Global(CCTK_ARGUMENTS); +} + +CCTK_INT 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("CarpetIntegrate::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; + + if (CCTK_MyProc(cctkGH)==0) printf("Integral: %f\n", integral); + + return 0; +} + diff --git a/CarpetExtra/CarpetIntegrateTest/src/Local.cc b/CarpetExtra/CarpetIntegrateTest/src/Local.cc new file mode 100644 index 000000000..d41b12c9c --- /dev/null +++ b/CarpetExtra/CarpetIntegrateTest/src/Local.cc @@ -0,0 +1,70 @@ +// $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/CarpetIntegrateTest/src/Local.cc,v 1.1 2004/09/01 17:47:53 schnetter Exp $ + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "cctk_Arguments.h" + +#include "carpet.hh" +#include "defs.hh" +#include "vect.hh" + + +#include "util_Table.h" +#include "math.h" + +extern "C" { CCTK_INT CarpetIntegrate_Local(CCTK_ARGUMENTS); +} + +static void SpatialDeterminant(CCTK_REAL gxx, + CCTK_REAL gxy, + CCTK_REAL gxz, + CCTK_REAL gyy, + CCTK_REAL gyz, + CCTK_REAL gzz, + CCTK_REAL *detg); + +CCTK_INT CarpetIntegrate_Local(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + using namespace std; + using namespace Carpet; + + 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); + + /* + SpatialDeterminant(gxx[index],gxy[index],gxz[index], + gyy[index],gyz[index],gzz[index], + &detg); + */ + + integrand[index] = 1; + + } + + return 0; +} + + +void SpatialDeterminant(CCTK_REAL gxx, + CCTK_REAL gxy, + CCTK_REAL gxz, + CCTK_REAL gyy, + CCTK_REAL gyz, + CCTK_REAL gzz, + CCTK_REAL *detg) +{ + + *detg = -gxz*gxz*gyy + 2.0*gxy*gxz*gyz + - gxx*gyz*gyz - gxy*gxy*gzz + gxx*gyy*gzz; + + return; +} diff --git a/CarpetExtra/CarpetIntegrateTest/src/make.code.defn b/CarpetExtra/CarpetIntegrateTest/src/make.code.defn new file mode 100644 index 000000000..61f66d804 --- /dev/null +++ b/CarpetExtra/CarpetIntegrateTest/src/make.code.defn @@ -0,0 +1,7 @@ +# $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/CarpetIntegrateTest/src/make.code.defn,v 1.1 2004/09/01 17:47:53 schnetter Exp $ + +# Source files in this directory +SRCS = Local.cc Global.cc + +# Subdirectories containing source files +SUBDIRS = |