ogs5py.fileclasses.msh.generator

Generators for the ogs MESH file.

Generators

These generators can be called with MSH.generate

rectangular([dim, mesh_origin, element_no, …]) Generate a rectangular grid in 2D or 3D.
radial([dim, mesh_origin, angles, rad, z_arr]) Generate a radial grid in 2D or 3D.
grid_adapter2D([out_dim, in_dim, out_res, …]) Generate a grid adapter.
grid_adapter3D([out_dim, in_dim, z_dim, …]) Generate a grid adapter.
block_adapter3D([xy_dim, z_dim, in_res]) Generate a block adapter.
gmsh(geo_object[, import_dim]) Generate mesh from pygmsh Geometry instance, gmsh code or gmsh .geo file.

block_adapter3D(xy_dim=10.0, z_dim=5.0, in_res=1.0)[source]

Generate a block adapter.

It has a given resolution at the southern side with gmsh.

Parameters:
  • xy_dim (float) – xy-Dimension of the whole block
  • z_dim (float) – z-Dimension of the whole block
  • in_res (float) – Grid resolution at the southern side of the block
Returns:

result – Result contains one ‘#FEM_MSH’ block of the OGS mesh file with the following information (sorted by keys):

mesh_data : dict

dictionary containing information about

  • AXISYMMETRY (bool)
  • CROSS_SECTION (bool)
  • PCS_TYPE (str)
  • GEO_TYPE (str)
  • GEO_NAME (str)
  • LAYER (int)
nodes : ndarray

Array with all node postions

elements : dict

contains nodelists for elements sorted by element types

material_id : dict

contains material ids for each element sorted by element types

element_id : dict

contains element ids for each element sorted by element types

Return type:

dictionary

gmsh(geo_object, import_dim=(1, 2, 3))[source]

Generate mesh from pygmsh Geometry instance, gmsh code or gmsh .geo file.

Parameters:
  • geo_object (str or list of str or Geometry instance from pygmsh) – Either path to the gmsh .geo file, list of codelines for a .geo file or a pygmsh Geometry instance from pygmsh.
  • import_dim (iterable of int or single int, optional) – State which elements should be imported by dimensionality. Default: (1, 2, 3)
Returns:

result – Result contains one ‘#FEM_MSH’ block of the OGS mesh file with the following information (sorted by keys):

mesh_data : dict

dictionary containing information about

  • AXISYMMETRY (bool)
  • CROSS_SECTION (bool)
  • PCS_TYPE (str)
  • GEO_TYPE (str)
  • GEO_NAME (str)
  • LAYER (int)
nodes : ndarray

Array with all node postions

elements : dict

contains nodelists for elements sorted by element types

material_id : dict

contains material ids for each element sorted by element types

element_id : dict

contains element ids for each element sorted by element types

Return type:

dictionary

grid_adapter2D(out_dim=(100.0, 100.0), in_dim=(50.0, 50.0), out_res=(10.0, 10.0), in_res=(1.0, 1.0), out_pos=(0.0, 0.0), in_pos=(25.0, 25.0), z_pos=0.0, in_mat=0, out_mat=0, fill=False)[source]

Generate a grid adapter.

2D adapter from an outer grid resolution to an inner grid resolution with gmsh.

Parameters:
  • out_dim (list of 2 float) – xy-Dimension of the outer block
  • in_dim (list of 2 float) – xy-Dimension of the inner block
  • out_res (list of 2 float) – Grid resolution of the outer block
  • in_res (list of 2 float) – Grid resolution of the inner block
  • out_pos (list of 2 float) – xy-Position of the origin of the outer block
  • in_pos (list of 2 float) – xy-Position of the origin of the inner block
  • z_pos (float) – z-Position of the origin of the whole block
  • in_mat (integer) – Material-ID of the inner block
  • out_mat (integer) – Material-ID of the outer block
  • fill (bool, optional) – State if the inner block should be filled with a rectangular mesh. Default: False.
Returns:

result – Result contains one ‘#FEM_MSH’ block of the OGS mesh file with the following information (sorted by keys):

mesh_data : dict

dictionary containing information about

  • AXISYMMETRY (bool)
  • CROSS_SECTION (bool)
  • PCS_TYPE (str)
  • GEO_TYPE (str)
  • GEO_NAME (str)
  • LAYER (int)
nodes : ndarray

Array with all node postions

elements : dict

contains nodelists for elements sorted by element types

material_id : dict

contains material ids for each element sorted by element types

