[yt-svn] commit/yt-3.0: MatthewTurk: This fixes two important fencepost errors, and now slicing works with RAMSES
Bitbucket
commits-noreply at bitbucket.org
Mon Aug 13 07:39:24 PDT 2012
1 new commit in yt-3.0:
https://bitbucket.org/yt_analysis/yt-3.0/changeset/e6db01a719d6/
changeset: e6db01a719d6
branch: yt-3.0
user: MatthewTurk
date: 2012-08-13 16:39:15
summary: This fixes two important fencepost errors, and now slicing works with RAMSES
data without any issues that I can identify. The old method of slicing took
~55 seconds start to finish, and gave bad results, and the new method takes ~6
seconds and gives good results.
affected #: 3 files
diff -r e97797d574b9a16fbe273cc0451cd661154c3ee5 -r e6db01a719d6c88f4288f515af2d847a4f3d4d08 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -224,11 +224,12 @@
self.level_counts.copy())
def fwidth(self, dobj):
+ # Recall domain_dimensions is the number of cells, not octs
base_dx = 1.0/self.domain.pf.domain_dimensions
widths = na.empty((self.cell_count, 3), dtype="float64")
dds = (2**self.ires(dobj))
for i in range(3):
- widths[:,i] = 2.0*base_dx[i] / dds
+ widths[:,i] = base_dx[i] / dds
return widths
def ires(self, dobj):
diff -r e97797d574b9a16fbe273cc0451cd661154c3ee5 -r e6db01a719d6c88f4288f515af2d847a4f3d4d08 yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -268,9 +268,9 @@
if cont.n_assigned >= cont.n:
raise AssertionError
next = &cont.my_octs[cont.n_assigned]
- cont.n_assigned += 1
cur.children[ind[0]][ind[1]][ind[2]] = next
next.local_ind = cont.offset + cont.n_assigned
+ cont.n_assigned += 1
next.parent = cur
for i in range(3):
next.pos[i] = ind[i] + (cur.pos[i] << 1)
@@ -305,7 +305,7 @@
for j in range(2):
for k in range(2):
ii = ((k*2)+j)*2+i
- if mask[oi + cur.offset, ii] == 0: continue
+ if mask[o.local_ind, ii] == 0: continue
ci = level_counts[o.level]
coords[ci, 0] = (o.pos[0] << 1) + i
coords[ci, 1] = (o.pos[1] << 1) + j
@@ -337,6 +337,9 @@
level_counts[o.level] += 1
return levels
+ @cython.boundscheck(False)
+ @cython.wraparound(False)
+ @cython.cdivision(True)
def count_levels(self, int max_level, int domain_id,
np.ndarray[np.uint8_t, ndim=2, cast=True] mask):
cdef np.ndarray[np.int64_t, ndim=1] level_count
@@ -347,13 +350,13 @@
for oi in range(cur.n):
o = &cur.my_octs[oi]
for i in range(8):
- if mask[oi + cur.offset, i] == 0: continue
+ if mask[o.local_ind, i] == 0: continue
level_count[o.level] += 1
return level_count
- #@cython.boundscheck(False)
- #@cython.wraparound(False)
- #@cython.cdivision(True)
+ @cython.boundscheck(False)
+ @cython.wraparound(False)
+ @cython.cdivision(True)
def fcoords(self, int domain_id,
np.ndarray[np.uint8_t, ndim=2, cast=True] mask,
np.int64_t cell_count,
@@ -385,7 +388,7 @@
for j in range(2):
for k in range(2):
ii = ((k*2)+j)*2+i
- if mask[oi + cur.offset, ii] == 0: continue
+ if mask[o.local_ind, ii] == 0: continue
ci = level_counts[o.level]
coords[ci, 0] = pos[0] + dx[0] * i
coords[ci, 1] = pos[1] + dx[1] * j
@@ -393,6 +396,9 @@
level_counts[o.level] += 1
return coords
+ @cython.boundscheck(False)
+ @cython.wraparound(False)
+ @cython.cdivision(True)
def fill_level(self, int domain, int level, dest_fields, source_fields,
np.ndarray[np.uint8_t, ndim=2, cast=True] mask, int offset):
cdef np.ndarray[np.float64_t, ndim=2] source
@@ -410,10 +416,11 @@
for n in range(dom.n):
o = &dom.my_octs[n]
if o.level != level: continue
- for i in range(8):
- if mask[n + dom.offset, i] == 0: continue
- val = source[o.ind, i]
- dest[local_filled + offset] = val
- assert(val != 0.0)
- local_filled += 1
+ for i in range(2):
+ for j in range(2):
+ for k in range(2):
+ ii = ((k*2)+j)*2+i
+ if mask[o.local_ind, ii] == 0: continue
+ dest[local_filled + offset] = source[o.ind, ii]
+ local_filled += 1
return local_filled
diff -r e97797d574b9a16fbe273cc0451cd661154c3ee5 -r e6db01a719d6c88f4288f515af2d847a4f3d4d08 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -164,8 +164,10 @@
cdef int i, j, k, n
cdef np.ndarray[np.uint8_t, ndim=2] mask = np.zeros((octree.nocts, 8), dtype='uint8')
cdef np.float64_t pos[3], dds[3]
+ # This dds is the oct-width
for i in range(3):
dds[i] = (octree.DRE[i] - octree.DLE[i]) / octree.nn[i]
+ # Pos is the center of the octs
pos[0] = octree.DLE[0] + dds[0]/2.0
for i in range(octree.nn[0]):
pos[1] = octree.DLE[1] + dds[1]/2.0
@@ -189,11 +191,12 @@
np.ndarray[np.uint8_t, ndim=2] mask,
int level = 0):
cdef np.float64_t LE[3], RE[3], sdds[3], spos[3]
- cdef int i, j, k, res
+ cdef int i, j, k, res, ii
cdef Oct *ch
- # Remember that pos is the *center* of the oct!
- # So, let's check each corner
+ # Remember that pos is the *center* of the oct, and dds is the oct
+ # width. So to get to the edges, we add/subtract half of dds.
for i in range(3):
+ # sdds is the cell width
sdds[i] = dds[i]/2.0
LE[i] = pos[i] - dds[i]/2.0
RE[i] = pos[i] + dds[i]/2.0
@@ -205,19 +208,22 @@
for i in range(8):
mask[root.local_ind,i] = 0
return
- # Now we visit all our children
+ # Now we visit all our children. We subtract off sdds for the first
+ # pass because we center it on the first cell.
spos[0] = pos[0] - sdds[0]/2.0
for i in range(2):
spos[1] = pos[1] - sdds[1]/2.0
for j in range(2):
spos[2] = pos[2] - sdds[2]/2.0
for k in range(2):
+ ii = ((k*2)+j)*2+i
ch = root.children[i][j][k]
if ch != NULL:
+ mask[root.local_ind, ii] = 0
self.recursively_select_octs(
ch, spos, sdds, mask, level + 1)
else:
- mask[root.local_ind, ((k*2)+j)*2+i] = \
+ mask[root.local_ind, ii] = \
self.select_cell(spos, sdds, eterm)
spos[2] += sdds[2]
spos[1] += sdds[1]
Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/
--
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