.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_preprocessing/plot_remeshing.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_remeshing.py: Remeshing with triangle elements ================================ .. sectionauthor:: Florian Zill (Helmholtz Centre for Environmental Research GmbH - UFZ) This short example showcases the function `remesh_with_tri` which allows us to take an existing mesh and re-discretize it with triangle elements. This is useful for models, where the underlying meshing script is not available or hard to adapt. .. GENERATED FROM PYTHON SOURCE LINES 14-25 .. code-block:: Python from pathlib import Path from tempfile import mkdtemp import ogstools as ogs from ogstools import examples from ogstools.msh2vtu import msh2vtu mesh = examples.load_meshseries_THM_2D_PVD().mesh(1) .. GENERATED FROM PYTHON SOURCE LINES 31-32 elements. .. GENERATED FROM PYTHON SOURCE LINES 32-34 .. code-block:: Python fig = mesh.plot_contourf(ogs.variables.material_id) .. image-sg:: /auto_examples/howto_preprocessing/images/sphx_glr_plot_remeshing_001.png :alt: plot remeshing :srcset: /auto_examples/howto_preprocessing/images/sphx_glr_plot_remeshing_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 35-37 Here, we do the remeshing and use msh2vtu to convert the resulting msh file to an OGS-compatible vtu file. .. GENERATED FROM PYTHON SOURCE LINES 39-46 .. code-block:: Python mesh = examples.load_meshseries_THM_2D_PVD().mesh(1) temp_dir = Path(mkdtemp()) msh_path = temp_dir / "tri_mesh.msh" ogs.meshlib.gmsh_meshing.remesh_with_triangle(mesh, msh_path) msh2vtu(msh_path, temp_dir, reindex=False, log_level="ERROR") mesh = ogs.Mesh(temp_dir / "tri_mesh_domain.vtu") fig = mesh.plot_contourf(ogs.variables.material_id) .. image-sg:: /auto_examples/howto_preprocessing/images/sphx_glr_plot_remeshing_002.png :alt: plot remeshing :srcset: /auto_examples/howto_preprocessing/images/sphx_glr_plot_remeshing_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.636 seconds) .. _sphx_glr_download_auto_examples_howto_preprocessing_plot_remeshing.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_remeshing.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_remeshing.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_remeshing.zip `