diff options
author | Peter Diener <diener@cct.lsu.edu> | 2013-04-29 14:25:24 -0500 |
---|---|---|
committer | Peter Diener <diener@cct.lsu.edu> | 2013-04-29 14:25:24 -0500 |
commit | d2265e829d3e1f3f9ab19bd5b805b82c7f79942f (patch) | |
tree | 773f1f0e8ff65aed03403e08107dad1a8a0f85e1 /Carpet | |
parent | 8b5e709c59ac6435721849d0f05a41f2505ce2b0 (diff) | |
parent | 8c63348a8570b61f802fd366812c74b6d5a6153e (diff) |
Merge branch 'master' of carpetgit@carpetcode.org:carpet
Diffstat (limited to 'Carpet')
-rw-r--r-- | Carpet/CarpetLib/src/mem.cc | 4 | ||||
-rw-r--r-- | Carpet/CarpetReduce/src/mask_coords.c | 38 | ||||
-rw-r--r-- | Carpet/Requirements/src/Requirements.cc | 1 | ||||
-rw-r--r-- | Carpet/Requirements/src/all_state.cc | 2 | ||||
-rw-r--r-- | Carpet/Requirements/src/gridpoint.cc | 2 |
5 files changed, 41 insertions, 6 deletions
diff --git a/Carpet/CarpetLib/src/mem.cc b/Carpet/CarpetLib/src/mem.cc index 89d8fb211..df374ae3e 100644 --- a/Carpet/CarpetLib/src/mem.cc +++ b/Carpet/CarpetLib/src/mem.cc @@ -105,6 +105,7 @@ mem (size_t const vectorlength, size_t const nelems, size_t const max_cache_linesize = get_max_cache_linesize(); size_t const vector_size = CCTK_REAL_VEC_SIZE * sizeof(T); size_t const alignment = align_up(max_cache_linesize, vector_size); + assert(alignment >= 1); // Safety check assert(alignment <= 1024); // Assume optimistically that operator new returns well-aligned @@ -123,7 +124,8 @@ mem (size_t const vectorlength, size_t const nelems, } else { allocate_with_alignment: // Operator new needs manual alignment - size_t const max_padding = alignment / sizeof(T) - 1; + size_t const max_padding = div_up(alignment, sizeof(T)); + assert(ptrdiff_t(max_padding) >= 0); storage_base_ = new T [vectorlength * nelems + max_padding]; storage_ = (T*) (size_t(storage_base_ + max_padding) & ~(alignment-1)); assert(size_t(storage_) >= size_t(storage_base_ ) and diff --git a/Carpet/CarpetReduce/src/mask_coords.c b/Carpet/CarpetReduce/src/mask_coords.c index 0a07bc854..afdc79410 100644 --- a/Carpet/CarpetReduce/src/mask_coords.c +++ b/Carpet/CarpetReduce/src/mask_coords.c @@ -1,4 +1,5 @@ #include <assert.h> +#include <stdlib.h> #include <cctk.h> #include <cctk_Arguments.h> @@ -21,6 +22,7 @@ CoordBase_SetupMask (CCTK_ARGUMENTS) CCTK_INT is_internal[2*cctk_dim]; CCTK_INT is_staggered[2*cctk_dim]; CCTK_INT shiftout[2*cctk_dim]; + CCTK_INT is_periodic[2*cctk_dim]; int bnd_points[2*cctk_dim]; /* points outside the domain */ int int_points[cctk_dim]; /* global interior points */ @@ -52,6 +54,28 @@ CoordBase_SetupMask (CCTK_ARGUMENTS) + for (int d=0; d<cctk_dim; ++d) { + for (int f=0; f<2; ++f) { + is_periodic[2*d+f] = 0; + } + } + CCTK_INT const *const periodic = + CCTK_ParameterGet("periodic", "PeriodicCarpet", NULL); + CCTK_INT const *const periodic_x = + CCTK_ParameterGet("periodic_x", "PeriodicCarpet", NULL); + CCTK_INT const *const periodic_y = + CCTK_ParameterGet("periodic_x", "PeriodicCarpet", NULL); + CCTK_INT const *const periodic_z = + CCTK_ParameterGet("periodic_x", "PeriodicCarpet", NULL); + is_periodic[0] = is_periodic[1] = + (periodic && *periodic) || (periodic_x && *periodic_x); + is_periodic[2] = is_periodic[3] = + (periodic && *periodic) || (periodic_y && *periodic_y); + is_periodic[4] = is_periodic[5] = + (periodic && *periodic) || (periodic_z && *periodic_z); + + + /* Calculate the number of boundary points. This excludes points that are directly on the boundary. */ for (int d=0; d<cctk_dim; ++d) { @@ -62,8 +86,12 @@ CoordBase_SetupMask (CCTK_ARGUMENTS) bnd_points[2*d+f] = shiftout[2*d+f]; } else { /* The boundary extends outwards */ - bnd_points[2*d+f] = - nboundaryzones[2*d+f] + shiftout[2*d+f] + is_staggered[2*d+f] - 1; + if (is_periodic[2*d+f]) { + bnd_points[2*d+f] = nboundaryzones[2*d+f]; + } else{ + bnd_points[2*d+f] = + nboundaryzones[2*d+f] + shiftout[2*d+f] + is_staggered[2*d+f] - 1; + } } } @@ -130,9 +158,9 @@ CoordBase_SetupMask (CCTK_ARGUMENTS) iweight[ind] = 0; } CCTK_ENDLOOP3(CoordBase_SetupMask_boundary); - /* When the boundary is not staggered, then give the points - directly on the boundary the weight 1/2 */ - if (! is_staggered[2*d+f]) { + /* When the boundary is neither staggered nor periodic, then + give the points directly on the boundary the weight 1/2 */ + if (! is_staggered[2*d+f] && ! is_periodic[2*d+f]) { /* Since we are going to cut off 1/2 at each boundary, the domain size must be at least 1 to begin with */ diff --git a/Carpet/Requirements/src/Requirements.cc b/Carpet/Requirements/src/Requirements.cc index 1401b7bc4..235acfa04 100644 --- a/Carpet/Requirements/src/Requirements.cc +++ b/Carpet/Requirements/src/Requirements.cc @@ -8,6 +8,7 @@ #include <iostream> #include <vector> +#include <cstdlib> #include <all_clauses.hh> #include <util.hh> diff --git a/Carpet/Requirements/src/all_state.cc b/Carpet/Requirements/src/all_state.cc index 419379e29..19fa0c1eb 100644 --- a/Carpet/Requirements/src/all_state.cc +++ b/Carpet/Requirements/src/all_state.cc @@ -6,6 +6,8 @@ #include <clauses.hh> #include <util.hh> +#include <cstdlib> + using namespace std; namespace Requirements { diff --git a/Carpet/Requirements/src/gridpoint.cc b/Carpet/Requirements/src/gridpoint.cc index 122970c8e..c351eec21 100644 --- a/Carpet/Requirements/src/gridpoint.cc +++ b/Carpet/Requirements/src/gridpoint.cc @@ -6,6 +6,8 @@ #include <gridpoint.hh> #include <util.hh> +#include <cstdlib> + namespace Requirements { using namespace std; |