.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorials\mesh\get_mesh_from_result_file.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_tutorials_mesh_get_mesh_from_result_file.py: .. _ref_tutorials_get_mesh_from_result_file: Get a mesh from a result file ============================== :bdg-mapdl:`MAPDL` :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` This tutorial explains how to extract a mesh from a result file. The mesh object in DPF is a :class:`MeshedRegion`. You can obtain a ``MeshedRegion`` by creating your own from scratch or by getting it from a result file. You can get the mesh from a result file using two approaches: - Using the :class:`Model` - Using the :class:`mesh_provider` operator .. note:: A ``Model`` extracts a large amount of information by default (results, mesh and analysis data). If using this helper takes a long time, consider using a ``DataSources`` object and instantiating operators directly with it. .. GENERATED FROM PYTHON SOURCE LINES 51-53 Import the necessary modules ----------------------------- .. GENERATED FROM PYTHON SOURCE LINES 53-57 .. code-block:: Python from ansys.dpf import core as dpf from ansys.dpf.core import examples, operators as ops .. GENERATED FROM PYTHON SOURCE LINES 58-63 MAPDL — import and get mesh ---------------------------- Define result file path and create a :class:`DataSources` object. .. GENERATED FROM PYTHON SOURCE LINES 63-67 .. code-block:: Python result_file_path_1 = examples.find_static_rst() ds_1 = dpf.DataSources(result_path=result_file_path_1) .. GENERATED FROM PYTHON SOURCE LINES 68-69 Get the mesh using the ``Model``. .. GENERATED FROM PYTHON SOURCE LINES 69-74 .. code-block:: Python model_1 = dpf.Model(data_sources=ds_1) meshed_region_11 = model_1.metadata.meshed_region print(meshed_region_11) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Meshed Region: 81 nodes 8 elements Unit: m With solid (3D) elements .. GENERATED FROM PYTHON SOURCE LINES 75-78 Get the mesh using the :class:`mesh_provider` operator. .. GENERATED FROM PYTHON SOURCE LINES 78-82 .. code-block:: Python meshed_region_12 = ops.mesh.mesh_provider(data_sources=ds_1).eval() print(meshed_region_12) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Meshed Region: 81 nodes 8 elements Unit: m With solid (3D) elements .. GENERATED FROM PYTHON SOURCE LINES 83-88 LS-DYNA — import and get mesh ------------------------------ The d3plot file requires an ``actunits`` file to get correct units when the simulation was run through Mechanical. .. GENERATED FROM PYTHON SOURCE LINES 88-94 .. code-block:: Python result_file_path_2 = examples.download_d3plot_beam() ds_2 = dpf.DataSources() ds_2.set_result_file_path(filepath=result_file_path_2[0], key="d3plot") ds_2.add_file_path(filepath=result_file_path_2[3], key="actunits") .. GENERATED FROM PYTHON SOURCE LINES 95-96 Get the mesh using the ``Model``. .. GENERATED FROM PYTHON SOURCE LINES 96-101 .. code-block:: Python model_2 = dpf.Model(data_sources=ds_2) meshed_region_21 = model_2.metadata.meshed_region print(meshed_region_21) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Meshed Region: 1940 nodes 2056 elements Unit: mm With solid (3D) elements, beam (1D) elements .. GENERATED FROM PYTHON SOURCE LINES 102-103 Get the mesh using the ``mesh_provider`` operator. .. GENERATED FROM PYTHON SOURCE LINES 103-107 .. code-block:: Python meshed_region_22 = ops.mesh.mesh_provider(data_sources=ds_2).eval() print(meshed_region_22) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Meshed Region: 1940 nodes 2056 elements Unit: mm With solid (3D) elements, beam (1D) elements .. GENERATED FROM PYTHON SOURCE LINES 108-110 Fluent — import and get mesh ----------------------------- .. GENERATED FROM PYTHON SOURCE LINES 110-114 .. code-block:: Python result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] ds_3 = dpf.DataSources(result_path=result_file_path_3) .. GENERATED FROM PYTHON SOURCE LINES 115-116 Get the mesh using the ``Model``. .. GENERATED FROM PYTHON SOURCE LINES 116-121 .. code-block:: Python model_3 = dpf.Model(data_sources=ds_3) meshed_region_31 = model_3.metadata.meshed_region print(meshed_region_31) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Meshed Region: 16660 nodes 13856 elements 44242 faces Unit: m With solid (3D) elements .. GENERATED FROM PYTHON SOURCE LINES 122-123 Get the mesh using the ``mesh_provider`` operator. .. GENERATED FROM PYTHON SOURCE LINES 123-127 .. code-block:: Python meshed_region_32 = ops.mesh.mesh_provider(data_sources=ds_3).eval() print(meshed_region_32) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Meshed Region: 16660 nodes 13856 elements 44242 faces Unit: m With solid (3D) elements .. GENERATED FROM PYTHON SOURCE LINES 128-130 CFX — import and get mesh -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 130-134 .. code-block:: Python result_file_path_4 = examples.download_cfx_mixing_elbow() ds_4 = dpf.DataSources(result_path=result_file_path_4) .. GENERATED FROM PYTHON SOURCE LINES 135-136 Get the mesh using the ``Model``. .. GENERATED FROM PYTHON SOURCE LINES 136-141 .. code-block:: Python model_4 = dpf.Model(data_sources=ds_4) meshed_region_41 = model_4.metadata.meshed_region print(meshed_region_41) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Meshed Region: 6219 nodes 15695 elements Unit: m With solid (3D) elements .. GENERATED FROM PYTHON SOURCE LINES 142-143 Get the mesh using the ``mesh_provider`` operator. .. GENERATED FROM PYTHON SOURCE LINES 143-146 .. code-block:: Python meshed_region_42 = ops.mesh.mesh_provider(data_sources=ds_4).eval() print(meshed_region_42) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Meshed Region: 6219 nodes 15695 elements Unit: m With solid (3D) elements .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 20.250 seconds) .. _sphx_glr_download_tutorials_mesh_get_mesh_from_result_file.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: get_mesh_from_result_file.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: get_mesh_from_result_file.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: get_mesh_from_result_file.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_