.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated_examples/plot_stress.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_generated_examples_plot_stress.py: Aggregate Y-Stress ==================== .. GENERATED FROM PYTHON SOURCE LINES 6-15 .. code-block:: Python # pylint: disable=pointless-statement from pathlib import Path import numpy as np from lasso.dyna import ArrayType from mesh2vec.mesh2vec_cae import Mesh2VecCae .. GENERATED FROM PYTHON SOURCE LINES 16-18 Load Shell from ANSA, simulation results from d3plot ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 18-38 .. code-block:: Python hg = Mesh2VecCae.from_ansa_shell( 10, Path("../../data/hat/Hatprofile.k"), json_mesh_file=Path("../../data/hat/cached_hat_key.json"), ) def mean_over_components_all_layers(v: list | np.ndarray) -> np.ndarray: """get mean over all components and all layers""" return np.mean(v, axis=-1) feature_name = hg.add_feature_from_d3plot( ArrayType.element_shell_stress, Path("../../data/hat/HAT.d3plot"), timestep=-1, shell_layer=mean_over_components_all_layers, ) .. GENERATED FROM PYTHON SOURCE LINES 39-41 Aggregate Feature and plot --------------------------- .. GENERATED FROM PYTHON SOURCE LINES 41-47 .. code-block:: Python name = hg.aggregate(feature_name, 1, lambda x: np.mean(np.mean(x))) fig = hg.get_visualization_plotly(str(name)) fig.update_layout(title=name) fig .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 48-50 Access the results ------------------- .. GENERATED FROM PYTHON SOURCE LINES 50-51 .. code-block:: Python hg.to_dataframe() .. raw:: html
vtx_id element_shell_stress_-1_mean_over_components_all_layers-<lambda>-1
0 4700000 -0.003867
1 4700001 -0.003714
2 4700002 0.000849
3 4700003 -0.005308
4 4700004 -0.007338
... ... ...
6395 2002173 -0.000210
6396 2002174 -0.000232
6397 2002175 0.000439
6398 2002176 -0.000076
6399 2002177 -0.000093

6400 rows × 2 columns



.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.450 seconds) .. _sphx_glr_download_generated_examples_plot_stress.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_stress.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_stress.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_stress.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_