.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_preprocessing/plot_meshlib_pyvista_input.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_preprocessing_plot_meshlib_pyvista_input.py: Creating meshes from pyvista surfaces ====================================== .. sectionauthor:: Tobias Meisel (Helmholtz Centre for Environmental Research GmbH - UFZ) For this example we create meshes from pyvista surfaces. See other examples for different meshing algorithms. .. GENERATED FROM PYTHON SOURCE LINES 10-25 .. code-block:: Python # Define a simple surface from ogstools import meshlib as ml bounds = (-200, 210, -200, 210) args = {"bound2D": bounds, "amplitude": 100, "spread": 100, "n": 40} surface1 = ml.Surface(ml.Gaussian2D(**args, height_offset=0), material_id=0) surface2 = ml.Surface(ml.Gaussian2D(**args, height_offset=-100), material_id=1) surface3 = ml.Surface(ml.Gaussian2D(**args, height_offset=-200), material_id=2) ls = ml.LayerSet([ml.Layer(surface1, surface2), ml.Layer(surface2, surface3)]) mesh = ml.to_region_tetraeder(ls, 40).mesh # interprets values as categories mesh["regions"] = [str(m) for m in mesh["MaterialIDs"]] .. GENERATED FROM PYTHON SOURCE LINES 26-27 Visualize the prism mesh .. GENERATED FROM PYTHON SOURCE LINES 27-28 .. code-block:: Python mesh.plot(scalars="regions", show_edges=True) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/howto_preprocessing/images/sphx_glr_plot_meshlib_pyvista_input_001.png :alt: plot meshlib pyvista input :srcset: /auto_examples/howto_preprocessing/images/sphx_glr_plot_meshlib_pyvista_input_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /builds/ogs/tools/ogstools/docs/auto_examples/howto_preprocessing/images/sphx_glr_plot_meshlib_pyvista_input_001.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.417 seconds) .. _sphx_glr_download_auto_examples_howto_preprocessing_plot_meshlib_pyvista_input.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_meshlib_pyvista_input.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_meshlib_pyvista_input.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_meshlib_pyvista_input.zip `