[yt-svn] commit/yt: chummels: Merged in atmyers/yt (pull request #2007)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Mar 16 09:39:40 PDT 2016
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/5179a7111bd9/
Changeset: 5179a7111bd9
Branch: yt
User: chummels
Date: 2016-03-16 16:39:28+00:00
Summary: Merged in atmyers/yt (pull request #2007)
Answer tests for unstructured mesh renderings
Affected #: 7 files
diff -r 02dd7d47781782a1e30561f1c4337111a02f7183 -r 5179a7111bd9bd4d9174f368a76f2acab232155c doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -415,9 +415,19 @@
determined by the ``thresh`` parameter, which can be varied to make the lines thicker or
thinner.
+The above example all involve 8-node hexahedral mesh elements. Here is another example from
+a dataset that uses 6-node wedge elements:
+
+.. python-script::
+
+ import yt
+ ds = yt.load("MOOSE_sample_data/wedge_out.e")
+ sl = yt.SlicePlot(ds, 2, ('connect2', 'diffused'))
+ sl.save()
+
Finally, slices can also be used to examine 2D unstructured mesh datasets, but the
slices must be taken to be normal to the ``'z'`` axis, or you'll get an error. Here is
-an example using another MOOSE dataset:
+an example using another MOOSE dataset that uses triangular mesh elements:
.. python-script::
diff -r 02dd7d47781782a1e30561f1c4337111a02f7183 -r 5179a7111bd9bd4d9174f368a76f2acab232155c doc/source/visualizing/unstructured_mesh_rendering.rst
--- a/doc/source/visualizing/unstructured_mesh_rendering.rst
+++ b/doc/source/visualizing/unstructured_mesh_rendering.rst
@@ -214,6 +214,29 @@
# render and save
sc.save()
+Here is an example using 6-node wedge elements:
+
+.. python-script::
+
+ import yt
+
+ ds = yt.load("MOOSE_sample_data/wedge_out.e")
+
+ # create a default scene
+ sc = yt.create_scene(ds, ('connect2', 'diffused'))
+
+ # override the default colormap
+ ms = sc.get_source(0)
+ ms.cmap = 'Eos A'
+
+ # adjust the camera position and orientation
+ cam = sc.camera
+ cam.set_position(ds.arr([1.0, -1.0, 1.0], 'code_length'))
+ cam.width = ds.arr([1.5, 1.5, 1.5], 'code_length')
+
+ # render and save
+ sc.save()
+
Another example, this time plotting the temperature field from a 20-node hex
MOOSE dataset:
@@ -273,7 +296,7 @@
# adjust the camera position and orientation
cam = sc.camera
camera_position = ds.arr([-1.0, 1.0, -0.5], 'code_length')
- north_vector = ds.arr([0.0, 1.0, 1.0], 'dimensionless')
+ north_vector = ds.arr([0.0, -1.0, -1.0], 'dimensionless')
cam.width = ds.arr([0.05, 0.05, 0.05], 'code_length')
cam.set_position(camera_position, north_vector)
diff -r 02dd7d47781782a1e30561f1c4337111a02f7183 -r 5179a7111bd9bd4d9174f368a76f2acab232155c tests/tests_2.7.yaml
--- a/tests/tests_2.7.yaml
+++ b/tests/tests_2.7.yaml
@@ -39,12 +39,13 @@
local_tipsy_270:
- yt/frontends/tipsy/tests/test_outputs.py
- local_varia_270:
+ local_varia_271:
- yt/analysis_modules/radmc3d_export
- yt/frontends/moab/tests/test_c5.py
- yt/analysis_modules/photon_simulator/tests/test_spectra.py
- yt/analysis_modules/photon_simulator/tests/test_sloshing.py
- yt/visualization/volume_rendering/tests/test_vr_orientation.py
+ - yt/visualization/volume_rendering/tests/test_mesh_render.py
local_orion_270:
- yt/frontends/boxlib/tests/test_orion.py
diff -r 02dd7d47781782a1e30561f1c4337111a02f7183 -r 5179a7111bd9bd4d9174f368a76f2acab232155c yt/frontends/exodus_ii/data_structures.py
--- a/yt/frontends/exodus_ii/data_structures.py
+++ b/yt/frontends/exodus_ii/data_structures.py
@@ -354,6 +354,11 @@
displaced_coords = self._apply_displacement(coords, mesh_id)
mi = np.minimum(displaced_coords.min(axis=0), mi)
ma = np.maximum(displaced_coords.max(axis=0), ma)
+
+ # pad domain boundaries
+ width = ma - mi
+ mi -= 0.1 * width
+ ma += 0.1 * width
return mi, ma
@classmethod
diff -r 02dd7d47781782a1e30561f1c4337111a02f7183 -r 5179a7111bd9bd4d9174f368a76f2acab232155c yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -133,11 +133,13 @@
self.light = None
self.data_source = data_source_or_all(data_source)
self._resolution = (512, 512)
+
if self.data_source is not None:
self.scene.set_new_unit_registry(self.data_source.ds.unit_registry)
self._focus = self.data_source.ds.domain_center
self._position = self.data_source.ds.domain_right_edge
- self._width = 1.5*self.data_source.ds.domain_width
+ self._width = self.data_source.ds.arr(
+ [1.5*self.data_source.ds.domain_width.max()]*3)
self._domain_center = self.data_source.ds.domain_center
self._domain_width = self.data_source.ds.domain_width
else:
@@ -175,7 +177,8 @@
raise RuntimeError(
'Cannot set the camera focus and position to the same value')
self._position = position
- self.switch_orientation()
+ self.switch_orientation(normal_vector=self.focus - self._position,
+ north_vector=None)
def fdel(self):
del self._position
@@ -232,7 +235,8 @@
raise RuntimeError(
'Cannot set the camera focus and position to the same value')
self._focus = focus
- self.switch_orientation()
+ self.switch_orientation(normal_vector=self.focus - self._position,
+ north_vector=None)
def fdel(self):
del self._focus
diff -r 02dd7d47781782a1e30561f1c4337111a02f7183 -r 5179a7111bd9bd4d9174f368a76f2acab232155c yt/visualization/volume_rendering/off_axis_projection.py
--- a/yt/visualization/volume_rendering/off_axis_projection.py
+++ b/yt/visualization/volume_rendering/off_axis_projection.py
@@ -155,7 +155,7 @@
camera.resolution = resolution
if not iterable(width):
width = data_source.ds.arr([width]*3)
- camera.position = center - width[2]*camera.normal_vector
+ camera.position = center - width[2]*normal_vector
camera.focus = center
# If north_vector is None, we set the default here.
diff -r 02dd7d47781782a1e30561f1c4337111a02f7183 -r 5179a7111bd9bd4d9174f368a76f2acab232155c 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
@@ -11,11 +11,18 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.testing import fake_tetrahedral_ds
-from yt.testing import fake_hexahedral_ds
-from yt.testing import requires_module
-from yt.visualization.volume_rendering.render_source import MeshSource
-from yt.visualization.volume_rendering.scene import Scene
+from yt.testing import \
+ fake_tetrahedral_ds, \
+ fake_hexahedral_ds, \
+ requires_module
+from yt.utilities.answer_testing.framework import \
+ requires_ds, \
+ data_dir_load, \
+ GenericImageTest
+from yt.visualization.volume_rendering.api import \
+ MeshSource, \
+ Scene, \
+ create_scene
@requires_module("pyembree")
@@ -39,3 +46,101 @@
images.append(im)
return images
+
+
+def compare(ds, im, test_prefix, decimals=12):
+ def mesh_render_image_func(filename_prefix):
+ return im.write_image(filename_prefix)
+
+ test = GenericImageTest(ds, mesh_render_image_func, decimals)
+ test.prefix = test_prefix
+ return test
+
+hex8 = "MOOSE_sample_data/out.e-s010"
+hex8_fields = [('connect1', 'diffused'), ('connect2', 'convected')]
+
+ at requires_ds(hex8)
+ at requires_module("pyembree")
+def test_hex8_render():
+ for field in hex8_fields:
+ ds = data_dir_load(hex8, kwargs={'step':-1})
+ sc = create_scene(ds, field)
+ im = sc.render()
+ yield compare(ds, im, "render_answers_hex8_%s_%s" % field)
+
+
+tet4 = "MOOSE_sample_data/high_order_elems_tet4_refine_out.e"
+tet4_fields = [("connect1", "u")]
+
+ at requires_ds(tet4)
+ at requires_module("pyembree")
+def test_tet4_render():
+ for field in tet4_fields:
+ ds = data_dir_load(tet4, kwargs={'step':-1})
+ sc = create_scene(ds, field)
+ im = sc.render()
+ yield compare(ds, im, "render_answers_tet4_%s_%s" % field)
+
+
+hex20 = "MOOSE_sample_data/mps_out.e"
+hex20_fields = [('connect2', 'temp')]
+
+ at requires_ds(hex20)
+ at requires_module("pyembree")
+def test_hex20_render():
+ for field in hex20_fields:
+ ds = data_dir_load(hex20, kwargs={'step':-1})
+ sc = create_scene(ds, field)
+ im = sc.render()
+ yield compare(ds, im, "render_answers_hex20_%s_%s" % field)
+
+
+wedge6 = "MOOSE_sample_data/wedge_out.e"
+wedge6_fields = [('connect1', 'diffused')]
+
+ at requires_ds(wedge6)
+ at requires_module("pyembree")
+def test_wedge6_render():
+ for field in wedge6_fields:
+ ds = data_dir_load(wedge6, kwargs={'step':-1})
+ sc = create_scene(ds, field)
+ im = sc.render()
+ yield compare(ds, im, "render_answers_wedge6_%s_%s" % field)
+
+
+ at requires_ds(hex8)
+ at requires_module("pyembree")
+def test_perspective_mesh_render():
+ ds = data_dir_load(hex8)
+ sc = create_scene(ds, ("connect2", "diffused"))
+
+ cam = sc.add_camera(ds, lens_type='perspective')
+ cam.focus = ds.arr([0.0, 0.0, 0.0], 'code_length')
+ cam_pos = ds.arr([-4.5, 4.5, -4.5], 'code_length')
+ north_vector = ds.arr([0.0, -1.0, -1.0], 'dimensionless')
+ cam.set_position(cam_pos, north_vector)
+ cam.resolution = (800, 800)
+ im = sc.render()
+ yield compare(ds, im, "perspective_mesh_render")
+
+
+ at requires_ds(hex8)
+ at requires_module("pyembree")
+def test_composite_mesh_render():
+ ds = data_dir_load(hex8)
+ sc = Scene()
+ cam = sc.add_camera(ds)
+ cam.focus = ds.arr([0.0, 0.0, 0.0], 'code_length')
+ cam.set_position(ds.arr([-3.0, 3.0, -3.0], 'code_length'),
+ ds.arr([0.0, -1.0, 0.0], 'dimensionless'))
+ cam.set_width = ds.arr([8.0, 8.0, 8.0], 'code_length')
+ cam.resolution = (800, 800)
+
+ ms1 = MeshSource(ds, ('connect1', 'diffused'))
+ ms2 = MeshSource(ds, ('connect2', 'diffused'))
+
+ sc.add_source(ms1)
+ sc.add_source(ms2)
+
+ im = sc.render()
+ yield compare(ds, im, "composite_mesh_render")
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