.. 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_vtu_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_vtu_input.py: Creating meshes from vtu surface files ====================================== .. sectionauthor:: Tobias Meisel (Helmholtz Centre for Environmental Research GmbH - UFZ) For this example we create meshes from surface layers. .. GENERATED FROM PYTHON SOURCE LINES 11-14 .. code-block:: Python from ogstools import meshlib as ml from ogstools.examples import surface_paths .. GENERATED FROM PYTHON SOURCE LINES 15-18 The loaded surfaces are defined within VTU files and adhere to properties such as non-intersecting boundaries with consistent x and y bounds. Alternatively, surfaces can also be created using PyVista with the same properties. .. GENERATED FROM PYTHON SOURCE LINES 18-24 .. code-block:: Python surface1 = ml.Surface(surface_paths[0], material_id=0) surface2 = ml.Surface(surface_paths[1], material_id=5) surface3 = ml.Surface(surface_paths[2], material_id=2) surface4 = ml.Surface(surface_paths[3], material_id=3) .. GENERATED FROM PYTHON SOURCE LINES 25-27 Create 3 layers from previously defined surfaces and add all layers to a layerset (ordererd from top to bottom) .. GENERATED FROM PYTHON SOURCE LINES 27-33 .. code-block:: Python layer1 = ml.Layer(top=surface1, bottom=surface2, num_subdivisions=2) layer2 = ml.Layer(top=surface2, bottom=surface3, num_subdivisions=1) layer3 = ml.Layer(top=surface3, bottom=surface4, num_subdivisions=0) layer_set1 = ml.LayerSet(layers=[layer1, layer2, layer3]) .. GENERATED FROM PYTHON SOURCE LINES 34-36 From layerset creation of simplified meshes (sm), prism meshes (pm), voxel meshes (vm), tetraeder mesh (tm) is possible. .. GENERATED FROM PYTHON SOURCE LINES 36-41 .. code-block:: Python sm = ml.to_region_simplified(layer_set1, xy_resolution=200, rank=3).mesh pm = ml.to_region_prism(layer_set1, resolution=200).mesh vm = ml.to_region_voxel(layer_set1, resolution=[200, 200, 50]).mesh tm = ml.to_region_tetraeder(layer_set1, resolution=200).mesh .. GENERATED FROM PYTHON SOURCE LINES 42-45 Simplified mesh --------------- %% .. GENERATED FROM PYTHON SOURCE LINES 45-48 .. code-block:: Python sm["regions"] = [str(m) for m in sm["MaterialIDs"]] sm.scale([1, 1, 5]).plot(scalars="regions", show_edges=True) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/howto_preprocessing/images/sphx_glr_plot_meshlib_vtu_input_001.png :alt: plot meshlib vtu input :srcset: /auto_examples/howto_preprocessing/images/sphx_glr_plot_meshlib_vtu_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_vtu_input_001.vtksz .. GENERATED FROM PYTHON SOURCE LINES 49-52 Voxel mesh --------------- %% .. GENERATED FROM PYTHON SOURCE LINES 52-55 .. code-block:: Python vm["regions"] = [str(m) for m in vm["MaterialIDs"]] vm.scale([1, 1, 5]).plot(scalars="regions", show_edges=True) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/howto_preprocessing/images/sphx_glr_plot_meshlib_vtu_input_002.png :alt: plot meshlib vtu input :srcset: /auto_examples/howto_preprocessing/images/sphx_glr_plot_meshlib_vtu_input_002.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_vtu_input_002.vtksz .. GENERATED FROM PYTHON SOURCE LINES 56-59 Prism mesh --------------- %% .. GENERATED FROM PYTHON SOURCE LINES 59-62 .. code-block:: Python pm["regions"] = [str(m) for m in pm["MaterialIDs"]] pm.scale([1, 1, 5]).plot(scalars="regions", show_edges=True) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/howto_preprocessing/images/sphx_glr_plot_meshlib_vtu_input_003.png :alt: plot meshlib vtu input :srcset: /auto_examples/howto_preprocessing/images/sphx_glr_plot_meshlib_vtu_input_003.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_vtu_input_003.vtksz .. GENERATED FROM PYTHON SOURCE LINES 63-66 Tetraeder mesh --------------- %% .. GENERATED FROM PYTHON SOURCE LINES 66-68 .. code-block:: Python tm["regions"] = [str(m) for m in tm["MaterialIDs"]] tm.scale([1, 1, 5]).plot(scalars="regions", show_edges=True) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/howto_preprocessing/images/sphx_glr_plot_meshlib_vtu_input_004.png :alt: plot meshlib vtu input :srcset: /auto_examples/howto_preprocessing/images/sphx_glr_plot_meshlib_vtu_input_004.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_vtu_input_004.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.308 seconds) .. _sphx_glr_download_auto_examples_howto_preprocessing_plot_meshlib_vtu_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_vtu_input.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_meshlib_vtu_input.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_meshlib_vtu_input.zip `