Reading Gmsh Meshes

exception gmsh_interop.reader.GmshFileFormatError[source]

Element types

class gmsh_interop.reader.GmshElementBase(order: int)[source]
abstract vertex_count() int[source]
abstract node_count() 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.

get_lexicographic_gmsh_node_indices() ndarray[tuple[int, ...], dtype[integer]][source]

Simplex Elements

class gmsh_interop.reader.GmshSimplexElementBase(order: int)[source]
class gmsh_interop.reader.GmshPoint(order: int)[source]
class gmsh_interop.reader.GmshIntervalElement(order: int)[source]
class gmsh_interop.reader.GmshTriangularElement(order: int)[source]
class gmsh_interop.reader.GmshIncompleteTriangularElement(order: int)[source]
class gmsh_interop.reader.GmshTetrahedralElement(order: int)[source]

Tensor Product Elements

class gmsh_interop.reader.GmshTensorProductElementBase(order: int)[source]
class gmsh_interop.reader.GmshQuadrilateralElement(order: int)[source]
class gmsh_interop.reader.GmshHexahedralElement(order: int)[source]

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>}
set_up_nodes(count: int) None[source]
add_node(node_nr: int, point: ndarray[tuple[int, ...], dtype[floating]]) None[source]
finalize_nodes() None[source]
set_up_elements(count: int) None[source]
add_element(element_nr: int, element_type: GmshElementBase, vertex_nrs: ndarray[tuple[int, ...], dtype[integer]], lexicographic_nodes: ndarray[tuple[int, ...], dtype[floating]], tag_numbers: Sequence[int]) None[source]
finalize_elements() None[source]
add_tag(name: str, index: int, dimension: int) None[source]
finalize_tags() None[source]

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 and meshpy.tet.MeshInfo by using similar fields, but instead of loading data into ForeignArrays, load into numpy arrays. Since this class is not wrapping any libraries in other languages – the Gmsh data is obtained via parsing text – use numpy 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.FileSource(filename: str)[source]

Added in version 2014.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: