-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost_processing.html
More file actions
478 lines (441 loc) · 44.6 KB
/
Copy pathpost_processing.html
File metadata and controls
478 lines (441 loc) · 44.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./">
<head>
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Post-Processing — fedoo documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=b86133f3" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=9edc463e" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery.css?v=fd6457a4" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-binder.css?v=f4aeca0c" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-dataframe.css?v=2082cf3c" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-rendered-html.css?v=1277b6f3" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-design.min.css?v=95c83b7e" />
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/sg-tags.js?v=d80f6fa4"></script>
<script src="_static/design-tabs.js?v=f930bc37"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="fedoo.DataSet" href="generated/fedoo.DataSet.html" />
<link rel="prev" title="fedoo.constraint.IPCSelfContact.associated_assembly_sum" href="generated/fedoo.constraint.IPCSelfContact.associated_assembly_sum.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" style="background: #24445C" >
<a href="index.html">
<img src="_static/fedOOLogos_ss_fond.png" class="logo" alt="Logo"/>
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p style="padding: 0.5em 1.618em; margin-bottom: 0;">
<a href="https://3mah.github.io/" style="color: #d9d9d9; font-weight: bold; text-decoration: none;">
← Back to 3MAH
</a>
</p>
<hr style="border-color: #4e4e4e; margin: 0.5em 1.618em;">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="Overview.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="Install.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="Quick_Start.html">Quick Start</a></li>
<li class="toctree-l1"><a class="reference internal" href="Mesh.html">Geometry and Mesh (<code class="xref py py-mod docutils literal notranslate"><span class="pre">fedoo.mesh</span></code>)</a></li>
<li class="toctree-l1"><a class="reference internal" href="ConstitutiveLaw.html">Constitutive Law (<code class="xref py py-mod docutils literal notranslate"><span class="pre">fedoo.constitutivelaw</span></code>)</a></li>
<li class="toctree-l1"><a class="reference internal" href="WeakForm.html">Weak Formulation (<code class="xref py py-mod docutils literal notranslate"><span class="pre">fedoo.weakform</span></code>)</a></li>
<li class="toctree-l1"><a class="reference internal" href="Assembly.html">Class Assembly</a></li>
<li class="toctree-l1"><a class="reference internal" href="Time.html">Time Integration (<code class="xref py py-mod docutils literal notranslate"><span class="pre">fedoo.time</span></code>)</a></li>
<li class="toctree-l1"><a class="reference internal" href="Problem.html">Problem (<code class="xref py py-mod docutils literal notranslate"><span class="pre">fedoo.problem</span></code>)</a></li>
<li class="toctree-l1"><a class="reference internal" href="boundary_conditions.html">Boundary conditions and constraints</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Post-Processing</a><ul>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.html">fedoo.DataSet</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.html">fedoo.MultiFrameDataSet</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.get_data.html">fedoo.DataSet.get_data</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.get_history.html">fedoo.MultiFrameDataSet.get_history</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.plot.html">fedoo.DataSet.plot</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.plot.html">fedoo.MultiFrameDataSet.plot</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.plot_history.html">fedoo.MultiFrameDataSet.plot_history</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.write_movie.html">fedoo.MultiFrameDataSet.write_movie</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.save.html">fedoo.DataSet.save</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.savez.html">fedoo.DataSet.savez</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.savez_compressed.html">fedoo.DataSet.savez_compressed</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.save_mesh.html">fedoo.DataSet.save_mesh</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.to_csv.html">fedoo.DataSet.to_csv</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.to_excel.html">fedoo.DataSet.to_excel</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.to_vtk.html">fedoo.DataSet.to_vtk</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.to_msh.html">fedoo.DataSet.to_msh</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.save_all.html">fedoo.MultiFrameDataSet.save_all</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.read_data.html">fedoo.read_data</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.read.html">fedoo.DataSet.read</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.DataSet.load.html">fedoo.DataSet.load</a></li>
<li class="toctree-l2"><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.load.html">fedoo.MultiFrameDataSet.load</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="examples/index.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="heterogeneous.html">Heterogeneous structures</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" style="background: #24445C" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">fedoo</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content style-external-links">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Post-Processing</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/post_processing.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="post-processing">
<span id="module-fedoo.post_processing"></span><h1>Post-Processing<a class="headerlink" href="#post-processing" title="Link to this heading"></a></h1>
<section id="get-results-from-a-problem">
<h2>Get results from a problem<a class="headerlink" href="#get-results-from-a-problem" title="Link to this heading"></a></h2>
<p>In fedoo, most of the standard results are easily exportable using the
<a class="reference internal" href="generated/fedoo.Problem.get_results.html#fedoo.Problem.get_results" title="fedoo.Problem.get_results"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fedoo.Problem.get_results()</span></code></a> method of the problem class.</p>
<p>The get_results method returns a <a class="reference internal" href="generated/fedoo.DataSet.html#fedoo.DataSet" title="fedoo.DataSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">fedoo.DataSet</span></code></a> object which comes
with several methods for plotting, saving and loading mesh dependent results.</p>
<p>To avoid a redundent call of the get_results function, especially for time
dependent problems, one can simply add some required output with the
<a class="reference internal" href="generated/fedoo.Problem.add_output.html#fedoo.Problem.add_output" title="fedoo.Problem.add_output"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fedoo.Problem.add_output()</span></code></a> method. This create a
<a class="reference internal" href="generated/fedoo.MultiFrameDataSet.html#fedoo.MultiFrameDataSet" title="fedoo.MultiFrameDataSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiFrameDataSet</span></code></a> object associated to the problem.
Once the required outputs are defined for a given problem, a call to the
<a class="reference internal" href="generated/fedoo.Problem.save_results.html#fedoo.Problem.save_results" title="fedoo.Problem.save_results"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fedoo.Problem.save_results()</span></code></a> method allow to save all the defined
fields on disk using the choosen file format, and associate the saved file to
an iteration of the <a class="reference internal" href="generated/fedoo.MultiFrameDataSet.html#fedoo.MultiFrameDataSet" title="fedoo.MultiFrameDataSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiFrameDataSet</span></code></a>. For non linear problems
solved using <code class="xref py py-meth docutils literal notranslate"><span class="pre">fedoo.Problem.nlsolve()</span></code>, results are automatically saved at
some iterations dependending on the choosen parameters.</p>
<p>The <a class="reference internal" href="generated/fedoo.MultiFrameDataSet.html#fedoo.MultiFrameDataSet" title="fedoo.MultiFrameDataSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiFrameDataSet</span></code></a> store the path of the saved files for each
iteration in the MultiFrameDataSet.list_data attribute. The method
<a class="reference internal" href="generated/fedoo.MultiFrameDataSet.load.html#fedoo.MultiFrameDataSet.load" title="fedoo.MultiFrameDataSet.load"><code class="xref py py-meth docutils literal notranslate"><span class="pre">MultiFrameDataSet.load()</span></code></a> is called to read the data
of a given iteration.</p>
<section id="class-dataset">
<h3>Class DataSet<a class="headerlink" href="#class-dataset" title="Link to this heading"></a></h3>
<table class="autosummary longtable docutils align-default">
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.DataSet.html#fedoo.DataSet" title="fedoo.DataSet"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet</span></code></a>([mesh, data, data_type])</p></td>
<td><p>Object to store, save, load and plot data associated to a mesh.</p></td>
</tr>
</tbody>
</table>
</section>
<section id="class-multiframedataset">
<h3>Class MultiFrameDataSet<a class="headerlink" href="#class-multiframedataset" title="Link to this heading"></a></h3>
<table class="autosummary longtable docutils align-default">
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.html#fedoo.MultiFrameDataSet" title="fedoo.MultiFrameDataSet"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MultiFrameDataSet</span></code></a>([mesh, list_data])</p></td>
<td><p></p></td>
</tr>
</tbody>
</table>
</section>
<section id="save-data-to-disk">
<h3>Save data to disk<a class="headerlink" href="#save-data-to-disk" title="Link to this heading"></a></h3>
<p>Once a DataSet is created using for instance the
<a class="reference internal" href="generated/fedoo.Problem.get_results.html#fedoo.Problem.get_results" title="fedoo.Problem.get_results"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fedoo.Problem.get_results()</span></code></a> method, the data can easily be saved on
disk using for instance the <a class="reference internal" href="generated/fedoo.DataSet.save.html#fedoo.DataSet.save" title="fedoo.DataSet.save"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fedoo.DataSet.save()</span></code></a> method.</p>
<dl class="simple">
<dt>The available file types are:</dt><dd><ul class="simple">
<li><p>‘fdz’: A zipped archive containing the mesh using the ‘vtk’ format
named ‘_mesh_.vtk’, and data from several iterations named ‘iter_x.npz’
where x is the iteration number (x=0 for the 1st iteration).</p></li>
<li><p>‘vtk’: The vtk format contains the mesh and the data in a single files.
The gauss points data are not included in the file.
This format is efficient for a linear problem when we need only one time
iteration. In case of multiple saved iterations, a directory is created
and one vtk file is saved per iteration. The mesh is included in every
file which is not memory efficient.</p></li>
<li><p>‘msh’: Format associated to gmsh. Have the same drawback as the vtk
format for time depend results and missing gauss points data. The vtk
format should be prefered.</p></li>
<li><p>‘npz’: Save data in a numpy file npz which doesn’t include the mesh. The
mesh is generally saved beside in a raw vtk files without results.</p></li>
<li><p>‘npz_compressed’: Same as npz with a compression of the zip archive.</p></li>
<li><p>‘csv’: Save DataSet that contains only one type of data
(ie Node, Element or Gauss point data) in a csv file (needs the library
pandas installed).
The mesh is not included and may be saved beside in a vtk file.</p></li>
<li><p>‘xlsx’: Same as csv but with the excel format.</p></li>
</ul>
</dd>
</dl>
</section>
<section id="read-data-from-disk">
<h3>Read data from disk<a class="headerlink" href="#read-data-from-disk" title="Link to this heading"></a></h3>
<p>To read data saved on disk, use the function <a class="reference internal" href="generated/fedoo.read_data.html#fedoo.read_data" title="fedoo.read_data"><code class="xref py py-func docutils literal notranslate"><span class="pre">read_data()</span></code></a>.
The data are imported as <a class="reference internal" href="generated/fedoo.DataSet.html#fedoo.DataSet" title="fedoo.DataSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">DataSet</span></code></a> or
<a class="reference internal" href="generated/fedoo.MultiFrameDataSet.html#fedoo.MultiFrameDataSet" title="fedoo.MultiFrameDataSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiFrameDataSet</span></code></a> objects depending on the imported file(s).</p>
<p class="rubric" id="very-simple-problem">Example</p>
<p>For example, defining and solving a very simple problem :</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">fedoo</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">fd</span>
<span class="n">fd</span><span class="o">.</span><span class="n">ModelingSpace</span><span class="p">(</span><span class="s2">"2Dstress"</span><span class="p">)</span>
<span class="n">mesh</span> <span class="o">=</span> <span class="n">fd</span><span class="o">.</span><span class="n">mesh</span><span class="o">.</span><span class="n">rectangle_mesh</span><span class="p">()</span>
<span class="n">material</span> <span class="o">=</span> <span class="n">fd</span><span class="o">.</span><span class="n">constitutivelaw</span><span class="o">.</span><span class="n">ElasticIsotrop</span><span class="p">(</span><span class="mf">2e5</span><span class="p">,</span> <span class="mf">0.3</span><span class="p">)</span>
<span class="n">wf</span> <span class="o">=</span> <span class="n">fd</span><span class="o">.</span><span class="n">weakform</span><span class="o">.</span><span class="n">StressEquilibrium</span><span class="p">(</span><span class="n">material</span><span class="p">)</span>
<span class="n">assembly</span> <span class="o">=</span> <span class="n">fd</span><span class="o">.</span><span class="n">Assembly</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">wf</span><span class="p">,</span> <span class="n">mesh</span><span class="p">)</span>
<span class="c1"># Define a new static problem</span>
<span class="n">pb</span> <span class="o">=</span> <span class="n">fd</span><span class="o">.</span><span class="n">problem</span><span class="o">.</span><span class="n">Linear</span><span class="p">(</span><span class="n">assembly</span><span class="p">)</span>
<span class="c1"># Boundary conditions</span>
<span class="n">pb</span><span class="o">.</span><span class="n">bc</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s1">'Dirichlet'</span><span class="p">,</span> <span class="s1">'left'</span><span class="p">,</span> <span class="s1">'Disp'</span><span class="p">,</span> <span class="mi">0</span> <span class="p">)</span>
<span class="n">pb</span><span class="o">.</span><span class="n">bc</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s1">'Dirichlet'</span><span class="p">,</span> <span class="s1">'right'</span><span class="p">,</span> <span class="s1">'Disp'</span><span class="p">,</span> <span class="p">[</span><span class="mf">0.2</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span> <span class="p">)</span>
<span class="c1"># Solve problem</span>
<span class="n">pb</span><span class="o">.</span><span class="n">solve</span><span class="p">()</span>
</pre></div>
</div>
<p>Then, we can catch the Stress, Displacement and Strain fields using:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">results</span> <span class="o">=</span> <span class="n">pb</span><span class="o">.</span><span class="n">get_results</span><span class="p">(</span><span class="n">assembly</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Stress"</span><span class="p">,</span> <span class="s2">"Disp"</span><span class="p">,</span> <span class="s2">"Strain"</span><span class="p">])</span>
<span class="c1"># plot the sigma_xx averaged at nodes</span>
<span class="n">results</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="s2">"Stress"</span><span class="p">,</span> <span class="n">component</span><span class="o">=</span><span class="s1">'XX'</span><span class="p">,</span> <span class="n">data_type</span><span class="o">=</span><span class="s1">'Node'</span><span class="p">)</span>
</pre></div>
</div>
<img alt="_images/example_plot_dataset.png" src="_images/example_plot_dataset.png" />
<p>Alternatively, if we take the same problem, but accounting for geometric
non linearities (nlgeom = True), we can automatically save results at specified
time interval (here the results are saved on a file).</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">wf</span><span class="o">.</span><span class="n">nlgeom</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">pb_nl</span> <span class="o">=</span> <span class="n">fd</span><span class="o">.</span><span class="n">problem</span><span class="o">.</span><span class="n">NonLinear</span><span class="p">(</span><span class="n">assembly</span><span class="p">)</span>
<span class="c1"># Boundary conditions</span>
<span class="n">pb_nl</span><span class="o">.</span><span class="n">bc</span> <span class="o">=</span> <span class="n">pb</span><span class="o">.</span><span class="n">bc</span>
<span class="n">results_nl</span> <span class="o">=</span> <span class="n">pb_nl</span><span class="o">.</span><span class="n">add_output</span><span class="p">(</span><span class="s1">'nl_results'</span><span class="p">,</span> <span class="n">assembly</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Stress"</span><span class="p">,</span> <span class="s2">"Disp"</span><span class="p">,</span> <span class="s2">"Strain"</span><span class="p">])</span>
<span class="n">pb_nl</span><span class="o">.</span><span class="n">nlsolve</span><span class="p">(</span><span class="n">dt</span> <span class="o">=</span> <span class="mf">0.1</span><span class="p">,</span> <span class="n">tmax</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">interval_output</span> <span class="o">=</span> <span class="mf">0.2</span><span class="p">)</span>
<span class="c1"># plot the sigma_xx averaged at nodes at the last increment</span>
<span class="n">results_nl</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="s2">"Stress"</span><span class="p">,</span> <span class="n">component</span><span class="o">=</span><span class="s1">'XX'</span><span class="p">,</span> <span class="n">data_type</span><span class="o">=</span><span class="s1">'Node'</span><span class="p">)</span>
</pre></div>
</div>
<img alt="_images/example_plot_dataset_nl.png" src="_images/example_plot_dataset_nl.png" />
</section>
</section>
<section id="fedoo-interactive-viewer">
<h2>Fedoo interactive viewer<a class="headerlink" href="#fedoo-interactive-viewer" title="Link to this heading"></a></h2>
<p>Fedoo includes a graphical application to visulize a result file or
a DataSet like object. To be able to launch the viewer, the
package pyvistaqt has to be installed.</p>
<p>Then the viewer can either be launched as a standalone application from
command line:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ python -m fedoo.viewer
</pre></div>
</div>
<p>or from a python code. The code below show different ways to start the viewer
inside a python code:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">fedoo</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">fd</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">fd</span><span class="o">.</span><span class="n">read_data</span><span class="p">(</span><span class="s1">'myfile.fdz'</span><span class="p">)</span> <span class="c1"># load a DataSet from file</span>
<span class="n">fd</span><span class="o">.</span><span class="n">viewer</span><span class="p">()</span> <span class="c1"># start the viewer with no file opened</span>
<span class="n">fd</span><span class="o">.</span><span class="n">viewer</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> <span class="c1"># start the viewer and open the result DataSet</span>
<span class="n">fd</span><span class="o">.</span><span class="n">viewer</span><span class="p">(</span><span class="s1">'myfile.fdz'</span><span class="p">)</span> <span class="c1"># start the viewer with the data from a file</span>
</pre></div>
</div>
<p>The viewer includes the following tools and features:</p>
<ul class="simple">
<li><p>Management of multiple independent windows, which can be linked together.</p></li>
<li><p>Field and iteration selectors for data exploration.</p></li>
<li><p>A wide range of plotting options.</p></li>
<li><p>Show or hide elements from predefined sets, rectangular selections,
or arbitrary expressions.</p></li>
<li><p>Plot results along an interactively defined line.</p></li>
<li><p>Plot time-history data, when applicable.</p></li>
<li><p>Clip the current mesh using an interactively defined plane.</p></li>
<li><p>Save figures and create movies using the current visualization settings.</p></li>
</ul>
</section>
<section id="basic-operations">
<h2>Basic operations<a class="headerlink" href="#basic-operations" title="Link to this heading"></a></h2>
<p>The principale methods/functions to extract, plot and manage
result data are listed in this section.</p>
<section id="extract-data">
<h3>Extract data<a class="headerlink" href="#extract-data" title="Link to this heading"></a></h3>
<table class="autosummary longtable docutils align-default">
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.DataSet.get_data.html#fedoo.DataSet.get_data" title="fedoo.DataSet.get_data"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.get_data</span></code></a>(field[, component, ...])</p></td>
<td><p>Retrieve data from the DataSet for a given field.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.get_history.html#fedoo.MultiFrameDataSet.get_history" title="fedoo.MultiFrameDataSet.get_history"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MultiFrameDataSet.get_history</span></code></a>(field[, ...])</p></td>
<td><p>Retrieve history data from the MultiFrameDataSet.</p></td>
</tr>
</tbody>
</table>
</section>
<section id="plotting-results">
<h3>Plotting results<a class="headerlink" href="#plotting-results" title="Link to this heading"></a></h3>
<p>A few convenient methods are proposed to generate images or movies from
<a class="reference internal" href="generated/fedoo.DataSet.html#fedoo.DataSet" title="fedoo.DataSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">DataSet</span></code></a> and <a class="reference internal" href="generated/fedoo.MultiFrameDataSet.html#fedoo.MultiFrameDataSet" title="fedoo.MultiFrameDataSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiFrameDataSet</span></code></a> objects.</p>
<table class="autosummary longtable docutils align-default">
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.DataSet.plot.html#fedoo.DataSet.plot" title="fedoo.DataSet.plot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.plot</span></code></a>([field, component, data_type, ...])</p></td>
<td><p>Plot a field on the surface of the associated mesh.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.plot.html#fedoo.MultiFrameDataSet.plot" title="fedoo.MultiFrameDataSet.plot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MultiFrameDataSet.plot</span></code></a>([field, component, ...])</p></td>
<td><p>Plot a field on the surface of the associated mesh.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.plot_history.html#fedoo.MultiFrameDataSet.plot_history" title="fedoo.MultiFrameDataSet.plot_history"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MultiFrameDataSet.plot_history</span></code></a>(field, indices)</p></td>
<td><p>Plot history data from the MultiFrameDataSet.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.write_movie.html#fedoo.MultiFrameDataSet.write_movie" title="fedoo.MultiFrameDataSet.write_movie"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MultiFrameDataSet.write_movie</span></code></a>([filename, ...])</p></td>
<td><p>Create a video from the data.</p></td>
</tr>
</tbody>
</table>
</section>
<section id="save-results">
<h3>Save results<a class="headerlink" href="#save-results" title="Link to this heading"></a></h3>
<table class="autosummary longtable docutils align-default">
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.DataSet.save.html#fedoo.DataSet.save" title="fedoo.DataSet.save"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.save</span></code></a>(filename[, save_mesh, compressed])</p></td>
<td><p>Save data to a file.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/fedoo.DataSet.savez.html#fedoo.DataSet.savez" title="fedoo.DataSet.savez"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.savez</span></code></a>(filename[, save_mesh])</p></td>
<td><p>Write a npz file using the numpy savez function.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.DataSet.savez_compressed.html#fedoo.DataSet.savez_compressed" title="fedoo.DataSet.savez_compressed"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.savez_compressed</span></code></a>(filename[, save_mesh])</p></td>
<td><p>Write a compressed npz file using the numpy savez_compressed function.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/fedoo.DataSet.save_mesh.html#fedoo.DataSet.save_mesh" title="fedoo.DataSet.save_mesh"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.save_mesh</span></code></a>(filename)</p></td>
<td><p>Save the mesh using a vtk file.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.DataSet.to_csv.html#fedoo.DataSet.to_csv" title="fedoo.DataSet.to_csv"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.to_csv</span></code></a>(filename[, save_mesh])</p></td>
<td><p>Write data in a csv file.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/fedoo.DataSet.to_excel.html#fedoo.DataSet.to_excel" title="fedoo.DataSet.to_excel"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.to_excel</span></code></a>(filename[, save_mesh])</p></td>
<td><p>Write data in a xlsx file (excel format).</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.DataSet.to_vtk.html#fedoo.DataSet.to_vtk" title="fedoo.DataSet.to_vtk"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.to_vtk</span></code></a>(filename[, binary, ...])</p></td>
<td><p>Write vtk file with the mesh and associated data.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/fedoo.DataSet.to_msh.html#fedoo.DataSet.to_msh" title="fedoo.DataSet.to_msh"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.to_msh</span></code></a>(filename)</p></td>
<td><p>Write a msh (gmsh format) file with mesh and associated data.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.save_all.html#fedoo.MultiFrameDataSet.save_all" title="fedoo.MultiFrameDataSet.save_all"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MultiFrameDataSet.save_all</span></code></a>(filename[, ...])</p></td>
<td><p>Save all data from MultiFrameDataSet.</p></td>
</tr>
</tbody>
</table>
</section>
<section id="read-results">
<h3>Read results<a class="headerlink" href="#read-results" title="Link to this heading"></a></h3>
<table class="autosummary longtable docutils align-default">
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.read_data.html#fedoo.read_data" title="fedoo.read_data"><code class="xref py py-obj docutils literal notranslate"><span class="pre">read_data</span></code></a>(filename[, file_format])</p></td>
<td><p>Read a file from disk.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/fedoo.DataSet.read.html#fedoo.DataSet.read" title="fedoo.DataSet.read"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.read</span></code></a>(filename[, file_format])</p></td>
<td><p>Read a file from disk.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/fedoo.DataSet.load.html#fedoo.DataSet.load" title="fedoo.DataSet.load"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSet.load</span></code></a>(data[, load_mesh, iteration])</p></td>
<td><p>Load data from a data object.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/fedoo.MultiFrameDataSet.load.html#fedoo.MultiFrameDataSet.load" title="fedoo.MultiFrameDataSet.load"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MultiFrameDataSet.load</span></code></a>([data, load_mesh])</p></td>
<td><p>Load data from a data object.</p></td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="advanced-operations">
<h2>Advanced operations<a class="headerlink" href="#advanced-operations" title="Link to this heading"></a></h2>
<section id="write-movies">
<h3>Write Movies<a class="headerlink" href="#write-movies" title="Link to this heading"></a></h3>
<p>A very simple way to write a movie from a <a class="reference internal" href="generated/fedoo.MultiFrameDataSet.html#fedoo.MultiFrameDataSet" title="fedoo.MultiFrameDataSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiFrameDataSet</span></code></a> is
to call the embedded method <a class="reference internal" href="generated/fedoo.MultiFrameDataSet.write_movie.html#fedoo.MultiFrameDataSet.write_movie" title="fedoo.MultiFrameDataSet.write_movie"><code class="xref py py-meth docutils literal notranslate"><span class="pre">MultiFrameDataSet.write_movie()</span></code></a>.</p>
<p>Though this method comes with lots of options, one may sometimes want to
fully control the movie rendering. This is easy to do by manualy writing the
movie using the pyvista library.</p>
<p>Here is an exemple to animate the linear results obtained in the
<a class="reference internal" href="#very-simple-problem"><span class="std std-ref">problem</span></a> defined above. The idea is to use a
scale_factor applied to the displacement (using the <em>scale</em> argument) and to
the stress field (modifiying the results data).</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">pyvista</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">pv</span>
<span class="n">results</span> <span class="o">=</span> <span class="n">pb</span><span class="o">.</span><span class="n">get_results</span><span class="p">(</span><span class="n">assembly</span><span class="p">,</span> <span class="p">[</span><span class="s1">'Stress'</span><span class="p">,</span> <span class="s1">'Disp'</span><span class="p">],</span> <span class="s1">'Node'</span><span class="p">)</span>
<span class="n">stress</span> <span class="o">=</span> <span class="n">results</span><span class="o">.</span><span class="n">node_data</span><span class="p">[</span><span class="s1">'Stress'</span><span class="p">]</span>
<span class="n">clim</span> <span class="o">=</span> <span class="p">[</span><span class="n">stress</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">min</span><span class="p">(),</span> <span class="n">stress</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">max</span><span class="p">()]</span> <span class="c1"># 3 -> xy in voigt notation</span>
<span class="n">pl</span> <span class="o">=</span> <span class="n">pv</span><span class="o">.</span><span class="n">Plotter</span><span class="p">(</span><span class="n">window_size</span> <span class="o">=</span> <span class="p">[</span><span class="mi">600</span><span class="p">,</span><span class="mi">400</span><span class="p">])</span>
<span class="n">pl</span><span class="o">.</span><span class="n">open_gif</span><span class="p">(</span><span class="s2">"my_movie.gif"</span><span class="p">,</span> <span class="n">fps</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
<span class="n">sargs</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">height</span><span class="o">=</span><span class="mf">0.10</span><span class="p">,</span> <span class="n">position_x</span><span class="o">=</span><span class="mf">0.2</span><span class="p">,</span> <span class="n">position_y</span><span class="o">=</span><span class="mf">0.05</span><span class="p">)</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">48</span><span class="p">):</span>
<span class="n">scale_factor</span> <span class="o">=</span> <span class="p">(</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">48</span>
<span class="n">results</span><span class="o">.</span><span class="n">node_data</span><span class="p">[</span><span class="s2">"Stress"</span><span class="p">]</span> <span class="o">=</span> <span class="n">scale_factor</span> <span class="o">*</span> <span class="n">stress</span>
<span class="n">results</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span>
<span class="s2">"Stress"</span><span class="p">,</span>
<span class="s2">"XY"</span><span class="p">,</span>
<span class="n">plotter</span><span class="o">=</span><span class="n">pl</span><span class="p">,</span>
<span class="n">scale</span><span class="o">=</span><span class="n">scale_factor</span><span class="p">,</span>
<span class="n">clim</span><span class="o">=</span><span class="n">clim</span><span class="p">,</span>
<span class="n">title</span><span class="o">=</span><span class="sa">f</span><span class="s2">"Iter: </span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span>
<span class="n">title_size</span> <span class="o">=</span> <span class="mi">10</span><span class="p">,</span>
<span class="n">scalar_bar_args</span><span class="o">=</span><span class="n">sargs</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">pl</span><span class="o">.</span><span class="n">hide_axes</span><span class="p">()</span>
<span class="n">pl</span><span class="o">.</span><span class="n">write_frame</span><span class="p">()</span>
<span class="n">pl</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
<img alt="_images/my_movie.gif" src="_images/my_movie.gif" />
</section>
<section id="multiplot-feature">
<h3>Multiplot feature<a class="headerlink" href="#multiplot-feature" title="Link to this heading"></a></h3>
<p>It is possible to create the plotter before calling the plot function.
This allow for instance to use the pyvista multiplot capability.
For instance,
we can plot the stress results after the example
<a class="reference internal" href="simple_examples.html#example-plate-with-hole"><span class="std std-ref">Plate with hole in tension</span></a>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">pyvista</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">pv</span>
<span class="n">pl</span> <span class="o">=</span> <span class="n">pv</span><span class="o">.</span><span class="n">Plotter</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">))</span>
<span class="c1"># or using the backgroundplotter:</span>
<span class="c1"># from pyvistaqt import BackgroundPlotter</span>
<span class="c1"># pl = BackgroundPlotter(shape = (2,2))</span>
<span class="n">results</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="s1">'Stress'</span><span class="p">,</span> <span class="s1">'vm'</span><span class="p">,</span> <span class="s1">'Node'</span><span class="p">,</span> <span class="n">plotter</span><span class="o">=</span><span class="n">pl</span><span class="p">)</span>
<span class="n">pl</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
<span class="n">results</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="s1">'Stress'</span><span class="p">,</span> <span class="s1">'XX'</span><span class="p">,</span> <span class="s1">'Node'</span><span class="p">,</span> <span class="n">plotter</span><span class="o">=</span><span class="n">pl</span><span class="p">)</span>
<span class="n">pl</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
<span class="n">results</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="s1">'Stress'</span><span class="p">,</span> <span class="s1">'YY'</span><span class="p">,</span> <span class="s1">'Node'</span><span class="p">,</span> <span class="n">plotter</span><span class="o">=</span><span class="n">pl</span><span class="p">)</span>
<span class="n">pl</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
<span class="n">results</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="s1">'Stress'</span><span class="p">,</span> <span class="s1">'XY'</span><span class="p">,</span> <span class="s1">'Node'</span><span class="p">,</span> <span class="n">plotter</span><span class="o">=</span><span class="n">pl</span><span class="p">)</span>
<span class="n">pl</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
<img alt="_images/multiplot.png" src="_images/multiplot.png" />
</section>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="generated/fedoo.constraint.IPCSelfContact.associated_assembly_sum.html" class="btn btn-neutral float-left" title="fedoo.constraint.IPCSelfContact.associated_assembly_sum" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="generated/fedoo.DataSet.html" class="btn btn-neutral float-right" title="fedoo.DataSet" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>© Copyright 2019, Etienne Prulière.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>