Skip to content

Commit

Permalink
Use box.grow_low and grow_high
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote committed Nov 1, 2023
1 parent 2392f32 commit 1c48b21
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions Python/pywarpx/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,26 +350,20 @@ def _get_intersect_slice(self, mfi, starts, stops, icstart, icstop, with_interna
The slice of the intersection relative to the global array where the data from individual block will go
"""
box = mfi.tilebox()
box_small_end = box.small_end
box_big_end = box.big_end
if self.include_ghosts:
nghosts = self.mf.n_grow_vect()
if with_internal_ghosts:
box.grow(self.mf.n_grow_vect())
box_small_end = box.small_end
box_big_end = box.big_end
box.grow(nghosts)
else:
# When available, this could be somewhat simplified by using box.grow_low and box.grow_high,
# which would remove the need of the temporary copies of small_end and big_end.
min_box = self.mf.box_array().minimal_box()
for i in range(self.dim):
if box_small_end[i] == min_box.small_end[i]:
box_small_end[i] -= nghosts[i]
if box_big_end[i] == min_box.big_end[i]:
box_big_end[i] += nghosts[i]
if box.small_end[i] == min_box.small_end[i]:
box.grow_low(i, nghosts[i])
if box.big_end[i] == min_box.big_end[i]:
box.grow_high(i, nghosts[i])

ilo = self._get_indices(box_small_end, 0)
ihi = self._get_indices(box_big_end, 0)
ilo = self._get_indices(box.small_end, 0)
ihi = self._get_indices(box.big_end, 0)

# Add 1 to the upper end to be consistent with the slicing notation
ihi_p1 = [i + 1 for i in ihi]
Expand Down

0 comments on commit 1c48b21

Please sign in to comment.