Note
Go to the end to download the full example code.
Get a mesh from a result file#
MAPDL LSDYNA Fluent CFX
This tutorial explains how to extract a mesh from a result file.
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.
You can get the mesh from a result file using two approaches:
Using the
ModelUsing the
mesh_provideroperator
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.
Import the necessary modules#
from ansys.dpf import core as dpf
from ansys.dpf.core import examples, operators as ops
MAPDL — import and get mesh#
Define result file path and create a
DataSources object.
result_file_path_1 = examples.find_static_rst()
ds_1 = dpf.DataSources(result_path=result_file_path_1)
Get the mesh using the Model.
model_1 = dpf.Model(data_sources=ds_1)
meshed_region_11 = model_1.metadata.meshed_region
print(meshed_region_11)
DPF Meshed Region:
81 nodes
8 elements
Unit: m
With solid (3D) elements
Get the mesh using the
mesh_provider
operator.
meshed_region_12 = ops.mesh.mesh_provider(data_sources=ds_1).eval()
print(meshed_region_12)
DPF Meshed Region:
81 nodes
8 elements
Unit: m
With solid (3D) elements
LS-DYNA — import and get mesh#
The d3plot file requires an actunits file to get correct units when the
simulation was run through Mechanical.
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")
Get the mesh using the Model.
model_2 = dpf.Model(data_sources=ds_2)
meshed_region_21 = model_2.metadata.meshed_region
print(meshed_region_21)
DPF Meshed Region:
1940 nodes
2056 elements
Unit: mm
With solid (3D) elements, beam (1D) elements
Get the mesh using the mesh_provider operator.
meshed_region_22 = ops.mesh.mesh_provider(data_sources=ds_2).eval()
print(meshed_region_22)
DPF Meshed Region:
1940 nodes
2056 elements
Unit: mm
With solid (3D) elements, beam (1D) elements
Fluent — import and get mesh#
result_file_path_3 = examples.download_fluent_axial_comp()["flprj"]
ds_3 = dpf.DataSources(result_path=result_file_path_3)
Get the mesh using the Model.
model_3 = dpf.Model(data_sources=ds_3)
meshed_region_31 = model_3.metadata.meshed_region
print(meshed_region_31)
DPF Meshed Region:
16660 nodes
13856 elements
44242 faces
Unit: m
With solid (3D) elements
Get the mesh using the mesh_provider operator.
meshed_region_32 = ops.mesh.mesh_provider(data_sources=ds_3).eval()
print(meshed_region_32)
DPF Meshed Region:
16660 nodes
13856 elements
44242 faces
Unit: m
With solid (3D) elements
CFX — import and get mesh#
result_file_path_4 = examples.download_cfx_mixing_elbow()
ds_4 = dpf.DataSources(result_path=result_file_path_4)
Get the mesh using the Model.
model_4 = dpf.Model(data_sources=ds_4)
meshed_region_41 = model_4.metadata.meshed_region
print(meshed_region_41)
DPF Meshed Region:
6219 nodes
15695 elements
Unit: m
With solid (3D) elements
Get the mesh using the mesh_provider operator.
meshed_region_42 = ops.mesh.mesh_provider(data_sources=ds_4).eval()
print(meshed_region_42)
DPF Meshed Region:
6219 nodes
15695 elements
Unit: m
With solid (3D) elements
Total running time of the script: (0 minutes 20.110 seconds)