[yt-svn] commit/yt: atmyers: Merged in MatthewTurk/yt (pull request #1894)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Dec 14 11:10:56 PST 2015
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/707e9f9d1a55/
Changeset: 707e9f9d1a55
Branch: yt
User: atmyers
Date: 2015-12-14 19:10:18+00:00
Summary: Merged in MatthewTurk/yt (pull request #1894)
Optimize covering grids
Affected #: 3 files
diff -r 81762aa466f368a730c369e7841f7234a06579b2 -r 707e9f9d1a558b417a765cfb2f811146ac0dde13 yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -592,20 +592,14 @@
return tuple(self.ActiveDimensions.tolist())
def _setup_data_source(self):
- LE = self.left_edge - self.base_dds
- RE = self.right_edge + self.base_dds
- if not all(self.ds.periodicity):
- for i in range(3):
- if self.ds.periodicity[i]: continue
- LE[i] = max(LE[i], self.ds.domain_left_edge[i])
- RE[i] = min(RE[i], self.ds.domain_right_edge[i])
- self._data_source = self.ds.region(self.center, LE, RE)
+ self._data_source = self.ds.region(self.center,
+ self.left_edge, self.right_edge)
self._data_source.min_level = 0
self._data_source.max_level = self.level
- self._pdata_source = self.ds.region(self.center,
- self.left_edge, self.right_edge)
- self._pdata_source.min_level = 0
- self._pdata_source.max_level = self.level
+ # This triggers "special" behavior in the RegionSelector to ensure we
+ # select *cells* whose bounding boxes overlap with our region, not just
+ # their cell centers.
+ self._data_source.loose_selection = True
def get_data(self, fields = None):
if fields is None: return
@@ -644,7 +638,7 @@
def _fill_particles(self, part):
for p in part:
- self[p] = self._pdata_source[p]
+ self[p] = self._data_source[p]
def _fill_fields(self, fields):
fields = [f for f in fields if f not in self.field_data]
diff -r 81762aa466f368a730c369e7841f7234a06579b2 -r 707e9f9d1a558b417a765cfb2f811146ac0dde13 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -804,6 +804,7 @@
cdef np.float64_t left_edge[3]
cdef np.float64_t right_edge[3]
cdef np.float64_t right_edge_shift[3]
+ cdef bint loose_selection
@cython.boundscheck(False)
@cython.wraparound(False)
@@ -818,6 +819,9 @@
cdef np.ndarray[np.float64_t, ndim=1] DRE = _ensure_code(dobj.ds.domain_right_edge)
cdef np.float64_t region_width[3]
cdef bint p[3]
+ # This is for if we want to include zones that overlap and whose
+ # centers are not strictly included.
+ self.loose_selection = getattr(dobj, "loose_selection", False)
for i in range(3):
region_width[i] = RE[i] - LE[i]
@@ -877,6 +881,13 @@
@cython.wraparound(False)
@cython.cdivision(True)
cdef int select_cell(self, np.float64_t pos[3], np.float64_t dds[3]) nogil:
+ cdef np.float64_t left_edge[3], right_edge[3]
+ cdef int i
+ if self.loose_selection:
+ for i in range(3):
+ left_edge[i] = pos[i] - dds[i]*0.5
+ right_edge[i] = pos[i] + dds[i]*0.5
+ return self.select_bbox(left_edge, right_edge)
return self.select_point(pos)
@cython.boundscheck(False)
diff -r 81762aa466f368a730c369e7841f7234a06579b2 -r 707e9f9d1a558b417a765cfb2f811146ac0dde13 yt/utilities/lib/misc_utilities.pyx
--- a/yt/utilities/lib/misc_utilities.pyx
+++ b/yt/utilities/lib/misc_utilities.pyx
@@ -798,6 +798,8 @@
cdef int offsets[3][3]
cdef np.int64_t off
for i in range(3):
+ # Offsets here is a way of accounting for periodicity. It keeps track
+ # of how to offset our grid as we loop over the icoords.
dim[i] = output_fields[0].shape[i]
offsets[i][0] = offsets[i][2] = 0
offsets[i][1] = 1
@@ -815,27 +817,36 @@
if offsets[0][wi] == 0: continue
off = (left_index[0] + level_dims[0]*(wi-1))
iind[0] = ipos[i, 0] * rf - off
+ # rf here is the "refinement factor", or, the number of zones
+ # that this zone could potentially contribute to our filled
+ # grid.
for oi in range(rf):
# Now we need to apply our offset
oind[0] = oi + iind[0]
- if oind[0] < 0 or oind[0] >= dim[0]:
+ if oind[0] < 0:
continue
+ elif oind[0] >= dim[0]:
+ break
for wj in range(3):
if offsets[1][wj] == 0: continue
off = (left_index[1] + level_dims[1]*(wj-1))
iind[1] = ipos[i, 1] * rf - off
for oj in range(rf):
oind[1] = oj + iind[1]
- if oind[1] < 0 or oind[1] >= dim[1]:
+ if oind[1] < 0:
continue
+ elif oind[1] >= dim[1]:
+ break
for wk in range(3):
if offsets[2][wk] == 0: continue
off = (left_index[2] + level_dims[2]*(wk-1))
iind[2] = ipos[i, 2] * rf - off
for ok in range(rf):
oind[2] = ok + iind[2]
- if oind[2] < 0 or oind[2] >= dim[2]:
+ if oind[2] < 0:
continue
+ elif oind[2] >= dim[2]:
+ break
ofield[oind[0], oind[1], oind[2]] = \
ifield[i]
tot += 1
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list