mymesh.mesh#

class mymesh.mesh(NodeCoords=None, NodeConn=None, Type=None, verbose=True)[source]#

The mesh class stores the nodes (NodeCoords) and elements (or node connectivity, NodeConn) as its primary attributes.

Parameters:
  • NodeCoords (array_like, optional) – Node coordinates, by default None. Node coordinates should be formatted as an nx3 or nx2 array of coordinates.

  • NodeConn (list, array_like, optional) – Node connectivity of elements, by default None. Node connectivity is formatted as a 2D array or list of lists where each row (or inner list) is contains the node IDs of the nodes that make up the element. NodeConn can contain a uniform element type or a mix of different element types.

  • Type (str or None, optional) – Mesh type, ‘surf’ for surface, ‘vol’ for volume, ‘line’ for line. If not provided, it will be determined automatically (mesh.identify_type()), by default None

  • verbose (bool, optional) – If true, some operations will print activity or other information, by default True

NodeData#

Node data dictionary for storing scalar or vector data associated with each node in the mesh. Each entry should be an array_like with the same length as the number of nodes in the mesh. When using mesh.write(), this data will be transferred to the written file if supported by that file type.

ElemData#

Element data dictionary for storing scalar or vector data associated with each element in the mesh. Each entry should be an array_like with the same length as the number of elements in the mesh. When using mesh.write(), this data will be transferred to the written file if supported by that file type.

NodeSets#

Dictionary used for creating named sets of nodes. Each entry should be a set (or array_like) of node numbers.

ElemSets#

Dictionary used for creating named sets of elements. Each entry should be a set (or array_like) of element numbers.

FaceSets#

Dictionary used for creating named sets of faces. Each entry should be a set (or array_like) of face numbers.

EdgeSets#

Dictionary used for creating named sets of edges. Each entry should be a set (or array_like) of edge numbers.

Properties#

BoundaryConn

Node connectivity for the boundary mesh of a surface.

BoundaryNodes

Array of node IDs on the boundary of a surface.

Centroids

Element centroids.

EdgeConn

Element-edge connectivity.

EdgeElemConn

Edge-element connectivity.

Edges

Element edges.

ElemConn

Node-Element connectivity.

ElemNeighbors

Element neighbors.

ElemNormals

Surface element normal vectors.

EulerCharacteristic

Topological Euler characteristic number.

FaceConn

Element-face connectivity.

FaceElemConn

Face-element connectivity.

Faces

Element faces.

Genus

Topological genus calculated from the Euler characteristic.

ND

Number of spatial dimensions.

NEdge

Number of edges in the mesh.

NElem

Number of elements in the mesh.

NFace

Number of faces in the mesh.

NNode

Number of nodes in the mesh.

NodeNeighbors

Node neighbors.

NodeNormals

Surface node normal vectors.

NodeNormalsMethod

Sets the method for calculating surface node normals.

SurfConn

Node connectivity for the surface mesh.

SurfElemConn

Node-Element connectivity for the surface mesh.

SurfNodeNeighbors

Node neighbors for the surface mesh.

SurfNodes

Array of node IDs on the surface of a mesh.

Surface

mesh object representation of the surface mesh.

cells

Alias for NodeConn

points

Alias for NodeCoords

Methods#

Clip([pt, normal])

Clip the mesh along a plane.

Contour(scalars, threshold[, ...])

Contour the mesh to extract an isosurface based on nodal scalar values.

CreateBoundaryLayer(nLayers[, FixedNodes, ...])

Generate boundary layer elements.

Crop(bounds[, method, InPlace, cleanup])

Crop the mesh to specified bounds.

Mirror([x, y, z, InPlace])

Mirror the mesh across Cartesian planes.

RenumberFacesBySet()

RenumberNodesBySet()

Threshold(scalars, threshold[, mode, ...])

Threshold the mesh by scalar values at either nodes or elements.

addEdges(NewEdges[, EdgeSet])

addElems(NewNodeConn[, ElemSet])

addFaces(NewFaces[, FaceSet])

addNodes(NewNodeCoords[, NodeSet])

cleanup([tol])

copy()

Create a copy of the mesh.

getCurvature([metrics, nRings, SplitFeatures])

getQuality([metrics, verbose])

Evaluate mesh quality.

identify_type()

Classify the mesh as either a surface or volume.

imread(voxelsize[, scalefactor, scaleorder, ...])

Load an image into a voxel mesh.

merge(Mesh2[, cleanup, tol])

Merge multiple meshes together into the current mesh.

meshio2mymesh()

Convert a meshio mesh object to a MyMesh mesh object

mymesh2meshio()

plot([show, return_fig, clim])

Generate a static plot of the mesh.

read()

Read a mesh file written in any file type supported by meshio

removeElems(ElemIds)

reset([properties, keep])

Reset some or all properties.

validate()

Check validity of the mesh.

view(**kwargs)

Generate an interactive plot of the mesh.

write(filename[, binary])

Write mesh to file.