[Yt-svn] yt-commit r356 - trunk/yt/lagos

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Sun Jan 6 00:01:20 PST 2008


Author: mturk
Date: Sun Jan  6 00:01:18 2008
New Revision: 356
URL: http://yt.spacepope.org/changeset/356

Log:

Minor shifts to accommodate new contours stuff.  (Contours are working, but
need more testing.)



Modified:
   trunk/yt/lagos/BaseDataTypes.py
   trunk/yt/lagos/DerivedFields.py
   trunk/yt/lagos/WeaveStrings.py

Modified: trunk/yt/lagos/BaseDataTypes.py
==============================================================================
--- trunk/yt/lagos/BaseDataTypes.py	(original)
+++ trunk/yt/lagos/BaseDataTypes.py	Sun Jan  6 00:01:18 2008
@@ -845,7 +845,7 @@
                 dx, grid["GridIndices"][pointI].ravel()], 'float64').swapaxes(0,1)
         return tr
 
-    def get_data(self, fields=None):
+    def get_data(self, fields=None, in_grids=False):
         self._get_list_of_grids()
         points = []
         #if not self.has_key('dx'):
@@ -859,7 +859,7 @@
             if self.data.has_key(field):
                 continue
             mylog.info("Getting field %s from %s", field, len(self._grids))
-            if field not in self.hierarchy.field_list:
+            if field not in self.hierarchy.field_list and not in_grids:
                 if self._generate_field(field):
                     continue # True means we already assigned it
             self[field] = na.concatenate(
@@ -882,12 +882,11 @@
         # Kind of a dangerous thing to do
         i = 0
         for grid in self._grids:
-            pointI = self._get_point_indices
+            pointI = self._get_point_indices(grid)
             new_field = na.ones(grid.ActiveDimensions, dtype=dtype) * default_val
             np = pointI[0].ravel().size
             new_field[pointI] = self[field][i:i+np]
             grid[field] = new_field.copy()
-            i += np
 
     def _generate_field(self, field):
         if fieldInfo.has_key(field):
@@ -978,7 +977,7 @@
 
     __gridRightEdge = None
     gridRightEdge = property(__get_gridRightEdge, __set_gridRightEdge,
-                              __del_gridRightEdge)
+                             __del_gridRightEdge)
 
 class ExtractedRegionBase(Enzo3DData):
     def __init__(self, base_region, indices):
@@ -1055,8 +1054,6 @@
         self._grids = grid_list
         self.fields = fields
         self.connection_pool = True
-        for grid in grid_list:
-            grid._file_access_pooling = True
 
     def _get_list_of_grids(self):
         pass
@@ -1170,6 +1167,21 @@
             if na.any(self[field] == -999) and len(self._grids) > 1:
                 raise KeyError
 
+    def flush_data(self, field=None):
+        self._get_list_of_grids()
+        # We don't generate coordinates here.
+        if field == None:
+            fields_to_get = self.fields
+        else:
+            fields_to_get = ensure_list(field)
+        for field in fields_to_get:
+            mylog.info("Flushing field %s to %s possible grids",
+                       field, len(self._grids))
+            grid_list = self._grids.tolist()
+            grid_list.reverse()
+            for grid in grid_list:
+                self._flush_data_to_grid(grid, field)
+
     @restore_grid_state
     def _get_data_from_grid(self, grid, fields):
         for field in ensure_list(fields):
@@ -1182,3 +1194,15 @@
                          compiler='gcc',
                          type_converters=converters.blitz,
                          auto_downcast=0, verbose=2)
+
+    def _flush_data_to_grid(self, grid, fields):
+        for field in ensure_list(fields):
+            locals_dict = self.__setup_weave_dict(grid)
+            locals_dict['fieldData'] = grid[field]
+            locals_dict['cubeData'] = self[field]
+            locals_dict['lastLevel'] = int(grid.Level == self.level)
+            weave.inline(DataCubeReplaceData,
+                         locals_dict.keys(), local_dict=locals_dict,
+                         compiler='gcc',
+                         type_converters=converters.blitz,
+                         auto_downcast=0, verbose=2)

Modified: trunk/yt/lagos/DerivedFields.py
==============================================================================
--- trunk/yt/lagos/DerivedFields.py	(original)
+++ trunk/yt/lagos/DerivedFields.py	Sun Jan  6 00:01:18 2008
@@ -465,6 +465,10 @@
           units=r"\rm{s}^{-1}",
           convert_function=_convertDivV)
 
+def _Contours(field, data):
+    return na.ones(data["Density"].shape)*-1
+add_field("Contours", validators=[ValidateSpatial(0)], take_log=False)
+
 def _Radius(field, data):
     center = data.get_field_parameter("center")
     radius = na.sqrt((data["x"] - center[0])**2.0 +

Modified: trunk/yt/lagos/WeaveStrings.py
==============================================================================
--- trunk/yt/lagos/WeaveStrings.py	(original)
+++ trunk/yt/lagos/WeaveStrings.py	Sun Jan  6 00:01:18 2008
@@ -120,7 +120,7 @@
 
 """
 
-DataCubeRefineCoarseData = \
+_baseDataCubeRefineCoarseData = \
 r"""
 
 // For every cell in fieldData, there are (dx_c / dx_f)**3.0 cells that it maps
@@ -157,10 +157,14 @@
             if (yf < 0 || yf > nyf) continue;
             for (zf = bz_f; zf < max_bz_f ; zf++) {
               if (zf < 0 || zf > nzf) continue;
-              cubeData(xf,yf,zf) = fieldData(xc,yc,zc);
+              %s
             }
           }
         }
     }
-
 """
+
+DataCubeRefineCoarseData = _baseDataCubeRefineCoarseData % \
+                           "cubeData(xf,yf,zf) = fieldData(xc,yc,zc);"
+DataCubeReplaceData = _baseDataCubeRefineCoarseData % \
+                           "fieldData(xc,yc,zc) = cubeData(xf,yf,zf);"



More information about the yt-svn mailing list