1- .. _ tutorials_get_mesh_from_result_file :
1+ .. _ ref_tutorials_get_mesh_from_result_file :
22
33=============================
44Get a mesh from a result file
55=============================
66
77:bdg-mapdl: `MAPDL ` :bdg-lsdyna: `LSDYNA ` :bdg-fluent: `Fluent ` :bdg-cfx: `CFX `
88
9- .. |Field | replace :: :class: `Field<ansys.dpf.core.field.Field> `
10- .. |FieldsContainer | replace :: :class: `FieldsContainer<ansys.dpf.core.fields_container.FieldsContainer> `
11- .. |MeshedRegion | replace :: :class: `MeshedRegion <ansys.dpf.core.meshed_region.MeshedRegion> `
12- .. |Model | replace :: :class: `Model <ansys.dpf.core.model.Model> `
13- .. |DataSources | replace :: :class: `Model <ansys.dpf.core.data_sources.DataSources> `
9+ .. include :: ../../../links_and_refs.rst
10+
1411.. |mesh_provider | replace :: :class: `mesh_provider <ansys.dpf.core.operators.mesh.mesh_provider.mesh_provider> `
15- .. |Examples | replace :: :mod: `Examples<ansys.dpf.core.examples> `
1612
17- The mesh object in DPF is a |MeshedRegion |. You can obtain a |MeshedRegion | by creating your
18- own by scratch or by getting it from a result file.
13+ This tutorial explains how to extract a mesh from a result file.
1914
20- This tutorial explains how to extract the models mesh from a result file.
15+ The mesh object in DPF is a |MeshedRegion |. You can obtain a |MeshedRegion | by creating your
16+ own from scratch or by getting it from a result file.
2117
18+ :jupyter-download-script: `Download tutorial as Python script<get_mesh_from_result_file> `
19+ :jupyter-download-notebook: `Download tutorial as Jupyter notebook<get_mesh_from_result_file> `
2220
2321Import the result file
2422----------------------
2523
26- Here we we will download result files available in our |Examples | package .
27- For more information about how to import your result file in DPF check
28- the :ref: ` ref_tutorials_import_data ` tutorial section.
24+ First, import a result file. For this tutorial, you can use one available in the |Examples | module .
25+ For more information about how to import your own result file in DPF, see the :ref: ` ref_tutorials_import_data `
26+ tutorials section.
2927
30- You have to create a |DataSources | object so the data can be accessed by
31- PyDPF-Core APIs.
28+ Here, we create a |DataSources | object so the data can be directly accessed by different
29+ PyDPF-Core APIs. This object manages paths to their files.
3230
3331.. tab-set ::
3432
3533 .. tab-item :: MAPDL
3634
3735 .. jupyter-execute ::
3836
39- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
37+ # Import the ``ansys.dpf.core `` module
4038 from ansys.dpf import core as dpf
39+ # Import the examples module
4140 from ansys.dpf.core import examples
41+ # Import the operators module
4242 from ansys.dpf.core import operators as ops
43- # Define the result file
43+
44+ # Define the result file path
4445 result_file_path_1 = examples.find_static_rst()
4546 # Create the DataSources object
46- my_data_sources_1 = dpf.DataSources(result_path=result_file_path_1)
47+ ds_1 = dpf.DataSources(result_path=result_file_path_1)
4748
4849 .. tab-item :: LSDYNA
4950
5051 .. jupyter-execute ::
5152
52- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
53+ # Import the ``ansys.dpf.core `` module
5354 from ansys.dpf import core as dpf
55+ # Import the examples module
5456 from ansys.dpf.core import examples
57+ # Import the operators module
5558 from ansys.dpf.core import operators as ops
56- # Define the result file
59+
60+ # Define the result file path
5761 result_file_path_2 = examples.download_d3plot_beam()
5862 # Create the DataSources object
59- my_data_sources_2 = dpf.DataSources()
60- my_data_sources_2 .set_result_file_path(filepath=result_file_path_2[0], key="d3plot")
61- my_data_sources_2 .add_file_path(filepath=result_file_path_2[3], key="actunits")
63+ ds_2 = dpf.DataSources()
64+ ds_2 .set_result_file_path(filepath=result_file_path_2[0], key="d3plot")
65+ ds_2 .add_file_path(filepath=result_file_path_2[3], key="actunits")
6266
6367 .. tab-item :: Fluent
6468
6569 .. jupyter-execute ::
6670
67- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
71+ # Import the ``ansys.dpf.core `` module
6872 from ansys.dpf import core as dpf
73+ # Import the examples module
6974 from ansys.dpf.core import examples
75+ # Import the operators module
7076 from ansys.dpf.core import operators as ops
71- # Define the result file
77+
78+ # Define the result file path
7279 result_file_path_3 = examples.download_fluent_axial_comp()["flprj"]
7380 # Create the DataSources object
74- my_data_sources_3 = dpf.DataSources(result_path=result_file_path_3)
81+ ds_3 = dpf.DataSources(result_path=result_file_path_3)
7582
7683 .. tab-item :: CFX
7784
7885 .. jupyter-execute ::
7986
80- # Import the ``ansys.dpf.core `` module, including examples files and the operators subpackage
87+ # Import the ``ansys.dpf.core `` module
8188 from ansys.dpf import core as dpf
89+ # Import the examples module
8290 from ansys.dpf.core import examples
91+ # Import the operators module
8392 from ansys.dpf.core import operators as ops
84- # Define the result file
93+ # Define the result file path
8594 result_file_path_4 = examples.download_cfx_mixing_elbow()
8695 # Create the DataSources object
87- my_data_sources_4 = dpf.DataSources(result_path=result_file_path_4)
96+ ds_4 = dpf.DataSources(result_path=result_file_path_4)
8897
8998
9099Get the mesh from the result file
91100---------------------------------
92101
93- You can Get the mesh from the result file by two methods:
102+ You can get the mesh from a result file by two methods:
94103
95- - :ref: `get_mesh_model `
96- - :ref: `get_mesh_mesh_provider `
104+ - :ref: `Using the DPF Model < get_mesh_model >`;
105+ - :ref: `Using the mesh_provider operator < get_mesh_mesh_provider >`.
97106
98107.. note ::
99108
100- The |Model | extracts a large amount of information by default (results, mesh and analysis data).
109+ A |Model | extracts a large amount of information by default (results, mesh and analysis data).
101110 If using this helper takes a long time for processing the code, mind using a |DataSources | object
102- and instantiating operators directly with it. Check the ":ref: `get_mesh_mesh_provider `" for more
103- information on how to get a mesh from a result file.
111+ and instantiating operators directly with it.
104112
105113.. _get_mesh_model :
106114
107115Using the DPF |Model |
108116^^^^^^^^^^^^^^^^^^^^^
109117
110118The |Model | is a helper designed to give shortcuts to access the analysis results
111- metadata, by opening a DataSources or a Streams, and to instanciate results provider
112- for it.
119+ metadata and to instanciate results providers by opening a |DataSources | or a Streams.
113120
114- Get the |MeshedRegion | by instantiating a |Model | object and accessing its metadata:
121+ Get the |MeshedRegion | by instantiating a |Model | object and accessing its metadata.
115122
116123.. tab-set ::
117124
118125 .. tab-item :: MAPDL
119126
120127 .. jupyter-execute ::
121128
122- # Create the model
123- my_model_1 = dpf.Model(data_sources=my_data_sources_1 )
129+ # Create the Model
130+ model_1 = dpf.Model(data_sources=ds_1 )
124131 # Get the mesh
125- my_meshed_region_1 = my_model_1 .metadata.meshed_region
132+ meshed_region_11 = model_1 .metadata.meshed_region
126133
127134 .. tab-item :: LSDYNA
128135
129136 .. jupyter-execute ::
130137
131- # Create the model
132- my_model_2 = dpf.Model(data_sources=my_data_sources_2 )
138+ # Create the Model
139+ model_2 = dpf.Model(data_sources=ds_2 )
133140 # Get the mesh
134- my_meshed_region_2 = my_model_2 .metadata.meshed_region
141+ meshed_region_21 = model_2 .metadata.meshed_region
135142
136143 .. tab-item :: Fluent
137144
138145 .. jupyter-execute ::
139146
140- # Create the model
141- my_model_3 = dpf.Model(data_sources=my_data_sources_3 )
147+ # Create the Model
148+ model_3 = dpf.Model(data_sources=ds_3 )
142149 # Get the mesh
143- my_meshed_region_3 = my_model_3 .metadata.meshed_region
150+ meshed_region_31 = model_3 .metadata.meshed_region
144151
145152 .. tab-item :: CFX
146153
147154 .. jupyter-execute ::
148155
149- # Create the model
150- my_model_4 = dpf.Model(data_sources=my_data_sources_4 )
156+ # Create the Model
157+ model_4 = dpf.Model(data_sources=ds_4 )
151158 # Get the mesh
152- my_meshed_region_4 = my_model_4 .metadata.meshed_region
159+ meshed_region_41 = model_4 .metadata.meshed_region
153160
154- Printing the |MeshedRegion | displays the mesh dimensions (number of nodes and elements,
155- unit and elements type):
161+ Printing the |MeshedRegion | displays the mesh dimensions:
162+
163+ - Number of nodes and elements;
164+ - Unit;
165+ - Elements type.
156166
157167.. tab-set ::
158168
159169 .. tab-item :: MAPDL
160170
161171 .. jupyter-execute ::
162172
163- # Print the meshed region
164- print(my_meshed_region_1 )
173+ # Print the MeshedRegion
174+ print(meshed_region_11 )
165175
166176 .. tab-item :: LSDYNA
167177
168178 .. jupyter-execute ::
169179
170- # Print the meshed region
171- print(my_meshed_region_2 )
180+ # Print the MeshedRegion
181+ print(meshed_region_21 )
172182
173183 .. tab-item :: Fluent
174184
175185 .. jupyter-execute ::
176186
177- # Print the meshed region
178- print(my_meshed_region_3 )
187+ # Print the MeshedRegion
188+ print(meshed_region_31 )
179189
180190 .. tab-item :: CFX
181191
182192 .. jupyter-execute ::
183193
184- # Print the meshed region
185- print(my_meshed_region_4 )
194+ # Print the MeshedRegion
195+ print(meshed_region_41 )
186196
187197.. _get_mesh_mesh_provider :
188198
189199Using the |mesh_provider | operator
190200^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
191201
192- Get the |MeshedRegion | by instantiating the |mesh_provider | operator and instantiating it with a
193- |DataSources | object as an argument:
202+ Get the |MeshedRegion | by instantiating the |mesh_provider | operator with the
203+ |DataSources | object as an argument.
194204
195205.. tab-set ::
196206
@@ -199,58 +209,61 @@ Get the |MeshedRegion| by instantiating the |mesh_provider| operator and instant
199209 .. jupyter-execute ::
200210
201211 # Get the mesh with the mesh_provider operator
202- my_meshed_region_12 = ops.mesh.mesh_provider(data_sources=my_data_sources_1 ).eval()
212+ meshed_region_12 = ops.mesh.mesh_provider(data_sources=ds_1 ).eval()
203213
204214 .. tab-item :: LSDYNA
205215
206216 .. jupyter-execute ::
207217
208218 # Get the mesh with the mesh_provider operator
209- my_meshed_region_22 = ops.mesh.mesh_provider(data_sources=my_data_sources_2 ).eval()
219+ meshed_region_22 = ops.mesh.mesh_provider(data_sources=ds_2 ).eval()
210220
211221 .. tab-item :: Fluent
212222
213223 .. jupyter-execute ::
214224
215225 # Get the mesh with the mesh_provider operator
216- my_meshed_region_32 = ops.mesh.mesh_provider(data_sources=my_data_sources_3 ).eval()
226+ meshed_region_32 = ops.mesh.mesh_provider(data_sources=ds_3 ).eval()
217227
218228 .. tab-item :: CFX
219229
220230 .. jupyter-execute ::
221231
222232 # Get the mesh with the mesh_provider operator
223- my_meshed_region_42 = ops.mesh.mesh_provider(data_sources=my_data_sources_4).eval()
233+ meshed_region_42 = ops.mesh.mesh_provider(data_sources=ds_4).eval()
234+
235+ Printing the |MeshedRegion | displays the mesh dimensions:
224236
225- Printing the |MeshedRegion | displays the mesh dimensions (number of nodes and elements,
226- unit and elements type):
237+ - Number of nodes and elements;
238+ - Unit;
239+ - Elements type.
227240
228241.. tab-set ::
229242
230243 .. tab-item :: MAPDL
231244
232245 .. jupyter-execute ::
233246
234- # Print the meshed region
235- print(my_meshed_region_12 )
247+ # Print the MeshedRegion
248+ print(meshed_region_12 )
236249
237250 .. tab-item :: LSDYNA
238251
239252 .. jupyter-execute ::
240253
241- # Print the meshed region
242- print(my_meshed_region_22 )
254+ # Print the MeshedRegion
255+ print(meshed_region_22 )
243256
244257 .. tab-item :: Fluent
245258
246259 .. jupyter-execute ::
247260
248- # Print the meshed region
249- print(my_meshed_region_32 )
261+ # Print the MeshedRegion
262+ print(meshed_region_32 )
250263
251264 .. tab-item :: CFX
252265
253266 .. jupyter-execute ::
254267
255- # Print the meshed region
256- print(my_meshed_region_42 )
268+ # Print the MeshedRegion
269+ print(meshed_region_42 )
0 commit comments