From 11c4d98017cbb86d08e15fd1b549180184b58a26 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 3 Sep 2009 16:19:15 -0500 Subject: Import Carpet Ignore-this: 309b4dd613f4af2b84aa5d6743fdb6b3 --- Carpet/CarpetMask/README | 7 +++--- Carpet/CarpetMask/configuration.ccl | 5 +++++ Carpet/CarpetMask/schedule.ccl | 6 ++++++ Carpet/CarpetMask/src/mask_excluded.cc | 39 ++++++++++++++++++---------------- Carpet/CarpetMask/src/mask_surface.cc | 33 ++++++++++++++++++++++++++++ Carpet/CarpetMask/src/mask_surface.hh | 2 ++ 6 files changed, 71 insertions(+), 21 deletions(-) create mode 100644 Carpet/CarpetMask/configuration.ccl (limited to 'Carpet/CarpetMask') diff --git a/Carpet/CarpetMask/README b/Carpet/CarpetMask/README index 9c2fde769..a54ac4dbb 100644 --- a/Carpet/CarpetMask/README +++ b/Carpet/CarpetMask/README @@ -1,9 +1,10 @@ Cactus Code Thorn CarpetMask -Thorn Author(s) : Erik Schnetter -Thorn Maintainer(s) : Erik Schnetter +Author(s) : Erik Schnetter +Maintainer(s): Erik Schnetter +Licence : GPLv2+ -------------------------------------------------------------------------- -Purpose of the thorn: +1. Purpose Remove unwanted regions from Carpet's reduction operations. This can be used e.g. to excise the interior of horizons. diff --git a/Carpet/CarpetMask/configuration.ccl b/Carpet/CarpetMask/configuration.ccl new file mode 100644 index 000000000..505f2b2b9 --- /dev/null +++ b/Carpet/CarpetMask/configuration.ccl @@ -0,0 +1,5 @@ +# Configuration definitions for thorn CarpetMask + +REQUIRES LoopControl + +REQUIRES THORNS: LoopControl diff --git a/Carpet/CarpetMask/schedule.ccl b/Carpet/CarpetMask/schedule.ccl index a7b972557..1b136ff9a 100644 --- a/Carpet/CarpetMask/schedule.ccl +++ b/Carpet/CarpetMask/schedule.ccl @@ -1,5 +1,11 @@ # Schedule definitions for thorn CarpetMask +SCHEDULE CarpetSurfaceParamCheck AT paramcheck +{ + LANG: C + OPTIONS: global +} "Check parameters" + # TODO: Schedule this only if there is an excluded centre which is active SCHEDULE GROUP MaskBase_SetupMask AT poststep AFTER SphericalSurface_HasBeenSet { diff --git a/Carpet/CarpetMask/src/mask_excluded.cc b/Carpet/CarpetMask/src/mask_excluded.cc index e842caf31..e179bc268 100644 --- a/Carpet/CarpetMask/src/mask_excluded.cc +++ b/Carpet/CarpetMask/src/mask_excluded.cc @@ -4,6 +4,8 @@ #include #include +#include + #include "mask_excluded.hh" @@ -46,25 +48,26 @@ namespace CarpetMask { bool const exterior = exclude_exterior[n]; - for (int k = 0; k < cctk_lsh[2]; ++ k) { - for (int j = 0; j < cctk_lsh[1]; ++ j) { - for (int i = 0; i < cctk_lsh[0]; ++ i) { - int const ind = CCTK_GFINDEX3D (cctkGH, i, j, k); - - CCTK_REAL const dx2 = pow (x[ind] - x0, 2); - CCTK_REAL const dy2 = pow (y[ind] - y0, 2); - CCTK_REAL const dz2 = pow (z[ind] - z0, 2); - - if (exterior ? - dx2 + dy2 + dz2 >= r2 : - dx2 + dy2 + dz2 <= r2) - { - weight[ind] = 0.0; - } - - } +#pragma omp parallel + LC_LOOP3(CarpetExcludedSetup, + i,j,k, + 0,0,0, cctk_lsh[0],cctk_lsh[1],cctk_lsh[2], + cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) + { + int const ind = CCTK_GFINDEX3D (cctkGH, i, j, k); + + CCTK_REAL const dx2 = pow (x[ind] - x0, 2); + CCTK_REAL const dy2 = pow (y[ind] - y0, 2); + CCTK_REAL const dz2 = pow (z[ind] - z0, 2); + + if (exterior ? + dx2 + dy2 + dz2 >= r2 : + dx2 + dy2 + dz2 <= r2) + { + weight[ind] = 0.0; } - } + + } LC_ENDLOOP3(CarpetExcludedSetup); } // if r>=0 } // for n diff --git a/Carpet/CarpetMask/src/mask_surface.cc b/Carpet/CarpetMask/src/mask_surface.cc index e1a02079f..d23dc5461 100644 --- a/Carpet/CarpetMask/src/mask_surface.cc +++ b/Carpet/CarpetMask/src/mask_surface.cc @@ -22,6 +22,33 @@ namespace CarpetMask { + /** + * Check parameters. + */ + + void + CarpetSurfaceParamCheck (CCTK_ARGUMENTS) + { + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + for (int n = 0; n < num_excluded; ++ n) { + + int const sn = excluded_surface[n]; + if (sn >= 0) { + + if (not (sn < nsurfaces)) { + CCTK_VParamWarn (CCTK_THORNSTRING, + "Mask %d depends on spherical surface %d, but there are only %d spherical surfaces", + n, sn, int(nsurfaces)); + } + + } // if sn >= 0 + } // for n + } + + + /** * Set the weight in the excluded regions to zero. */ @@ -52,6 +79,11 @@ namespace CarpetMask { int const sn = excluded_surface[n]; if (sn >= 0) { + if (not (sn < nsurfaces)) { + CCTK_VWarn (CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING, + "Mask %d depends on spherical surface %d, but there are only %d spherical surfaces", + n, sn, int(nsurfaces)); + } assert (sn < nsurfaces); if (sf_active[sn]) { @@ -81,6 +113,7 @@ namespace CarpetMask { } } +#pragma omp parallel for for (int k = 0; k < cctk_lsh[2]; ++ k) { for (int j = 0; j < cctk_lsh[1]; ++ j) { for (int i = 0; i < cctk_lsh[0]; ++ i) { diff --git a/Carpet/CarpetMask/src/mask_surface.hh b/Carpet/CarpetMask/src/mask_surface.hh index a3e1f19d0..63e46d35b 100644 --- a/Carpet/CarpetMask/src/mask_surface.hh +++ b/Carpet/CarpetMask/src/mask_surface.hh @@ -4,6 +4,8 @@ namespace CarpetMask { extern "C" { + void + CarpetSurfaceParamCheck (CCTK_ARGUMENTS); void CarpetSurfaceSetup (CCTK_ARGUMENTS); } -- cgit v1.2.3