Skip to main content

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​

NameTypeRequiredDefaultDescription

filename

str | None

Optional

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/write

Path to the mesh file. Assigning a valid file path loads the specified mesh and updates the available mesh data.

points

Type numpy.ndarrayAccess read-only

Vertex coordinates of the mesh, represented as an N-by-3 array where N is the number of vertices.

elements

Type numpy.ndarrayAccess read-only

Vertex indices defining the tetrahedral volume elements represented as an N-by-4 array.

boundary_elements

Type numpy.ndarrayAccess read-only

Vertex indices defining the triangular boundary elements represented as an N-by-3 array.

domain

Type numpy.ndarrayAccess read-only

Available domain IDs identifying three-dimensional mesh regions. These IDs are used to assign materials and select regions for visualization.

boundary

Type numpy.ndarrayAccess read-only

Available boundary IDs identifying a set of surfaces of the mesh. These IDs are used to assign boundary conditions and select surfaces for visualization.

Methods​

show

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.

Resolution

Set m.filename to a valid mesh file path before accessing mesh data.

tanager:meshmessage:NoMeshFile
Condition

The specified mesh file does not exist.

Resolution

Check the file path and confirm that the mesh file exists.

tanager:validatormessage:MustBeDataType
Condition

A non-string value is assigned to filename.

Resolution

Specify the mesh file path as a string.