113. lib.misc_c
— Miscellaneous accelerated low level functions.¶
This module contains miscellaneous compiled C-versions of some time-critical low level functions in pyFormex. These functions are not intended for the end user. They are called internally by other pyFormex functions to speed up their operation.
113.1. Functions defined in module lib.misc_c¶
- lib.misc_c.coordsfuse(x, val, flag, sel, tol)¶
Fuse points whose coordinates are (almost) the same.
- Parameters:
x (float32 array (npts, 3)) – The coordinates of npts points.
val (int32 array (npts)) – An integer code for each point, such that points with the same code are in the same neighborhood. Any point will only be compared with the other points in its neighborhood. The points in x and the values in val should be sorted according to increasing value.
flag (int32 array (npts)) – A value 1 if the point is not fused and 0 if it is already fused.
sel (int32 array (npts)) – The index of the point that this point is fused with (the point itself if it is not fused).
tol (float) – The absolute tolerance to define equality between coordinates.
- Returns:
None – After return the flag and sel arrays are changed. The flag array flags with a 1 the points that remain in the fused set. For the merged points, the sel array contains the index of the point they are merged with.
See also
coords.Coords.fuse()
the user oriented method to fuse points
- lib.misc_c.isoline(data, level)¶
Create an isocontour through data at given level.
- Parameters:
data (float32 array (nx,ny)) – The data values at points with coordinates equal to their indices. This defines a 2D area (0..nx-1, 0..ny-1)
level (float) – Data value at which the isocontour is to be constructed
- Returns:
float32 array (nseg, 2, 2) – The line segments of the isocontour. Each segment consist of two points with two coordinates. The result is empty if level is outside the data range.
See also
plugins.isosurface.isoline()
the user oriented function to use this
Notes
This function uses a marching square algorithm.
- lib.misc_c.isosurface(data, level, tet)¶
Create an isosurface through data at given level.
- Parameters:
data (float32 array (nx,ny,nz)) – The 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) – The data value at which the isosurface is to be constructed
tet (int) – If zero, a marching cubes algorithm is used. If nonzero, a marching tetrahedrons algorithm is used. The latter is slower and produces a lot more triangles, but results in a smoother surface.
- Returns:
float32 array (ntri, 3, 3) – The triangles defining the isosurface. Each triangle consists of 3 points with 3 coordinates. The result is empty if level is outside the data range.
See also
plugins.isosurface.isosurface()
the user oriented function to use this
Notes
The algorithms are based on those from http://paulbourke.net/geometry/polygonise/
- lib.misc_c.nodalsum(val, elems, nnod)¶
Compute the nodal sum of values defined on elements.
- Parameters:
val (float32 array (nelems, nplex, nval)) – The data sets: nval values at nplex nodes of nelems elements.
elems (int32 array (nelems, nplex)) – The node indices of the elements.
nnod (int) – The number of nodes. It should be higher than the highest node number used in elems (maxnod). If negative, it will be set to maxnod+1.
- Returns:
sum (float32 array (nnod, nval)) – The sum of all the values at same node
cnt (int32 array (nnod)) – The number of values that were summed at each node
See also
arraytools.nodalSum()
the user oriented function to use this