qtcad.device.mesh2d module
2d Mesh and SubMesh classes.
- class qtcad.device.mesh2d.Mesh(scaling_factor, filename, verbose=True)
Bases:
Mesh
Class to store and process mesh properties such as node coordinates and elements.
- Attributes:
dim (int) – Dimension of the mesh
tri_number (int) – Number of triangular elements in the mesh.
line_number (int) – Number of line elements in the mesh.
node_number (int) – Number of global nodes.
glob_nodes (2D array) – Coordinates of the global nodes. First array index: global node index. Second array index: Cartesian direction (x or y).
elem_number (int) – Number of elements in the mesh including boundary elements.
all_connectivity (list) – Global nodes contained by all elements, including boundary elements.
connectivity (2D array) – Global nodes contained by each line element. The row index labels distinct elements, while the column index labels local nodes for each element, so the array shape is Ntriang x 3, where Ntriang is the number of triangular elements. Values stored in the array are global node indices, starting from 0.
- __init__(scaling_factor, filename, verbose=True)
Constructor for the mesh class.
- Parameters:
scaling_factor (float) – Factor by which node coordinates are multiplied to correspond to SI units.
filename (str) – Path to the mesh file to use to build the mesh.
verbose (bool, optional) – If True, print mesh statistics. Default: True.
- centroids()
Calculate the centroid of each triangular element.
- Returns:
2D array – Centroid of each element.
Note
The output is a 2D array corresponding to a column vector to comply with the indexing convention used for higher dimensinal meshes
- loc_node_coords()
Get arrays containing the local-node coordinates for each element.
- Returns:
tuple – a tuple (x_loc_nodes, y_loc_nodes) where x_loc_nodes (y_loc_nodes) is a 2D array containing the x (y) coordinate at each local node (column idx) and element (row idx)
- nodes_in_box(coords_min, coords_max)
Gets indices of global nodes within a box.
- Parameters:
coords_min (tuple) – Minimum xy coordinate values.
coords_max (tuple) – Maximum xy coordinate values.
- Returns:
1d array of int – The indices of the global nodes within the box.
- show(length_unit='nm')
Display the mesh using pyplot.
- Parameters:
length_unit (str, optional) – Units of length to use when plotting. Default: “nm”. Other choices are: “um”, “mm”, and “m”.
- tri_areas()
Calculate the area of each triangular element.
- Returns:
1D array – The area of each element.
- class qtcad.device.mesh2d.SubMesh(parent, nodes, verbose=True)
Bases:
SubMesh
A submesh is a subset of a parent mesh.
- Attributes:
nodes_in_parent (1d array) – Number of each node belonging to the submesh in the parent mesh.
Note
All other attributes are inherited from the parent mesh.
- __init__(parent, nodes, verbose=True)
Constructor of the submesh class.
- Parameters:
parent (mesh object) – The parent mesh.
nodes (1d array, string, or list of strings) – The nodes defining the subset of the parent mesh, or region label, or list of region labels.
verbose (bool, optional) – If True, print mesh statistics. Default: True.