ogstools.gmsh_tools package#

ogstools.gmsh_tools.cuboid(lengths=1.0, n_edge_cells=1, n_layers=1, structured_grid=True, order=1, mixed_elements=False, out_name=None, msh_version=None)[source]#
Return type:

Path

ogstools.gmsh_tools.rect(lengths=1.0, n_edge_cells=1, n_layers=1, structured_grid=True, order=1, mixed_elements=False, jiggle=0.0, out_name=None, 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 | None) – 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.

Return type:

Path

ogstools.gmsh_tools.remesh_with_triangles(mesh, output_file=None, refinement=None, local_ref=None, mesh_opts=None, extract_regions=False)[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 | None) – The full filepath to the resulting file

  • refinement (dict | None) –

    specification for refinement of region edges

    You can provide a dict with the following data: - ‘SizeMin’: Minimum element size (default: median point distance) - ‘SizeMax’: Maximum element size (default: 3 * median point distance) - ‘DistMin’: Distance until which SizeMin is used (default: 0) - ‘DistMax’: Distance after which SizeMax is used (default: 3 * median point distance) - ‘Sampling’: Sampling number (resolution for field evaluation)

  • local_ref (list[dict] | dict | None) –

    specification/s of local refinement

    Allows the same refinement options as in refinement, but the dict has to contain an entry named ‘pts’ which provides the points around which the refinement is performed.

  • mesh_opts (dict | None) – Meshing options. Will be passed to gmsh.option.setNumber(f”Mesh.{key}”, value). Additionally pass ‘order’ to set the element order (1=linear, 2=quadratic, …).

  • extract_regions (bool) – If True, each region (MaterialIDs) of the new mesh will be saved as an individual mesh in addition to the domain mesh.

Return type:

Path

Submodules#