From 3d18e299788c753ae99866b52f916346f5c91039 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 2 Oct 2008 11:50:19 -0500 Subject: CarpetMask: Allow excluding the exterior of large coordinate spheres Allow excluding the exterior of large coordinate spheres from norm calculations. --- Carpet/CarpetMask/param.ccl | 4 ++++ Carpet/CarpetMask/src/mask_excluded.cc | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Carpet/CarpetMask/param.ccl b/Carpet/CarpetMask/param.ccl index 8db65e41b..f63bceab3 100644 --- a/Carpet/CarpetMask/param.ccl +++ b/Carpet/CarpetMask/param.ccl @@ -36,6 +36,10 @@ CCTK_REAL excluded_radius[10] "radius of excluded region" STEERABLE=always 0.0:* :: "" } -1.0 +BOOLEAN exclude_exterior[10] "exclude the exterior of this radius, otherwise the interior" STEERABLE=always +{ +} no + # Exclude spherical surfaces diff --git a/Carpet/CarpetMask/src/mask_excluded.cc b/Carpet/CarpetMask/src/mask_excluded.cc index 97268ef42..e842caf31 100644 --- a/Carpet/CarpetMask/src/mask_excluded.cc +++ b/Carpet/CarpetMask/src/mask_excluded.cc @@ -44,6 +44,8 @@ namespace CarpetMask { CCTK_REAL const r2 = pow (r0, 2); + 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) { @@ -53,7 +55,10 @@ namespace CarpetMask { CCTK_REAL const dy2 = pow (y[ind] - y0, 2); CCTK_REAL const dz2 = pow (z[ind] - z0, 2); - if (dx2 + dy2 + dz2 <= r2) { + if (exterior ? + dx2 + dy2 + dz2 >= r2 : + dx2 + dy2 + dz2 <= r2) + { weight[ind] = 0.0; } -- cgit v1.2.3 From e7f44eaefaf88a8848d9ba2454df2c981cb3627f Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 1 Oct 2008 17:24:36 -0500 Subject: Carpet: Add parameter to require a minimum number of points per processor --- Carpet/Carpet/param.ccl | 6 ++++++ Carpet/Carpet/src/Recompose.cc | 28 ++++++++++++++++++++++++---- Carpet/Carpet/src/SetupGH.cc | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/Carpet/Carpet/param.ccl b/Carpet/Carpet/param.ccl index 94b4c7e4e..74b2be338 100644 --- a/Carpet/Carpet/param.ccl +++ b/Carpet/Carpet/param.ccl @@ -440,6 +440,12 @@ CCTK_REAL aspect_ratio_z "Desired aspect ratio for each processor's domain" STEE (0:* :: "" } 1.0 +CCTK_INT min_points_per_proc "Minimum number of grid points per processor" STEERABLE=always +{ + -1 :: "infinity" + 1:* :: "that many" +} -1 + CCTK_INT num_threads "Number of threads per process" STEERABLE=recover diff --git a/Carpet/Carpet/src/Recompose.cc b/Carpet/Carpet/src/Recompose.cc index ac4732523..2d6c7beac 100644 --- a/Carpet/Carpet/src/Recompose.cc +++ b/Carpet/Carpet/src/Recompose.cc @@ -105,8 +105,8 @@ namespace Carpet { // assert (all(regsss.at(rl).at(c).at(ml).extent.lower() <= // regsss.at(rl).at(c).at(ml).extent.upper())); // Check strides - const ivect str - = (maxspacereflevelfact / spacereffacts.at(rl) * ipow(mgfact, ml)); + ivect const str = + (maxspacereflevelfact / spacereffacts.at(rl) * ipow(mgfact, ml)); assert (all(regsss.at(ml).at(rl).at(c).extent.stride() % str == 0)); // Check alignments assert (all(regsss.at(ml).at(rl).at(c).extent.lower() % str == 0)); @@ -1314,6 +1314,8 @@ namespace Carpet { vector > & superregss, vector > & regss) { + DECLARE_CCTK_PARAMETERS; + if (DEBUG) cout << "SRMA enter" << endl; int const nmaps = superregss.size(); @@ -1358,7 +1360,21 @@ namespace Carpet { } } - const int nprocs = CCTK_nProcs (cctkGH); + int const real_nprocs = CCTK_nProcs (cctkGH); + if (DEBUG) cout << "SRMA real_nprocs " << real_nprocs << endl; + + // Deactivate some processors if there are too many + int nprocs; + if (min_points_per_proc < 0) { + nprocs = real_nprocs; + } else { + CCTK_REAL mycost = 0; + for (int r=0; r=0 and m used (nprocs, false); + for (int c=0; c= 0 and p < nprocs); + assert (not used.at(p)); + used.at(p) = true; + } + for (int c=0; c > superregss(1); superregss.at(rl) = superregs; -- cgit v1.2.3 From 2b34ea7469762dd5746a3e76340e47e65295667b Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 1 Oct 2008 17:24:56 -0500 Subject: CarpetLib: Allow expanding empty bboxes --- Carpet/CarpetLib/src/bbox.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Carpet/CarpetLib/src/bbox.cc b/Carpet/CarpetLib/src/bbox.cc index 6183f17e5..a14e1e9a3 100644 --- a/Carpet/CarpetLib/src/bbox.cc +++ b/Carpet/CarpetLib/src/bbox.cc @@ -160,7 +160,8 @@ bool bbox::operator> (const bbox& b) const { template bbox bbox::expand (const vect& lo, const vect& hi) const { // Allow expansion only into directions where the extent is not negative - assert (all(lower()<=upper() or (lo==T(0) and hi==T(0)))); + // assert (all(lower()<=upper() or (lo==T(0) and hi==T(0)))); + assert (all(shape()>=vect(0) or (lo==T(0) and hi==T(0)))); const vect str = stride(); const vect lb = lower() - lo * str; const vect ub = upper() + hi * str; -- cgit v1.2.3 From fc759003275724d722e4d9ddb7b2f4b1f721c377 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 1 Oct 2008 17:25:25 -0500 Subject: CarpetReduce: Use LoopControl --- Carpet/CarpetReduce/configuration.ccl | 4 +- Carpet/CarpetReduce/interface.ccl | 2 + Carpet/CarpetReduce/src/mask_carpet.cc | 98 +++++++++++++++++----------------- Carpet/CarpetReduce/src/mask_coords.c | 48 +++++++++-------- Carpet/CarpetReduce/src/mask_init.c | 68 +++++++++++------------ 5 files changed, 114 insertions(+), 106 deletions(-) diff --git a/Carpet/CarpetReduce/configuration.ccl b/Carpet/CarpetReduce/configuration.ccl index 50ee465ed..f81217393 100644 --- a/Carpet/CarpetReduce/configuration.ccl +++ b/Carpet/CarpetReduce/configuration.ccl @@ -1,5 +1,5 @@ # Configuration definitions for thorn CarpetReduce -REQUIRES Carpet CarpetLib +REQUIRES Carpet CarpetLib LoopControl -REQUIRES THORNS: Carpet CarpetLib +REQUIRES THORNS: Carpet CarpetLib LoopControl diff --git a/Carpet/CarpetReduce/interface.ccl b/Carpet/CarpetReduce/interface.ccl index e19087aa9..467607cb5 100644 --- a/Carpet/CarpetReduce/interface.ccl +++ b/Carpet/CarpetReduce/interface.ccl @@ -10,6 +10,8 @@ uses include header: carpet.hh uses include header: carpet_typecase.hh +uses include header: loopcontrol.h + CCTK_INT FUNCTION \ SymmetryTableHandleForGrid (CCTK_POINTER_TO_CONST IN cctkGH) REQUIRES FUNCTION SymmetryTableHandleForGrid diff --git a/Carpet/CarpetReduce/src/mask_carpet.cc b/Carpet/CarpetReduce/src/mask_carpet.cc index 5593dfbfa..679c85392 100644 --- a/Carpet/CarpetReduce/src/mask_carpet.cc +++ b/Carpet/CarpetReduce/src/mask_carpet.cc @@ -7,6 +7,8 @@ #include +#include + #include "mask_carpet.hh" @@ -133,15 +135,15 @@ namespace CarpetMask { // Set weight on the boundary to 1/2 assert (dim == 3); -#pragma omp parallel for - for (int k=imin[2]; k mask (cctk_lsh[0] * cctk_lsh[1] * cctk_lsh[2]); assert (dim == 3); -#pragma omp parallel for - for (int k=0; k 0) { - weight[ind] *= 1.0 - 1.0 / mask[ind]; - } - } +#pragma omp parallel + LC_LOOP3(CarpetMaskSetup_restriction_boundary_apply, + 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); + if (mask[ind] > 0) { + weight[ind] *= 1.0 - 1.0 / mask[ind]; } - } + } LC_ENDLOOP3(CarpetMaskSetup_restriction_boundary_apply); } END_LOCAL_COMPONENT_LOOP; diff --git a/Carpet/CarpetReduce/src/mask_coords.c b/Carpet/CarpetReduce/src/mask_coords.c index 654cfee40..a5ef4324d 100644 --- a/Carpet/CarpetReduce/src/mask_coords.c +++ b/Carpet/CarpetReduce/src/mask_coords.c @@ -4,6 +4,8 @@ #include #include +#include + void @@ -49,7 +51,7 @@ CoordBase_SetupMask (CCTK_ARGUMENTS) if (is_internal[2*d+f]) { /* The boundary extends inwards */ - bnd_points[2*d+f] = shiftout[2*d+f]; + bnd_points[2*d+f] = shiftout[2*d+f] - is_staggered[2*d+f]; } else { /* The boundary extends outwards */ bnd_points[2*d+f] = @@ -113,17 +115,17 @@ CoordBase_SetupMask (CCTK_ARGUMENTS) CCTK_VInfo (CCTK_THORNSTRING, "Setting boundary points in direction %d face %d to weight 0", d, f); } -#pragma omp parallel for - for (int k=bmin[2]; k +#include + void @@ -29,17 +31,17 @@ MaskBase_InitMask (CCTK_ARGUMENTS) CCTK_INFO ("Initialising to weight 1"); } -#pragma omp parallel for - for (int k=0; k Date: Fri, 3 Oct 2008 16:17:01 -0500 Subject: CarpetInterp2: Export a simple interpolator API as aliased function --- Carpet/CarpetInterp2/interface.ccl | 23 ++++++++-- Carpet/CarpetInterp2/src/interp2.cc | 78 +++++++++++++++++++++++++++++++++ Carpet/CarpetInterp2/src/make.code.defn | 2 +- 3 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 Carpet/CarpetInterp2/src/interp2.cc diff --git a/Carpet/CarpetInterp2/interface.ccl b/Carpet/CarpetInterp2/interface.ccl index fc822c9e1..1a8e1c177 100644 --- a/Carpet/CarpetInterp2/interface.ccl +++ b/Carpet/CarpetInterp2/interface.ccl @@ -41,7 +41,24 @@ CCTK_INT FUNCTION \ CCTK_INT IN npoints, \ CCTK_POINTER_TO_CONST IN globalcoords, \ CCTK_INT ARRAY OUT patch, \ - CCTK_POINTER IN localcoords, \ - CCTK_POINTER IN dadx, \ - CCTK_POINTER IN ddadxdx) + CCTK_POINTER IN localcoords, \ + CCTK_POINTER IN dadx, \ + CCTK_POINTER IN ddadxdx) USES FUNCTION MultiPatch_GlobalToLocal + + + +CCTK_INT FUNCTION \ + InterpGridArrays \ + (CCTK_POINTER_TO_CONST IN cctkGH, \ + CCTK_INT IN N_dims, \ + CCTK_INT IN order, \ + CCTK_INT IN N_interp_points, \ + CCTK_POINTER_TO_CONST IN interp_coords, \ + CCTK_INT IN N_input_arrays, \ + CCTK_INT ARRAY IN input_array_indices, \ + CCTK_INT IN N_output_arrays, \ + CCTK_POINTER IN output_arrays) +PROVIDES FUNCTION InterpGridArrays \ + WITH CarpetInterp2_InterpGridArrays \ + LANGUAGE C diff --git a/Carpet/CarpetInterp2/src/interp2.cc b/Carpet/CarpetInterp2/src/interp2.cc new file mode 100644 index 000000000..f8a17df99 --- /dev/null +++ b/Carpet/CarpetInterp2/src/interp2.cc @@ -0,0 +1,78 @@ +#include + +#include "fasterp.hh" + + + +namespace CarpetInterp2 { + + extern "C" + CCTK_INT + CarpetInterp2_InterpGridArrays (CCTK_POINTER_TO_CONST const cctkGH_, + CCTK_INT const N_dims, + CCTK_INT const order, + CCTK_INT const N_interp_points, + CCTK_POINTER_TO_CONST const interp_coords_, + CCTK_INT const N_input_arrays, + CCTK_INT const * const input_array_indices, + CCTK_INT const N_output_arrays, + CCTK_POINTER const output_arrays_) + { + // Check input values and convert types + cGH const * const cctkGH = static_cast (cctkGH_); + assert (cctkGH); + + assert (N_dims == dim); + + assert (N_interp_points >= 0); + + CCTK_REAL const * const * const interp_coords = + static_cast (interp_coords_); + assert (interp_coords); + for (int d=0; d= 0); + + assert (input_array_indices); + for (int n=0; n=0 and + input_array_indices[n]= 0); + assert (N_output_arrays == N_input_arrays); + + CCTK_REAL * const * const output_arrays = + static_cast (output_arrays_); + assert (output_arrays); + for (int n=0; n varinds (N_input_arrays); + for (int n=0; n values (N_input_arrays); + for (int n=0; n