diff --git a/src/SolidGrid.h b/src/SolidGrid.h index 3aa664cf6..0ce721077 100644 --- a/src/SolidGrid.h +++ b/src/SolidGrid.h @@ -166,6 +166,9 @@ class SolidGrid { int TryDepth(size_t grid_size); public: BALLS* balls; + inline SolidGrid() { + depth = 0; + } void Build(); void InitFinder(finder_t&); void CleanFinder(finder_t&); diff --git a/src/SolidGrid.hpp b/src/SolidGrid.hpp index 10c89f435..301a632c2 100644 --- a/src/SolidGrid.hpp +++ b/src/SolidGrid.hpp @@ -25,7 +25,6 @@ int SolidGrid::TryDepth(size_t grid_size) { while (data[data_offset + k] != -1) { k++; if (k >= depth) { - printf("failed at %ld %d\n", data_offset, k); return -1; } } @@ -38,7 +37,7 @@ template void SolidGrid::Build () { if (balls->size() > 0) { double maxr = 0.5; - depth = 4; + if (depth < 1) depth = 4; for (size_t i=0; isize(); i++) { double val = balls->getRad(i); if (maxr < val) maxr = val; @@ -60,7 +59,14 @@ void SolidGrid::Build () { size_t grid_size = 1; for (int k=0; k<3; k++) grid_size = grid_size * (maxs[k]-mins[k]+1); depth = 4; - while (TryDepth(grid_size)) { depth = depth*2; if (depth > 1000) { printf("Too large SolidGrid depth\n"); exit(-1); } } + while (TryDepth(grid_size)) { + depth = depth*2; + output("Too many particles per bin in SolidGrid. Increasing bin size to %d\n", depth); + if (depth > 1024) { + ERROR("Too large SolidGrid bin size (hardcoded limit)\n"); + exit(-1); + } + } } else { delta = 1.0; depth = 0; diff --git a/tests/solid/main.cpp b/tests/solid/main.cpp index 901d984e9..f4783d68e 100644 --- a/tests/solid/main.cpp +++ b/tests/solid/main.cpp @@ -14,6 +14,9 @@ #define CudaDeviceFunction typedef float real_t; +#define ERROR printf +#define output printf + const int max_cache_size = 1024; #include "SolidTree.h" #include "SolidTree.hpp"