Skip to content

Commit 8901fc3

Browse files
update the read_mesh_metadata.rst to the tutorials guidelines
1 parent c3deaec commit 8901fc3

File tree

1 file changed

+82
-62
lines changed

1 file changed

+82
-62
lines changed

doc/source/user_guide/tutorials/mesh/read_mesh_metadata.rst

+82-62
Original file line numberDiff line numberDiff line change
@@ -6,88 +6,98 @@ Read a mesh metadata
66

77
:bdg-lsdyna:`LSDYNA` :bdg-fluent:`Fluent` :bdg-cfx:`CFX`
88

9-
.. |MeshedRegion| replace:: :class:`MeshedRegion <ansys.dpf.core.meshed_region.MeshedRegion>`
10-
.. |Model| replace:: :class:`Model <ansys.dpf.core.model.Model>`
11-
.. |DataSources| replace:: :class:`Model <ansys.dpf.core.data_sources.DataSources>`
12-
.. |MeshInfo| replace:: :class:`MeshInfo <ansys.dpf.core.mesh_info.MeshInfo>`
13-
.. |Examples| replace:: :mod:`Examples<ansys.dpf.core.examples>`
9+
.. include:: ../../../links_and_refs.rst
1410

1511
This tutorial explains how to read a mesh metadata (data about the elements, nodes, faces, region, zone ...)
16-
for LSDYNA, Fluent or CFX result files.
12+
before extracting the mesh from a result file.
1713

18-
The mesh object in DPF is a |MeshedRegion|. You can obtain a |MeshedRegion| by creating your
19-
own by scratch or by getting it from a result file. For more information check the
20-
:ref:`tutorials_create_a_mesh_from_scratch` and :ref:`tutorials_get_mesh_from_result_file` tutorials.
14+
:jupyter-download-script:`Download tutorial as Python script<read_mesh_metadata>`
15+
:jupyter-download-notebook:`Download tutorial as Jupyter notebook<read_mesh_metadata>`
2116

22-
We have the |MeshInfo| object to read metadata information before extracting the |MeshedRegion|.
23-
You can obtain this object by creating a |Model| with a result file.
17+
Get the result file
18+
-------------------
2419

25-
Define the |Model|
26-
------------------
27-
28-
Here we we will download result files available in our |Examples| package.
29-
For more information about how to import your result file in DPF check
30-
the :ref:`ref_tutorials_import_data` tutorial section.
20+
First, import a result file. For this tutorial, you can use one available in the |Examples| module.
21+
For more information about how to import your own result file in DPF, see the :ref:`ref_tutorials_import_data`
22+
tutorial section.
3123

3224
.. tab-set::
3325

3426
.. tab-item:: LSDYNA
3527

3628
.. jupyter-execute::
3729

38-
# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
30+
# Import the ``ansys.dpf.core`` module
3931
from ansys.dpf import core as dpf
32+
# Import the examples module
4033
from ansys.dpf.core import examples
41-
from ansys.dpf.core import operators as ops
42-
# Define the result file
34+
35+
# Define the result file path
4336
result_file_path_2 = examples.download_d3plot_beam()
44-
# Create the DataSources object
45-
my_data_sources_2 = dpf.DataSources()
46-
my_data_sources_2.set_result_file_path(filepath=result_file_path_2[0], key="d3plot")
47-
my_data_sources_2.add_file_path(filepath=result_file_path_2[3], key="actunits")
48-
# Create the model
49-
my_model_2 = dpf.Model(data_sources=my_data_sources_2)
50-
# Get the mesh
51-
my_meshed_region_2 = my_model_2.metadata.meshed_region
5237

5338
.. tab-item:: Fluent
5439

5540
.. jupyter-execute::
5641

57-
# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
42+
# Import the ``ansys.dpf.core`` module
5843
from ansys.dpf import core as dpf
44+
# Import the examples module
5945
from ansys.dpf.core import examples
60-
from ansys.dpf.core import operators as ops
61-
# Define the result file
46+
47+
# Define the result file path
6248
result_file_path_3 = examples.download_fluent_axial_comp()["flprj"]
63-
# Create the model
64-
my_model_3 = dpf.Model(data_sources=result_file_path_3)
65-
# Get the mesh
66-
my_meshed_region_3 = my_model_3.metadata.meshed_region
6749

6850
.. tab-item:: CFX
6951

7052
.. jupyter-execute::
7153

