.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_preprocessing/plot_terrain_meshing.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_terrain_meshing.py: Terrain meshing =============== .. sectionauthor:: Dominik Kern (TU Bergakademie Freiberg) .. GENERATED FROM PYTHON SOURCE LINES 10-12 .. code-block:: Python :dedent: 1 .. GENERATED FROM PYTHON SOURCE LINES 18-28 Here we show different tools to mesh a minimum example of a terrain, given by raster data. These are: * `Gmsh `_ * `OGS Utilities `_ * `PyVista `_ * `TetGen `_ .. image:: ../../examples/howto_preprocessing/terrain_meshing/terrain.png .. GENERATED FROM PYTHON SOURCE LINES 30-55 Gmsh ---- If the relief is given as relief.grd, then we need to convert it first (file names are hard coded): .. code-block:: python python -m ogstools.examples.mesh_terrain.grd2stl Running: .. code-block:: python python -m ogstools.examples.mesh_terrain.pyvista_mesh reads in `relief.stl` and meshes the volume between the relief and a *z*-coordinate specified in the script. In addition it creates physical groups for all bounding surfaces. .. image:: ../../examples/howto_preprocessing/terrain_meshing/gmsh.png .. literalinclude:: ../../../ogstools/examples/mesh_terrain/gmsh_mesh.py :language: python .. GENERATED FROM PYTHON SOURCE LINES 57-73 OGS Utilities ------------- OGS comes with some utilities for meshing. Required are raster files (`.grd`) and a file specifying their sequence (here `layer_file_list`). The following commands create a 2D mesh, extrude it to 3D-wedge elements and then fit in a structured hex mesh. .. code-block:: bash generateStructuredMesh -e tri --lx 10 --nx 20 --ly 10 --ny 20 -o tri2d_mesh.vtu createLayeredMeshFromRasters -i tri2d_mesh.vtu -o wedge3d_mesh.vtu -r layer_file_list Vtu2Grid -i wedge3d_mesh.vtu -o hex3d_mesh.vtu -x 0.4 .. image:: ../../examples/howto_preprocessing/terrain_meshing/ogstools.png .. GENERATED FROM PYTHON SOURCE LINES 75-93 PyVista ------- PyVista is mainly made for visualization, but brings some meshing functionality. It has a grid reader to read relief.grd and a meshio-interface to write to relief.vtu. Running: .. code-block:: bash python -m ogstools.examples.mesh_terrain.pyvista_mesh generates a structured mesh on the relief and extrudes it downwards to 3D. .. image:: ../../examples/howto_preprocessing/terrain_meshing/pyvista.png .. literalinclude:: ../../../ogstools/examples/mesh_terrain/pyvista_mesh.py :language: python .. GENERATED FROM PYTHON SOURCE LINES 95-107 TetGen ------ TetGen creates a 3D mesh from a 2D mesh on a closed surface. This surface may be either read from stl-files or PyVista-data. Currently the *pyvista-tetgen basic example* (`tetgen_example.py`) has been prepared for terrain meshing (`tetgen_mesh.py`), but is not finished yet. .. literalinclude:: ../../../ogstools/examples/mesh_terrain/tetgen_mesh.py :language: Python .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_howto_preprocessing_plot_terrain_meshing.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_terrain_meshing.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_terrain_meshing.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_terrain_meshing.zip `