.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_conversions/plot_C_feflowlib_2layers_model.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_conversions_plot_C_feflowlib_2layers_model.py: Feflowlib: How to work with FEFLOW data in pyvista. =================================================== .. sectionauthor:: Julian Heinze (Helmholtz Centre for Environmental Research GmbH - UFZ) In this example we show how a simple FEFLOW model consisting of two layers can be converted to a pyvista.UnstructuredGrid. .. GENERATED FROM PYTHON SOURCE LINES 11-12 1. Let us convert only the points and cells at first. .. GENERATED FROM PYTHON SOURCE LINES 12-25 .. code-block:: Python import ifm_contrib as ifm import ogstools as ogs from ogstools.examples import feflow_model_2layers from ogstools.feflowlib import ( convert_geometry_mesh, update_geometry, ) # Load a FEFLOW model (.fem) or FEFLOW results file (.dac) as a FEFLOW document. feflow_model = ifm.loadDocument(str(feflow_model_2layers)) pv_mesh = convert_geometry_mesh(feflow_model) pv_mesh.plot(show_edges=True, off_screen=True) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/howto_conversions/images/sphx_glr_plot_C_feflowlib_2layers_model_001.png :alt: plot C feflowlib 2layers model :srcset: /auto_examples/howto_conversions/images/sphx_glr_plot_C_feflowlib_2layers_model_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /builds/ogs/tools/ogstools/docs/auto_examples/howto_conversions/images/sphx_glr_plot_C_feflowlib_2layers_model_001.vtksz .. GENERATED FROM PYTHON SOURCE LINES 26-27 2. To this mesh we add point and cell data. .. GENERATED FROM PYTHON SOURCE LINES 27-31 .. code-block:: Python pv_mesh = update_geometry(pv_mesh, feflow_model) pv_mesh.plot(scalars="P_HEAD", show_edges=True, off_screen=True) # Print information about the mesh. print(pv_mesh) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/howto_conversions/images/sphx_glr_plot_C_feflowlib_2layers_model_002.png :alt: plot C feflowlib 2layers model :srcset: /auto_examples/howto_conversions/images/sphx_glr_plot_C_feflowlib_2layers_model_002.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /builds/ogs/tools/ogstools/docs/auto_examples/howto_conversions/images/sphx_glr_plot_C_feflowlib_2layers_model_002.vtksz .. rst-class:: sphx-glr-script-out .. code-block:: none UnstructuredGrid (0x7cd485b01300) N Cells: 32 N Points: 75 X Bounds: 3.000e+01, 7.000e+01 Y Bounds: 3.000e+01, 7.000e+01 Z Bounds: -2.000e+01, 0.000e+00 N Arrays: 22 .. GENERATED FROM PYTHON SOURCE LINES 32-36 3. As the FEFLOW data now are a pyvista.UnstructuredGrid, all pyvista functionalities can be applied to it. Further information can be found at https://docs.pyvista.org/version/stable/user-guide/simple.html. For example it can be saved as a VTK Unstructured Grid File (\*.vtu). This allows to use the FEFLOW model for ``OGS`` simulation or to observe it in ``Paraview```. .. GENERATED FROM PYTHON SOURCE LINES 36-37 .. code-block:: Python pv_mesh.save("2layers_model.vtu") .. GENERATED FROM PYTHON SOURCE LINES 38-39 4. Use the ogstools plotting functionalities. .. GENERATED FROM PYTHON SOURCE LINES 39-40 .. code-block:: Python fig = ogs.plot.contourf(pv_mesh.slice("z"), "P_HEAD") .. image-sg:: /auto_examples/howto_conversions/images/sphx_glr_plot_C_feflowlib_2layers_model_003.png :alt: plot C feflowlib 2layers model :srcset: /auto_examples/howto_conversions/images/sphx_glr_plot_C_feflowlib_2layers_model_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.675 seconds) .. _sphx_glr_download_auto_examples_howto_conversions_plot_C_feflowlib_2layers_model.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_C_feflowlib_2layers_model.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_C_feflowlib_2layers_model.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_C_feflowlib_2layers_model.zip `