qtcad.device.mesh3d module
3d Mesh and SubMesh classes.
- class qtcad.device.mesh3d.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
tetra_number (int) – Number of tetrahedral elements in the mesh
tri_number (int) – Number of triangular 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, y, or z).
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 Ntetra x 4, where Ntetra is the number of tetrahetral 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, gmsh.model obj) – If a string is passed it represents the path to the mesh file to build the mesh. If a gmsh.model is passed it represents the gmsh model object to build the mesh.
verbose (bool, optional) – If True, print mesh statistics. Default: True.
- centroids()
Calculate the centroid of each tetrahedral element.
- Returns:
2D array – Centroid of each element, with row index corresponding to elements and column index to x, y, z coordinates.
- loc_node_coords()
Get arrays containing the local-node coordinates for each element.
- Returns:
tuple – a tuple (x_loc_nodes, y_loc_nodes, z_loc_nodes) where x_loc_nodes (y_loc_nodes, z_loc_nodes) is a 2D array containing the x (y, z) 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 xyz coordinate values.
coords_max (tuple) – Maximum xyz coordinate values.
- Returns:
1d array of int – The indices of the global nodes within the box.
- show()
Plot the mesh using PyVista.
- tetra_volumes()
Calculate the volume of all elements assuming that they are all tetrahedral.
- Returns:
1D array – the volume of each element
- class qtcad.device.mesh3d.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 submesh statistics. Default: True.