Skip to content

Commit d198f45

Browse files
add import_result_file.rst tutorial
1 parent 1fd80a7 commit d198f45

File tree

1 file changed

+320
-0
lines changed

1 file changed

+320
-0
lines changed
Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,322 @@
11
.. _ref_tutorials_import_result_file:
22

3+
=========================
4+
Import result file in DPF
5+
=========================
6+
7+
.. |Model| replace:: :class:`Model <ansys.dpf.core.model.Model>`
8+
.. |DataSources| replace:: :class:`DataSources <ansys.dpf.core.data_sources.DataSources>`
9+
.. |Examples| replace:: :mod:`Examples<ansys.dpf.core.examples>`
10+
.. |set_result_file_path| replace:: :func:`set_result_file_path() <ansys.dpf.core.data_sources.DataSources.set_result_file_path>`
11+
.. |add_file_path| replace:: :func:`add_file_path() <ansys.dpf.core.data_sources.DataSources.add_file_path>`
12+
13+
This tutorial shows how to import a result file in DPF.
14+
15+
You have two approaches to import a result file in DPF:
16+
17+
- Using the |DataSources| object
18+
- Using the |Model| object
19+
20+
.. note::
21+
22+
The |Model| extracts a large amount of information by default (results, mesh and analysis data).
23+
If using this helper takes a long time for processing the code, mind using a |DataSources| object
24+
and instantiating operators directly with it. Check the ":ref:`get_mesh_mesh_provider`" for more
25+
information on how to get a mesh from a result file.
26+
27+
Define the result file path
28+
---------------------------
29+
30+
Both approaches need a file path to be defined. Here we will download result files available in
31+
our |Examples| package.
32+
33+
.. tab-set::
34+
35+
.. tab-item:: MAPDL
36+
37+
.. jupyter-execute::
38+
39+
# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
40+
from ansys.dpf import core as dpf
41+
from ansys.dpf.core import examples
42+
from ansys.dpf.core import operators as ops
43+
44+
# Define the .rst result file
45+
result_file_path_11 = examples.find_static_rst()
46+
47+
# Define the modal superposition harmonic analysis (.mode, .rfrq and .rst) result files
48+
result_file_path_12 = examples.download_msup_files_to_dict()
49+
50+
print("1:", "\n",result_file_path_11, "\n")
51+
print("2:", "\n",result_file_path_12, "\n")
52+
53+
.. tab-item:: LSDYNA
54+
55+
.. jupyter-execute::
56+
57+
# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
58+
from ansys.dpf import core as dpf
59+
from ansys.dpf.core import examples
60+
from ansys.dpf.core import operators as ops
61+
62+
# Define the .d3plot result file
63+
result_file_path_21 = examples.download_d3plot_beam()
64+
65+
# Define the .binout result file
66+
result_file_path_22 = examples.download_binout_matsum()
67+
68+
print("1:", "\n",result_file_path_21, "\n")
69+
print("2:", "\n",result_file_path_22, "\n")
70+
71+
.. tab-item:: Fluent
72+
73+
.. jupyter-execute::
74+
75+
# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
76+
from ansys.dpf import core as dpf
77+
from ansys.dpf.core import examples
78+
from ansys.dpf.core import operators as ops
79+
80+
# Define the project .flprj result file
81+
result_file_path_31 = examples.download_fluent_axial_comp()["flprj"]
82+
83+
# Define the CFF .cas.h5/.dat.h5 result files
84+
result_file_path_32 = examples.download_fluent_axial_comp()
85+
86+
print("1:", "\n",result_file_path_31, "\n")
87+
print("2:", "\n",result_file_path_32, "\n")
88+
89+
.. tab-item:: CFX
90+
91+
.. jupyter-execute::
92+
93+
# Import the ``ansys.dpf.core`` module, including examples files and the operators subpackage
94+
from ansys.dpf import core as dpf
95+
from ansys.dpf.core import examples
96+
from ansys.dpf.core import operators as ops
97+
98+
# Define the project .res result file
99+
result_file_path_41 = examples.download_cfx_mixing_elbow()
100+
101+
# Define the CFF .cas.cff/.dat.cff result files
102+
result_file_path_42 = examples.download_cfx_heating_coil()
103+
104+
print("1:", "\n",result_file_path_41, "\n")
105+
print("2:", "\n",result_file_path_42, "\n")
106+
107+
Use a |DataSources|
108+
-------------------
109+
110+
The |DataSources| object manages paths to their files. Use this object to declare data
111+
inputs for DPF operators and define their locations.
112+
113+
.. tab-set::
114+
115+
.. tab-item:: MAPDL
116+
117+
**a) `.rst` result file**
118+
119+
You create the |DataSources| object by defining the the path to the main result file.
120+
121+
.. jupyter-execute::
122+
123+
# Create the DataSources object
124+
my_data_sources_11 = dpf.DataSources(result_path=result_file_path_11)
125+
126+
**b) `.mode`, `.rfrq` and `.rst` result files**
127+
128+
In the modal superposition, modal coefficients are multiplied by mode shapes (of a previous modal analysis)
129+
to analyse a structure under given boundary conditions in a range of frequencies. Doing this expansion “on demand”
130+
in DPF instead of in the solver reduces the size of the result files.
131+
132+
The expansion is recursive in DPF: first the modal response is read. Then, “upstream” mode shapes are found in
133+
the data sources, where they are read and expanded.
134+
135+
To create a recursive workflow you have to add the upstream data to the main |DataSources| object. Upstream refers
136+
to a source that provides data to a particular process.
137+
138+
.. jupyter-execute::
139+
140+
# Create the DataSources object
141+
my_data_sources_12 = dpf.DataSources()
142+
# Define the main result data
143+
my_data_sources_12.set_result_file_path(filepath=result_file_path_12["rfrq"], key='rfrq')
144+
145+
# Create the upstream DataSources object with the main upstream data
146+
up_stream_ds_12 = dpf.DataSources(result_path=result_file_path_12["mode"])
147+
# Add the additional upstream data to the upstream DataSources object
148+
up_stream_ds_12.add_file_path(filepath=result_file_path_12["rst"])
149+
150+
# Add the upstream DataSources to the main DataSources object
151+
my_data_sources_12.add_upstream(upstream_data_sources=up_stream_ds_12)
152+
153+
.. tab-item:: LSDYNA
154+
155+
**a) `.d3plot` result file**
156+
157+
This LS-DYNA d3plot file contains several individual results, each at different times.
158+
The d3plot file does not contain information related to Units. In this case, as the
159+
simulation was run through Mechanical, a ``file.actunits`` file is produced. If this
160+
file is supplemented in the |DataSources|, the units will be correctly fetched for all
161+
results in the file as well as for the mesh.
162+
163+
.. jupyter-execute::
164+
165+
# Create the DataSources object
166+
my_data_sources_21 = dpf.DataSources()
167+
my_data_sources_21.set_result_file_path(filepath=result_file_path_21[0], key="d3plot")
168+
my_data_sources_21.add_file_path(filepath=result_file_path_21[3], key="actunits")
169+
170+
**b) `.binout` result file**
171+
172+
The extension key ``.binout`` is not specified in the result file. Thus, we use the
173+
|set_result_file_path| method to correctly implement the result file to the |DataSources| by giving
174+
explicitly the extension key as an argument.
175+
176+
.. jupyter-execute::
177+
178+
# Create the DataSources object
179+
my_data_sources_22 = dpf.DataSources()
180+
# Define the the path to the main result
181+
my_data_sources_22.set_result_file_path(filepath=result_file_path_22, key="binout")
182+
183+
.. tab-item:: Fluent
184+
185+
**a) `.flprj` result file**
186+
187+
You create the |DataSources| object by defining the the path to the main result file.
188+
189+
.. jupyter-execute::
190+
191+
# Create the DataSources object
192+
my_data_sources_31 = dpf.DataSources(result_path=result_file_path_31)
193+
194+
**b) `.cas.h5`, `.dat.h5` result files**
195+
196+
Here we have a main and an additional result files. Thus, we use the
197+
|set_result_file_path| method, to correctly implement the result file to the |DataSources| by giving
198+
explicitly the first extension key as an argument, and the |add_file_path| method, to add the additional
199+
result file.
200+
201+
.. jupyter-execute::
202+
203+
# Create the DataSources object
204+
my_data_sources_32 = dpf.DataSources()
205+
# Define the path to the main result file
206+
my_data_sources_32.set_result_file_path(filepath=result_file_path_32['cas'][0], key="cas")
207+
# Add the additional result file to the DataSources
208+
my_data_sources_32.add_file_path(filepath=result_file_path_32['dat'][0], key="dat")
209+
210+
.. tab-item:: CFX
211+
212+
**a) `.res` result file**
213+
214+
You create the |DataSources| object by defining the the path to the main result file.
215+
216+
.. jupyter-execute::
217+
218+
# Create the DataSources object
219+
my_data_sources_41 = dpf.DataSources(result_path=result_file_path_41)
220+
221+
**b) `.cas.cff`, `.dat.cff` result files**
222+
223+
Here we have a main and an additional result files. Thus, we use the
224+
|set_result_file_path| method, to correctly implement the result file to the |DataSources| by giving
225+
explicitly the first extension key as an argument, and the |add_file_path| method, to add the additional
226+
result file.
227+
228+
.. jupyter-execute::
229+
230+
# Create the DataSources object
231+
my_data_sources_42 = dpf.DataSources()
232+
# Define the path to the main result file
233+
my_data_sources_42.set_result_file_path(filepath=result_file_path_42["cas"], key="cas")
234+
# Add the additional result file to the DataSources
235+
my_data_sources_42.add_file_path(filepath=result_file_path_42["dat"], key="dat")
236+
237+
Use a |Model|
238+
-------------
239+
240+
The |Model| is a helper designed to give shortcuts to the user to access the analysis results
241+
metadata, by opening a DataSources or a Streams, and to instanciate results provider for it.
242+
243+
To create a |Model| you can provide the result file path, in the case you are working with a single result
244+
file with an explicit extension key, or a |DataSources| as an argument.
245+
246+
.. tab-set::
247+
248+
.. tab-item:: MAPDL
249+
250+
**a) `.rst` result file**
251+
252+
.. jupyter-execute::
253+
254+
# Create the model with the result file path
255+
my_model_11 = dpf.Model(data_sources=result_file_path_11)
256+
257+
# Create the model with the DataSources
258+
my_model_12 = dpf.Model(data_sources=my_data_sources_11)
259+
260+
**b) `.mode`, `.rfrq` and `.rst` result files**
261+
262+
.. jupyter-execute::
263+
264+
# Create the model with the DataSources
265+
my_model_13 = dpf.Model(data_sources=my_data_sources_12)
266+
267+
.. tab-item:: LSDYNA
268+
269+
**a) `.d3plot` result file**
270+
271+
.. jupyter-execute::
272+
273+
# Create the model with the DataSources
274+
my_model_21 = dpf.Model(data_sources=my_data_sources_21)
275+
276+
**b) `.binout` result file**
277+
278+
.. jupyter-execute::
279+
280+
# Create the model with the DataSources
281+
my_model_22 = dpf.Model(data_sources=my_data_sources_22)
282+
283+
.. tab-item:: Fluent
284+
285+
**a) `.flprj` result file**
286+
287+
.. jupyter-execute::
288+
289+
# Create the model with the result file path
290+
my_model_31 = dpf.Model(data_sources=result_file_path_31)
291+
292+
# Create the model with the DataSources
293+
my_model_32 = dpf.Model(data_sources=my_data_sources_31)
294+
295+
**b) `.cas.h5`, `.dat.h5` result files**
296+
297+
.. jupyter-execute::
298+
299+
# Create the model with the DataSources
300+
my_model_33 = dpf.Model(data_sources=my_data_sources_32)
301+
302+
.. tab-item:: CFX
303+
304+
.. jupyter-execute::
305+
306+
**a) `.res` result file**
307+
308+
.. jupyter-execute::
309+
310+
# Create the model with the result file path
311+
my_model_41 = dpf.Model(data_sources=result_file_path_41)
312+
313+
# Create the model with the DataSources
314+
my_model_42 = dpf.Model(data_sources=my_data_sources_41)
315+
316+
**b) `.cas.cff`, `.dat.cff` result files**
317+
318+
.. jupyter-execute::
319+
320+
# Create the model with the DataSources
321+
my_model_43 = dpf.Model(data_sources=my_data_sources_42)
322+

0 commit comments

Comments
 (0)