stem.IO package

Submodules

stem.IO.io_utils module

class stem.IO.io_utils.IOUtils

Bases: object

static create_value_and_table(part_name: str, parameters: LoadParametersABC | BoundaryParametersABC, current_time: float) Tuple[List[float], List[int]]

Assemble values and tables for the boundary condition from the value attribute of the boundary parameters. If the displacement or rotation is time-dependent, a table is required. If the displacement or rotation is constant, a value is required. Each direction (x,y,z), requires either a table or a value. When a table is provided, the value is interpolated. If a value is provided, the table is set to 0.

Args:
Raises:
  • ValueError: if table ids are not initialised.

  • ValueError: when element in parameters.value is not of type int, float or Table.

  • ValueError: when provided parameters class doesn’t implement values (e.g. AbsorbingBoundary).

Returns:
  • _value (List[float]): list of values for the boundary condition or load

  • _table (List[int]): list of table ids for the boundary condition or load

static create_vector_constraint_table_process_dict(global_domain: str, part_name: str, parameters: LoadParametersABC | BoundaryParametersABC, variable_name: str, current_time: float) Dict[str, Any]

Creates a dictionary containing the vector constraint table process parameters. The vector constraint table process is used for loads and boundary conditions. This process applies either a constant value or a time-dependent table to the load or boundary condition.

Args:
  • global_domain (str): name of the global domain

  • part_name (str): name of the model part on which the load is applied

  • parameters (Union[stem.load.LoadParametersABC, stem.boundary.BoundaryParametersABC]): boundary parameters object.

  • variable_name (str): name of the variable to which the boundary condition or load is applied

  • current_time (float): current time of the analysis.

Returns:
  • Dict[str, Any]: dictionary containing the load parameters

static write_json_file(output_folder: str, file_name: str, dictionary: Dict[Any, Any])

Write a dictionary to a json file.

Args:
  • output_folder (str): output folder path

  • file_name (str): name of the json file

  • dictionary (Dict[Any, Any]): dictionary to be written to the json file

stem.IO.kratos_additional_processes_io module

class stem.IO.kratos_additional_processes_io.KratosAdditionalProcessesIO(domain: str)

Bases: object

Class containing methods for additional Kratos processes

Attributes:
  • domain (str): name of the Kratos domain

Constructor of KratosBoundariesIO class

Args:
  • domain (str): name of the Kratos domain

create_additional_processes_dict(part_name: str, parameters: AdditionalProcessesParametersABC) List[Dict[str, Any]] | None

Creates a list of dictionaries containing the parameters for the additional processes

Args:
Returns:
  • List[Dict[str, Any]]: list of dictionaries containing the parameters for the additional process

stem.IO.kratos_boundaries_io module

class stem.IO.kratos_boundaries_io.KratosBoundariesIO(domain: str)

Bases: object

Class containing methods to write boundary conditions to Kratos

Attributes:
  • domain (str): name of the Kratos domain

Constructor of KratosBoundariesIO class

Args:
  • domain (str): name of the Kratos domain

create_boundary_condition_dict(part_name: str, parameters: BoundaryParametersABC, current_time: float, use_linear_elastic_strategy: bool) Dict[str, Any] | None

Creates a dictionary containing the boundary parameters

Args:
  • part_name (str): part name where the boundary condition is applied

  • parameters (stem.boundary.BoundaryParametersABC): boundary parameters object

  • current_time (float): current time of the analysis

  • use_linear_elastic_strategy (bool): flag to determine if the linear elastic strategy is used

Returns:
  • Dict[str, Any]: dictionary containing the boundary parameters

stem.IO.kratos_io module

stem.IO.kratos_io.ElementAdditionalProcessParameters = (<class 'stem.additional_processes.Excavation'>, <class 'stem.additional_processes.ParameterFieldParameters'>, <class 'stem.additional_processes.ExtrapolateIntegrationPointToNodesParameters'>)

Type alias for additional process parameter classes which can be applied to elements.

TypeAlias:
class stem.IO.kratos_io.KratosIO(ndim: int)

Bases: object

Class containing methods to write mesh and problem data to Kratos

Attributes:

Constructor of KratosIO class

Args:
  • ndim (int): The number of dimensions of the problem.

initialise_model_ids(model: Model)

Initialise the ids of the model parts and tables.

Args:

model (stem.model.Model): the model object containing the model parts and tables.

write_conditions_process_model_part(process_model_part: ModelPart, mat_id: int, kratos_element_type: str) List[str]

Writes the conditions of the process model part to the mdpa file.

Args:
  • process_model_part (stem.model_part.ModelPart): the process model part to write to mdpa.

  • mat_id (int): the material id connected to the conditions block

  • kratos_element_type (str): the kratos element type for the condition.

Raises:
  • ValueError: if model part is not a process model part

  • ValueError: if mesh not initialised first

Returns:
  • block_text (List[str]): list of strings for the elements of the body model part. Each element is a line in the mdpa file.

write_elements_body_model_part(body_model_part: BodyModelPart, mat_id: int, kratos_element_type: str) List[str]

Writes the elements of the body model part to the mdpa file

Args:
  • body_model_part (stem.model_part.BodyModelPart): the body model part to write to mdpa.

  • mat_id (int): the material id connected to the element block

  • kratos_element_type (str): the kratos element type

Raises:
  • ValueError: if model part is not a body model part

