Skip to content

Commit

Permalink
Skip empty levels in stratified hash nnps
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapb authored and prabhuramachandran committed Feb 8, 2021
1 parent 3e14c7d commit 3bc458d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pysph/base/stratified_hash_nnps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,28 @@ cdef class StratifiedHashNNPS(NNPS):
cdef HashTable* hash_level = NULL
cdef HashEntry* candidate_cell = NULL

cdef double hmax_level

for i from 0<=i<self.num_levels:
hash_level = self.current_hash[i]
if hash_level.number_of_particles() == 0:
continue

h_max = fmax(self.radius_scale*h, self._get_h_max(self.current_cells, i))
H = <int> ceil(h_max*self.H/self._get_h_max(self.current_cells, i))
hmax_level = self._get_h_max(self.current_cells, i)
h_max = fmax(self.radius_scale*h, hmax_level)
H = <int> ceil(h_max*self.H / hmax_level)

mask_len = (2*H+1)*(2*H+1)*(2*H+1)

x_boxes = <int*> malloc(mask_len*sizeof(int))
y_boxes = <int*> malloc(mask_len*sizeof(int))
z_boxes = <int*> malloc(mask_len*sizeof(int))

hash_level = self.current_hash[i]
find_cell_id_raw(
x - xmin[0],
y - xmin[1],
z - xmin[2],
self._get_h_max(self.current_cells, i)/self.H,
hmax_level / self.H,
&c_x, &c_y, &c_z
)

Expand Down Expand Up @@ -277,7 +282,6 @@ cdef class StratifiedHashNNPS(NNPS):
@cython.cdivision(True)
cpdef _refresh(self):
self.interval_size = (self.cell_size - self.hmin)/self.num_levels + EPS

cdef HashTable** current_hash
cdef int i, j
for i from 0<=i<self.narrays:
Expand Down

0 comments on commit 3bc458d

Please sign in to comment.