.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples_mesh/example_convert_mesh.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_mesh_example_convert_mesh.py: ================================================================================ Convert mesh file to .msh format ================================================================================ .. GENERATED FROM PYTHON SOURCE LINES 7-13 .. code-block:: default import os import numpy as np import matplotlib.pyplot as plt import freshkiss3d as fk .. GENERATED FROM PYTHON SOURCE LINES 14-22 Convert a mesh file to ``.msh`` -------------------------------- To convert your mesh to ``.msh`` format simply call **fk.convert_to_msh(file_in, file_out)** with file_in and file_out being: - **file_in**: targeted mesh - **file_out**: output file for which you have to choose a name .. GENERATED FROM PYTHON SOURCE LINES 23-29 .. code-block:: default file_in = 'inputs/tiny_square.mesh' file_out = 'inputs/tiny_square.msh' fk.convert_to_msh(file_in, file_out) .. GENERATED FROM PYTHON SOURCE LINES 30-33 .. note:: Mesh conversion is compatible with MEDIT .mesh and GMSH .msh file_in format. .. GENERATED FROM PYTHON SOURCE LINES 36-38 Check file conversion succeded ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 39-48 .. code-block:: default TG, vertex_labels, boundary_labels = fk.read_msh(file_out) x = np.asarray(TG.x) y = np.asarray(TG.y) trivtx = np.asarray(TG.trivtx) plt.triplot(x, y, trivtx) plt.show() .. image-sg:: /auto_examples_mesh/images/sphx_glr_example_convert_mesh_001.png :alt: example convert mesh :srcset: /auto_examples_mesh/images/sphx_glr_example_convert_mesh_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 49-51 Remove file_out which was only built for example purpose: .. GENERATED FROM PYTHON SOURCE LINES 52-56 .. code-block:: default os.system('rm {}'.format(file_out)) .. rst-class:: sphx-glr-script-out .. code-block:: none 0 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.094 seconds) .. _sphx_glr_download_auto_examples_mesh_example_convert_mesh.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_convert_mesh.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_convert_mesh.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_