element_id : dict

contains element ids for each element sorted by element types

Return type:

dictionary

grid_adapter3D(out_dim=(100.0, 100.0), in_dim=(50.0, 50.0), z_dim=-10.0, out_res=(10.0, 10.0, 10.0), in_res=(5.0, 5.0, 5.0), out_pos=(0.0, 0.0), in_pos=(25.0, 25.0), z_pos=0.0, in_mat=0, out_mat=0, fill=False)[source]

Generate a grid adapter.

3D adapter from an outer grid resolution to an inner grid resolution with gmsh.

Parameters:
  • out_dim (list of 2 float) – xy-Dimension of the outer block
  • in_dim (list of 2 float) – xy-Dimension of the inner block
  • z_dim (float) – z-Dimension of the whole block
  • out_res (list of 3 float) – Grid resolution of the outer block
  • in_res (list of 3 float) – Grid resolution of the inner block
  • out_pos (list of 2 float) – xy-Position of the origin of the outer block
  • in_pos (list of 2 float) – xy-Position of the origin of the inner block
  • z_dim – z-Position of the origin of the whole block
  • in_mat (integer) – Material-ID of the inner block
  • out_mat (integer) – Material-ID of the outer block
  • fill (bool, optional) – State if the inner block should be filled with a rectangular mesh. Default: False.
Returns:

result – Result contains one ‘#FEM_MSH’ block of the OGS mesh file with the following information (sorted by keys):

mesh_data : dict

dictionary containing information about

  • AXISYMMETRY (bool)
  • CROSS_SECTION (bool)
  • PCS_TYPE (str)
  • GEO_TYPE (str)
  • GEO_NAME (str)
  • LAYER (int)
nodes : ndarray

Array with all node postions

elements : dict

contains nodelists for elements sorted by element types

material_id : dict

contains material ids for each element sorted by element types

element_id : dict

contains element ids for each element sorted by element types

Return type:

dictionary

radial(dim=3, mesh_origin=(0.0, 0.0, 0.0), angles=16, rad=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), z_arr=array([ 0, -1]))[source]

Generate a radial grid in 2D or 3D.

Parameters:
  • dim (int, optional) – Dimension of the resulting mesh, either 2 or 3. Default: 3
  • mesh_origin (list of float, optional) – Origin of the mesh Default: [0.0, 0.0, 0.0]
  • angles (int, optional) – Number of elements in each direction. Default: [10, 10, 10]
  • rad (array, optional) – array of radii to set in the mesh
  • z_arr (array, optional) – array of z values to set the layers in the mesh (only needed for dim=3) needs to be sorted in negative z direction
Returns:

result – Result contains one ‘#FEM_MSH’ block of the OGS mesh file with the following information (sorted by keys):

mesh_data : dict

dictionary containing information about

  • AXISYMMETRY (bool)
  • CROSS_SECTION (bool)
  • PCS_TYPE (str)
  • GEO_TYPE (str)
  • GEO_NAME (str)
  • LAYER (int)
nodes : ndarray

Array with all node postions

elements : dict

contains nodelists for elements sorted by element types

material_id : dict

contains material ids for each element sorted by element types

element_id : dict

contains element ids for each element sorted by element types

Return type:

dictionary

rectangular(dim=2, mesh_origin=(0.0, 0.0, 0.0), element_no=(10, 10, 10), element_size=(1.0, 1.0, 1.0))[source]

Generate a rectangular grid in 2D or 3D.

Parameters:
  • dim (int, optional) – Dimension of the resulting mesh, either 2 or 3. Default: 3
  • mesh_origin (list of float, optional) – Origin of the mesh Default: [0.0, 0.0, 0.0]
  • element_no (list of int, optional) – Number of elements in each direction. Default: [10, 10, 10]
  • element_size (list of float, optional) – Size of an element in each direction. Default: [1.0 ,1.0 ,1.0]
Returns:

result – Result contains one ‘#FEM_MSH’ block of the OGS mesh file with the following information (sorted by keys):

mesh_data : dict

dictionary containing information about

  • AXISYMMETRY (bool)
  • CROSS_SECTION (bool)
  • PCS_TYPE (str)
  • GEO_TYPE (str)
  • GEO_NAME (str)
  • LAYER (int)
nodes : ndarray

Array with all node postions

elements : dict

contains nodelists for elements sorted by element types

material_id : dict

contains material ids for each element sorted by element types

element_id : dict

contains element ids for each element sorted by element types

Return type:

dictionary