[yt-svn] commit/yt: 3 new changesets
Bitbucket
commits-noreply at bitbucket.org
Fri Nov 11 10:52:22 PST 2011
3 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/1197f2be0042/
changeset: 1197f2be0042
branch: yt
user: MatthewTurk
date: 2011-11-11 18:06:08
summary: Minor change to the FillRegion routine to make it clearer what it's doing.
Adding a calculate_fill_grids routine, which I hope to use for better smoothed
grid calculations.
affected #: 2 files
diff -r 4de2d40209098bb7f4f657f9b2412a0103ea0e5e -r 1197f2be00429b606bf7132be6d42c9c40c5aa26 yt/utilities/_amr_utils/PointsInVolume.pyx
--- a/yt/utilities/_amr_utils/PointsInVolume.pyx
+++ b/yt/utilities/_amr_utils/PointsInVolume.pyx
@@ -215,3 +215,38 @@
break
return good
+def calculate_fill_grids(int fill_level, int refratio, int last_level,
+ np.ndarray[np.int64_t, ndim=1] domain_width,
+ np.ndarray[np.int64_t, ndim=1] cg_start_index,
+ np.ndarray[np.int32_t, ndim=1] cg_dims,
+ np.ndarray[np.int64_t, ndim=1] g_start_index,
+ np.ndarray[np.int32_t, ndim=1] g_dims,
+ np.ndarray[np.int32_t, ndim=3] g_child_mask):
+ cdef np.int64_t cgstart[3], gstart[3]
+ cdef np.int64_t cgend[3], gend[3]
+ cdef np.int64_t dw[3]
+ cdef np.int64_t cxi, cyi, czi, gxi, gyi, gzi, ci, cj, ck
+ cdef int i, total
+ for i in range(3):
+ dw[i] = domain_width[i]
+ cgstart[i] = cg_start_index[i]
+ gstart[i] = g_start_index[i]
+ cgend[i] = cgstart[i] + cg_dims[i]
+ gend[i] = gstart[i] + g_dims[i]
+ for cxi in range(cgstart[0], cgend[0]+1):
+ ci = (cxi % dw[0])
+ if ci < 0: ci += dw[0]
+ if ci < gstart[0]*refratio or ci >= gend[0]*refratio: continue
+ gxi = (<np.int64_t> (ci / refratio)) - gstart[0]
+ for cyi in range(cgstart[1], cgend[1]):
+ cj = (cyi % dw[1])
+ if cj < 0: cj += dw[1]
+ if cj < gstart[1]*refratio or cj >= gend[1]*refratio: continue
+ gyi = (<np.int64_t> (cj / refratio)) - gstart[1]
+ for czi in range(cgstart[2], cgend[2]):
+ ck = (czi % dw[2])
+ if ck < 0: ck += dw[2]
+ if ck < gstart[2]*refratio or cj >= gend[2]*refratio: continue
+ gzi = (<np.int64_t> (ck / refratio)) - gstart[2]
+ if last_level or g_child_mask[gxi, gyi, gzi] > 0: total += 1
+ return total
diff -r 4de2d40209098bb7f4f657f9b2412a0103ea0e5e -r 1197f2be00429b606bf7132be6d42c9c40c5aa26 yt/utilities/data_point_utilities.c
--- a/yt/utilities/data_point_utilities.c
+++ b/yt/utilities/data_point_utilities.c
@@ -937,6 +937,15 @@
/* These functions are both called with
func(cubedata, griddata) */
+static void dcNothing(PyArrayObject* c_data, npy_int64 xc, npy_int64 yc, npy_int64 zc,
+ PyArrayObject* g_data, npy_int64 xg, npy_int64 yg, npy_int64 zg)
+{
+ return;
+}
+
+/* These functions are both called with
+ func(cubedata, griddata) */
+
static void dcRefine(PyArrayObject* c_data, npy_int64 xc, npy_int64 yc, npy_int64 zc,
PyArrayObject* g_data, npy_int64 xg, npy_int64 yg, npy_int64 zg)
{
@@ -1107,36 +1116,37 @@
cdx = (*(npy_int32 *) PyArray_GETPTR1(oc_dims, 0));
cdy = (*(npy_int32 *) PyArray_GETPTR1(oc_dims, 1));
cdz = (*(npy_int32 *) PyArray_GETPTR1(oc_dims, 2));
- cxe = (cxs + cdx - 1);
- cye = (cys + cdy - 1);
- cze = (czs + cdz - 1);
+ cxe = (cxs + cdx);
+ cye = (cys + cdy);
+ cze = (czs + cdz);
/* It turns out that C89 doesn't define a mechanism for choosing the sign
of the remainder.
*/
//fprintf(stderr, "ci == %d, cxi == %d, dw[0] == %d\n", (int) ci, (int) cxi, (int) dw[0]);
- for(cxi=cxs;cxi<=cxe;cxi++) {
+ for(cxi=cxs;cxi<cxe;cxi++) {
ci = (cxi % dw[0]);
ci = (ci < 0) ? ci + dw[0] : ci;
if ( ci < gxs*refratio || ci >= gxe*refratio) continue;
gxi = floor(ci / refratio) - gxs;
- for(cyi=cys;cyi<=cye;cyi++) {
+ for(cyi=cys;cyi<cye;cyi++) {
cj = cyi % dw[1];
cj = (cj < 0) ? cj + dw[1] : cj;
if ( cj < gys*refratio || cj >= gye*refratio) continue;
gyi = floor(cj / refratio) - gys;
- for(czi=czs;czi<=cze;czi++) {
+ for(czi=czs;czi<cze;czi++) {
ck = czi % dw[2];
ck = (ck < 0) ? ck + dw[2] : ck;
if ( ck < gzs*refratio || ck >= gze*refratio) continue;
gzi = floor(ck / refratio) - gzs;
if ((ll) || (*(npy_int32*)PyArray_GETPTR3(mask, gxi,gyi,gzi) > 0))
{
- for(n=0;n<n_fields;n++){
- to_call(c_data[n],
- cxi - cxs, cyi - cys, czi - czs,
- g_data[n], gxi, gyi, gzi);
- }
+ if (direction!=2)
+ for(n=0;n<n_fields;n++){
+ to_call(c_data[n],
+ cxi - cxs, cyi - cys, czi - czs,
+ g_data[n], gxi, gyi, gzi);
+ }
total += 1;
}
}
https://bitbucket.org/yt_analysis/yt/changeset/9d18fc3a9406/
changeset: 9d18fc3a9406
branch: yt
user: MatthewTurk
date: 2011-11-11 19:32:35
summary: Adding support for ghost zones in Enzo outputs.
affected #: 2 files
diff -r 1197f2be00429b606bf7132be6d42c9c40c5aa26 -r 9d18fc3a940699586cdb23d91f6b18419c955ee6 yt/frontends/enzo/data_structures.py
--- a/yt/frontends/enzo/data_structures.py
+++ b/yt/frontends/enzo/data_structures.py
@@ -205,6 +205,8 @@
list_of_sets = []
if len(list_of_sets) == 0 and rank == 3:
mylog.debug("Detected packed HDF5")
+ if self.parameters.get("WriteGhostZones", 0) == 1:
+ self.data_style= "enzo_packed_3d_gz"
self.data_style = 'enzo_packed_3d'
elif len(list_of_sets) > 0 and rank == 3:
mylog.debug("Detected unpacked HDF5")
diff -r 1197f2be00429b606bf7132be6d42c9c40c5aa26 -r 9d18fc3a940699586cdb23d91f6b18419c955ee6 yt/frontends/enzo/io.py
--- a/yt/frontends/enzo/io.py
+++ b/yt/frontends/enzo/io.py
@@ -181,8 +181,8 @@
mylog.debug("Finished read of %s", sets)
def _read_data_set(self, grid, field):
- return hdf5_light_reader.ReadData(grid.filename,
- "/Grid%08i/%s" % (grid.id, field)).swapaxes(0,2)
+ return self.modify(hdf5_light_reader.ReadData(grid.filename,
+ "/Grid%08i/%s" % (grid.id, field)))
def _read_data_slice(self, grid, field, axis, coord):
axis = _axis_ids[axis]
@@ -197,6 +197,18 @@
def _read_exception(self):
return (exceptions.KeyError, hdf5_light_reader.ReadingError)
+class IOHandlerPackedHDF5GhostZones(IOHandlerPackedHDF5):
+ _data_style = "enzo_packed_3d_gz"
+
+ def modify(self, field):
+ tr = field[3:-3,3:-3,3:-3].swapaxes(0,2)
+ return tr.copy() # To ensure contiguous
+
+ def _read_data_slice(self, grid, field, axis, coord):
+ axis = _axis_ids[axis]
+ return hdf5_light_reader.ReadDataSlice(grid.filename, "/Grid%08i/%s" %
+ (grid.id, field), axis, coord)[3:-3,3:-3].transpose()
+
class IOHandlerInMemory(BaseIOHandler):
_data_style = "enzo_inline"
https://bitbucket.org/yt_analysis/yt/changeset/8f056f151151/
changeset: 8f056f151151
branch: yt
user: MatthewTurk
date: 2011-11-11 19:51:48
summary: Adding support for ghost zone datasets written out by Enzo. This should reduce
or eliminate the slowness of calculating basic fields in ghost zones. There
may still be bugs.
affected #: 3 files
diff -r 9d18fc3a940699586cdb23d91f6b18419c955ee6 -r 8f056f1511519d40c9bfdce38fc067f2d23e2357 yt/data_objects/grid_patch.py
--- a/yt/data_objects/grid_patch.py
+++ b/yt/data_objects/grid_patch.py
@@ -166,14 +166,14 @@
def keys(self):
return self.field_data.keys()
- def get_data(self, field):
+ def get_data(self, field, convert = True):
"""
Returns a field or set of fields for a key or set of keys
"""
if not self.field_data.has_key(field):
if field in self.hierarchy.field_list:
conv_factor = 1.0
- if self.pf.field_info.has_key(field):
+ if self.pf.field_info.has_key(field) and convert == True:
conv_factor = self.pf.field_info[field]._convert_function(self)
if self.pf.field_info[field].particle_type and \
self.NumberOfParticles == 0:
diff -r 9d18fc3a940699586cdb23d91f6b18419c955ee6 -r 8f056f1511519d40c9bfdce38fc067f2d23e2357 yt/frontends/enzo/data_structures.py
--- a/yt/frontends/enzo/data_structures.py
+++ b/yt/frontends/enzo/data_structures.py
@@ -127,6 +127,56 @@
def set_filename(self, filename):
pass
+class EnzoGridGZ(EnzoGrid):
+
+ __slots__ = ()
+
+ def retrieve_ghost_zones(self, n_zones, fields, all_levels=False,
+ smoothed=False):
+ # We ignore smoothed in this case.
+ if n_zones > 3:
+ return EnzoGrid.retrieve_ghost_zones(
+ self, n_zones, fields, all_levels, smoothed)
+ # ----- Below is mostly the original code, except we remove the field
+ # ----- access section
+ # We will attempt this by creating a datacube that is exactly bigger
+ # than the grid by nZones*dx in each direction
+ nl = self.get_global_startindex() - n_zones
+ nr = nl + self.ActiveDimensions + 2*n_zones
+ new_left_edge = nl * self.dds + self.pf.domain_left_edge
+ new_right_edge = nr * self.dds + self.pf.domain_left_edge
+ # Something different needs to be done for the root grid, though
+ level = self.Level
+ args = (level, new_left_edge, new_right_edge)
+ kwargs = {'dims': self.ActiveDimensions + 2*n_zones,
+ 'num_ghost_zones':n_zones,
+ 'use_pbar':False}
+ # This should update the arguments to set the field parameters to be
+ # those of this grid.
+ kwargs.update(self.field_parameters)
+ if smoothed:
+ #cube = self.hierarchy.smoothed_covering_grid(
+ # level, new_left_edge, new_right_edge, **kwargs)
+ cube = self.hierarchy.smoothed_covering_grid(
+ level, new_left_edge, **kwargs)
+ else:
+ cube = self.hierarchy.covering_grid(
+ level, new_left_edge, **kwargs)
+ # ----- This is EnzoGrid.get_data, duplicated here mostly for
+ # ---- efficiency's sake.
+ sl = (slice(3 - n_zones, 3 - n_zones) for i in range(3))
+ for field in fields:
+ if field in self.hierarchy.field_list:
+ conv_factor = 1.0
+ if self.pf.field_info.has_key(field):
+ conv_factor = self.pf.field_info[field]._convert_function(self)
+ if self.pf.field_info[field].particle_type: continue
+ temp = self.hierarchy.io._read_raw_data_set(self, field)
+ temp = temp.swapaxes(0, 2)
+ print "SETTING CUBE"
+ cube.field_data[field] = na.multiply(temp, conv_factor, temp)[sl]
+ return cube
+
class EnzoHierarchy(AMRHierarchy):
_strip_path = False
@@ -207,7 +257,9 @@
mylog.debug("Detected packed HDF5")
if self.parameters.get("WriteGhostZones", 0) == 1:
self.data_style= "enzo_packed_3d_gz"
- self.data_style = 'enzo_packed_3d'
+ self.grid = EnzoGridGZ
+ else:
+ self.data_style = 'enzo_packed_3d'
elif len(list_of_sets) > 0 and rank == 3:
mylog.debug("Detected unpacked HDF5")
self.data_style = 'enzo_hdf5'
diff -r 9d18fc3a940699586cdb23d91f6b18419c955ee6 -r 8f056f1511519d40c9bfdce38fc067f2d23e2357 yt/frontends/enzo/io.py
--- a/yt/frontends/enzo/io.py
+++ b/yt/frontends/enzo/io.py
@@ -209,6 +209,10 @@
return hdf5_light_reader.ReadDataSlice(grid.filename, "/Grid%08i/%s" %
(grid.id, field), axis, coord)[3:-3,3:-3].transpose()
+ def _read_raw_data_set(self, grid, field):
+ return hdf5_light_reader.ReadData(grid.filename,
+ "/Grid%08i/%s" % (grid.id, field))
+
class IOHandlerInMemory(BaseIOHandler):
_data_style = "enzo_inline"
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