Skip to content

Commit

Permalink
Fixing the SolidGrid print issue
Browse files Browse the repository at this point in the history
  • Loading branch information
llaniewski committed Aug 18, 2023
1 parent 769d4b7 commit c207d33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/SolidGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
Expand Down
12 changes: 9 additions & 3 deletions src/SolidGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ int SolidGrid<BALLS>::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;
}
}
Expand All @@ -38,7 +37,7 @@ template <class BALLS>
void SolidGrid<BALLS>::Build () {
if (balls->size() > 0) {
double maxr = 0.5;
depth = 4;
if (depth < 1) depth = 4;
for (size_t i=0; i<balls->size(); i++) {
double val = balls->getRad(i);
if (maxr < val) maxr = val;
Expand All @@ -60,7 +59,14 @@ void SolidGrid<BALLS>::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;
Expand Down
3 changes: 3 additions & 0 deletions tests/solid/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c207d33

Please sign in to comment.