ogstools.meshlib.gmsh_meshing module#

ogstools.meshlib.gmsh_meshing.rect(lengths=1.0, n_edge_cells=1, n_layers=1, structured_grid=True, order=1, mixed_elements=False, jiggle=0.0, out_name=Path('rect.msh'), msh_version=None, layer_ids=None)[source]#

Generates a rectangular mesh using gmsh.

Parameters:
  • lengths (float | tuple[float, float]) – Length of the rectangle in x and y direction. Provide a tuple (x, y) or a scalar for a square. All values must be >= 1e-7 and <= 1e12.

  • n_edge_cells (int | tuple[int, int]) – Number of edge cells in x and y direction. Provide a tuple (x, y) or a scalar for a square. All values must be >= 1.

  • n_layers (int) – Number of layers in y direction. Must be >= 1.

  • structured_grid (bool) – If True, the mesh will be structured. If False, the mesh will be unstructured.

  • order (int) – Order of the mesh elements. 1 for linear, 2 for quadratic.

  • mixed_elements (bool) – If True, the mesh will be mixed elements. If False, the mesh will be structured.

  • jiggle (float) – Amount of random displacement to apply to the mesh nodes. Default is 0.0 (no displacement).

  • out_name (Path | str) – Name of the output mesh file. Default is “rect.msh”.

  • msh_version (float | None) – Version of the GMSH mesh file format. Default is None (use the default version).

  • layer_ids (list | None) – List of layer IDs for the physical groups. If None, the IDs will be generated automatically.

ogstools.meshlib.gmsh_meshing.cuboid(lengths=1.0, n_edge_cells=1, n_layers=1, structured_grid=True, order=1, mixed_elements=False, out_name=Path('unit_cube.msh'), msh_version=None)[source]#
ogstools.meshlib.gmsh_meshing.remesh_with_triangles(mesh, output_file=Path() / 'tri_mesh.msh', size_factor=1.0, order=1)[source]#

Discretizes a given Mesh with triangles and saves as gmsh .msh.

Requires the mesh to be 2D and to contain ‘MaterialIDs in the cell data.

Parameters:
  • mesh (UnstructuredGrid) – The mesh which shall be discretized with triangles

  • output_file (Path | str) – The full filepath to the resulting file

  • size_factor (float) – A factor to scale the element sizes.

  • order (int) – The element order (1=linear, 2=quadratic, …)