[yt-svn] commit/yt-3.0: 2 new changesets

Bitbucket commits-noreply at bitbucket.org
Sat Aug 11 09:52:49 PDT 2012


2 new commits in yt-3.0:


https://bitbucket.org/yt_analysis/yt-3.0/changeset/fd508927002b/
changeset:   fd508927002b
branch:      yt-3.0
user:        MatthewTurk
date:        2012-08-11 04:19:40
summary:     In the RAMSES reader, all field values now get filled.
affected #:  3 files

diff -r f274670eb23a93e38461faab3aac83dafdac6a56 -r fd508927002ba3b5ac7939f50d562dd3eb21d7f2 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -235,7 +235,7 @@
         all_fields = self.domain.pf.h.field_list
         fields = [f for ft, f in fields]
         tr = {}
-        filled = pos = total = 0
+        filled = pos = level_offset = 0
         min_level = self.domain.pf.min_level
         for field in fields:
             tr[field] = na.zeros(self.cell_count, 'float64')
@@ -243,7 +243,6 @@
             if offset == -1: continue
             content.seek(offset)
             nc = self.domain.level_count[level]
-            level_offset = 0
             temp = {}
             for field in all_fields:
                 temp[field] = na.empty((nc, 8), dtype="float64")
@@ -257,11 +256,10 @@
                         #print "Reading %s in %s : %s" % (field, level,
                         #        self.domain.domain_id)
                         temp[field][:,i] = fpu.read_vector(content, 'd') # cell 1
-            filled = oct_handler.fill_level(self.domain.domain_id, level,
+            level_offset += oct_handler.fill_level(self.domain.domain_id, level,
                                    tr, temp, self.mask, level_offset)
-            total += filled
-            #print "FILL (%s : %s) %s" % (self.domain.domain_id, level, filled)
-        #print "DONE (%s) %s of %s" % (self.domain.domain_id, total, self.cell_count)
+            #print "FILL (%s : %s) %s" % (self.domain.domain_id, level, level_offset)
+        #print "DONE (%s) %s of %s" % (self.domain.domain_id, level_offset, self.cell_count)
         return tr
 
 class RAMSESGeometryHandler(OctreeGeometryHandler):


diff -r f274670eb23a93e38461faab3aac83dafdac6a56 -r fd508927002ba3b5ac7939f50d562dd3eb21d7f2 yt/frontends/ramses/io.py
--- a/yt/frontends/ramses/io.py
+++ b/yt/frontends/ramses/io.py
@@ -50,8 +50,9 @@
                 content = cStringIO.StringIO(f.read())
                 rv = subset.fill(content, fields)
                 for ft, f in fields:
-                    print "Filling %s with %s (%0.3e %0.3e)" % (
-                        f, subset.cell_count, rv[f].min(), rv[f].max())
+                    print "Filling %s with %s (%0.3e %0.3e) (%s:%s)" % (
+                        f, subset.cell_count, rv[f].min(), rv[f].max(),
+                        cp, cp+subset.cell_count)
                     tr[(ft, f)][cp:cp+subset.cell_count] = rv.pop(f)
                 cp += subset.cell_count
         return tr


diff -r f274670eb23a93e38461faab3aac83dafdac6a56 -r fd508927002ba3b5ac7939f50d562dd3eb21d7f2 yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -382,18 +382,18 @@
         cdef int n
         cdef int i, j, k, ii
         cdef int local_pos, local_filled
+        cdef np.float64_t val
         for key in dest_fields:
             local_filled = 0
             dest = dest_fields[key]
             source = source_fields[key]
             for n in range(dom.n):
                 o = &dom.my_octs[n]
-                for i in range(2):
-                    for j in range(2):
-                        for k in range(2):
-                            ii = ((k*2)+j)*2+i
-                            if mask[n + dom.offset,ii] == 0: continue
-                            if o.level == level:
-                                dest[local_filled] = source[o.ind,((k*2)+j)*2+i]
-                                local_filled += 1
+                if o.level != level: continue
+                for i in range(8):
+                    if mask[n + dom.offset, i] == 0: continue
+                    val = source[o.ind,((k*2)+j)*2+i]
+                    dest[local_filled + offset] = val
+                    assert(val != 0.0)
+                    local_filled += 1
         return local_filled



https://bitbucket.org/yt_analysis/yt-3.0/changeset/309c32c2ed9f/
changeset:   309c32c2ed9f
branch:      yt-3.0
user:        MatthewTurk
date:        2012-08-11 18:48:57
summary:     Octs are iterated over in the order they are added to the domain.  So, this can
end up with out-of-level-order octs in a given domain when those octs are part
of a different domain's "essential" octs.  So we need to pass a level_count
array in to most routines (other than the fill routine) to ensure that the
coords and resolutions match up.
affected #:  3 files

diff -r fd508927002ba3b5ac7939f50d562dd3eb21d7f2 -r 309c32c2ed9f36b2585bc1dd93a18d38af48affd yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -207,26 +207,34 @@
         self.domain = domain
         self.oct_handler = domain.pf.h.oct_handler
         self.cell_count = cell_count
+        level_counts = self.oct_handler.count_levels(
+            self.domain.pf.max_level, self.domain.domain_id, mask)
+        level_counts[1:] = level_counts[:-1]
+        level_counts[0] = 0
+        self.level_counts = na.add.accumulate(level_counts)
 
     def icoords(self, dobj):
         return self.oct_handler.icoords(self.domain.domain_id, self.mask,
-                                        self.cell_count)
+                                        self.cell_count,
+                                        self.level_counts.copy())
 
     def fcoords(self, dobj):
         return self.oct_handler.fcoords(self.domain.domain_id, self.mask,
-                                        self.cell_count)
+                                        self.cell_count,
+                                        self.level_counts.copy())
 
     def fwidth(self, dobj):
         base_dx = 1.0/self.domain.pf.domain_dimensions
