[yt-svn] commit/yt: jwise77: Reverting speedup changes to smoothed covering grids. Although they

Bitbucket commits-noreply at bitbucket.org
Wed Apr 18 11:03:34 PDT 2012


1 new commit in yt:


https://bitbucket.org/yt_analysis/yt/changeset/8ce2d50069f8/
changeset:   8ce2d50069f8
branch:      yt
user:        jwise77
date:        2012-04-18 19:02:15
summary:     Reverting speedup changes to smoothed covering grids.  Although they
were faster by considering a subset of grids, they produced artifacts
and crashes.  We will continue to work on a solution.
affected #:  1 file

diff -r 45351792a9a8d97db6f292ea7a08caf8290efa8b -r 8ce2d50069f8064fde303a000932211dc3dbe48a yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -3521,62 +3521,16 @@
         self._base_dx = (
               (self.pf.domain_right_edge - self.pf.domain_left_edge) /
                self.pf.domain_dimensions.astype("float64"))
-        self.global_endindex = None
         AMRCoveringGridBase.__init__(self, *args, **kwargs)
         self._final_start_index = self.global_startindex
 
     def _get_list_of_grids(self):
         if self._grids is not None: return
-        # Check for ill-behaved AMR schemes (Enzo) where we may have
-        # root-tile-boundary issues.  This is specific to the root tiles not
-        # allowing grids to cross them and also allowing > 1 level of
-        # difference between neighboring areas.
-        nz = 0
-        buf = 0.0
-        self.min_level = 0
-        dl = ((self.global_startindex.astype("float64") + 1)
-           / (self.pf.refine_by**self.level))
-        dr = ((self.global_startindex.astype("float64")
-              + self.ActiveDimensions - 1)
-           / (self.pf.refine_by**self.level))
-        if na.any(dl == na.rint(dl)) or na.any(dr == na.rint(dr)):
-            nz = 2 * self.pf.refine_by**self.level
-            buf = self._base_dx
-        if nz <= self.pf.refine_by**3: # delta level of 3
-            last_buf = [None,None,None]
-            count = 0
-            # Repeat until no more grids are covered (up to a delta level of 3)
-            while na.any(buf != last_buf) or count == 3:
-                cg = self.pf.h.covering_grid(self.level,
-                     self.left_edge - buf, self.ActiveDimensions + nz)
-                cg._use_pbar = False
-                count = cg.ActiveDimensions.prod()
-                for g in cg._grids:
-                    count -= cg._get_data_from_grid(g, [])
-                    if count <= 0:
-                        self.min_level = g.Level
-                        break
-                last_buf = buf
-                # Increase box by 2 cell widths at the min covering level
-                buf = 2*self._base_dx / self.pf.refine_by**self.min_level
-                nz += 4 * self.pf.refine_by**(self.level-self.min_level)
-                count += 1
-        else:
-            nz = buf = 0
-            self.min_level = 0
-        # This should not cost substantial additional time.
-        BLE = self.left_edge - buf
-        BRE = self.right_edge + buf
-        if na.any(BLE < self.pf.domain_left_edge) or \
-           na.any(BRE > self.pf.domain_right_edge):
-            grids,ind = self.pf.hierarchy.get_periodic_box_grids_below_level(
-                            BLE, BRE, self.level, self.min_level)
-        else:
-            grids,ind = self.pf.hierarchy.get_box_grids_below_level(
-                BLE, BRE, self.level,
-                min(self.level, self.min_level))
-        sort_ind = na.argsort(self.pf.h.grid_levels.ravel()[ind])
-        self._grids = self.pf.hierarchy.grids[ind][(sort_ind,)]
+        buffer = ((self.pf.domain_right_edge - self.pf.domain_left_edge)
+                 / self.pf.domain_dimensions).max()
+        AMRCoveringGridBase._get_list_of_grids(self, buffer)
+        # We reverse the order to ensure that coarse grids are first
+        self._grids = self._grids[::-1]
 
     def get_data(self, field=None):
         self._get_list_of_grids()
