.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/05-Legacy/09-basics.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_05-Legacy_09-basics.py: .. _ref_basics: Basic features ============== This example shows you how you can get and use a ``Result`` object. .. GENERATED FROM PYTHON SOURCE LINES 10-13 Perform required imports ------------------------ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 13-17 .. code-block:: Python from ansys.dpf import post from ansys.dpf.post import examples .. GENERATED FROM PYTHON SOURCE LINES 18-22 Get ``Solution`` object ----------------------- Get the ``Solution`` object and instantiate with the path for the result file. .. GENERATED FROM PYTHON SOURCE LINES 22-26 .. code-block:: Python example_path = examples.download_all_kinds_of_complexity() solution = post.load_solution(example_path) .. GENERATED FROM PYTHON SOURCE LINES 27-29 Get ``Result`` objects ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 31-34 Get displacement result ~~~~~~~~~~~~~~~~~~~~~~~ Get the displacement ``Result`` object. .. GENERATED FROM PYTHON SOURCE LINES 34-38 .. code-block:: Python displacement_result = solution.displacement() displacement = displacement_result.vector .. GENERATED FROM PYTHON SOURCE LINES 39-42 Get information on result ~~~~~~~~~~~~~~~~~~~~~~~~~ Get information on the displacement result. .. GENERATED FROM PYTHON SOURCE LINES 42-54 .. code-block:: Python displacement.num_fields disp_data = displacement.get_data_at_field(0) len(disp_data) disp_data[1] displacement.max_data displacement.get_max_data_at_field(0) displacement.min_data .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([[-1.82645944e-06, -1.04473039e+01, -2.94677257e-04]]) .. GENERATED FROM PYTHON SOURCE LINES 55-59 Get stress result ~~~~~~~~~~~~~~~~~ Get the stress ``Result`` object for a tensor. You can get the nodal or elemental location. The default is the nodal location. .. GENERATED FROM PYTHON SOURCE LINES 59-63 .. code-block:: Python el_stress_result = solution.stress(location=post.locations.elemental) nod_stress_result = solution.stress(location=post.locations.nodal) .. GENERATED FROM PYTHON SOURCE LINES 64-67 Get information on result ~~~~~~~~~~~~~~~~~~~~~~~~~ Get information on the stress result. .. GENERATED FROM PYTHON SOURCE LINES 67-78 .. code-block:: Python el_stress = el_stress_result.tensor nod_stress = nod_stress_result.tensor el_field = el_stress[0] el_field.location nod_field = nod_stress[0] nod_field.location el_stress.get_max_data_at_field(0) .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([1.72236948e+10, 3.94412425e+09, 4.40791214e+09, 2.82004580e+09, 1.90183439e+09, 4.26474819e+09]) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.130 seconds) .. _sphx_glr_download_examples_05-Legacy_09-basics.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 09-basics.ipynb <09-basics.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 09-basics.py <09-basics.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_