[yt-svn] commit/yt: jzuhone: Roundoff error in the bounding boxes was causing the kD-tree to be unable to find the right grids when constructing the tree. This occurs when the domain size is numerically very large, as FLASH uses cgs for all units by default.

Bitbucket commits-noreply at bitbucket.org
Thu Jan 19 05:26:00 PST 2012


1 new commit in yt:


https://bitbucket.org/yt_analysis/yt/changeset/0a01c6a96497/
changeset:   0a01c6a96497
branch:      yt
user:        jzuhone
date:        2012-01-19 07:19:20
summary:     Roundoff error in the bounding boxes was causing the kD-tree to be unable to find the right grids when constructing the tree. This occurs when the domain size is numerically very large, as FLASH uses cgs for all units by default.

Sam suggested this fix to "finesse" the roundoff error when reading in FLASH bounding boxes. It's somewhat hackish, so if someone has a more elegant solution feel free to change it.

This may also fix issues I was having with taking slices on grid boundaries, but I'll have to see.
affected #:  1 file

diff -r 92dfa5b8e574eb291f94b6a3e9d23a55148019e7 -r 0a01c6a964977fa37e72016a70697278ae000418 yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -106,6 +106,7 @@
         
         self.grid_left_edge[:] = f["/bounding box"][:,:,0]
         self.grid_right_edge[:] = f["/bounding box"][:,:,1]
+        
         # Move this to the parameter file
         try:
             nxb = pf._find_parameter("integer", "nxb", True)
@@ -129,7 +130,12 @@
         self.grids = na.empty(self.num_grids, dtype='object')
         for i in xrange(self.num_grids):
             self.grids[i] = self.grid(i+1, self, self.grid_levels[i,0])
-
+        dx = ((self.parameter_file.domain_right_edge -
+               self.parameter_file.domain_left_edge)/
+              self.parameter_file.refine_by**(self.grid_levels.max())).astype('float64')
+        self.grid_left_edge = na.rint(self.grid_left_edge/dx)*dx
+        self.grid_right_edge = na.rint(self.grid_right_edge/dx)*dx
+                        
     def _populate_grid_objects(self):
         # We only handle 3D data, so offset is 7 (nfaces+1)
         
@@ -285,9 +291,9 @@
         else:
             raise RuntimeError("Can't figure out FLASH file version.")
         self.domain_left_edge = na.array(
-            [self._find_parameter("real", "%smin" % ax) for ax in 'xyz'])
+            [self._find_parameter("real", "%smin" % ax) for ax in 'xyz']).astype("float64")
         self.domain_right_edge = na.array(
-            [self._find_parameter("real", "%smax" % ax) for ax in 'xyz'])
+            [self._find_parameter("real", "%smax" % ax) for ax in 'xyz']).astype("float64")
         self.min_level = self._find_parameter(
             "integer", "lrefine_min", scalar = False) - 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