grid_extralines_gen_decouplings module

Generate a decouplings.dat for CRTomo

From a given extra_lines.dat file (see triangular grid generation in manual), generate a decouplings.dat for the decoupling of cell interfaces from the regularisation.

As only the start and end points are given, the algorithm must find all nodes generated by GMSH along those lines. This is done by comparing the orthogonal distance of each node to the line. All nodes within a certain threshold distance are assumed to lie on the line. The threshold is computed by taking the minimal node distance of the grid (pdist function) and then multiplying with 0.75. This probably is a little bit overkill and we could also use some measure of machine precision.

For convenience this threshold can be overwritten using the –eps option.

Some of the for-loops can probably be optimized or replaced by some numpy broadcasting rules.

Examples

# enter the output directory of cr_trig_create.py grid_extralines_gen_decouplings.py

# this creates the file decouplings.dat grid_extralines_gen_decouplings.py –plot_node_nrs –plot_elm_nrs

grid_extralines_gen_decouplings.check_options(options)[source]
grid_extralines_gen_decouplings.debug_plot(grid, extra_lines, decoupling_elements, options)[source]
grid_extralines_gen_decouplings.distances(x, y, px, py, plot=False)[source]

Compute shortest distance of points (px, py) to the line described by the end points in (x, y).

Parameters:
  • x (x and y coordinates of line)

  • y (x and y coordinates of line)

  • px (x coordinates of data points)

  • py (y coordiante of data points)

Returns:

distances

Return type:

list of distances

grid_extralines_gen_decouplings.get_decouplings_for_line(grid, line, settings, fids=None)[source]

Compute the element pairs for regularisation decoupling, given a grid object and a line, denoted by start and end coordinates, in the grid.

Parameters:
  • grid (a crtomo.grid.crt_grid object)

  • line (np.array/list with 4 entries: x1, y1, x2, x2, denoting start and end) – point

  • fids (None, or: list with file ids for) – debug_nodes

Returns:

neighbors – line

Return type:

Mx2 array with the numbers of adjoining elements along the given

grid_extralines_gen_decouplings.handle_cmd_options_v2()[source]
grid_extralines_gen_decouplings.line_line_intersect(x, y)[source]

Compute the intersection point of two lines

Parameters:
  • array (y = x4)

  • array

  • p1 (line 1 is defined by)

  • p2

  • p3 (line 2 is defined by)

  • p4

Returns:

  • Ix (x-coordinate of intersection)

  • Iy (y-coordinate of intersection)

grid_extralines_gen_decouplings.main()[source]