Reading Gmsh Meshes¶
Element types¶
- class gmsh_interop.reader.GmshElementBase(order: int)[source]¶
-
- abstract lexicographic_node_tuples() Sequence[tuple[int, ...]] [source]¶
Generate tuples enumerating the node indices present in this element. Each tuple has a length equal to the dimension of the element. The tuples constituents are non-negative integers whose sum is less than or equal to the order of the element.
Simplex Elements¶
Tensor Product Elements¶
Receiver interface¶
- class gmsh_interop.reader.GmshMeshReceiverBase[source]¶
- gmsh_element_type_to_info_map: ClassVar[dict[int, GmshElementBase]] = {1: <gmsh_interop.reader.GmshIntervalElement object>, 2: <gmsh_interop.reader.GmshTriangularElement object>, 3: <gmsh_interop.reader.GmshQuadrilateralElement object>, 4: <gmsh_interop.reader.GmshTetrahedralElement object>, 5: <gmsh_interop.reader.GmshHexahedralElement object>, 8: <gmsh_interop.reader.GmshIntervalElement object>, 9: <gmsh_interop.reader.GmshTriangularElement object>, 10: <gmsh_interop.reader.GmshQuadrilateralElement object>, 11: <gmsh_interop.reader.GmshTetrahedralElement object>, 12: <gmsh_interop.reader.GmshHexahedralElement object>, 15: <gmsh_interop.reader.GmshPoint object>, 20: <gmsh_interop.reader.GmshIncompleteTriangularElement object>, 21: <gmsh_interop.reader.GmshTriangularElement object>, 22: <gmsh_interop.reader.GmshIncompleteTriangularElement object>, 23: <gmsh_interop.reader.GmshTriangularElement object>, 24: <gmsh_interop.reader.GmshIncompleteTriangularElement object>, 25: <gmsh_interop.reader.GmshTriangularElement object>, 26: <gmsh_interop.reader.GmshIntervalElement object>, 27: <gmsh_interop.reader.GmshIntervalElement object>, 28: <gmsh_interop.reader.GmshIntervalElement object>, 29: <gmsh_interop.reader.GmshTetrahedralElement object>, 30: <gmsh_interop.reader.GmshTetrahedralElement object>, 31: <gmsh_interop.reader.GmshTetrahedralElement object>, 36: <gmsh_interop.reader.GmshQuadrilateralElement object>, 37: <gmsh_interop.reader.GmshQuadrilateralElement object>, 38: <gmsh_interop.reader.GmshQuadrilateralElement object>, 42: <gmsh_interop.reader.GmshTriangularElement object>, 43: <gmsh_interop.reader.GmshTriangularElement object>, 44: <gmsh_interop.reader.GmshTriangularElement object>, 45: <gmsh_interop.reader.GmshTriangularElement object>, 46: <gmsh_interop.reader.GmshTriangularElement object>, 47: <gmsh_interop.reader.GmshQuadrilateralElement object>, 48: <gmsh_interop.reader.GmshQuadrilateralElement object>, 49: <gmsh_interop.reader.GmshQuadrilateralElement object>, 50: <gmsh_interop.reader.GmshQuadrilateralElement object>, 51: <gmsh_interop.reader.GmshQuadrilateralElement object>, 62: <gmsh_interop.reader.GmshIntervalElement object>, 63: <gmsh_interop.reader.GmshIntervalElement object>, 64: <gmsh_interop.reader.GmshIntervalElement object>, 65: <gmsh_interop.reader.GmshIntervalElement object>, 66: <gmsh_interop.reader.GmshIntervalElement object>, 71: <gmsh_interop.reader.GmshTetrahedralElement object>, 72: <gmsh_interop.reader.GmshTetrahedralElement object>, 73: <gmsh_interop.reader.GmshTetrahedralElement object>, 74: <gmsh_interop.reader.GmshTetrahedralElement object>, 75: <gmsh_interop.reader.GmshTetrahedralElement object>, 92: <gmsh_interop.reader.GmshHexahedralElement object>, 93: <gmsh_interop.reader.GmshHexahedralElement object>, 94: <gmsh_interop.reader.GmshHexahedralElement object>, 95: <gmsh_interop.reader.GmshHexahedralElement object>, 96: <gmsh_interop.reader.GmshHexahedralElement object>, 97: <gmsh_interop.reader.GmshHexahedralElement object>, 98: <gmsh_interop.reader.GmshHexahedralElement object>}¶
Receiver example implementation¶
- class gmsh_interop.reader.GmshMeshReceiverNumPy[source]¶
GmshReceiver that loads fields into
numpy
arrays.This class emulates the semantics of
meshpy.triangle.MeshInfo
andmeshpy.tet.MeshInfo
by using similar fields, but instead of loading data into ForeignArrays, load intonumpy
arrays. Since this class is not wrapping any libraries in other languages – the Gmsh data is obtained via parsing text – usenumpy
arrays as the base array data structure for convenience.Added in version 2014.1.
Reader¶
- class gmsh_interop.reader.ScriptSource(source: str, extension: str)[source]¶
Added in version 2016.1.
- class gmsh_interop.reader.ScriptWithFilesSource(source: str, filenames: Iterable[str], source_name: str = 'temp.geo')[source]¶
Added in version 2016.1.
- source¶
The script code to be fed to gmsh.
- filenames¶
The names of files to be copied to the temporary directory where gmsh is run.
- gmsh_interop.reader.read_gmsh(receiver: GmshMeshReceiverBase, filename: str, force_dimension: int | None = None) None [source]¶
Read a gmsh mesh file from filename and feed it to receiver.
- Parameters:
receiver – Implements the
GmshMeshReceiverBase
interface.force_dimension – if not None, truncate point coordinates to this many dimensions.
- gmsh_interop.reader.generate_gmsh(receiver: GmshMeshReceiverBase, source: str | ScriptSource | FileSource | ScriptWithFilesSource, dimensions: int | None = None, order: int | None = None, other_options: tuple[str, ...] = (), extension: str = 'geo', gmsh_executable: str = 'gmsh', force_dimension: int | None = None, target_unit: Literal['M', 'MM'] | None = None, output_file_name: str | None = None, save_tmp_files_in: str | None = None) None [source]¶
Run gmsh and feed the output to receiver.
- Parameters:
receiver – a class that implements the
GmshMeshReceiverBase
interface.source – an instance of
ScriptSource
orFileSource
.