ogstools.feflowlib.tools module#

class ogstools.feflowlib.tools.helpFormat[source]#

Bases: ArgumentDefaultsHelpFormatter, RawTextHelpFormatter

A helper class for passing the correct format for the CLI arguments.

ogstools.feflowlib.tools.get_specific_surface(surface_mesh, filter_condition)[source]#

Return only cells that match the filter condition for the normals of the input-surface mesh. A standard use case could be to extract the cells that have a normal in a particular direction, e.g. upward in the z-direction. The filter condition would then be: lambda normals: normals[:, 2] > 0.

Parameters:
  • surface_mesh (PolyData) – The surface mesh.

  • filter_condition (Callable[[pyvista_ndarray], pyvista_ndarray]) – A condition to set up the filter for the normals.

Returns:

specific_cells

Return type:

UnstructuredGrid

ogstools.feflowlib.tools.assign_bulk_ids(mesh)[source]#

Add data arrays for bulk_node_ids and bulk_element_ids to the given bulk mesh.

Parameters:

mesh (UnstructuredGrid) – bulk mesh

Return type:

None

ogstools.feflowlib.tools.remove_bulk_ids(mesh)[source]#

Remove data arrays for bulk_node_ids and bulk_element_ids of the given bulk mesh.

Parameters:

mesh (UnstructuredGrid) – bulk mesh

Return type:

None

ogstools.feflowlib.tools.get_dimension(mesh)[source]#

Return the dimension of the mesh.

Parameters:

mesh (UnstructuredGrid) – mesh

Return type:

int

ogstools.feflowlib.tools.extract_point_boundary_conditions(out_mesh_path, mesh)[source]#

Returns the point boundary conditions of the mesh. It works by iterating all point data and looking for data arrays that include the string “_BC”. Depending on what follows, it defines the boundary condition type.

Parameters:
  • out_mesh_path (Path) – path of the output mesh

  • mesh (UnstructuredGrid) – mesh

Returns:

dict_of_point_boundary_conditions

Return type:

dict

ogstools.feflowlib.tools.write_point_boundary_conditions(out_mesh_path, mesh)[source]#

Writes the point boundary conditions that are returned from ‘extract_point_boundary_conditions()’

Parameters:
  • out_mesh_path (Path) – path for writing

  • mesh (UnstructuredGrid) – mesh

Return type:

None

ogstools.feflowlib.tools.extract_cell_boundary_conditions(bulk_mesh_path, mesh)[source]#

Returns the cell boundary conditions of the mesh. It works by iterating all cell data and looking for data arrays that include the strings “P_SOUF” or “P_IOFLOW”. +++WARNING+++: This function still in a experimental state since it is not clear how exactly this function will be used in the future. TODO: Allow a generic definition of the normal vector for the filter condition.

Parameters:
  • bulk_mesh_path (Path) – name of the mesh

  • mesh (UnstructuredGrid) – mesh

Returns:

path with name of mesh, topsurface mesh with cell boundary conditions

Return type:

tuple[Path, UnstructuredGrid]

ogstools.feflowlib.tools.get_material_properties(mesh, property)[source]#

Get the material properties of the mesh converted from FEFLOW. There are several methods available to access the material properties. Either they are accessible with the FEFLOW API(ifm) or with brute-force methods, which check each element, like this function.

Parameters:
  • mesh (UnstructuredGrid) – mesh

  • property (str) – property

Returns:

material_properties

Return type:

dict

ogstools.feflowlib.tools.get_material_properties_of_HT_model(mesh)[source]#

Get a dictionary of all necessaray parameter values for a HT problem for each material in the mesh.

Parameters:

mesh (UnstructuredGrid) – mesh

Returns:

material_properties

Return type:

defaultdict

ogstools.feflowlib.tools.get_material_properties_of_CT_model(mesh)[source]#

Gets the material properties/parameter for each chemical species/component of the model.

Parameters:

mesh (UnstructuredGrid) – mesh

Return type:

defaultdict

ogstools.feflowlib.tools.get_species(mesh)[source]#

Get the names of chemical species of a mesh. Only works, if species-specific porosity values are assigned and named ‘*_P_PORO’.

Parameters:

mesh (UnstructuredGrid) – mesh

Returns:

list of species

Return type:

list

