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

Bitbucket commits-noreply at bitbucket.org
Thu Nov 10 07:26:28 PST 2011


2 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/f26a801bd2c3/
changeset:   f26a801bd2c3
branch:      yt
user:        MatthewTurk
date:        2011-11-09 22:15:24
summary:     Adding isocontour tests and enabling parallelism for isocontours.
affected #:  2 files

diff -r c83c0ec05170fe71d142ca6c16230a99ce06a37f -r f26a801bd2c3a8dc207d9945c730109cd149008e tests/object_field_values.py
--- a/tests/object_field_values.py
+++ b/tests/object_field_values.py
@@ -73,12 +73,38 @@
         YTStaticOutputTest.setup(self)
         known_objects[self.object_name](self)
 
+class YTExtractIsocontoursTest(YTFieldValuesTest):
+    def run(self):
+        val = self.data_object.quantities["WeightedAverageQuantity"](
+            "Density", "Density")
+        triangles = self.data_object.extract_isocontours("Density",
+            val, rescale = False, sample_values = "Temperature")
+        self.result = triangles
+
+    def compare(self, old_result):
+        self.compare_array_delta(self.result, old_result, 1e-7)
+
+class YTIsocontourFluxTest(YTFieldValuesTest):
+    def run(self):
+        val = self.data_object.quantities["WeightedAverageQuantity"](
+            "Density", "Density")
+        flux = self.data_object.calculate_isocontour_flux(
+           "Density", val, "x-velocity", "y-velocity", "z-velocity")
+        self.result = flux
+
+    def compare(self, old_result):
+        self.compare_value_delta(self.result, old_result, 1e-7)
+
 for object_name in known_objects:
     for field in field_list + particle_field_list:
         if "cut_region" in object_name and field in particle_field_list:
             continue
         create_test(YTFieldValuesTest, "%s_%s" % (object_name, field),
                     field = field, object_name = object_name)
+    create_test(YTExtractIsocontoursTest, "%s" % (object_name),
+                object_name = object_name)
+    create_test(YTIsocontourFluxTest, "%s" % (object_name),
+                object_name = object_name)
     
 class YTDerivedQuantityTest(YTStaticOutputTest):
     def setup(self):
@@ -140,4 +166,3 @@
                     "%s_%s" % (object_name, field),
                     field_name = field, 
                     object_name = object_name)
-


diff -r c83c0ec05170fe71d142ca6c16230a99ce06a37f -r f26a801bd2c3a8dc207d9945c730109cd149008e yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -2266,7 +2266,7 @@
             grid.child_mask, self.domain_width, dls[grid.Level],
             self.axis)
 
-class AMR3DData(AMRData, GridPropertiesMixin):
+class AMR3DData(AMRData, GridPropertiesMixin, ParallelAnalysisInterface):
     _key_fields = ['x','y','z','dx','dy','dz']
     """
     Class describing a cluster of data points, not necessarily sharing any
@@ -2280,6 +2280,7 @@
         used as a base class.  Note that *center* is supplied, but only used
         for fields and quantities that require it.
         """
+        ParallelAnalysisInterface.__init__(self)
         AMRData.__init__(self, pf, fields, **kwargs)
         self._set_center(center)
         self.coords = None
@@ -2479,12 +2480,19 @@
             format.  Suitable for loading into meshlab.
         rescale : bool, optional
             If true, the vertices will be rescaled within their min/max.
+        sample_values : string, optional
+            Any field whose value should be extracted at the center of each
+            triangle.
 
         Returns
         -------
         verts : array of floats
             The array of vertices, x,y,z.  Taken in threes, these are the
             triangle vertices.
+        samples : array of floats
+            If `sample_values` is specified, this will be returned and will
+            contain the values of the field specified at the center of each
+            triangle.
 
         References
         ----------
@@ -2504,9 +2512,7 @@
         """
         verts = []
         samples = []
-        pb = get_pbar("Extracting Isocontours", len(self._grids))
-        for i, g in enumerate(self._grids):
-            pb.update(i)
+        for i, g in enumerate(self._get_grid_objs()):
             mask = self._get_cut_mask(g) * g.child_mask
             vals = g.get_vertex_centered_data(field)
             if sample_values is not None:
@@ -2519,20 +2525,24 @@
                 my_verts, svals = my_verts
                 samples.append(svals)
             verts.append(my_verts)
-        pb.finish()
-        verts = na.concatenate(verts)
+        verts = na.concatenate(verts).transpose()
+        verts = self.comm.par_combine_object(verts, op='cat', datatype='array')
+        verts = verts.transpose()
         if sample_values is not None:
             samples = na.concatenate(samples)
+            samples = self.comm.par_combine_object(samples, op='cat',
+                                datatype='array')
         if rescale:
             mi = na.min(verts, axis=0)
             ma = na.max(verts, axis=0)
             verts = (verts - mi) / (ma - mi).max()
-        if filename is not None:
+        if filename is not None and self.comm.rank == 0:
             f = open(filename, "w")
             for v1 in verts:
                 f.write("v %0.16e %0.16e %0.16e\n" % (v1[0], v1[1], v1[2]))
             for i in range(len(verts)/3):
                 f.write("f %s %s %s\n" % (i*3+1, i*3+2, i*3+3))
+            f.close()
         if sample_values is not None:
             return verts, samples
         return verts



https://bitbucket.org/yt_analysis/yt/changeset/4f5784fc9216/
changeset:   4f5784fc9216
branch:      yt
user:        MatthewTurk
date:        2011-11-09 22:18:57
summary:     Parallelizing flux calculation.
affected #:  1 file

diff -r f26a801bd2c3a8dc207d9945c730109cd149008e -r 4f5784fc9216982bdb6f64d63e6ff5f765ba6353 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -2612,7 +2612,7 @@
         ...     "x-velocity", "y-velocity", "z-velocity", "Metal_Density")
         """
         flux = 0.0
-        for g in self._grids:
+        for g in self._get_grid_objs():
             mask = self._get_cut_mask(g) * g.child_mask
             vals = g.get_vertex_centered_data(field)
             if fluxing_field is None:
@@ -2623,6 +2623,7 @@
                          [field_x, field_y, field_z]]
             flux += march_cubes_grid_flux(value, vals, xv, yv, zv,
                         ff, mask, g.LeftEdge, g.dds)
+        flux = self.comm.mpi_allreduce(flux, op="sum")
         return flux
 
     def extract_connected_sets(self, field, num_levels, min_val, max_val,

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