114. lib.misc_e — Python equivalents of the functions in lib.misc_c

The functions in this module should be exact emulations of the external functions in the compiled library.

114.1. Functions defined in module lib.misc_e

lib.misc_e.coordsfuse(x, val, flag, sel, tol)[source]

Fusing nodes.

This is a low level function performing the internal loop of the fuse operation. It is not intended to be called by the user.

lib.misc_e.nodalsum(val, elems, nnod)[source]

Compute the nodal sum of values defined on elements.

Parameters:

  • val : float (nelems,nplex,nval): nval values at nplex nodes of nelems elements.

  • elems : int (nelems,nplex): node indices of the elements.

  • nnod : int: the number of nodes. Should be higher than the maxnod, the highest node number in elems. If negative, will be set to maxnod+1.

Returns a tuple of two arrays:

  • sum: float: (nnod, nval): sum of all the values at same node

  • cnt: int: (nnod): number of values summed at each node

lib.misc_e.splitSquare(pos, val, level)[source]

Split a single square

lib.misc_e.isoline(data, level)[source]

Create an isoline through data at given level.

  • data: (nx,ny) shaped array of data values at points with coordinates equal to their indices. This defines a 2D area [0,nx-1], [0,ny-1],

  • level: data value at which the isoline is to be constructed

Returns an (nseg,2,2) array defining the segments of the isoline. The result may be empty (if level is outside the data range).

lib.misc_e.polygoniseCube(pos, val, level)[source]

Polygonise a single cube

lib.misc_e.vertexinterp(level, p1, p2, val1, val2)[source]

Interpolate between cube vertices

Linearly interpolate the position where an isosurface cuts an edge between two vertices, each with their own scalar value

p1,p2 are (3,) arrays, marking the cubes opposite corners (0 and 6) v1,v2 are values at these points level is the level value of the surface

lib.misc_e.isosurface(data, level, tet=False)[source]

Create an isosurface through data at given level.

Parameters:
  • data (array_like) – An (nx,ny,nz) shaped array of data values at points with coordinates equal to their indices. This defines a 3D volume [0,nx-1], [0,ny-1], [0,nz-1]

  • level (float) – Data value at which the isosurface is to be constructed.

Returns:

array – An (ntr,3,3) array defining the triangles of the isosurface. The result is empty if level is outside the data range.

See also

plugins.isosurface.isosurface()

a faster parallel version

Notes

This function was inspired by the example by Paul Bourke on http://paulbourke.net/geometry/polygonise/.

Normally this function is invoked from the higer level function plugins.isosurface.isosurface(), which allows multiprocessing to further speed up the process.