CRTomo-Meshgen Tests - Extra linesΒΆ

Various tests for adding extra lines to generated meshes

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

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)

Total running time of the script: (0 minutes 18.476 seconds)

Gallery generated by Sphinx-Gallery