1- .. _ tutorials_explore_mesh :
1+ .. _ ref_tutorials_explore_mesh :
22
33==============
44Explore a mesh
55==============
66
77:bdg-mapdl: `MAPDL ` :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- .. |Nodes | replace :: :class: `Nodes <ansys.dpf.core.nodes.Nodes> `
14- .. |Elements | replace :: :class: `Elements <ansys.dpf.core.elements.Elements> `
15- .. |Faces | replace :: :class: `Faces <ansys.dpf.core.faces.Faces> `
16- .. |Scoping | replace :: :class: `Scoping <ansys.dpf.core.scoping.Scoping> `
9+ .. include :: ../../../links_and_refs.rst
1710.. |PropertyField | replace :: :class: `PropertyField <ansys.dpf.core.property_field.PropertyField> `
18- .. |Examples | replace :: :mod: ` Examples <ansys.dpf.core.examples > `
11+ .. |element_types | replace :: :class: ` list of available element types in a DPF mesh <ansys.dpf.core.elements.element_types > `
1912
20- This tutorial explains how to access the mesh data and metadata (data about the elements, nodes, faces, region, zone ...)
21- so it can be manipulated.
13+ This tutorial explains how to access a mesh data and metadata so it can be manipulated.
2214
23-
24- There is a general method to read the |MeshedRegion | by manipulating
25- the methods of this object.
15+ :jupyter-download-script: `Download tutorial as Python script<explore_mesh> `
16+ :jupyter-download-notebook: `Download tutorial as Jupyter notebook<explore_mesh> `
2617
2718Define the mesh
2819---------------
2920
3021The mesh object in DPF is a |MeshedRegion |. You can obtain a |MeshedRegion | by creating your
31- own by scratch or by getting it from a result file. For more information check the
32- :ref: `tutorials_create_a_mesh_from_scratch ` and :ref: `tutorials_get_mesh_from_result_file ` tutorials.
22+ own from scratch or by getting it from a result file. For more information check the
23+ :ref: `ref_tutorials_create_a_mesh_from_scratch ` and :ref: `ref_tutorials_get_mesh_from_result_file ` tutorials.
3324
34- Here we we will download a result file available in our |Examples | package.
35- For more information about how to import your result file in DPF check
36- the :ref: `ref_tutorials_import_data ` tutorial section.
25+ For this tutorial, we get a |MeshedRegion | from a result file. You can use one available in the |Examples | module.
26+ For more information see the :ref: `ref_tutorials_get_mesh_from_result_file ` tutorial.
3727
3828.. tab-set ::
3929
4030 .. tab-item :: MAPDL
4131
4232 .. jupyter-execute ::
4333
44- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
34+ # Import the ``ansys.dpf.core `` module
4535 from ansys.dpf import core as dpf
36+ # Import the examples module
4637 from ansys.dpf.core import examples
38+ # Import the operators module
4739 from ansys.dpf.core import operators as ops
48- # Define the result file
40+
41+ # Define the result file path
4942 result_file_path_1 = examples.find_static_rst()
5043 # Create the model
51- my_model_1 = dpf.Model(data_sources=result_file_path_1)
44+ model_1 = dpf.Model(data_sources=result_file_path_1)
5245 # Get the mesh
53- my_meshed_region_1 = my_model_1 .metadata.meshed_region
46+ meshed_region_1 = model_1 .metadata.meshed_region
5447
5548 .. tab-item :: LSDYNA
5649
5750 .. jupyter-execute ::
5851
59- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
52+ # Import the ``ansys.dpf.core `` module
6053 from ansys.dpf import core as dpf
54+ # Import the examples module
6155 from ansys.dpf.core import examples
56+ # Import the operators module
6257 from ansys.dpf.core import operators as ops
63- # Define the result file
58+
59+ # Define the result file path
6460 result_file_path_2 = examples.download_d3plot_beam()
6561 # Create the DataSources object
66- my_data_sources_2 = dpf.DataSources()
67- my_data_sources_2 .set_result_file_path(filepath=result_file_path_2[0], key="d3plot")
68- my_data_sources_2 .add_file_path(filepath=result_file_path_2[3], key="actunits")
62+ ds_2 = dpf.DataSources()
63+ ds_2 .set_result_file_path(filepath=result_file_path_2[0], key="d3plot")
64+ ds_2 .add_file_path(filepath=result_file_path_2[3], key="actunits")
6965 # Create the model
70- my_model_2 = dpf.Model(data_sources=my_data_sources_2 )
66+ model_2 = dpf.Model(data_sources=ds_2 )
7167 # Get the mesh
72- my_meshed_region_2 = my_model_2 .metadata.meshed_region
68+ meshed_region_2 = model_2 .metadata.meshed_region
7369
7470 .. tab-item :: Fluent
7571
7672 .. jupyter-execute ::
7773
78- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
74+ # Import the ``ansys.dpf.core `` module
7975 from ansys.dpf import core as dpf
76+ # Import the examples module
8077 from ansys.dpf.core import examples
78+ # Import the operators module
8179 from ansys.dpf.core import operators as ops
82- # Define the result file
80+
81+ # Define the result file path
8382 result_file_path_3 = examples.download_fluent_axial_comp()["flprj"]
8483 # Create the model
85- my_model_3 = dpf.Model(data_sources=result_file_path_3)
84+ model_3 = dpf.Model(data_sources=result_file_path_3)
8685 # Get the mesh
87- my_meshed_region_3 = my_model_3 .metadata.meshed_region
86+ meshed_region_3 = model_3 .metadata.meshed_region
8887
8988 .. tab-item :: CFX
9089
9190 .. jupyter-execute ::
9291
93- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
92+ # Import the ``ansys.dpf.core `` module
9493 from ansys.dpf import core as dpf
94+ # Import the examples module
9595 from ansys.dpf.core import examples
96+ # Import the operators module
9697 from ansys.dpf.core import operators as ops
97- # Define the result file
98+
99+ # Define the result file path
98100 result_file_path_4 = examples.download_cfx_mixing_elbow()
99101 # Create the model
100- my_model_4 = dpf.Model(data_sources=result_file_path_4)
102+ model_4 = dpf.Model(data_sources=result_file_path_4)
101103 # Get the mesh
102- my_meshed_region_4 = my_model_4 .metadata.meshed_region
104+ meshed_region_4 = model_4 .metadata.meshed_region
103105
104- Read the mesh
105- -------------
106+ Explore the mesh data
107+ ---------------------
106108
107- From the | MeshedRegion | you can access its information by manipulating this object properties .
108- The mesh information includes :
109+ You can access the mesh data by manipulating the | MeshedRegion | object methods .
110+ The mesh data includes :
109111
110112- Unit;
111113- Nodes, elements and faces;
112- - Named selections;
113- - Properties.
114+ - Named selections.
114115
115- Check all the information you can get at: |MeshedRegion |.
116+ Check all the types of data you can get from a mesh at |MeshedRegion |.
116117
117- Access the mesh nodes, element , faces and named selection
118- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
118+ When instantiating nodes, elements , faces and named selections you get the correspondent DPF objects:
119+ | Nodes |, | Elements |, | Faces | and | Scoping |.
119120
120- When instantiating the nodes, element, faces and named selection you get the correspondent DPF objects:
121- |Nodes |, |Elements |, |Faces | and |Scoping |. For example:
121+ Here, we get the mesh nodes.
122122
123123.. tab-set ::
124124
125125 .. tab-item :: MAPDL
126126
127127 .. jupyter-execute ::
128128
129- # Get the mesh elements
130- my_nodes_1 = my_meshed_region_1.nodes
129+ # Get the mesh nodes
130+ nodes_1 = meshed_region_1.nodes
131+
132+ # Print the object type
133+ print("Object type: ",type(nodes_1),'\n ')
134+
131135 # Print the nodes
132- print(my_nodes_1)
133- print("Object type: ",type(my_nodes_1))
136+ print("Nodes: ", nodes_1)
134137
135138 .. tab-item :: LSDYNA
136139
137140 .. jupyter-execute ::
138141
139- # Get the mesh elements
140- my_nodes_2 = my_meshed_region_2.nodes
142+ # Get the mesh nodes
143+ nodes_2 = meshed_region_2.nodes
144+
145+ # Print the object type
146+ print("Object type: ",type(nodes_2),'\n ')
147+
141148 # Print the nodes
142- print(my_nodes_2)
143- print("Object type: ",type(my_nodes_2))
149+ print("Nodes: ", nodes_2)
144150
145151 .. tab-item :: Fluent
146152
147153 .. jupyter-execute ::
148154
149- # Get the mesh elements
150- my_nodes_3 = my_meshed_region_3.nodes
155+ # Get the mesh nodes
156+ nodes_3 = meshed_region_3.nodes
157+
158+ # Print the object type
159+ print("Object type: ",type(nodes_3),'\n ')
160+
151161 # Print the nodes
152- print(my_nodes_3)
153- print("Object type: ",type(my_nodes_3))
162+ print("Nodes: ", nodes_3)
154163
155164 .. tab-item :: CFX
156165
157166 .. jupyter-execute ::
158167
159- # Get the mesh elements
160- my_nodes_4 = my_meshed_region_4.nodes
168+ # Get the mesh nodes
169+ nodes_4 = meshed_region_4.nodes
170+
171+ # Print the object type
172+ print("Object type: ",type(nodes_4),'\n ')
173+
161174 # Print the nodes
162- print(my_nodes_4)
163- print("Object type: ",type(my_nodes_4))
175+ print("Nodes: ", nodes_4)
176+
177+ Explore the mesh metadata
178+ -------------------------
164179
165- Access the mesh properties
166- ^^^^^^^^^^^^^^^^^^^^^^^^^^
180+ You can access the mesh metadata by manipulating the |MeshedRegion | object properties.
167181
168- When handling properties you can check which are the available ones and also
169- chose those you want to extract.
182+ You can check which ones are available.
170183
171184.. tab-set ::
172185
@@ -175,39 +188,48 @@ chose those you want to extract.
175188 .. jupyter-execute ::
176189
177190 # Get the available properties
178- my_available_props_1 = my_meshed_region_1.available_property_fields
191+ available_props_1 = meshed_region_1.available_property_fields
192+
179193 # Print the available properties
180- print(my_available_props_1 )
194+ print("Available properties: ", available_props_1 )
181195
182196 .. tab-item :: LSDYNA
183197
184198 .. jupyter-execute ::
185199
186200 # Get the available properties
187- my_available_props_2 = my_meshed_region_2.available_property_fields
201+ available_props_2 = meshed_region_2.available_property_fields
202+
188203 # Print the available properties
189- print(my_available_props_2 )
204+ print("Available properties: ", available_props_2 )
190205
191206 .. tab-item :: Fluent
192207
193208 .. jupyter-execute ::
194209
195210 # Get the available properties
196- my_available_props_3 = my_meshed_region_3.available_property_fields
211+ available_props_3 = meshed_region_3.available_property_fields
212+
197213 # Print the available properties
198- print(my_available_props_3 )
214+ print("Available properties: ", available_props_3 )
199215
200216 .. tab-item :: CFX
201217
202218 .. jupyter-execute ::
203219
204220 # Get the available properties
205- my_available_props_4 = my_meshed_region_4.available_property_fields
221+ available_props_4 = meshed_region_4.available_property_fields
222+
206223 # Print the available properties
207- print(my_available_props_4 )
224+ print("Available properties: ", available_props_4 )
208225
209- When extracting those properties you get a |PropertyField | with that information. Their data is mapped
210- to the entity they are defined at:
226+ You can also chose which property you want to extract.
227+
228+ When extracting the properties you get a |PropertyField | with that information. Their data is mapped to
229+ the entity they are defined at.
230+
231+ The element type is given as a number. Check the |element_types | to find the
232+ corresponding element name.
211233
212234.. tab-set ::
213235
@@ -216,34 +238,38 @@ to the entity they are defined at:
216238 .. jupyter-execute ::
217239
218240 # Get the element types on the mesh
219- my_el_types_1 = my_meshed_region_1.property_field(property_name="eltype")
220- # Print the element types
221- print(my_el_types_1)
241+ el_types_1 = meshed_region_1.property_field(property_name="eltype")
242+
243+ # Print the element types by element
244+ print(el_types_1)
222245
223246
224247 .. tab-item :: LSDYNA
225248
226249 .. jupyter-execute ::
227250
228251 # Get the element types on the mesh
229- my_el_types_2 = my_meshed_region_2.property_field(property_name="eltype")
230- # Print the element types
231- print(my_el_types_2)
252+ el_types_2 = meshed_region_2.property_field(property_name="eltype")
253+
254+ # Print the element types by element
255+ print(el_types_2)
232256
233257 .. tab-item :: Fluent
234258
235259 .. jupyter-execute ::
236260
237261 # Get the element types on the mesh
238- my_el_types_3 = my_meshed_region_3.property_field(property_name="eltype")
239- # Print the element types
240- print(my_el_types_3)
262+ el_types_3 = meshed_region_3.property_field(property_name="eltype")
263+
264+ # Print the element types by element
265+ print(el_types_3)
241266
242267 .. tab-item :: CFX
243268
244269 .. jupyter-execute ::
245270
246271 # Get the element types on the mesh
247- my_el_types_4 = my_meshed_region_4.property_field(property_name="eltype")
248- # Print the element types
249- print(my_el_types_4)
272+ el_types_4 = meshed_region_4.property_field(property_name="eltype")
273+
274+ # Print the element types by element
275+ print(el_types_4)
0 commit comments