Mesh
Description
Represents the computational mesh used to discretize a three-dimensional electromagnetic model into finite elements.
The mesh contains tetrahedral volume elements and triangular boundary elements, together with their vertex coordinates and identification IDs. Domain IDs identify three-dimensional regions used for material assignments, while boundary IDs identify surfaces used for boundary conditions.
Mesh geometry and available IDs can be inspected directly from Python. The mesh can also be visualized in 3D to examine its structure or display selected regions and boundary surfaces before running a simulation.
Construction
m = Mesh()
m = Mesh() creates a mesh object without loading a mesh file. Assign a
file path to m.filename before accessing the mesh data.
m = Mesh(filename)
m = Mesh(filename) loads the specified mesh file filename and makes
its geometry, domain IDs, and boundary IDs available for inspection.
Constructor Inputs
filename
str | None
None
Path to the finite-element mesh file to load. If omitted, the mesh file can be specified later through the filename property.
Properties
filename- Type
str | NoneAccess read/writePath to the mesh file. Assigning a valid file path loads the specified mesh and updates the available mesh data.
points- Type
numpy.ndarrayAccess read-onlyVertex coordinates of the mesh, represented as an N-by-3 array where N is the number of vertices.
elements- Type
numpy.ndarrayAccess read-onlyVertex indices defining the tetrahedral volume elements represented as an N-by-4 array.
boundary_elements- Type
numpy.ndarrayAccess read-onlyVertex indices defining the triangular boundary elements represented as an N-by-3 array.
domain- Type
numpy.ndarrayAccess read-onlyAvailable domain IDs identifying three-dimensional mesh regions. These IDs are used to assign materials and select regions for visualization.
boundary- Type
numpy.ndarrayAccess read-onlyAvailable boundary IDs identifying a set of surfaces of the mesh. These IDs are used to assign boundary conditions and select surfaces for visualization.
Methods
Visualize the mesh in 3D, with options to display selected volume regions or boundary surfaces.
Examples
from hado.mesh import Mesh
m = Mesh("model.msh")
print(m.domain)
print(m.boundary)
m.show(domain=2)
m.show(boundary=1)
Notes
Domain IDs and boundary IDs are defined by the mesh file and are independent of the vertex and element indices. A single domain ID may identify multiple tetrahedral elements, while a single boundary ID may identify multiple triangular surface elements.
Errors / Exceptions
Error / Exceptions List
tanager:meshmessage: EmptyMeshFile - Condition
Mesh data is requested for an object without an assigned mesh file.
ResolutionSet
m.filenameto a valid mesh file path before accessing mesh data. tanager:meshmessage: NoMeshFile - Condition
The specified mesh file does not exist.
ResolutionCheck the file path and confirm that the mesh file exists.
tanager:validatormessage: MustBeDataType - Condition
A non-string value is assigned to
filename.ResolutionSpecify the mesh file path as a string.