ogstools.feflowlib.tools.add_species_to_prj_file(xpath, parameter_dict, species_list, model)[source]#

Adds the entries needed in the prj-file for components/species. Since in ogs6py no corresponding feature exists to use the common ogs6py.media-class, the generic method add_block is used.

WARNING: After add_block was used, the ogs6py-model cannot be altered with common ogs6py functions!

Parameters:
  • xpath (str) – Path to the species/components sektion in the prj-file.

  • parameter_dict (dict) – Dictionary with all the parameter names and values.

  • species_list (list) – List of all species.

  • model (OGS) – Model to setup prj-file, there the species will be added to.

Return type:

None

ogstools.feflowlib.tools.combine_material_properties(mesh, properties_list)[source]#

Combine multiple material properties. The combined properties are returned as list of values in a dictionary.

Parameters:
  • mesh (UnstructuredGrid) – mesh

  • properties_list (list) – list of properties to be combined

Returns:

material_properties

Return type:

defaultdict

ogstools.feflowlib.tools.write_mesh_of_combined_properties(mesh, property_list, new_property, material_id, saving_path)[source]#

Writes a separate mesh-file with a specific material that has inhomogeneous property values within the material group. It can also be used to write multiple properties into a “new property” data array. For example, write a data array for a tensor defined by data arrays representing values of different spatial directions. Nevertheless it can still be be used to write the inhomogeneous values of a single property into a separate mesh-file.

Parameters:
  • mesh (UnstructuredGrid) – mesh

  • property_list (list) – list of properties

  • new_property (str) – name of the combined properties

  • material – material with inhomogeneous properties

  • saving_path (Path) – path to save the mesh

  • material_id (int)

Returns:

filename

Return type:

str

ogstools.feflowlib.tools.materials_in_steady_state_diffusion(material_properties, model)[source]#

Create the section for material properties for steady state diffusion processes in the prj-file.

Parameters:
  • bulk_mesh_path – path of bulk mesh

  • mesh – mesh

  • material_properties (dict) – material properties

  • model (OGS) – model to setup prj-file

Returns:

model

Return type:

OGS

ogstools.feflowlib.tools.materials_in_liquid_flow(material_properties, model)[source]#

Create the section for material properties in liquid flow processes in the prj-file.

Parameters:
  • bulk_mesh_path – path of bulk mesh

  • mesh – mesh

  • material_properties (dict) – material properties

  • model (OGS) – model to setup prj-file

Returns:

model

Return type:

OGS

ogstools.feflowlib.tools.materials_in_HT(material_properties, model)[source]#

Create the section for material properties for HT processes in the prj-file.

Parameters:
  • material_properties (dict) – material properties

  • model (OGS) – model to setup prj-file

Returns:

model

Return type:

OGS

ogstools.feflowlib.tools.materials_in_HC(material_properties, species_list, model)[source]#

Create the section for material properties for HC processes in the prj-file.

Parameters:
  • material_properties (dict) – material properties

  • model (OGS) – model to setup prj-file

  • species_list (list)

Returns:

model

Return type:

OGS

class ogstools.feflowlib.tools.RequestParams[source]#

Bases: TypedDict

model: NotRequired[OGS]#
species_list: NotRequired[list]#
ogstools.feflowlib.tools.setup_prj_file(bulk_mesh_path, mesh, material_properties, process, **kwargs)[source]#

Sets up a prj-file for ogs simulations using ogs6py.

Parameters:
  • bulk_mesh_path (Path) – path of bulk mesh

  • mesh (UnstructuredGrid) – mesh

  • material_properties (dict) – material properties

  • process (str) – the process to be prepared

  • kwargs (Unpack)

Keyword Arguments (kwargs):
  • model (ogs.OGS) – A ogs6py (ogs) model that is extended, should be used for templates

  • species_list (list) – All chemical species that occur in a model, if the model is to simulate a Component Transport (HC/CT) process.

Returns:

model

Return type:

OGS

ogstools.feflowlib.tools.deactivate_cells(mesh)[source]#

Multiplies the MaterialID of all cells that are inactive in FEFLOW by -1. Therefore, the input mesh is modified. :param mesh: mesh :return: 0 for no cells have been deactivated and 1 for cells have been deactivated

Parameters:

mesh (UnstructuredGrid)

Return type:

int