.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\06-plotting\01-compare_results.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_06-plotting_01-compare_results.py: .. _compare_results: Compare results using the plotter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This example shows how to plot several mesh/result combinations on the same plot so that you can compare results at different time steps. .. GENERATED FROM PYTHON SOURCE LINES 11-16 .. code-block:: Python from ansys.dpf import core as dpf from ansys.dpf.core import examples from ansys.dpf.core.plotter import DpfPlotter .. GENERATED FROM PYTHON SOURCE LINES 17-21 Compare two results ~~~~~~~~~~~~~~~~~~~ Use the :class:`ansys.dpf.core.plotter.DpfPlotter` class to plot two different results over the same mesh and compare them. .. GENERATED FROM PYTHON SOURCE LINES 21-32 .. code-block:: Python # Here we create a Model and request its mesh model = dpf.Model(examples.find_msup_transient()) mesh_set2 = model.metadata.meshed_region # Then we need to request the displacement for two different time steps displacement_operator = model.results.displacement() displacement_operator.inputs.time_scoping.connect([2, 15]) displacement_set2 = displacement_operator.outputs.fields_container()[0] displacement_set15 = displacement_operator.outputs.fields_container()[1] .. GENERATED FROM PYTHON SOURCE LINES 33-35 Use the :class:`ansys.dpf.core.plotter.DpfPlotter` class to add plots for the first mesh and the first result. .. GENERATED FROM PYTHON SOURCE LINES 35-51 .. code-block:: Python pl = DpfPlotter() pl.add_field(displacement_set2, mesh_set2) # Create a new mesh and translate it along the x axis. mesh_set15 = mesh_set2.deep_copy() overall_field = dpf.fields_factory.create_3d_vector_field(1, dpf.locations.overall) overall_field.append([0.2, 0.0, 0.0], 1) coordinates_to_update = mesh_set15.nodes.coordinates_field add_operator = dpf.operators.math.add(coordinates_to_update, overall_field) coordinates_updated = add_operator.outputs.field() coordinates_to_update.data = coordinates_updated.data # Use the :class:`ansys.dpf.core.plotter.DpfPlotter` class to add plots for the # second mesh and the second result. pl.add_field(displacement_set15, mesh_set15) pl.show_figure(show_axes=True) .. image-sg:: /examples/06-plotting/images/sphx_glr_01-compare_results_001.png :alt: 01 compare results :srcset: /examples/06-plotting/images/sphx_glr_01-compare_results_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.688 seconds) .. _sphx_glr_download_examples_06-plotting_01-compare_results.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 01-compare_results.ipynb <01-compare_results.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01-compare_results.py <01-compare_results.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_