silex_lib_gmsh
Utilities for reading and writing Gmsh meshes and result fields.
- SILEXlight.silex_lib_gmsh.WriteResults(filename, nodes, elements, elttype, fields=[])[source]
Write a mesh and optional fields to a Gmsh
.mshfile.- Parameters:
filename (str or path-like) – Output file name without or with
.mshextension.nodes (numpy.ndarray) – Node coordinates, shape
(n_nodes, 2)or(n_nodes, 3).elements (numpy.ndarray) – Element connectivity array.
elttype (int) –
Gmsh element type id.
Supported ids in this writer: -
1: 2-node line -2: 3-node triangle -3: 4-node quadrangle -4: 4-node tetrahedron -5: 8-node hexahedron -8: 3-node second-order line -9: 6-node second-order triangle -11: 10-node second-order tetrahedronCommon Gmsh ids reference: -
1: 2-node line -2: 3-node triangle -3: 4-node quadrangle -4: 4-node tetrahedron -5: 8-node hexahedron -6: 6-node prism -7: 5-node pyramid -8: 3-node second-order line -9: 6-node second-order triangle -10: 9-node second-order quadrangle -11: 10-node second-order tetrahedron -12: 27-node second-order hexahedron -13: 18-node second-order prism -14: 14-node second-order pyramid -15: 1-node point -16: 8-node second-order quadrangle -17: 20-node second-order hexahedron -18: 15-node second-order prism -19: 13-node second-order pyramidfields (list, optional) – Field descriptors as
[values, 'nodal'|'elemental', ncomp, name].
- SILEXlight.silex_lib_gmsh.ReadGmshNodes(file, nbcoord)[source]
Read node coordinates from a Gmsh
.mshfile.- Parameters:
file (str or path-like) – Input mesh file.
nbcoord (int) – Number of coordinates per node (2 or 3).
- SILEXlight.silex_lib_gmsh.ReadGmshElements(file, elmttype, prop)[source]
Read elements of a given type and physical property from Gmsh file.
- Parameters:
file (str or path-like) – Input mesh file.
elmttype (int) –
Gmsh element type id to extract.
Currently handled by this reader: -
1: 2-node line -2: 3-node triangle -3: 4-node quadrangle -4: 4-node tetrahedron -5: 8-node hexahedron -8: 3-node second-order line -9: 6-node second-order triangle -11: 10-node second-order tetrahedronprop (int) – Physical tag to filter elements.
- Returns:
(elements, unique_node_ids).- Return type:
tuple