.. 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-23 .. code-block:: default import numpy as np # For visualization only import ogstools.meshplotlib as mpl # For visualization only 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 24-25 Define a simple surface .. GENERATED FROM PYTHON SOURCE LINES 25-34 .. code-block:: default 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 .. GENERATED FROM PYTHON SOURCE LINES 35-36 Visualize the prism mesh .. GENERATED FROM PYTHON SOURCE LINES 36-43 .. code-block:: default slices = np.reshape(mesh.slice_along_axis(n=4, axis="y"), (1, -1)) mpl.setup.aspect_limits = [0.2, 5.0] fig = mpl.plot(slices, "MaterialIDs") for ax, slice in zip(fig.axes, np.ravel(slices)): ax.set_title(f"z = {slice.center[2]:.1f} {mpl.setup.length.data_unit}") _ = fig .. image-sg:: /auto_examples/howto_meshlib/images/sphx_glr_plot_meshlib_pyvista_input_001.png :alt: z = -90.0 m, z = -52.5 m, z = -60.8 m, z = -93.7 m :srcset: /auto_examples/howto_meshlib/images/sphx_glr_plot_meshlib_pyvista_input_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.859 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-python :download:`Download Python source code: plot_meshlib_pyvista_input.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_meshlib_pyvista_input.ipynb `