.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/Mesh/remesh.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_examples_Mesh_remesh.py: Periodic remeshing ================== Remesh a gyroid volume mesh with mmg while keeping its boundaries, so that the mesh stays periodic for finite element simulations. Requires the ``mmg`` executables: ``conda install -c conda-forge mmg``. .. GENERATED FROM PYTHON SOURCE LINES 10-31 .. code-block:: Python from pathlib import Path from microgen import Tpms from microgen.remesh import remesh_keeping_boundaries_for_fem from microgen.shape.surface_functions import gyroid data_dir = Path("remesh_data") data_dir.mkdir(exist_ok=True) tpms = Tpms(surface_function=gyroid, offset=1.0, resolution=50) initial_gyroid = tpms.grid_sheet initial_gyroid.save(data_dir / "initial_gyroid_mesh.vtk") max_element_edge_length = 0.02 remeshed_gyroid = remesh_keeping_boundaries_for_fem( initial_gyroid, hmax=max_element_edge_length, ) remeshed_gyroid.save(data_dir / "remeshed_gyroid_mesh.vtk") .. GENERATED FROM PYTHON SOURCE LINES 32-41 Initial mesh: .. image:: /_static/examples/initial_mesh.png Remeshed mesh: .. image:: /_static/examples/remeshed_mesh.png sphinx_gallery_thumbnail_path = "_static/examples/remeshed_mesh.png" .. _sphx_glr_download_examples_Mesh_remesh.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: remesh.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: remesh.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: remesh.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_