.. 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-10 .. code-block:: Python from ogstools import examples .. GENERATED FROM PYTHON SOURCE LINES 11-18 To read your own data as a mesh series you can do: .. code-block:: python from ogstools.meshlib import MeshSeries mesh_series = MeshSeries("filepath/filename_pvd_or_xdmf") .. GENERATED FROM PYTHON SOURCE LINES 20-22 MeshSeries takes as mandatory argument a str OR pathlib.Path that represents the location of the pvd or xdmf file. Here, we load example data: .. GENERATED FROM PYTHON SOURCE LINES 22-25 .. code-block:: Python ms = examples.load_meshseries_HT_2D_XDMF() .. GENERATED FROM PYTHON SOURCE LINES 26-30 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 30-39 .. code-block:: Python 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. 900. 1800.]. Time value at step 10 is 9000.0 s. .. GENERATED FROM PYTHON SOURCE LINES 40-41 Read data is cached. The function read is only slow for each new timestep requested. .. GENERATED FROM PYTHON SOURCE LINES 41-51 .. code-block:: Python 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) .. tab-set:: .. tab-item:: Static Scene .. 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 .. tab-item:: Interactive Scene .. offlineviewer:: /builds/ogs/tools/ogstools/docs/auto_examples/howto_meshlib/images/sphx_glr_plot_meshseries_001.vtksz .. GENERATED FROM PYTHON SOURCE LINES 52-54 MeshSeries from PVD file ========================= .. GENERATED FROM PYTHON SOURCE LINES 54-57 .. code-block:: Python ms = examples.load_meshseries_THM_2D_PVD() ms.read(0).plot() .. tab-set:: .. tab-item:: Static Scene .. 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 .. tab-item:: Interactive Scene .. offlineviewer:: /builds/ogs/tools/ogstools/docs/auto_examples/howto_meshlib/images/sphx_glr_plot_meshseries_002.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.582 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-jupyter :download:`Download Jupyter notebook: plot_meshseries.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_meshseries.py `