aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetSlab
diff options
context:
space:
mode:
Diffstat (limited to 'Carpet/CarpetSlab')
-rw-r--r--Carpet/CarpetSlab/src/mapping.cc17
-rw-r--r--Carpet/CarpetSlab/src/slab.cc15
2 files changed, 30 insertions, 2 deletions
diff --git a/Carpet/CarpetSlab/src/mapping.cc b/Carpet/CarpetSlab/src/mapping.cc
index f4b4fd351..0b5de6eae 100644
--- a/Carpet/CarpetSlab/src/mapping.cc
+++ b/Carpet/CarpetSlab/src/mapping.cc
@@ -133,9 +133,24 @@ namespace CarpetSlab {
for (int dd=0; dd<hdim; ++dd) {
downsample[dd] = downsample_ ? downsample_[dd] : 1;
if (extent[dd]<0) {
+ int const oldmap = Carpet::map;
+ int const grouptype = CCTK_GroupTypeFromVarI (vindex);
+ assert (grouptype >= 0);
+ if (grouptype == CCTK_GF) {
+ assert (reflevel >= 0);
+ assert (oldmap >= 0 || maps == 1);
+ if (oldmap == -1) {
+ enter_singlemap_mode (const_cast<cGH*>(cctkGH), 0);
+ }
+ }
int gsh[dim];
- int ierr = CCTK_GroupgshVI(cctkGH, dim, gsh, vindex);
+ int ierr = CCTK_GroupgshVI (cctkGH, dim, gsh, vindex);
assert (!ierr);
+ if (grouptype == CCTK_GF) {
+ if (oldmap == -1) {
+ leave_singlemap_mode (const_cast<cGH*>(cctkGH));
+ }
+ }
const int totlen = gsh[dirs[dd]-1];
assert (totlen>=0);
// Partial argument check
diff --git a/Carpet/CarpetSlab/src/slab.cc b/Carpet/CarpetSlab/src/slab.cc
index ff2ee5cfa..d50ee25a1 100644
--- a/Carpet/CarpetSlab/src/slab.cc
+++ b/Carpet/CarpetSlab/src/slab.cc
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
+#include <algorithm>
#include <vector>
#include "cctk.h"
@@ -32,6 +33,7 @@ extern "C" {
namespace CarpetSlab {
+ using namespace std;
using namespace Carpet;
@@ -132,7 +134,7 @@ namespace CarpetSlab {
// Check extent
for (int dd=0; dd<hdim; ++dd) {
- assert (origin[dirs[dd]-1] + length[dd] <= sizes[dirs[dd]]);
+ assert (origin[dirs[dd]-1] + length[dd] <= sizes[dirs[dd]-1]);
}
// Get insider information about variable
@@ -154,6 +156,17 @@ namespace CarpetSlab {
// Determine own rank
const int rank = CCTK_MyProc(cgh);
+ // Sanity check
+ // (if this fails, someone requested an insane number of grid points)
+ {
+ int max = INT_MAX;
+ for (int dd=0; dd<dim; ++dd) {
+ assert (length[dd] >= 0 && length[dd] <= max);
+ if (length[dd] > 0) max /= length[dd];
+ }
+ assert (typesize <= max);
+ }
+
// Calculate global size
int totalsize = 1;
for (int dd=0; dd<hdim; ++dd) {