.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_feflowlib/plot_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_feflowlib_plot_2layers_model.py: 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:: default import ifm_contrib as ifm import ogstools.meshplotlib as mpl from ogstools.feflowlib import ( convert_geometry_mesh, update_geometry, ) from ogstools.feflowlib.examples import path_2layers_model # Load a FEFLOW model (.fem) or FEFLOW results file (.dac) as a FEFLOW document. feflow_model = ifm.loadDocument(path_2layers_model) pv_mesh = convert_geometry_mesh(feflow_model) pv_mesh.plot(show_edges=True, off_screen=True) .. image-sg:: /auto_examples/howto_feflowlib/images/sphx_glr_plot_2layers_model_001.png :alt: plot 2layers model :srcset: /auto_examples/howto_feflowlib/images/sphx_glr_plot_2layers_model_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 06.12.2023 08:41:09 - INFO - There are 75 number of points and 32 number of cells to be converted. .. 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:: default 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) .. image-sg:: /auto_examples/howto_feflowlib/images/sphx_glr_plot_2layers_model_002.png :alt: plot 2layers model :srcset: /auto_examples/howto_feflowlib/images/sphx_glr_plot_2layers_model_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 06.12.2023 08:41:09 - INFO - MaterialIDs refer to: {} 06.12.2023 08:41:09 - INFO - These data arrays refer to point data: ['SLICE', 'TOP_NODE', 'X', 'Y', 'P_BC_FLOW', 'P_ELEV', 'P_HEAD', 'P_MSH_XY', 'P_MSH_Y', 'P_PRESS'] 06.12.2023 08:41:09 - INFO - These data arrays refer to cell data: ['LAYER', 'TOP_ELEMENT', 'P_COMP', 'P_CONDX', 'P_CONDY', 'P_CONDZ', 'P_INACTIVE_ELE', 'P_IOFLOW', 'P_SOUF', 'P_TRAF_IN', 'P_TRAF_OUT', 'MaterialIDs'] 06.12.2023 08:41:09 - INFO - These data arrays have been neglected as they are full of nans: ['P_MOD_FLOW', 'P_BCFLOWMOD_2ND', 'P_BCFLOWMOD_2ND_INT', 'P_BCFLOWMOD_3RD', 'P_BCFLOWMOD_3RD_INT', 'P_BCFLOWMOD_4TH', 'P_BCFLOW_2ND', 'P_BCFLOW_2ND_INT', 'P_BCFLOW_3RD', 'P_BCFLOW_3RD_INT', 'P_BCFLOW_4TH', 'P_FLOWBCC_1ST_MAX', 'P_FLOWBCC_FIRST', 'P_FLOWBCC_2ND_MAX', 'P_FLOWBCC_2ND_MAX_INT', 'P_FLOWBCC_2ND_MIN', 'P_FLOWBCC_2ND_MIN_INT', 'P_FLOWBCC_3RD_MAX_FLUX', 'P_FLOWBCC_3RD_MAX_HEAD', 'P_FLOWBCC_3RD_MAX_INT_FLUX', 'P_FLOWBCC_3RD_MAX_INT_HEAD', 'P_FLOWBCC_3RD_MIN_FLUX', 'P_FLOWBCC_3RD_MIN_HEAD', 'P_FLOWBCC_3RD_MIN_INT_FLUX', 'P_FLOWBCC_3RD_MIN_INT_HEAD', 'P_FLOWBCC_LAST', 'P_FLOWBCC_4TH_MIN'] UnstructuredGrid (0x7f5914b52f40) 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:: default pv_mesh.save("2layers_model.vtu") .. GENERATED FROM PYTHON SOURCE LINES 38-39 4. As the converted mesh is a pyvista.UnstructuredGrid, we can plot it using meshplotlib. .. GENERATED FROM PYTHON SOURCE LINES 39-40 .. code-block:: default fig = mpl.plot(pv_mesh.slice("z"), "P_HEAD") .. image-sg:: /auto_examples/howto_feflowlib/images/sphx_glr_plot_2layers_model_003.png :alt: plot 2layers model :srcset: /auto_examples/howto_feflowlib/images/sphx_glr_plot_2layers_model_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.425 seconds) .. _sphx_glr_download_auto_examples_howto_feflowlib_plot_2layers_model.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_2layers_model.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_2layers_model.ipynb `