.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_meshlib/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_meshlib_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. .. GENERATED FROM PYTHON SOURCE LINES 11-18 .. code-block:: Python from ogstools.meshlib.boundary import Layer from ogstools.meshlib.boundary_set import LayerSet from ogstools.meshlib.boundary_subset import Gaussian2D, Surface from ogstools.meshlib.region import to_region_tetraeder # See other examples for different meshing algorithms .. GENERATED FROM PYTHON SOURCE LINES 19-20 Define a simple surface .. GENERATED FROM PYTHON SOURCE LINES 20-31 .. code-block:: Python bounds = (-200, 210, -200, 210) args = {"bound2D": bounds, "amplitude": 100, "spread": 100, "n": 40} surface1 = Surface(Gaussian2D(**args, height_offset=0), material_id=0) surface2 = Surface(Gaussian2D(**args, height_offset=-100), material_id=1) surface3 = Surface(Gaussian2D(**args, height_offset=-200), material_id=2) ls = LayerSet([Layer(surface1, surface2), Layer(surface2, surface3)]) mesh = to_region_tetraeder(ls, 40).mesh # interprets values as categories mesh["regions"] = [str(m) for m in mesh["MaterialIDs"]] .. GENERATED FROM PYTHON SOURCE LINES 32-33 Visualize the prism mesh .. GENERATED FROM PYTHON SOURCE LINES 33-34 .. code-block:: Python mesh.plot(scalars="regions", show_edges=True) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/howto_meshlib/images/sphx_glr_plot_meshlib_pyvista_input_001.png :alt: plot meshlib pyvista input :srcset: /auto_examples/howto_meshlib/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_meshlib/images/sphx_glr_plot_meshlib_pyvista_input_001.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.029 seconds) .. _sphx_glr_download_auto_examples_howto_meshlib_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 `