Returns:
  • block_text (List[str]): list of strings for the elements of the body model part. Each element is a line in the mdpa file.

write_input_files_for_kratos(model: Model, mesh_file_name: str, materials_file_name: str = 'MaterialParameters.json', project_file_name: str = 'ProjectParameters.json')

Writes all required input files for a Kratos simulation, i.e: project parameters json; material parameters json and the mdpa mesh file.

Args:
  • model (stem.model.Model): The model object containing all the required info.

  • mesh_file_name (str): The name of the mesh file.

  • materials_file_name (str): The name of the materials file.

  • project_file_name (str): name of the project parameters file. Defaults to ProjectParameters.json.

Raises:
  • ValueError: if solver settings are not initialised in model.

write_submodelpart_body_model_part(body_model_part: BodyModelPart) List[str]

Writes the submodelpart block for a body model part (physical parts with materials).

Args:
Raises:
  • ValueError: if model part is not a body model part

  • ValueError: if mesh not initialised first

Returns:
  • block_text (List[str]): list of strings for the submodelpart. Each element is a line in the mdpa file.

write_submodelpart_process_model_part(process_model_part: ModelPart) List[str]

Writes the submodelpart block for a process model part (loads, boundary conditions or additional processes such as excavations).

Args:
Raises:
  • ValueError: if model part is not a process model part

  • ValueError: if mesh not initialised first

Returns:
  • block_text (List[str]): list of strings for the submodelpart. Each element is a line in the mdpa file.

stem.IO.kratos_loads_io module

class stem.IO.kratos_loads_io.KratosLoadsIO(domain: str)

Bases: object

Class containing methods to write loads to Kratos

Attributes:
  • domain (str): name of the Kratos domain

Constructor of KratosLoadsIO class

Args:
  • domain (str): name of the Kratos domain

create_load_dict(part_name: str, parameters: LoadParametersABC, current_time) Dict[str, Any] | None

Creates a dictionary containing the load parameters

Args:
  • part_name (str): name of the model part on which the load is applied

  • parameters (stem.load.LoadParametersABC): load parameters object

Raises:
  • NotImplementedError: if the load type is not implemented

Returns:
  • Dict[str, Any]: dictionary containing the load parameters

stem.IO.kratos_material_io module

class stem.IO.kratos_material_io.KratosMaterialIO(ndim: int, domain: str)

Bases: object

Class containing methods to write materials to Kratos

Attributes:
  • ndim (int): number of dimensions of the mesh

Constructor of KratosMaterialIO class

Args:
  • ndim (int): number of dimensions of the mesh

create_material_dict(part_name: str, material: SoilMaterial | StructuralMaterial, material_id: int) Dict[str, Any]

Creates a dictionary containing the material parameters

Args:
  • part_name (str): name of the body model part for the material

  • material (Union[stem.soil_material.SoilMaterial, stem.soil_material.StructuralMaterial]): material object

  • material_id (int): material id

Raises:
  • ValueError: if material is not of either SoilMaterial or StructuralMaterial type

Returns:
  • Dict[str, Any]: dictionary containing the material parameters

stem.IO.kratos_output_io module

class stem.IO.kratos_output_io.KratosOutputsIO(domain: str)

Bases: object

Class containing methods to write outputs to Kratos

Attributes:
  • domain (str): name of the Kratos domain

Constructor of KratosOutputsIO class

Args:
  • domain (str): name of the Kratos domain

create_output_process_dictionary(output_settings: List[Output]) Dict[str, Any]

Creates a dictionary containing the output_processes, that specifies which output to request Kratos and the type of output (‘GiD’, ‘VTK’, ‘JSON’)

Args:
Returns:
  • output_dict (Dict[str, Any]): dictionary containing two other dictionary for output properties:

    • the first containing the “output_process” dictionary. - the second containing the “processes” dictionary, which includes JSON outputs.

stem.IO.kratos_solver_io module

class stem.IO.kratos_solver_io.KratosSolverIO(ndim: int, domain: str)

Bases: object

Class containing methods to write Kratos solver settings

Attributes:
  • ndim (int): The number of dimensions of the problem (2 or 3).

  • domain (str): The name of the Kratos domain.

Class to read and write Kratos solver settings.

Args:
  • ndim (int): The number of dimensions of the problem (2 or 3).

  • domain (str): The name of the Kratos domain.

create_settings_dictionary(problem_data: Problem, mesh_file_name: str, materials_file_name: str, model_parts: List[ModelPart]) Dict[str, Any]

Creates a dictionary containing the solver settings

Args:
  • problem_data (stem.solver.Problem): The problem data

  • mesh_file_name (str): The name of the mesh file

  • materials_file_name (str): The name of the materials file

  • model_parts (List[stem.model_part.ModelPart]): The list of model parts

Returns:
  • Dict[str, Any]: dictionary containing the problem data and the solver settings

stem.IO.kratos_water_processes_io module

class stem.IO.kratos_water_processes_io.KratosWaterProcessesIO(domain: str)

Bases: object

Class containing methods to write water processes to Kratos

Attributes:
  • domain (str): name of the Kratos domain

Constructor of KratosWaterProcessesIO class

Args:
  • domain (str): name of the Kratos domain

create_water_process_dict(part_name: str, parameters: WaterProcessParametersABC) Dict[str, Any] | None

Creates a dictionary containing the water process parameters

Args:
Returns:
  • Dict[str, Any]: dictionary containing the water process parameters

Module contents