-        coords = na.empty((self.cell_count, 3), dtype="float64")
+        widths = na.empty((self.cell_count, 3), dtype="float64")
         dds = (2**self.ires(dobj))
         for i in range(3):
-            coords[:,i] = base_dx[i] / dds
-        return coords
+            widths[:,i] = 2.0*base_dx[i] / dds
+        return widths
 
     def ires(self, dobj):
         return self.oct_handler.ires(self.domain.domain_id, self.mask,
-                                     self.cell_count)
+                                     self.cell_count,
+                                     self.level_counts.copy())
 
     def fill(self, content, fields):
         # Here we get a copy of the file, which we skip through and read the


diff -r fd508927002ba3b5ac7939f50d562dd3eb21d7f2 -r 309c32c2ed9f36b2585bc1dd93a18d38af48affd yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -288,28 +288,29 @@
     @cython.wraparound(False)
     @cython.cdivision(True)
     def icoords(self, int domain_id,
-                np.ndarray[np.uint8_t, ndim=1, cast=True] mask,
-                np.int64_t cell_count):
+                np.ndarray[np.uint8_t, ndim=2, cast=True] mask,
+                np.int64_t cell_count,
+                np.ndarray[np.int64_t, ndim=1] level_counts):
         # Wham, bam, it's a scam
-        cdef np.int64_t i, j, k, oi, ci, n
+        cdef np.int64_t i, j, k, oi, ci, n, ii, level
         cdef OctAllocationContainer *cur = self.domains[domain_id - 1]
         cdef Oct *o
         n = mask.shape[0]
         cdef np.ndarray[np.int64_t, ndim=2] coords
         coords = np.empty((cell_count, 3), dtype="int64")
-
-        ci = 0
         for oi in range(cur.n):
-            if mask[oi + cur.offset] == 0: continue
             o = &cur.my_octs[oi]
+            if o.level != level: continue
             for i in range(2):
                 for j in range(2):
                     for k in range(2):
-                        if o.children[i][j][k] != NULL: continue
+                        ii = ((k*2)+j)*2+i
+                        if mask[oi + cur.offset, ii] == 0: continue
+                        ci = level_counts[o.level]
                         coords[ci, 0] = (o.pos[0] << 1) + i
                         coords[ci, 1] = (o.pos[1] << 1) + j
                         coords[ci, 2] = (o.pos[2] << 1) + k
