From 1c48b21966439c45ba58ad60397268cc3d52a3e4 Mon Sep 17 00:00:00 2001 From: Dave Grote Date: Tue, 31 Oct 2023 18:43:39 -0700 Subject: [PATCH] Use box.grow_low and grow_high --- Python/pywarpx/fields.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/Python/pywarpx/fields.py b/Python/pywarpx/fields.py index bdba6d25123..f2b9a281205 100644 --- a/Python/pywarpx/fields.py +++ b/Python/pywarpx/fields.py @@ -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]