mymesh.utils#

Various mesh utilities

Mesh Connectivity#

getNodeNeighbors(NodeCoords, NodeConn[, ...])

Determines the adjacent nodes for each node in the mesh

getElemConnectivity(NodeCoords, NodeConn)

Determines the elements connected to each node in the mesh

getNodeNeighborhood(NodeCoords, NodeConn, nRings)

Gives the connected nodes in an n ring neighborhood for each node in the mesh

getNodeNeighborhoodByRadius(NodeCoords, ...)

Gives the connected nodes in a neighborhood with a specified radius for each node in the mesh.

getElemNeighbors(NodeCoords, NodeConn[, ...])

Get list of neighboring elements for each element in the mesh.

getConnectedNodes(NodeCoords, NodeConn[, ...])

Identifies groups of connected nodes.

getConnectedElements(NodeCoords, NodeConn[, ...])

Identifies groups of connected nodes.

Mesh Measurements#

Centroids(NodeCoords, NodeConn)

Calculate element centroids.

CalcFaceNormal(NodeCoords, SurfConn)

Calculates normal vectors on the faces of a triangular surface mesh.

Face2NodeNormal(NodeCoords, NodeConn, ...[, ...])

Calculate node normal vectors based on the element face normals.

DetectFeatures(NodeCoords, SurfConn[, angle])

Classifies nodes as edges or corners if the angle between adjacent surface elements is less than or equal to angle.

TriSurfVol(NodeCoords, SurfConn)

Calculates the volume contained within a surface mesh.

TetMeshVol(NodeCoords, NodeConn)

Calculates the volume contained within a tetrahedral mesh

MVBB(Points[, return_matrix])

Calculate the minimum volume bounding box of the set of points

AABB(Points)

Calculate the axis-aligned bounding box of a set of points

Mesh Manipulations#

MirrorMesh(NodeCoords, NodeConn[, x, y, z])

Creates a mirrored copy of a mesh by mirroring about the planes defined by X=x, Y=y, and Z=z

MergeMesh(NodeCoords1, NodeConn1, ...[, ...])

Merge two meshes together

DilateVoxel(VoxelCoords, VoxelConn)

For a given voxel mesh, will generate a layer of voxels that wrap around the current voxel mesh.

ErodeVoxel(NodeCoords, NodeConn[, nLayers])

Removes the specified number of layers from a hexahedral mesh

makePyramidLayer(VoxelCoords, VoxelConn[, ...])

Generate a set of pyramid elements that cover the surface of the voxel mesh.

Surface Projection#

ValueMapping(NodeCoords1, SurfConn1, ...[, ...])

Maps nodal values one surface to another.

SurfMapping(NodeCoords1, SurfConn1, ...[, ...])

Generate a mapping matrix from to map data from one surface to another using barycentric interpolation.

Project2Surface(Points, Normals, NodeCoords, ...)

Projects a node along its normal vector onto a surface.

BaryTri(Nodes, Pt)

Returns the bary centric coordinates of a point (Pt) relative to a triangle (Nodes)

BaryTris(Tris, Pt)

Returns the barycentric coordinates of a point or points relative to a triangle.

BaryTet(Nodes, Pt)

Returns the bary centric coordinates of a point (Pt) relative to a tetrahedron (Nodes)

Mesh Clean Up#

DeleteDuplicateNodes(NodeCoords, NodeConn[, ...])

Remove nodes that are duplicated in the mesh, either at exactly the same location as another node or a distance < tol apart.

DeleteDegenerateElements(NodeCoords, NodeConn)

Deletes degenerate elements from a mesh.

CleanupDegenerateElements(NodeCoords, NodeConn)

Checks for elements with degenerate edges and either changes the element type or removes the element depending on how degenerate it is.

RelabelNodes(NodeCoords, NodeConn, newIds[, ...])

Relabel the nodes in the mesh according to the newIds list

Miscellaneous#

SortRaggedByLength(In[, return_idx, ...])

Sorted a ragged list of lists by the length of each sublist

SplitRaggedByLength(In[, return_idx, return_inv])

Split a ragged list of lists into a list of array_like groupings of the original list in which all rows are equal length.

PadRagged(In[, fillval])

Pads a 2d list of lists with variable length into a rectangular numpy array with specified fill value.

ExtractRagged(In[, delval, dtype])

Convert a padded numpy array to a ragged list of list by removing entries that match the specified value.

identify_type(NodeCoords, NodeConn)

Classify the mesh as either a surface or volume. A mesh is classified as a volume mesh (vol) if any elements are unambiguous volume elements - pyramid (5 nodes), wedge (6), hexahedron (8), or if any of a random sample of 10 elements (or all elements if NElem < 10) has a volume less than machine precision (np.finfo(float).eps). Alternatively, a surface mesh (surf) is identified if any of the elements is a triangle (3 nodes). In the case of a mesh containing both triangular and volume elements, the mesh will be classified arbitrarily by whichever appears first in NodeConn. A line mesh is identified if any line (2 node) elements are present.