.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_meshlib/plot_meshseries.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_auto_examples_howto_meshlib_plot_meshseries.py: Read mesh from file (vtu or xdmf) into pyvista mesh ===================================================== .. GENERATED FROM PYTHON SOURCE LINES 8-12 .. code-block:: default from ogstools.meshlib import MeshSeries from ogstools.meshlib.examples import xdmf_file from ogstools.meshplotlib.examples import THM_2D_file as pvd_file .. GENERATED FROM PYTHON SOURCE LINES 13-14 MeshSeries takes as mandatory argument a str OR pathlib.Path that represents the location of the pvd or xdmf file. .. GENERATED FROM PYTHON SOURCE LINES 14-18 .. code-block:: default print(xdmf_file) ms = MeshSeries(xdmf_file) .. rst-class:: sphx-glr-script-out .. code-block:: none /workspaces/tools/ogstools/meshlib/examples/2D_single_fracture_HT_2D_single_fracture.xdmf .. GENERATED FROM PYTHON SOURCE LINES 19-23 Accessing time values ======================= All time value (in seconds) are within a range (e.g. can be converted to list) Python slicing is supported. .. GENERATED FROM PYTHON SOURCE LINES 23-32 .. code-block:: default print(f"First 3 time values are: {ms.timevalues[:3]}.") # Accessing a specific time step timestep = 10 print(f"Time value at step {timestep} is {ms.timevalues[timestep]} s.") .. rst-class:: sphx-glr-script-out .. code-block:: none First 3 time values are: [0.0, 900.0, 1800.0]. Time value at step 10 is 9000.0 s. .. GENERATED FROM PYTHON SOURCE LINES 33-34 Read data is cached. The function read is only slow for each new timestep requested. .. GENERATED FROM PYTHON SOURCE LINES 34-44 .. code-block:: default mesh_ts10 = ms.read(timestep) # The mesh taken from a specific time step of the mesh series is a pyvista mesh # Here we use pyvista functionality plot. mesh_ts10.plot(show_edges=True) .. image-sg:: /auto_examples/howto_meshlib/images/sphx_glr_plot_meshseries_001.png :alt: plot meshseries :srcset: /auto_examples/howto_meshlib/images/sphx_glr_plot_meshseries_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 45-47 MeshSeries from PVD file ========================= .. GENERATED FROM PYTHON SOURCE LINES 47-50 .. code-block:: default ms = MeshSeries(pvd_file) ms.read(0).plot() .. image-sg:: /auto_examples/howto_meshlib/images/sphx_glr_plot_meshseries_002.png :alt: plot meshseries :srcset: /auto_examples/howto_meshlib/images/sphx_glr_plot_meshseries_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.361 seconds) .. _sphx_glr_download_auto_examples_howto_meshlib_plot_meshseries.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_meshseries.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_meshseries.ipynb `