Explore a mesh#

MAPDL LSDYNA Fluent CFX

This tutorial explains how to access a mesh data and metadata so it can be manipulated.

The mesh object in DPF is a MeshedRegion. You can obtain a MeshedRegion by creating your own from scratch or by getting it from a result file. For more information, see the Create a mesh from scratch and Get a mesh from a result file tutorials.

Import the necessary modules#

from ansys.dpf import core as dpf
from ansys.dpf.core import examples, operators as ops

Define the mesh#

For this tutorial, we get a MeshedRegion from a result file. For more information see the Get a mesh from a result file tutorial.

MAPDL

result_file_path_1 = examples.find_static_rst()
model_1 = dpf.Model(data_sources=result_file_path_1)
meshed_region_1 = model_1.metadata.meshed_region

LS-DYNA

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)
meshed_region_2 = model_2.metadata.meshed_region

Fluent

result_file_path_3 = examples.download_fluent_axial_comp()["flprj"]
model_3 = dpf.Model(data_sources=result_file_path_3)
meshed_region_3 = model_3.metadata.meshed_region

CFX

result_file_path_4 = examples.download_cfx_mixing_elbow()
model_4 = dpf.Model(data_sources=result_file_path_4)
meshed_region_4 = model_4.metadata.meshed_region

Explore the mesh data#

Access the mesh data by manipulating the MeshedRegion object methods. The mesh data includes:

  • Unit

  • Nodes, elements, and faces

  • Named selections

The MeshedRegion.nodes, MeshedRegion.elements, MeshedRegion.faces, and MeshedRegion.named_selections properties return corresponding DPF objects: Nodes, Elements, Faces, and Scoping.

Here, we explore the data about the mesh nodes for each solver.

nodes_1 = meshed_region_1.nodes
print("Object type: ", type(nodes_1), "\n")
print("Nodes (MAPDL): ", nodes_1)
Object type:  <class 'ansys.dpf.core.nodes.Nodes'>

Nodes (MAPDL):  DPF Node collection with 81 nodes
nodes_2 = meshed_region_2.nodes
print("Nodes (LSDYNA): ", nodes_2)
Nodes (LSDYNA):  DPF Node collection with 1940 nodes
nodes_3 = meshed_region_3.nodes
print("Nodes (Fluent): ", nodes_3)
Nodes (Fluent):  DPF Node collection with 16660 nodes
nodes_4 = meshed_region_4.nodes
print("Nodes (CFX): ", nodes_4)
Nodes (CFX):  DPF Node collection with 6219 nodes

Get the mesh bounding box#

Use the MeshedRegion.bounding_box property to get the bounding box. It is a 6D Field with 1 entity containing the bounding box data in the format [x_min, y_min, z_min, x_max, y_max, z_max].

bbox_1 = meshed_region_1.bounding_box
print("Bounding box (MAPDL): ", bbox_1)

bbox_2 = meshed_region_2.bounding_box
print("Bounding box (LSDYNA): ", bbox_2)

bbox_3 = meshed_region_3.bounding_box
print("Bounding box (Fluent): ", bbox_3)

bbox_4 = meshed_region_4.bounding_box
print("Bounding box (CFX): ", bbox_4)
Bounding box (MAPDL):  DPF bounding_box Field
  Location: overall
  Unit: m
  1 entities
  Data: 6 components and 1 elementary data

  IDs                   data(m)
  ------------          ----------
  0                     0.000000e+00   3.000000e-02   0.000000e+00   3.000000e-02   6.000000e-02   3.000000e-02



Bounding box (LSDYNA):  DPF bounding_box Field
  Location: overall
  Unit: mm
  1 entities
  Data: 6 components and 1 elementary data

  IDs                   data(mm)
  ------------          ----------
  0                     -1.500000e+02  -1.500000e+02  0.000000e+00   1.500000e+02   1.500000e+02   1.010000e+02



Bounding box (Fluent):  DPF bounding_box Field
  Location: overall
  Unit: m
  1 entities
  Data: 6 components and 1 elementary data

  IDs                   data(m)
  ------------          ----------
  0                     -5.146646e-02  -1.041350e-01  -6.350001e-02  2.717609e-02   -5.315754e-02  1.847001e-02



Bounding box (CFX):  DPF bounding_box Field
  Location: overall
  Unit: m
  1 entities
  Data: 6 components and 1 elementary data

  IDs                   data(m)
  ------------          ----------
  0                     -5.000000e-01  -1.000000e+00  0.000000e+00   5.000000e-01   6.000000e+00   6.500000e+00

Explore the mesh metadata#

Access the mesh metadata by manipulating the MeshedRegion object properties. Check which metadata properties are available for each result file.

available_props_1 = meshed_region_1.available_property_fields
print("Available properties (MAPDL): ", available_props_1)

available_props_2 = meshed_region_2.available_property_fields
print("Available properties (LSDYNA): ", available_props_2)

available_props_3 = meshed_region_3.available_property_fields
print("Available properties (Fluent): ", available_props_3)

available_props_4 = meshed_region_4.available_property_fields
print("Available properties (CFX): ", available_props_4)
Available properties (MAPDL):  ['connectivity', 'elprops', 'eltype', 'apdl_element_type', 'section', 'mat', 'apdl_tshape']
Available properties (LSDYNA):  ['connectivity', 'eltype', 'mat']
Available properties (Fluent):  ['connectivity', 'eltype', 'faces_type', 'faces_nodes_connectivity', 'elements_faces_connectivity', 'elements_faces_reversed']
Available properties (CFX):  ['connectivity', 'eltype']

Extract a specific property — the element types for each mesh.

The element type is given as a number. See element_types for the corresponding element names.

el_types_1 = meshed_region_1.elements.element_types_field
print("Element types (MAPDL): ", el_types_1)

el_types_2 = meshed_region_2.property_field(property_name="eltype")
print("Element types (LSDYNA): ", el_types_2)

el_types_3 = meshed_region_3.property_field(property_name="eltype")
print("Element types (Fluent): ", el_types_3)

el_types_4 = meshed_region_4.property_field(property_name="eltype")
print("Element types (CFX): ", el_types_4)
Element types (MAPDL):  DPF Property Field
  8 entities
  Data: 1 components and 8 elementary data

  Elemental
  IDs                   data
  ------------          ----------
  5                     1

  6                     1

  1                     1

  ...


Element types (LSDYNA):  DPF Property Field
  2056 entities
  Data: 1 components and 2056 elementary data

  Elemental
  IDs                   data
  ------------          ----------
  257                   11

  258                   11

  259                   11

  ...


Element types (Fluent):  DPF Property Field
  13856 entities
  Data: 1 components and 13856 elementary data

  Elemental
  IDs                   data
  ------------          ----------
  1                     11

  2                     11

  3                     11

  ...


Element types (CFX):  DPF Property Field
  15695 entities
  Data: 1 components and 15695 elementary data

  Elemental
  IDs                   data
  ------------          ----------
  1                     10

  2                     10

  3                     10

  ...

Total running time of the script: (0 minutes 12.138 seconds)

Gallery generated by Sphinx-Gallery