seamsh.gmsh module
- seamsh.gmsh.convert_to_gis(input_filename, projection, output_filename)
Converts a triangular gmsh mesh into shapefile or geopackage.
- Parameters:
input_filename (
str) – any mesh file readable by gmsh (typically a .msh file)projection (
SpatialReference) – the projection assigned to the output layer, mesh files do not store any projection so neither checks nor re-projections are performed (if none mesh projection will be used).output_filename (
str) – shape file (.shp) or geopackage (.gpkg) file
- Return type:
None
- seamsh.gmsh.join_meshes(existing, added, output, version=4.1, binary=False)
Joins to an existing mesh the meshes generated along its boundary (see seamsh.geometry.Domain.add_boundary_curves_msh). The existing mesh is kept as it is (nodes, elements, tags and entities). The nodes of the added meshes that have the exact coordinates of a boundary node of the existing mesh are that node, the others get new tags. The line elements on the shared boundary are removed (they are interior once joined) and the physical groups with the same name are merged. Both meshes must be in the same coordinate system.
- Parameters:
existing (
str) – the existing mesh file (any format readable by gmsh)added – the mesh file to join to it, or a list of files joined in turn
output (
str) – output mesh file (.msh)version (
float) – msh file version (typically 2.2 or 4.1)binary (
bool) – if True, write the mesh in binary .msh format
- Return type:
None
- seamsh.gmsh.mesh(domain, filename, mesh_size, version=4.1, intermediate_file_name=None, smoothness=0.3, output_srs=None, transfinite_curves={}, quad=False, binary=False, modify_existing=False)
Calls gmsh to generate a mesh from a geometry and a mesh size callback
- Parameters:
domain (
Domain) – the input geometryfilename (
str) – output mesh file (.msh)mesh_size (
Callable[[ndarray,SpatialReference],ndarray]) – callbable prescribing the mesh element sizeversion (
float) – msh file version (typically 2.0 or 4.0)intermediate_file_name (
str) – if not None, save intermediate meshes to those files for debugging purpose (suffixes and extensions will be appended), if == “-”, an interactive gmsh graphical window will pop up after each meshing step.smoothness – Maximum gradation of the mesh size, any positive value is valid but a value in the range [0.1,0.5] is recommended.
output_srs (
SpatialReference) – coordinate system of the output file (if None, the coordinate system of the domain is used).tranfinite_curves – dict(str, int) prescribe a fixed number of mesh getElements on curves with given physical tag.
quad (
bool) – if True, generate quadrangles instead of triangles. This a achieved by generating a quad-dominant mesh and then splitting all elements (quads and triangles) into quads. So the resulting mesh size is half the prescribed one.binary (
bool) – if True, write the mesh in binary .msh format (smaller and much faster to write for large meshes) instead of ASCII.modify_existing (
bool) – when the domain extends an existing mesh (see seamsh.geometry.Domain.add_boundary_curves_msh), the output is the existing mesh and the new one joined. If False, the existing mesh is kept as it is (its triangles are frozen neighbors of the new ones in the valence repair, Mesh.ValenceRepair2D); if True, both are then repaired together (gmsh.model.mesh.optimize “ValenceRepair2D”).
- Return type:
None
- seamsh.gmsh.reproject(input_filename, input_srs, output_filename, output_srs, output_version=4.1, binary=False)
Change the coordinate of an existing mesh.
- Parameters:
input_filename (
str) – input mesh file (any format readable by gmsh).input_srs (
SpatialReference) – coordinate system of the input mesh. If None, the model projection is used.output_filename (
str) – output mesh file (.msh)output_srs (
SpatialReference) – coordinate system of the output file (if None, the coordinate system of the domain is used).output_version (
float) – msh file version (typically 2.0 or 4.0)binary (
bool) – if True, write the mesh in binary .msh format (smaller and much faster to write for large meshes) instead of ASCII.