72-
# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
54+
# Import the ``ansys.dpf.core`` module
7355
from ansys.dpf import core as dpf
56+
# Import the examples module
7457
from ansys.dpf.core import examples
75-
from ansys.dpf.core import operators as ops
76-
# Define the result file
58+
59+
# Define the result file path
7760
result_file_path_4 = examples.download_cfx_mixing_elbow()
78-
# Create the model
79-
my_model_4 = dpf.Model(data_sources=result_file_path_4)
80-
# Get the mesh
81-
my_meshed_region_4 = my_model_4.metadata.meshed_region
61+
62+
Create the |Model|
63+
------------------
64+
65+
Create a |Model| object with the result file. The |Model| is a helper designed to give shortcuts to
66+
access the analysis results metadata and to instanciate results providers by opening a |DataSources| or a Streams.
67+
68+
.. tab-set::
69+
70+
.. tab-item:: LSDYNA
71+
72+
.. jupyter-execute::
73+
74+
# Create the DataSources object
75+
ds_2 = dpf.DataSources()
76+
ds_2.set_result_file_path(filepath=result_file_path_2[0], key="d3plot")
77+
ds_2.add_file_path(filepath=result_file_path_2[3], key="actunits")
78+
# Create the Model
79+
model_2 = dpf.Model(data_sources=ds_2)
80+
81+
.. tab-item:: Fluent
82+
83+
.. jupyter-execute::
84+
85+
# Create the Model
86+
model_3 = dpf.Model(data_sources=result_file_path_3)
87+
88+
.. tab-item:: CFX
89+
90+
.. jupyter-execute::
91+
92+
# Create the Model
93+
model_4 = dpf.Model(data_sources=result_file_path_4)
8294

8395
Read the mesh metadata
8496
----------------------
8597

86-
The |Model| is a helper designed to give shortcuts to access the analysis results
87-
metadata, by opening a DataSources or a Streams, and to instanciate results provider
88-
for it.
98+
You can access the mesh metadata with the |MeshInfo| object. It reads the metadata information before extracting
99+
the MeshedRegion from the result file.
89100

90-
From the |Model| you can access the |MeshedRegion| metadata information with the |MeshInfo| object.
91101
The mesh metadata information includes :
92102

93103
- Properties;
@@ -98,7 +108,7 @@ The mesh metadata information includes :
98108
- Number of nodes and elements;
99109
- Elements types.
100110

101-
Get the the mesh metadata information and print the available ones:
111+
Get the the mesh metadata information and print the available ones.
102112

103113
.. tab-set::
104114

@@ -107,30 +117,34 @@ Get the the mesh metadata information and print the available ones:
107117
.. jupyter-execute::
108118

109119
# Get the mesh metadata information
110-
my_mesh_info_2 = my_model_2.metadata.mesh_info
120+
mesh_info_2 = model_2.metadata.mesh_info
121+
111122
# Print the mesh metadata information
112-
print(my_mesh_info_2)
123+
print(mesh_info_2)
113124

114125
.. tab-item:: Fluent
115126

116127
.. jupyter-execute::
117128

118129
# Get the mesh metadata information
119-
my_mesh_info_3 = my_model_3.metadata.mesh_info
130+
mesh_info_3 = model_3.metadata.mesh_info
131+
120132
# Print the mesh metadata information
121-
print(my_mesh_info_3)
133+
print(mesh_info_3)
122134

123135
.. tab-item:: CFX
124136

125137
.. jupyter-execute::
126138

127139
# Get the mesh metadata information
128-
my_mesh_info_4 = my_model_4.metadata.mesh_info
140+
mesh_info_4 = model_4.metadata.mesh_info
141+
129142
# Print the mesh metadata information
130-
print(my_mesh_info_4)
143+
print(mesh_info_4)
131144

132145
You can extract each of those mesh information by manipulating the |MeshInfo| object properties.
133-
For example we can check the part names (for the LSDYNA result file) or the cell zone names
146+
147+
For example, we can check the part names (for the LSDYNA result file) or the cell zone names
134148
(for the Fluent or CFX result files):
135149

136150
.. tab-set::
@@ -140,24 +154,30 @@ For example we can check the part names (for the LSDYNA result file) or the cell
140154
.. jupyter-execute::
141155

142156
# Get the part names
143-
my_cell_zones_2 = my_mesh_info_2.get_property("part_names")
144-
print(my_cell_zones_2)
157+
cell_zones_2 = mesh_info_2.get_property("part_names")
158+
159+
# Print the part names
160+
print(cell_zones_2)
145161

146162
.. tab-item:: Fluent
147163

148164
.. jupyter-execute::
149165

150166
# Get the cell zone names
151-
my_cell_zones_3 = my_mesh_info_3.get_property("cell_zone_names")
152-
print(my_cell_zones_3)
167+
cell_zones_3 = mesh_info_3.get_property("cell_zone_names")
168+
169+
# Print the cell zone names
170+
print(cell_zones_3)
153171

154172
.. tab-item:: CFX
155173

156174
.. jupyter-execute::
157175

158176
# Get the cell zone names
159-
my_cell_zones_4 = my_mesh_info_4.get_property("cell_zone_names")
160-
print(my_cell_zones_4)
177+
cell_zones_4 = mesh_info_4.get_property("cell_zone_names")
178+
179+
# Print the cell zone names
180+
print(cell_zones_4)
161181

162-
For more information on reading a mesh from a LSDYNA, Fluent or CFX file check the examples sections:
163-
:ref:`examples_lsdyna`, :ref:`fluids_examples` and :ref:`examples_cfx`.
182+
For more information on reading a mesh from a LSDYNA, Fluent or CFX file check the :ref:`examples_lsdyna`,
183+
:ref:`fluids_examples` and :ref:`examples_cfx` examples sections.

0 commit comments

Comments
 (0)