.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorials\mesh\explore_mesh_metadata.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_explore_mesh_metadata.py: .. _ref_tutorials_explore_mesh_metadata: Explore a mesh metadata ======================== :bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX` .. note:: This tutorial requires DPF 9.1 or above (2025 R1). This tutorial explains how to read mesh metadata (data about the elements, nodes, faces, regions, zones, ...) before extracting the mesh from a result file. The mesh metadata information is stored in a :class:`PropertyField` or in a :class:`StringField`. It describes the mesh composition and is mapped to the entity it is defined at. Available metadata includes: - Properties, parts, faces, bodies, zones - Number of nodes and elements - Element types .. GENERATED FROM PYTHON SOURCE LINES 50-52 Import the necessary modules ----------------------------- .. GENERATED FROM PYTHON SOURCE LINES 52-56 .. code-block:: Python from ansys.dpf import core as dpf from ansys.dpf.core import examples .. GENERATED FROM PYTHON SOURCE LINES 57-62 LS-DYNA — explore mesh metadata --------------------------------- Import the result file and create the :class:`Model`. .. GENERATED FROM PYTHON SOURCE LINES 62-69 .. 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") model_2 = dpf.Model(data_sources=ds_2) .. GENERATED FROM PYTHON SOURCE LINES 70-72 Access the :class:`MeshInfo` object to explore available metadata before extracting the mesh. .. GENERATED FROM PYTHON SOURCE LINES 72-76 .. code-block:: Python mesh_info_2 = model_2.metadata.mesh_info print(mesh_info_2) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF MeshInfo ------------------------------ with properties: part_names StringField part_scoping Scoping .. GENERATED FROM PYTHON SOURCE LINES 77-78 Extract specific metadata — here the part names. .. GENERATED FROM PYTHON SOURCE LINES 78-82 .. code-block:: Python cell_zones_2 = mesh_info_2.get_property("part_names") print(cell_zones_2) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF String Field 2 part entities Data:2 elementary data part IDs data ------------ ---------- 1 2 ball .. GENERATED FROM PYTHON SOURCE LINES 83-85 Fluent — explore mesh metadata -------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 85-92 .. code-block:: Python result_file_path_3 = examples.download_fluent_axial_comp()["flprj"] model_3 = dpf.Model(data_sources=result_file_path_3) mesh_info_3 = model_3.metadata.mesh_info print(mesh_info_3) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF MeshInfo ------------------------------ with properties: num_cells int num_nodes int num_faces int body_names StringField body_cell_topology PropertyField body_face_topology PropertyField body_scoping Scoping cell_zone_names StringField cell_zone_elements PropertyField cell_zone_scoping Scoping face_zone_names StringField face_zone_elements PropertyField face_zone_scoping Scoping zone_names StringField num_elem_zone PropertyField zone_scoping Scoping splittable_by StringField .. GENERATED FROM PYTHON SOURCE LINES 93-94 Extract the cell zone names. .. GENERATED FROM PYTHON SOURCE LINES 94-98 .. code-block:: Python cell_zones_3 = mesh_info_3.get_property("cell_zone_names") print(cell_zones_3) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF String Field 2 zone entities Data:2 elementary data zone IDs data ------------ ---------- 13 fluid-rotor 28 fluid-stator .. GENERATED FROM PYTHON SOURCE LINES 99-101 CFX — explore mesh metadata ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 101-108 .. code-block:: Python result_file_path_4 = examples.download_cfx_mixing_elbow() model_4 = dpf.Model(data_sources=result_file_path_4) mesh_info_4 = model_4.metadata.mesh_info print(mesh_info_4) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF MeshInfo ------------------------------ with properties: num_nodes int num_cells int body_names StringField body_cell_topology PropertyField num_faces int body_face_topology PropertyField body_scoping Scoping cell_zone_names StringField cell_zone_elements PropertyField face_zone_names StringField cell_zone_scoping Scoping face_zone_elements PropertyField face_zone_scoping Scoping zone_names StringField num_elem_zone PropertyField zone_scoping Scoping splittable_by StringField .. GENERATED FROM PYTHON SOURCE LINES 109-110 Extract the cell zone names. .. GENERATED FROM PYTHON SOURCE LINES 110-113 .. code-block:: Python cell_zones_4 = mesh_info_4.get_property("cell_zone_names") print(cell_zones_4) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF String Field 3 zone entities Data:3 elementary data zone IDs data ------------ ---------- 2 ZN1/ES1 3 ZN1/ES2 4 ZN1/ES3 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.936 seconds) .. _sphx_glr_download_tutorials_mesh_explore_mesh_metadata.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: explore_mesh_metadata.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: explore_mesh_metadata.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: explore_mesh_metadata.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_