.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/00_grids/plot_mesh_generation.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_00_grids_plot_mesh_generation.py: Creating meshes with the mesh_gen object ======================================== There is a new (2026) interface to :py:mod:`cr_trig_create`, :py:class:`crtomo.mesh_interface.CRTomoGMSHMeshGenerator`. This example present various ways to use this generator class. .. note:: You can access the generator class in two ways: ``from crtomo.mesh_interface import CRTomoGMSHMeshGenerator`` or using the top-level module ``crtomo``: ``from crtomo import CRTomoGMSHMeshGenerator``. There is also an already initialized instance of the mesh loaded as ``crtomo.mesh_gen``. In most cases, this instance is the easiest way to use the generator. .. GENERATED FROM PYTHON SOURCE LINES 23-24 The top level crtomo import suffices for most tasks .. GENERATED FROM PYTHON SOURCE LINES 24-26 .. code-block:: Python import crtomo import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 27-33 Defining the mesh boundaries and electrode positions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. note:: Always work clockwise when denoting boundary nodes! .. GENERATED FROM PYTHON SOURCE LINES 33-56 .. code-block:: Python # define the electrode positions electrodes = np.array(( (0, 0), (1, 0), (2, 0), (3, 0), )) # define the boundary geometry # the last number indicates the type of boundary element towards the next node # 12: Neumann no-flow boundaries (for surface boundaries) # 11: mixed boundary types (subsurface boundaries) boundaries = np.array(( (-1, 0, 12), (0, 0, 12), (1, 0, 12), (2, 0, 12), (3, 0, 12), (4, 0, 11), (4, -2, 11), (-1, -2, 11), )) .. GENERATED FROM PYTHON SOURCE LINES 57-59 Mesh Generation ^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 59-70 .. code-block:: Python mesh = crtomo.mesh_gen.gen_mesh( boundaries, electrodes, char_lengths=[ 0.5, 0.45, 0.45, 0.45, ], ) _ = mesh.plot() .. image-sg:: /_examples/00_grids/images/sphx_glr_plot_mesh_generation_001.png :alt: plot mesh generation :srcset: /_examples/00_grids/images/sphx_glr_plot_mesh_generation_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Calling the mesh generation routines... done This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found .. _sphx_glr_download__examples_00_grids_plot_mesh_generation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_mesh_generation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_mesh_generation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_mesh_generation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_