.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/07_testing/plot_01_test_meshgen.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_07_testing_plot_01_test_meshgen.py: CRTomo-Meshgen Tests - Extra lines ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Various tests for adding extra lines to generated meshes .. GENERATED FROM PYTHON SOURCE LINES 9-159 .. 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 Calling the mesh generation routines... done This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found POINT {} must be inserted on boundary POINT (-1 -0.2) fix_extra_lines Second fix Calling the mesh generation routines... done This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found POINT {} must be inserted on boundary POINT (0 -4) fix_extra_lines Second fix Calling the mesh generation routines... done This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found POINT {} must be inserted on boundary POINT (-1 -1) POINT {} must be inserted on boundary POINT (4 -1) POINT {} must be inserted on boundary POINT (0 -4) fix_extra_lines Second fix Calling the mesh generation routines... done This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found POINT {} must be inserted on boundary POINT (-1 -1) POINT {} must be inserted on boundary POINT (4 -1) POINT {} must be inserted on boundary POINT (-1 -2) POINT {} must be inserted on boundary POINT (4 -2) POINT {} must be inserted on boundary POINT (0 -4) fix_extra_lines Second fix Calling the mesh generation routines... done This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found POINT {} must be inserted on boundary POINT (-1 -1) POINT {} must be inserted on boundary POINT (4 -1) POINT {} must be inserted on boundary POINT (-1 -2) POINT {} must be inserted on boundary POINT (4 -2) POINT {} must be inserted on boundary POINT (-1 -3) POINT {} must be inserted on boundary POINT (4 -3) POINT {} must be inserted on boundary POINT (0 -4) fix_extra_lines Second fix Calling the mesh generation routines... done This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found POINT {} must be inserted on boundary POINT (-1 -1) POINT {} must be inserted on boundary POINT (4 -1) fix_extra_lines Second fix Calling the mesh generation routines... done This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found POINT {} must be inserted on boundary POINT (-1 -1) POINT {} must be inserted on boundary POINT (4 -1) fix_extra_lines Second fix Calling the mesh generation routines... done This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found | .. code-block:: Python import numpy as np import crtomo # ########################################################################### def test_mesh(mesh): """Conduct a simple forward modelling """ tdm = crtomo.tdMan(grid=mesh) tdm.add_homogeneous_model(100, 0) tdm.configs.gen_dipole_dipole(skipc=0) tdm.model(silent=True) return True # ########################################################################### electrodes = np.array(( (0, 0), (1, 0), (2, 0), (3, 0), )) boundaries = np.array(( (-1, 0, 12), (0, 0, 12), (1, 0, 12), (2, 0, 12), (3, 0, 12), (4, 0, 11), (4, -4, 11), (-1, -4, 11), )) # ########################################################################### mesh = crtomo.mesh_gen.gen_mesh( boundaries, electrodes, char_lengths=[0.5, 0.5, 0.5, 0.5], ) test_mesh(mesh) # ########################################################################### mesh = crtomo.mesh_gen.gen_mesh( boundaries, electrodes, ) test_mesh(mesh) # ########################################################################### # test for over-extending lines mesh = crtomo.mesh_gen.gen_mesh( boundaries, electrodes, extra_lines=[ # horizontal [-5, -1, 5, 1], ] ) test_mesh(mesh) # ########################################################################### # extra line through electrode mesh = crtomo.mesh_gen.gen_mesh( boundaries, electrodes, extra_lines=[ [0, -5, 0, 1], ] ) test_mesh(mesh) # ########################################################################### # extra lines that cross mesh = crtomo.mesh_gen.gen_mesh( boundaries, electrodes, extra_lines=[ [-5, -1, 5, -1], [0, -5, 0, 1], ] ) test_mesh(mesh) # ########################################################################### # extra lines that cross (multiple times) mesh = crtomo.mesh_gen.gen_mesh( boundaries, electrodes, extra_lines=[ [-5, -1, 5, -1], [-5, -2, 5, -2], [0, -5, 0, 1], ] ) test_mesh(mesh) # ########################################################################### # extra lines that cross (multiple times) mesh = crtomo.mesh_gen.gen_mesh( boundaries, electrodes, extra_lines=[ # three horizontal lines [-5, -1, 5, -1], [-5, -2, 5, -2], [-5, -3, 5, -3], # one vertical line [0, -5, 0, 1], ] ) test_mesh(mesh) # parallel extra lines, one of which starts within the other mesh = crtomo.mesh_gen.gen_mesh( boundaries, electrodes, extra_lines=[ [-5, -1, 1, -1], [0, -1, 5, -1], ] ) test_mesh(mesh) # lines ending/starting at some point mesh = crtomo.mesh_gen.gen_mesh( boundaries, electrodes, extra_lines=[ [-5, -1, 0, -1], [0, -1, 5, -1], ] ) test_mesh(mesh) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 18.476 seconds) .. _sphx_glr_download__examples_07_testing_plot_01_test_meshgen.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_test_meshgen.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_test_meshgen.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_test_meshgen.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_