[yt-svn] commit/yt: 7 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed May 3 11:48:29 PDT 2017
7 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/a4ee70dfbcb9/
Changeset: a4ee70dfbcb9
Branch: yt
User: atmyers
Date: 2017-05-01 18:31:06+00:00
Summary: set up the 'all' field ftype for stream unstructured mesh datasets.
Affected #: 2 files
diff -r 37ff7ec366ee14773a581197430d0b100344fe1e -r a4ee70dfbcb9db8864f973cde7602f876c9b8a37 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -18,7 +18,10 @@
import weakref
import numpy as np
import uuid
-from itertools import chain, product
+from itertools import \
+ chain, \
+ product, \
+ repeat
from numbers import Number as numeric_type
@@ -71,6 +74,8 @@
StreamFieldInfo
from yt.frontends.exodus_ii.util import \
get_num_pseudo_dims
+from yt.data_objects.unions import MeshUnion
+
class StreamGrid(AMRGridPatch):
"""
@@ -1643,7 +1648,8 @@
connec = ensure_list(self.stream_handler.fields.pop("connectivity"))
self.meshes = [StreamUnstructuredMesh(
i, self.index_filename, c1, c2, self)
- for i, (c1, c2) in enumerate(zip(connec, coords))]
+ for i, (c1, c2) in enumerate(zip(connec, repeat(coords[0])))]
+ self.mesh_union = MeshUnion("mesh_union", self.meshes)
def _setup_data_io(self):
if self.stream_handler.io is not None:
@@ -1653,6 +1659,8 @@
def _detect_output_fields(self):
self.field_list = list(set(self.stream_handler.get_fields()))
+ fnames = list(set([fn for ft, fn in self.field_list]))
+ self.field_list += [('all', fname) for fname in fnames]
class StreamUnstructuredMeshDataset(StreamDataset):
_index_class = StreamUnstructuredIndex
@@ -1867,13 +1875,13 @@
sds = StreamUnstructuredMeshDataset(handler, geometry=geometry,
unit_system=unit_system)
- fluid_types = ()
+ fluid_types = ['all']
for i in range(1, num_meshes + 1):
- fluid_types += ('connect%d' % i,)
- sds.fluid_types = fluid_types
+ fluid_types += ['connect%d' % i]
+ sds.fluid_types = tuple(fluid_types)
- sds._node_fields = node_data[0].keys()
- sds._elem_fields = elem_data[0].keys()
+ sds._node_fields = [[f[1] for f in m][0] for m in node_data if m]
+ sds._elem_fields = [[f[1] for f in m][0] for m in elem_data if m]
sds.default_field = [f for f in sds.field_list
if f[0] == 'connect1'][-1]
diff -r 37ff7ec366ee14773a581197430d0b100344fe1e -r a4ee70dfbcb9db8864f973cde7602f876c9b8a37 yt/frontends/stream/io.py
--- a/yt/frontends/stream/io.py
+++ b/yt/frontends/stream/io.py
@@ -263,26 +263,37 @@
def _read_fluid_selection(self, chunks, selector, fields, size):
chunks = list(chunks)
- chunk = chunks[0]
- mesh_id = chunk.objs[0].mesh_id
rv = {}
for field in fields:
- if field in self.ds._node_fields:
- nodes_per_element = self.fields[mesh_id][field].shape[1]
- rv[field] = np.empty((size, nodes_per_element), dtype="float64")
+ ftype, fname = field
+ if ftype == "all":
+ ci = np.concatenate([mesh.connectivity_indices
+ for mesh in self.ds.index.mesh_union])
else:
- rv[field] = np.empty(size, dtype="float64")
- ngrids = sum(len(chunk.objs) for chunk in chunks)
- mylog.debug("Reading %s cells of %s fields in %s blocks",
- size, [fname for ftype, fname in fields], ngrids)
+ mesh_id = int(ftype[-1]) - 1
+ m = self.ds.index.meshes[mesh_id]
+ ci = m.connectivity_indices
+ num_elem = ci.shape[0]
+ if fname in self.ds._node_fields:
+ nodes_per_element = ci.shape[1]
+ rv[field] = np.empty((num_elem, nodes_per_element), dtype="float64")
+ else:
+ rv[field] = np.empty(num_elem, dtype="float64")
for field in fields:
ind = 0
ftype, fname = field
- for chunk in chunks:
- for g in chunk.objs:
- ds = self.fields[g.mesh_id].get(field, None)
- if ds is None:
- ds = self.fields[g.mesh_id][fname]
- ind += g.select(selector, ds, rv[field], ind) # caches
+ if ftype == "all":
+ mesh_ids = [mesh.mesh_id + 1 for mesh in self.ds.index.mesh_union]
+ objs = [mesh for mesh in self.ds.index.mesh_union]
+ else:
+ mesh_ids = [int(ftype[-1])]
+ chunk = chunks[mesh_ids[0] - 1]
+ objs = chunk.objs
+ for g in objs:
+ ds = self.fields[g.mesh_id].get(field, None)
+ if ds is None:
+ f = ('connect%d' % (g.mesh_id + 1), fname)
+ ds = self.fields[g.mesh_id][f]
+ ind += g.select(selector, ds, rv[field], ind) # caches
return rv
https://bitbucket.org/yt_analysis/yt/commits/2094e73e5c5e/
Changeset: 2094e73e5c5e
User: atmyers
Date: 2017-05-02 18:17:23+00:00
Summary: remove unused variable.
Affected #: 1 file
diff -r a4ee70dfbcb9db8864f973cde7602f876c9b8a37 -r 2094e73e5c5e504696c1697e146bc2d24711dcad yt/frontends/stream/io.py
--- a/yt/frontends/stream/io.py
+++ b/yt/frontends/stream/io.py
@@ -283,7 +283,6 @@
ind = 0
ftype, fname = field
if ftype == "all":
- mesh_ids = [mesh.mesh_id + 1 for mesh in self.ds.index.mesh_union]
objs = [mesh for mesh in self.ds.index.mesh_union]
else:
mesh_ids = [int(ftype[-1])]
https://bitbucket.org/yt_analysis/yt/commits/92333d79a967/
Changeset: 92333d79a967
User: atmyers
Date: 2017-05-02 18:17:43+00:00
Summary: fix inconsistent indentation.
Affected #: 1 file
diff -r 2094e73e5c5e504696c1697e146bc2d24711dcad -r 92333d79a967c072eec39fceac8df5182f9b4307 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -1647,7 +1647,7 @@
coords = ensure_list(self.stream_handler.fields.pop("coordinates"))
connec = ensure_list(self.stream_handler.fields.pop("connectivity"))
self.meshes = [StreamUnstructuredMesh(
- i, self.index_filename, c1, c2, self)
+ i, self.index_filename, c1, c2, self)
for i, (c1, c2) in enumerate(zip(connec, repeat(coords[0])))]
self.mesh_union = MeshUnion("mesh_union", self.meshes)
https://bitbucket.org/yt_analysis/yt/commits/de119e196680/
Changeset: de119e196680
User: atmyers
Date: 2017-05-02 18:18:25+00:00
Summary: add test for stream multi-mesh
Affected #: 1 file
diff -r 92333d79a967c072eec39fceac8df5182f9b4307 -r de119e19668040cb779709a0dde2422bc6c0a478 yt/frontends/stream/tests/test_stream_unstructured.py
--- /dev/null
+++ b/yt/frontends/stream/tests/test_stream_unstructured.py
@@ -0,0 +1,28 @@
+import numpy as np
+
+from yt import load_unstructured_mesh, SlicePlot
+
+def test_multi_mesh():
+ coordsMulti = np.array([[0.0, 0.0],
+ [1.0, 0.0],
+ [1.0, 1.0],
+ [0.0, 1.0]], dtype=np.float64)
+
+ connect1 = np.array([[0, 1, 3], ], dtype=np.int64)
+ connect2 = np.array([[1, 2, 3], ], dtype=np.int64)
+
+ data1 = {}
+ data2 = {}
+ data1['connect1', 'test'] = np.array([[0.0, 1.0, 3.0], ], dtype=np.float64)
+ data2['connect2', 'test'] = np.array([[1.0, 2.0, 3.0], ], dtype=np.float64)
+
+ connectList = [connect1, connect2]
+ dataList = [data1, data2]
+
+ ds = load_unstructured_mesh(connectList, coordsMulti, dataList)
+
+ sl = SlicePlot(ds, 'z', ('connect1', 'test'))
+ sl = SlicePlot(ds, 'z', ('connect2', 'test'))
+ sl = SlicePlot(ds, 'z', ('all', 'test'))
+ sl.annotate_mesh_lines()
+
https://bitbucket.org/yt_analysis/yt/commits/e25894149d0c/
Changeset: e25894149d0c
User: atmyers
Date: 2017-05-02 18:22:21+00:00
Summary: add multi-mesh example to docs.
Affected #: 1 file
diff -r de119e19668040cb779709a0dde2422bc6c0a478 -r e25894149d0cd6167912d5358480bf944712f9d1 doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -1401,15 +1401,51 @@
ds = yt.load_unstructured_mesh(connect, coords, data)
-Note that load_unstructured_mesh can take either a single mesh or a list of meshes.
-Here, we only have one mesh. The in-memory dataset can then be visualized as usual,
-e.g.:
+The in-memory dataset can then be visualized as usual, e.g.:
.. code-block:: python
sl = yt.SlicePlot(ds, 'z', 'test')
sl.annotate_mesh_lines()
+Note that load_unstructured_mesh can take either a single mesh or a list of meshes.
+To load multiple meshes, you can do:
+
+.. code-block:: python
+
+ import yt
+ import numpy as np
+
+ coordsMulti = np.array([[0.0, 0.0],
+ [1.0, 0.0],
+ [1.0, 1.0],
+ [0.0, 1.0]], dtype=np.float64)
+
+ connect1 = np.array([[0, 1, 3], ], dtype=np.int64)
+ connect2 = np.array([[1, 2, 3], ], dtype=np.int64)
+
+ data1 = {}
+ data2 = {}
+ data1['connect1', 'test'] = np.array([[0.0, 1.0, 3.0], ], dtype=np.float64)
+ data2['connect2', 'test'] = np.array([[1.0, 2.0, 3.0], ], dtype=np.float64)
+
+ connectList = [connect1, connect2]
+ dataList = [data1, data2]
+
+ ds = yt.load_unstructured_mesh(connectList, coordsMulti, dataList)
+
+ # only plot the first mesh
+ sl = yt.SlicePlot(ds, 'z', ('connect1', 'test'))
+
+ # only plot the second
+ sl = yt.SlicePlot(ds, 'z', ('connect2', 'test'))
+
+ # plot both
+ sl = yt.SlicePlot(ds, 'z', ('all', 'test'))
+
+Note that you must respect the field naming convention that fields on the first
+mesh will have the type 'connect1', fields on the second will have 'connect2', etc...
+
.. rubric:: Caveats
* Integration is not implemented.
https://bitbucket.org/yt_analysis/yt/commits/e01f5103c0b9/
Changeset: e01f5103c0b9
User: atmyers
Date: 2017-05-02 21:25:45+00:00
Summary: Raise an expection when trying to 3D render mesh unions, and skip these fields in the tests.
Affected #: 2 files
diff -r e25894149d0cd6167912d5358480bf944712f9d1 -r e01f5103c0b9e6babd4b27a53821a27e1a939b2b yt/visualization/volume_rendering/render_source.py
--- a/yt/visualization/volume_rendering/render_source.py
+++ b/yt/visualization/volume_rendering/render_source.py
@@ -531,6 +531,9 @@
# Error checking
assert(self.field is not None)
assert(self.data_source is not None)
+ if self.field[0] == 'all':
+ raise NotImplementedError("Mesh unions are not implemented "
+ "for 3D rendering")
if self.engine == 'embree':
self.volume = mesh_traversal.YTEmbreeScene()
diff -r e25894149d0cd6167912d5358480bf944712f9d1 -r e01f5103c0b9e6babd4b27a53821a27e1a939b2b yt/visualization/volume_rendering/tests/test_mesh_render.py
--- a/yt/visualization/volume_rendering/tests/test_mesh_render.py
+++ b/yt/visualization/volume_rendering/tests/test_mesh_render.py
@@ -40,6 +40,8 @@
ds = fake_tetrahedral_ds()
for field in ds.field_list:
+ if field[0] == 'all':
+ continue
sc = Scene()
sc.add_source(MeshSource(ds, field))
sc.add_camera()
@@ -48,6 +50,8 @@
ds = fake_hexahedral_ds()
for field in ds.field_list:
+ if field[0] == 'all':
+ continue
sc = Scene()
sc.add_source(MeshSource(ds, field))
sc.add_camera()
https://bitbucket.org/yt_analysis/yt/commits/1da4a169ce6e/
Changeset: 1da4a169ce6e
User: xarthisius
Date: 2017-05-03 17:52:55+00:00
Summary: Merge pull request #1357 from atmyers/unstructured_bug_fixes
[BUGFIX] Fix multiple mesh support for streaming unstructured datasets . Closes Issue #1350.
Affected #: 6 files
diff -r 8f01bbe64d90b35ea7d65e2918791cdbec362ccb -r 1da4a169ce6e44d59d643b8704bc6ffa11db5600 doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -1401,15 +1401,51 @@
ds = yt.load_unstructured_mesh(connect, coords, data)
-Note that load_unstructured_mesh can take either a single mesh or a list of meshes.
-Here, we only have one mesh. The in-memory dataset can then be visualized as usual,
-e.g.:
+The in-memory dataset can then be visualized as usual, e.g.:
.. code-block:: python
sl = yt.SlicePlot(ds, 'z', 'test')
sl.annotate_mesh_lines()
+Note that load_unstructured_mesh can take either a single mesh or a list of meshes.
+To load multiple meshes, you can do:
+
+.. code-block:: python
+
+ import yt
+ import numpy as np
+
+ coordsMulti = np.array([[0.0, 0.0],
+ [1.0, 0.0],
+ [1.0, 1.0],
+ [0.0, 1.0]], dtype=np.float64)
+
+ connect1 = np.array([[0, 1, 3], ], dtype=np.int64)
+ connect2 = np.array([[1, 2, 3], ], dtype=np.int64)
+
+ data1 = {}
+ data2 = {}
+ data1['connect1', 'test'] = np.array([[0.0, 1.0, 3.0], ], dtype=np.float64)
+ data2['connect2', 'test'] = np.array([[1.0, 2.0, 3.0], ], dtype=np.float64)
+
+ connectList = [connect1, connect2]
+ dataList = [data1, data2]
+
+ ds = yt.load_unstructured_mesh(connectList, coordsMulti, dataList)
+
+ # only plot the first mesh
+ sl = yt.SlicePlot(ds, 'z', ('connect1', 'test'))
+
+ # only plot the second
+ sl = yt.SlicePlot(ds, 'z', ('connect2', 'test'))
+
+ # plot both
+ sl = yt.SlicePlot(ds, 'z', ('all', 'test'))
+
+Note that you must respect the field naming convention that fields on the first
+mesh will have the type 'connect1', fields on the second will have 'connect2', etc...
+
.. rubric:: Caveats
* Integration is not implemented.
diff -r 8f01bbe64d90b35ea7d65e2918791cdbec362ccb -r 1da4a169ce6e44d59d643b8704bc6ffa11db5600 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -18,7 +18,10 @@
import weakref
import numpy as np
import uuid
-from itertools import chain, product
+from itertools import \
+ chain, \
+ product, \
+ repeat
from numbers import Number as numeric_type
@@ -71,6 +74,8 @@
StreamFieldInfo
from yt.frontends.exodus_ii.util import \
get_num_pseudo_dims
+from yt.data_objects.unions import MeshUnion
+
class StreamGrid(AMRGridPatch):
"""
@@ -1642,8 +1647,9 @@
coords = ensure_list(self.stream_handler.fields.pop("coordinates"))
connec = ensure_list(self.stream_handler.fields.pop("connectivity"))
self.meshes = [StreamUnstructuredMesh(
- i, self.index_filename, c1, c2, self)
- for i, (c1, c2) in enumerate(zip(connec, coords))]
+ i, self.index_filename, c1, c2, self)
+ for i, (c1, c2) in enumerate(zip(connec, repeat(coords[0])))]
+ self.mesh_union = MeshUnion("mesh_union", self.meshes)
def _setup_data_io(self):
if self.stream_handler.io is not None:
@@ -1653,6 +1659,8 @@
def _detect_output_fields(self):
self.field_list = list(set(self.stream_handler.get_fields()))
+ fnames = list(set([fn for ft, fn in self.field_list]))
+ self.field_list += [('all', fname) for fname in fnames]
class StreamUnstructuredMeshDataset(StreamDataset):
_index_class = StreamUnstructuredIndex
@@ -1867,13 +1875,13 @@
sds = StreamUnstructuredMeshDataset(handler, geometry=geometry,
unit_system=unit_system)
- fluid_types = ()
+ fluid_types = ['all']
for i in range(1, num_meshes + 1):
- fluid_types += ('connect%d' % i,)
- sds.fluid_types = fluid_types
+ fluid_types += ['connect%d' % i]
+ sds.fluid_types = tuple(fluid_types)
- sds._node_fields = node_data[0].keys()
- sds._elem_fields = elem_data[0].keys()
+ sds._node_fields = [[f[1] for f in m][0] for m in node_data if m]
+ sds._elem_fields = [[f[1] for f in m][0] for m in elem_data if m]
sds.default_field = [f for f in sds.field_list
if f[0] == 'connect1'][-1]
diff -r 8f01bbe64d90b35ea7d65e2918791cdbec362ccb -r 1da4a169ce6e44d59d643b8704bc6ffa11db5600 yt/frontends/stream/io.py
--- a/yt/frontends/stream/io.py
+++ b/yt/frontends/stream/io.py
@@ -263,26 +263,36 @@
def _read_fluid_selection(self, chunks, selector, fields, size):
chunks = list(chunks)
- chunk = chunks[0]
- mesh_id = chunk.objs[0].mesh_id
rv = {}
for field in fields:
- if field in self.ds._node_fields:
- nodes_per_element = self.fields[mesh_id][field].shape[1]
- rv[field] = np.empty((size, nodes_per_element), dtype="float64")
+ ftype, fname = field
+ if ftype == "all":
+ ci = np.concatenate([mesh.connectivity_indices
+ for mesh in self.ds.index.mesh_union])
else:
- rv[field] = np.empty(size, dtype="float64")
- ngrids = sum(len(chunk.objs) for chunk in chunks)
- mylog.debug("Reading %s cells of %s fields in %s blocks",
- size, [fname for ftype, fname in fields], ngrids)
+ mesh_id = int(ftype[-1]) - 1
+ m = self.ds.index.meshes[mesh_id]
+ ci = m.connectivity_indices
+ num_elem = ci.shape[0]
+ if fname in self.ds._node_fields:
+ nodes_per_element = ci.shape[1]
+ rv[field] = np.empty((num_elem, nodes_per_element), dtype="float64")
+ else:
+ rv[field] = np.empty(num_elem, dtype="float64")
for field in fields:
ind = 0
ftype, fname = field
- for chunk in chunks:
- for g in chunk.objs:
- ds = self.fields[g.mesh_id].get(field, None)
- if ds is None:
- ds = self.fields[g.mesh_id][fname]
- ind += g.select(selector, ds, rv[field], ind) # caches
+ if ftype == "all":
+ objs = [mesh for mesh in self.ds.index.mesh_union]
+ else:
+ mesh_ids = [int(ftype[-1])]
+ chunk = chunks[mesh_ids[0] - 1]
+ objs = chunk.objs
+ for g in objs:
+ ds = self.fields[g.mesh_id].get(field, None)
+ if ds is None:
+ f = ('connect%d' % (g.mesh_id + 1), fname)
+ ds = self.fields[g.mesh_id][f]
+ ind += g.select(selector, ds, rv[field], ind) # caches
return rv
diff -r 8f01bbe64d90b35ea7d65e2918791cdbec362ccb -r 1da4a169ce6e44d59d643b8704bc6ffa11db5600 yt/frontends/stream/tests/test_stream_unstructured.py
--- /dev/null
+++ b/yt/frontends/stream/tests/test_stream_unstructured.py
@@ -0,0 +1,28 @@
+import numpy as np
+
+from yt import load_unstructured_mesh, SlicePlot
+
+def test_multi_mesh():
+ coordsMulti = np.array([[0.0, 0.0],
+ [1.0, 0.0],
+ [1.0, 1.0],
+ [0.0, 1.0]], dtype=np.float64)
+
+ connect1 = np.array([[0, 1, 3], ], dtype=np.int64)
+ connect2 = np.array([[1, 2, 3], ], dtype=np.int64)
+
+ data1 = {}
+ data2 = {}
+ data1['connect1', 'test'] = np.array([[0.0, 1.0, 3.0], ], dtype=np.float64)
+ data2['connect2', 'test'] = np.array([[1.0, 2.0, 3.0], ], dtype=np.float64)
+
+ connectList = [connect1, connect2]
+ dataList = [data1, data2]
+
+ ds = load_unstructured_mesh(connectList, coordsMulti, dataList)
+
+ sl = SlicePlot(ds, 'z', ('connect1', 'test'))
+ sl = SlicePlot(ds, 'z', ('connect2', 'test'))
+ sl = SlicePlot(ds, 'z', ('all', 'test'))
+ sl.annotate_mesh_lines()
+
diff -r 8f01bbe64d90b35ea7d65e2918791cdbec362ccb -r 1da4a169ce6e44d59d643b8704bc6ffa11db5600 yt/visualization/volume_rendering/render_source.py
--- a/yt/visualization/volume_rendering/render_source.py
+++ b/yt/visualization/volume_rendering/render_source.py
@@ -531,6 +531,9 @@
# Error checking
assert(self.field is not None)
assert(self.data_source is not None)
+ if self.field[0] == 'all':
+ raise NotImplementedError("Mesh unions are not implemented "
+ "for 3D rendering")
if self.engine == 'embree':
self.volume = mesh_traversal.YTEmbreeScene()
diff -r 8f01bbe64d90b35ea7d65e2918791cdbec362ccb -r 1da4a169ce6e44d59d643b8704bc6ffa11db5600 yt/visualization/volume_rendering/tests/test_mesh_render.py
--- a/yt/visualization/volume_rendering/tests/test_mesh_render.py
+++ b/yt/visualization/volume_rendering/tests/test_mesh_render.py
@@ -40,6 +40,8 @@
ds = fake_tetrahedral_ds()
for field in ds.field_list:
+ if field[0] == 'all':
+ continue
sc = Scene()
sc.add_source(MeshSource(ds, field))
sc.add_camera()
@@ -48,6 +50,8 @@
ds = fake_hexahedral_ds()
for field in ds.field_list:
+ if field[0] == 'all':
+ continue
sc = Scene()
sc.add_source(MeshSource(ds, field))
sc.add_camera()
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