-                        ci += 1
+                        level_counts[o.level] += 1
         return coords
 
     @cython.boundscheck(False)
@@ -317,7 +318,8 @@
     @cython.cdivision(True)
     def ires(self, int domain_id,
                 np.ndarray[np.uint8_t, ndim=2, cast=True] mask,
-                np.int64_t cell_count):
+                np.int64_t cell_count,
+                np.ndarray[np.int64_t, ndim=1] level_counts):
         # Wham, bam, it's a scam
         cdef np.int64_t i, j, k, oi, ci, n
         cdef OctAllocationContainer *cur = self.domains[domain_id - 1]
@@ -329,17 +331,33 @@
         for oi in range(cur.n):
             o = &cur.my_octs[oi]
             for i in range(8):
-                if mask[oi + cur.offset, i]:
-                    levels[ci] = o.level
-                    ci += 1
+                if mask[oi + cur.offset, i] == 0: continue
+                ci = level_counts[o.level]
+                levels[ci] = o.level
+                level_counts[o.level] += 1
         return levels
 
+    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
+        cdef OctAllocationContainer *cur = self.domains[domain_id - 1]
+        cdef Oct *o
+        cdef int oi, i
+        level_count = np.zeros(max_level, 'int64')
+        for oi in range(cur.n):
+            o = &cur.my_octs[oi]
+            for i in range(8):
+                if mask[oi + cur.offset, i] == 0: continue
+                level_count[o.level] += 1
+        return level_count
+
     #@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):
+                np.int64_t cell_count,
+                np.ndarray[np.int64_t, ndim=1] level_counts):
         # Wham, bam, it's a scam
         cdef np.int64_t i, j, k, oi, ci, n, ii
         cdef OctAllocationContainer *cur = self.domains[domain_id - 1]
@@ -354,12 +372,13 @@
             # position.  Note that the positions will also all be offset by
             # dx/2.0.  This is also for *oct grids*, not cells.
             base_dx[i] = (self.DRE[i] - self.DLE[i])/self.nn[i]
-        ci = 0
         for oi in range(cur.n):
             o = &cur.my_octs[oi]
             for i in range(3):
                 # This gives the *grid* width for this level
                 dx[i] = base_dx[i] / (1 << o.level)
+                # o.pos is the *grid* index, so pos[i] is the center of the
+                # first cell in the grid
                 pos[i] = self.DLE[i] + o.pos[i]*dx[i] + dx[i]/4.0
                 dx[i] = dx[i] / 2.0 # This is now the *offset* 
             for i in range(2):
@@ -367,10 +386,11 @@
                     for k in range(2):
                         ii = ((k*2)+j)*2+i
                         if mask[oi + cur.offset, ii] == 0: continue
+                        ci = level_counts[o.level]
                         coords[ci, 0] = pos[0] + dx[0] * i
                         coords[ci, 1] = pos[1] + dx[1] * j
                         coords[ci, 2] = pos[2] + dx[2] * k
-                        ci += 1
+                        level_counts[o.level] += 1
         return coords
 
     def fill_level(self, int domain, int level, dest_fields, source_fields,
@@ -392,7 +412,7 @@
                 if o.level != level: continue
                 for i in range(8):
                     if mask[n + dom.offset, i] == 0: continue
-                    val = source[o.ind,((k*2)+j)*2+i]
+                    val = source[o.ind, i]
                     dest[local_filled + offset] = val
                     assert(val != 0.0)
                     local_filled += 1


diff -r fd508927002ba3b5ac7939f50d562dd3eb21d7f2 -r 309c32c2ed9f36b2585bc1dd93a18d38af48affd yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -202,7 +202,8 @@
         cdef int eterm[3] 
         eterm[0] = eterm[1] = eterm[2] = 0
         if res == 0:
-            for i in range(8): mask[root.local_ind,i] = 0
+            for i in range(8):
+                mask[root.local_ind,i] = 0
             return
         # Now we visit all our children
         spos[0] = pos[0] - sdds[0]/2.0

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