@@ -3592,11 +3546,11 @@
         # We jump-start our task here
         mylog.debug("Getting fields %s from %s possible grids",
                    fields_to_get, len(self._grids))
-        self._update_level_state(self.min_level, fields_to_get, initialize=True)
+        self._update_level_state(0, fields_to_get)
         if self._use_pbar: pbar = \
                 get_pbar('Searching grids for values ', len(self._grids))
         # The grids are assumed to be pre-sorted
-        last_level = self.min_level
+        last_level = 0
         for gi, grid in enumerate(self._grids):
             if self._use_pbar: pbar.update(gi)
             if grid.Level > last_level and grid.Level <= self.level:
@@ -3614,31 +3568,27 @@
                     raise KeyError(n_bad)
         if self._use_pbar: pbar.finish()
 
-    def _update_level_state(self, level, fields = None, initialize=False):
+    def _update_level_state(self, level, fields = None):
         dx = self._base_dx / self.pf.refine_by**level
         self.field_data['cdx'] = dx[0]
         self.field_data['cdy'] = dx[1]
         self.field_data['cdz'] = dx[2]
         LL = self.left_edge - self.pf.domain_left_edge
-        RL = self.right_edge - self.pf.domain_left_edge
         self._old_global_startindex = self.global_startindex
-        self._old_global_endindex = self.global_endindex
-        # We use one grid cell at LEAST, plus one buffer on all sides
-        self.global_startindex = na.floor(LL / dx).astype('int64') - 1
-        self.global_endindex = na.ceil(RL / dx).astype('int64') + 1
+        self.global_startindex = na.rint(LL / dx).astype('int64') - 1
         self.domain_width = na.rint((self.pf.domain_right_edge -
                     self.pf.domain_left_edge)/dx).astype('int64')
-        if (level == 0 or initialize) and self.level > 0:
-            idims = self.global_endindex - self.global_startindex
+        if level == 0 and self.level > 0:
+            # We use one grid cell at LEAST, plus one buffer on all sides
+            idims = na.rint((self.right_edge-self.left_edge)/dx).astype('int64') + 2
             fields = ensure_list(fields)
             for field in fields:
                 self.field_data[field] = na.zeros(idims,dtype='float64')-999
             self._cur_dims = idims.astype("int32")
-        elif (level == 0 or initialize) and self.level == 0:
+        elif level == 0 and self.level == 0:
             DLE = self.pf.domain_left_edge
             self.global_startindex = na.array(na.floor(LL/ dx), dtype='int64')
             idims = na.rint((self.right_edge-self.left_edge)/dx).astype('int64')
-            #idims = self.global_endindex - self.global_startindex
             fields = ensure_list(fields)
             for field in fields:
                 self.field_data[field] = na.zeros(idims,dtype='float64')-999
@@ -3647,16 +3597,15 @@
     def _refine(self, dlevel, fields):
         rf = float(self.pf.refine_by**dlevel)
 
-        input_left = (self._old_global_startindex + 0.5) * rf
-        input_right = (self._old_global_endindex - 0.5) * rf
-        output_left = self.global_startindex + 0.5
-        output_right = self.global_endindex - 0.5
-        output_dims = (output_right - output_left + 1).astype('int32')
+        input_left = (self._old_global_startindex + 0.5) * rf 
+        dx = na.fromiter((self['cd%s' % ax] for ax in 'xyz'), count=3, dtype='float64')
+        output_dims = na.rint((self.right_edge-self.left_edge)/dx+0.5).astype('int32') + 2
 
         self._cur_dims = output_dims
 
         for field in fields:
             output_field = na.zeros(output_dims, dtype="float64")
+            output_left = self.global_startindex + 0.5
             ghost_zone_interpolate(rf, self[field], input_left,
                                    output_field, output_left)
             self.field_data[field] = output_field

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