STEM-Vibrations 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. STEM-Vibrations-0.1/LICENSE.md +28 -0
  2. STEM-Vibrations-0.1/PKG-INFO +24 -0
  3. STEM-Vibrations-0.1/README.md +35 -0
  4. STEM-Vibrations-0.1/STEM_Vibrations.egg-info/PKG-INFO +24 -0
  5. STEM-Vibrations-0.1/STEM_Vibrations.egg-info/SOURCES.txt +63 -0
  6. STEM-Vibrations-0.1/STEM_Vibrations.egg-info/dependency_links.txt +1 -0
  7. STEM-Vibrations-0.1/STEM_Vibrations.egg-info/not-zip-safe +1 -0
  8. STEM-Vibrations-0.1/STEM_Vibrations.egg-info/requires.txt +15 -0
  9. STEM-Vibrations-0.1/STEM_Vibrations.egg-info/top_level.txt +1 -0
  10. STEM-Vibrations-0.1/pyproject.toml +3 -0
  11. STEM-Vibrations-0.1/setup.cfg +43 -0
  12. STEM-Vibrations-0.1/setup.py +4 -0
  13. STEM-Vibrations-0.1/stem/IO/__init__.py +0 -0
  14. STEM-Vibrations-0.1/stem/IO/io_utils.py +119 -0
  15. STEM-Vibrations-0.1/stem/IO/kratos_additional_processes_io.py +115 -0
  16. STEM-Vibrations-0.1/stem/IO/kratos_boundaries_io.py +78 -0
  17. STEM-Vibrations-0.1/stem/IO/kratos_io.py +1140 -0
  18. STEM-Vibrations-0.1/stem/IO/kratos_loads_io.py +113 -0
  19. STEM-Vibrations-0.1/stem/IO/kratos_material_io.py +393 -0
  20. STEM-Vibrations-0.1/stem/IO/kratos_output_io.py +293 -0
  21. STEM-Vibrations-0.1/stem/IO/kratos_solver_io.py +308 -0
  22. STEM-Vibrations-0.1/stem/IO/kratos_water_processes_io.py +73 -0
  23. STEM-Vibrations-0.1/stem/__init__.py +1 -0
  24. STEM-Vibrations-0.1/stem/__version__.py +4 -0
  25. STEM-Vibrations-0.1/stem/additional_processes.py +89 -0
  26. STEM-Vibrations-0.1/stem/boundary.py +239 -0
  27. STEM-Vibrations-0.1/stem/default_materials.py +75 -0
  28. STEM-Vibrations-0.1/stem/field_generator.py +184 -0
  29. STEM-Vibrations-0.1/stem/geometry.py +496 -0
  30. STEM-Vibrations-0.1/stem/globals.py +82 -0
  31. STEM-Vibrations-0.1/stem/load.py +342 -0
  32. STEM-Vibrations-0.1/stem/mesh.py +226 -0
  33. STEM-Vibrations-0.1/stem/model.py +1573 -0
  34. STEM-Vibrations-0.1/stem/model_part.py +152 -0
  35. STEM-Vibrations-0.1/stem/output.py +381 -0
  36. STEM-Vibrations-0.1/stem/plot_utils.py +330 -0
  37. STEM-Vibrations-0.1/stem/soil_material.py +321 -0
  38. STEM-Vibrations-0.1/stem/solver.py +546 -0
  39. STEM-Vibrations-0.1/stem/stem.py +144 -0
  40. STEM-Vibrations-0.1/stem/structural_material.py +261 -0
  41. STEM-Vibrations-0.1/stem/table.py +60 -0
  42. STEM-Vibrations-0.1/stem/utils.py +527 -0
  43. STEM-Vibrations-0.1/stem/water_processes.py +28 -0
  44. STEM-Vibrations-0.1/tests/test_additional_processes.py +74 -0
  45. STEM-Vibrations-0.1/tests/test_default_materials.py +46 -0
  46. STEM-Vibrations-0.1/tests/test_generator.py +49 -0
  47. STEM-Vibrations-0.1/tests/test_geometry.py +228 -0
  48. STEM-Vibrations-0.1/tests/test_globals.py +119 -0
  49. STEM-Vibrations-0.1/tests/test_kratos_additional_processes_io.py +113 -0
  50. STEM-Vibrations-0.1/tests/test_kratos_boundaries_io.py +86 -0
  51. STEM-Vibrations-0.1/tests/test_kratos_io.py +1132 -0
  52. STEM-Vibrations-0.1/tests/test_kratos_loads_io.py +153 -0
  53. STEM-Vibrations-0.1/tests/test_kratos_material_io.py +220 -0
  54. STEM-Vibrations-0.1/tests/test_kratos_outputs_io.py +269 -0
  55. STEM-Vibrations-0.1/tests/test_kratos_solver_io.py +193 -0
  56. STEM-Vibrations-0.1/tests/test_kratos_water_processes_io.py +52 -0
  57. STEM-Vibrations-0.1/tests/test_mesh.py +279 -0
  58. STEM-Vibrations-0.1/tests/test_model.py +3215 -0
  59. STEM-Vibrations-0.1/tests/test_model_part.py +310 -0
  60. STEM-Vibrations-0.1/tests/test_plot_utils.py +149 -0
  61. STEM-Vibrations-0.1/tests/test_soil_material.py +45 -0
  62. STEM-Vibrations-0.1/tests/test_structural_material.py +38 -0
  63. STEM-Vibrations-0.1/tests/test_table.py +26 -0
  64. STEM-Vibrations-0.1/tests/test_utils.py +615 -0
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, StemVibrations
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.1
2
+ Name: STEM-Vibrations
3
+ Version: 0.1
4
+ Summary: STEM model
5
+ Author: attr: stem.__author__
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: BSD License
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE.md
12
+ Requires-Dist: numpy>=1.24
13
+ Requires-Dist: scipy>=1.10.1
14
+ Requires-Dist: plotly>=5.15.0
15
+ Provides-Extra: testing
16
+ Requires-Dist: pytest>=7.2; extra == "testing"
17
+ Requires-Dist: pytest-cov>=4.0; extra == "testing"
18
+ Requires-Dist: tox>=4.4; extra == "testing"
19
+ Requires-Dist: mypy>=1.1; extra == "testing"
20
+ Requires-Dist: beautifulsoup4>=4.12; extra == "testing"
21
+ Requires-Dist: matplotlib==3.7.4; extra == "testing"
22
+ Provides-Extra: docs
23
+ Requires-Dist: Sphinx==6.2.1; extra == "docs"
24
+ Requires-Dist: sphinx-rtd-theme==1.2.2; extra == "docs"
@@ -0,0 +1,35 @@
1
+ ```
2
+ _______..___________. _______ .___ ___.
3
+ / || || ____|| \/ |
4
+ | (----``---| |----`| |__ | \ / |
5
+ \ \ | | | __| | |\/| |
6
+ .----) | | | | |____ | | | |
7
+ |_______/ |__| |_______||__| |__|
8
+
9
+ ```
10
+
11
+ # STEM: Soil and Track System Modeling Tool
12
+
13
+ ![Tests](https://github.com/StemVibrations/STEM/actions/workflows/tests.yml/badge.svg)
14
+ [![Documentation Status](https://readthedocs.org/projects/stemvibrations/badge/?version=latest)](https://stemvibrations.readthedocs.io/badge=latest)
15
+ [![codecov](https://codecov.io/gh/stemvibrations/stem/graph/badge.svg?token=0DMYCZF4BU)](https://codecov.io/gh/stemvibrations/stem)
16
+
17
+ The STEM model is designed to create and analyse models of soil and track systems.
18
+ The tool provides a set of commands for creating the geometry of the model, defining the soil and track properties, setting the boundary conditions and loads, generating the mesh, and performing post-processing on the results.
19
+
20
+ ## Installation
21
+
22
+ STEM can be downloaded and installed on any system that supports Python.
23
+ To install the STEM, follow the following steps:
24
+
25
+ ```python
26
+ pip install git+https://github.com/StemVibrations/STEM.git
27
+ ```
28
+
29
+ It is also needed to download Kratos Multiphysics. Kratos Multiphysics can be downloaded [here](https://github.com/StemVibrations/StemKratos).
30
+
31
+ Further details about the installation can be found [here](https://stemvibrations.readthedocs.io/).
32
+
33
+ ## Usage
34
+
35
+ To use STEM please refer to the tutorials available [here](https://stemvibrations.readthedocs.io/).
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.1
2
+ Name: STEM-Vibrations
3
+ Version: 0.1
4
+ Summary: STEM model
5
+ Author: attr: stem.__author__
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: BSD License
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE.md
12
+ Requires-Dist: numpy>=1.24
13
+ Requires-Dist: scipy>=1.10.1
14
+ Requires-Dist: plotly>=5.15.0
15
+ Provides-Extra: testing
16
+ Requires-Dist: pytest>=7.2; extra == "testing"
17
+ Requires-Dist: pytest-cov>=4.0; extra == "testing"
18
+ Requires-Dist: tox>=4.4; extra == "testing"
19
+ Requires-Dist: mypy>=1.1; extra == "testing"
20
+ Requires-Dist: beautifulsoup4>=4.12; extra == "testing"
21
+ Requires-Dist: matplotlib==3.7.4; extra == "testing"
22
+ Provides-Extra: docs
23
+ Requires-Dist: Sphinx==6.2.1; extra == "docs"
24
+ Requires-Dist: sphinx-rtd-theme==1.2.2; extra == "docs"
@@ -0,0 +1,63 @@
1
+ LICENSE.md
2
+ README.md
3
+ pyproject.toml
4
+ setup.cfg
5
+ setup.py
6
+ STEM_Vibrations.egg-info/PKG-INFO
7
+ STEM_Vibrations.egg-info/SOURCES.txt
8
+ STEM_Vibrations.egg-info/dependency_links.txt
9
+ STEM_Vibrations.egg-info/not-zip-safe
10
+ STEM_Vibrations.egg-info/requires.txt
11
+ STEM_Vibrations.egg-info/top_level.txt
12
+ stem/__init__.py
13
+ stem/__version__.py
14
+ stem/additional_processes.py
15
+ stem/boundary.py
16
+ stem/default_materials.py
17
+ stem/field_generator.py
18
+ stem/geometry.py
19
+ stem/globals.py
20
+ stem/load.py
21
+ stem/mesh.py
22
+ stem/model.py
23
+ stem/model_part.py
24
+ stem/output.py
25
+ stem/plot_utils.py
26
+ stem/soil_material.py
27
+ stem/solver.py
28
+ stem/stem.py
29
+ stem/structural_material.py
30
+ stem/table.py
31
+ stem/utils.py
32
+ stem/water_processes.py
33
+ stem/IO/__init__.py
34
+ stem/IO/io_utils.py
35
+ stem/IO/kratos_additional_processes_io.py
36
+ stem/IO/kratos_boundaries_io.py
37
+ stem/IO/kratos_io.py
38
+ stem/IO/kratos_loads_io.py
39
+ stem/IO/kratos_material_io.py
40
+ stem/IO/kratos_output_io.py
41
+ stem/IO/kratos_solver_io.py
42
+ stem/IO/kratos_water_processes_io.py
43
+ tests/test_additional_processes.py
44
+ tests/test_default_materials.py
45
+ tests/test_generator.py
46
+ tests/test_geometry.py
47
+ tests/test_globals.py
48
+ tests/test_kratos_additional_processes_io.py
49
+ tests/test_kratos_boundaries_io.py
50
+ tests/test_kratos_io.py
51
+ tests/test_kratos_loads_io.py
52
+ tests/test_kratos_material_io.py
53
+ tests/test_kratos_outputs_io.py
54
+ tests/test_kratos_solver_io.py
55
+ tests/test_kratos_water_processes_io.py
56
+ tests/test_mesh.py
57
+ tests/test_model.py
58
+ tests/test_model_part.py
59
+ tests/test_plot_utils.py
60
+ tests/test_soil_material.py
61
+ tests/test_structural_material.py
62
+ tests/test_table.py
63
+ tests/test_utils.py
@@ -0,0 +1,15 @@
1
+ numpy>=1.24
2
+ scipy>=1.10.1
3
+ plotly>=5.15.0
4
+
5
+ [docs]
6
+ Sphinx==6.2.1
7
+ sphinx-rtd-theme==1.2.2
8
+
9
+ [testing]
10
+ pytest>=7.2
11
+ pytest-cov>=4.0
12
+ tox>=4.4
13
+ mypy>=1.1
14
+ beautifulsoup4>=4.12
15
+ matplotlib==3.7.4
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,43 @@
1
+ [metadata]
2
+ name = STEM-Vibrations
3
+ version = attr: stem.__version__
4
+ author = attr: stem.__author__
5
+ description = STEM model
6
+ long_description = file: ReadMe.md
7
+ long_description_content_type = text/markdown
8
+ classifiers =
9
+ Programming Language :: Python :: 3
10
+ License :: OSI Approved :: BSD License
11
+ Operating System :: OS Independent
12
+
13
+ [options]
14
+ packages =
15
+ stem
16
+ stem.IO
17
+ include_package_data = True
18
+ install_requires =
19
+ numpy>=1.24
20
+ scipy>=1.10.1
21
+ plotly>=5.15.0
22
+ python_requires = >=3.8
23
+ zip_safe = False
24
+ find_links =
25
+ git+https://github.com/StemVibrations/gmsh_utils
26
+ git+https://github.com/StemVibrations/RandomFields
27
+
28
+ [options.extras_require]
29
+ testing =
30
+ pytest>=7.2
31
+ pytest-cov>=4.0
32
+ tox>=4.4
33
+ mypy>=1.1
34
+ beautifulsoup4>=4.12
35
+ matplotlib==3.7.4
36
+ docs =
37
+ Sphinx==6.2.1
38
+ sphinx-rtd-theme==1.2.2
39
+
40
+ [egg_info]
41
+ tag_build =
42
+ tag_date = 0
43
+
@@ -0,0 +1,4 @@
1
+ from setuptools import setup
2
+
3
+ if __name__ == '__main__':
4
+ setup()
File without changes
@@ -0,0 +1,119 @@
1
+ from typing import Sequence, Dict, Any, List, Union, Optional, Tuple
2
+ from pathlib import Path
3
+ import json
4
+ from copy import deepcopy
5
+
6
+ from stem.table import Table
7
+ from stem.boundary import BoundaryParametersABC
8
+ from stem.load import LoadParametersABC
9
+
10
+ class IOUtils:
11
+
12
+ @staticmethod
13
+ def write_json_file(output_folder: str, file_name: str, dictionary: Dict[Any, Any]):
14
+ """
15
+ Write a dictionary to a json file.
16
+
17
+ Args:
18
+ - output_folder (str): output folder path
19
+ - file_name (str): name of the json file
20
+ - dictionary (Dict[Any, Any]): dictionary to be written to the json file
21
+
22
+ """
23
+ # write json file
24
+ output_folder_pth = Path(output_folder)
25
+ output_folder_pth.mkdir(exist_ok=True, parents=True)
26
+
27
+ output_path_file = output_folder_pth.joinpath(file_name)
28
+ json.dump(dictionary, open(output_path_file, "w"), indent=4)
29
+
30
+ @staticmethod
31
+ def create_value_and_table(part_name: str, parameters: Union["LoadParametersABC", "BoundaryParametersABC"]) \
32
+ -> Tuple[List[float], List[int]]:
33
+ """
34
+ Assemble values and tables for the boundary condition from the `value` attribute of the boundary parameters.
35
+ If the displacement or rotation is time-dependent, a `table` is required. If the displacement or rotation is
36
+ constant, a `value` is required. Each direction (x,y,z), requires either a `table` or a `value`. When a `table`
37
+ is provided, the `value` is set to 0. If a `value` is provided, the `table` is set to 0.
38
+
39
+ Args:
40
+ - part_name (str): name of the model part on which the boundary is applied.
41
+ - parameters (Union[:class:`stem.load.LoadParametersABC`, \
42
+ :class:`stem.boundary.BoundaryParametersABC`]): boundary parameters object.
43
+
44
+ Raises:
45
+ - ValueError: if table ids are not initialised.
46
+ - ValueError: when element in `parameters.value` is not of type int, float or Table.
47
+ - ValueError: when provided parameters class doesn't implement values (e.g. AbsorbingBoundary).
48
+
49
+ Returns:
50
+ - _value (List[float]): list of values for the boundary condition or load
51
+ - _table (List[int]): list of table ids for the boundary condition \
52
+ or load
53
+ """
54
+
55
+ _value: List[float] = []
56
+ _table: List[int] = []
57
+
58
+ if hasattr(parameters, "value"):
59
+
60
+ # check the values per direction
61
+ for vv in parameters.value:
62
+ # if a table is provided, the value is set to 0
63
+ if isinstance(vv, Table):
64
+ if vv.id is None:
65
+ raise ValueError(f"Table id is not initialised for values in {parameters.__class__.__name__}"
66
+ f" in model part: {part_name}.")
67
+ _table.append(vv.id)
68
+ _value.append(0.0)
69
+ # if a value is provided, the table is set to 0
70
+ elif isinstance(vv, (int, float)):
71
+ _table.append(0)
72
+ _value.append(float(vv))
73
+ else:
74
+ raise ValueError(f"'value' attribute in {parameters.__class__.__name__} in model part "
75
+ f"`{part_name}`. The value ({vv}) is a `{vv.__class__.__name__}` object"
76
+ f" but only a Table, float or integer are valid inputs.")
77
+
78
+ else:
79
+ raise ValueError(f"Attribute `value` does not exist in class: {parameters.__class__.__name__}.")
80
+
81
+ return _value, _table
82
+
83
+ @staticmethod
84
+ def create_vector_constraint_table_process_dict(global_domain: str, part_name: str,
85
+ parameters: Union[LoadParametersABC, BoundaryParametersABC],
86
+ variable_name: str) -> Dict[str, Any]:
87
+ """
88
+ Creates a dictionary containing the vector constraint table process parameters. The vector constraint table
89
+ process is used for loads and boundary conditions. This process applies either a constant value or a
90
+ time-dependent table to the load or boundary condition.
91
+
92
+ Args:
93
+ - global_domain (str): name of the global domain
94
+ - part_name (str): name of the model part on which the load is applied
95
+ - parameters (Union[:class:`stem.load.LoadParametersABC`, \
96
+ :class:`stem.boundary.BoundaryParametersABC`]): boundary parameters object.
97
+ - variable_name (str): name of the variable to which the boundary condition or load is applied
98
+
99
+ Returns:
100
+ - Dict[str, Any]: dictionary containing the load parameters
101
+ """
102
+
103
+ # initialize load dictionary
104
+ load_dict: Dict[str, Any] = {
105
+ "python_module": "apply_vector_constraint_table_process",
106
+ "kratos_module": "KratosMultiphysics.GeoMechanicsApplication",
107
+ "process_name": "ApplyVectorConstraintTableProcess",
108
+ "Parameters": deepcopy(parameters.__dict__),
109
+ }
110
+
111
+ load_dict["Parameters"]["model_part_name"] = f"{global_domain}.{part_name}"
112
+ load_dict["Parameters"]["variable_name"] = variable_name
113
+
114
+ # get tables and values
115
+ _value, _table = IOUtils.create_value_and_table(part_name, parameters)
116
+ load_dict["Parameters"]["table"] = _table
117
+ load_dict["Parameters"]["value"] = _value
118
+
119
+ return load_dict
@@ -0,0 +1,115 @@
1
+ from typing import Any, Dict, Union
2
+
3
+ from stem.additional_processes import *
4
+
5
+
6
+ class KratosAdditionalProcessesIO:
7
+ """
8
+ Class containing methods for additional Kratos processes
9
+
10
+ Attributes:
11
+ - domain (str): name of the Kratos domain
12
+
13
+ """
14
+
15
+ def __init__(self, domain: str):
16
+ """
17
+ Constructor of KratosBoundariesIO class
18
+
19
+ Args:
20
+ - domain (str): name of the Kratos domain
21
+
22
+ """
23
+ self.domain = domain
24
+
25
+ def __create_excavation_dict(
26
+ self, part_name: str, parameters: Excavation
27
+ ) -> Dict[str, Any]:
28
+ """
29
+ Creates a dictionary containing the parameters for the excavation process
30
+
31
+ Args:
32
+ - part_name (str): part name where the excavation is applied
33
+ - parameters (:class:`stem.additional_processes.Excavation`): excavation parameters object
34
+
35
+ Returns:
36
+ - Dict[str, Any]: dictionary containing the additional process parameters
37
+ """
38
+
39
+ # initialize boundary dictionary
40
+ process_dict: Dict[str, Any] = {
41
+ "python_module": "apply_excavation_process",
42
+ "kratos_module": "KratosMultiphysics.GeoMechanicsApplication",
43
+ "process_name": "ApplyExcavationProcess",
44
+ "Parameters": {},
45
+ }
46
+
47
+ process_dict["Parameters"]["model_part_name"] = f"{self.domain}.{part_name}"
48
+ process_dict["Parameters"]["variable_name"] = "EXCAVATION"
49
+ process_dict["Parameters"]["deactivate_soil_part"] = parameters.deactivate_body_model_part
50
+
51
+ return process_dict
52
+
53
+ def __create_parameter_field_dict(
54
+ self, part_name: str, parameters: ParameterFieldParameters
55
+ ) -> Dict[str, Any]:
56
+ """
57
+ Creates a dictionary containing the parameters for the parameter field process
58
+
59
+ Args:
60
+ - part_name (str): part name where the parameter field is applied
61
+ - parameters (:class:`stem.additional_processes.ParameterFieldParameters`): parameter field parameters object
62
+
63
+ Returns:
64
+ - Dict[str, Any]: dictionary containing the additional process parameters
65
+ """
66
+
67
+ # initialize boundary dictionary
68
+ process_dict: Dict[str, Any] = {
69
+ "python_module": "set_parameter_field_process",
70
+ "kratos_module": "KratosMultiphysics.GeoMechanicsApplication",
71
+ "process_name": "SetParameterFieldProcess",
72
+ "Parameters": {},
73
+ }
74
+
75
+ process_dict["Parameters"]["model_part_name"] = f"{self.domain}.{part_name}"
76
+ process_dict["Parameters"]["variable_name"] = parameters.property_name
77
+ process_dict["Parameters"]["func_type"] = parameters.function_type
78
+
79
+ # initialise to dummy
80
+ process_dict["Parameters"]["function"] = "dummy"
81
+ process_dict["Parameters"]["dataset"] = "dummy"
82
+
83
+ if parameters.function_type == "json_file":
84
+
85
+ process_dict["Parameters"]["dataset_file_name"] = parameters.field_file_name
86
+ elif parameters.function_type == "input":
87
+ process_dict["Parameters"]["function"] = parameters.tiny_expr_function
88
+ else:
89
+ raise ValueError(f"function type {parameters.function_type} not supported.")
90
+
91
+ return process_dict
92
+
93
+ def create_additional_processes_dict(
94
+ self, part_name: str, parameters: AdditionalProcessesParametersABC
95
+ ) -> Union[Dict[str, Any], None]:
96
+ """
97
+ Creates a dictionary containing the boundary parameters
98
+
99
+ Args:
100
+ - part_name (str): part name where the boundary condition is applied
101
+ - parameters (:class:`stem.additional_processes.AdditionalProcessesParametersABC`): additional process \
102
+ parameters object
103
+
104
+ Returns:
105
+ - Dict[str, Any]: dictionary containing the parameters for the additional process
106
+ """
107
+
108
+ # add boundary parameters to dictionary based on boundary type.
109
+
110
+ if isinstance(parameters, Excavation):
111
+ return self.__create_excavation_dict(part_name, parameters)
112
+ elif isinstance(parameters, ParameterFieldParameters):
113
+ return self.__create_parameter_field_dict(part_name, parameters)
114
+ else:
115
+ raise NotImplementedError
@@ -0,0 +1,78 @@
1
+ from copy import deepcopy
2
+ from typing import Any, Dict, Union, List
3
+
4
+ from stem.boundary import *
5
+ from stem.IO.io_utils import IOUtils
6
+
7
+
8
+ class KratosBoundariesIO:
9
+ """
10
+ Class containing methods to write boundary conditions to Kratos
11
+
12
+ Attributes:
13
+ - domain (str): name of the Kratos domain
14
+
15
+ """
16
+
17
+ def __init__(self, domain: str):
18
+ """
19
+ Constructor of KratosBoundariesIO class
20
+
21
+ Args:
22
+ - domain (str): name of the Kratos domain
23
+
24
+ """
25
+ self.domain = domain
26
+
27
+ def __create_absorbing_boundary_dict(
28
+ self, part_name: str, parameters: AbsorbingBoundary
29
+ ) -> Dict[str, Any]:
30
+ """
31
+ Creates a dictionary containing the absorbing boundary parameters
32
+
33
+ Args:
34
+ - part_name (str): part name where the boundary condition is applied
35
+ - parameters (:class:`stem.boundary.AbsorbingBoundary`): absorbing boundary parameters object
36
+
37
+ Returns:
38
+ - Dict[str, Any]: dictionary containing the boundary parameters
39
+ """
40
+
41
+ # initialize boundary dictionary
42
+ boundary_dict: Dict[str, Any] = {
43
+ "python_module": "set_absorbing_boundary_parameters_process",
44
+ "kratos_module": "KratosMultiphysics.GeoMechanicsApplication",
45
+ "process_name": "SetAbsorbingBoundaryParametersProcess",
46
+ "Parameters": deepcopy(parameters.__dict__),
47
+ }
48
+
49
+ boundary_dict["Parameters"]["model_part_name"] = f"{self.domain}.{part_name}"
50
+
51
+ return boundary_dict
52
+
53
+ def create_boundary_condition_dict(
54
+ self, part_name: str, parameters: BoundaryParametersABC
55
+ ) -> Union[Dict[str, Any], None]:
56
+ """
57
+ Creates a dictionary containing the boundary parameters
58
+
59
+ Args:
60
+ - part_name (str): part name where the boundary condition is applied
61
+ - parameters (:class:`stem.boundary.BoundaryParametersABC`): boundary parameters object
62
+
63
+ Returns:
64
+ - Dict[str, Any]: dictionary containing the boundary parameters
65
+ """
66
+
67
+ # add boundary parameters to dictionary based on boundary type.
68
+
69
+ if isinstance(parameters, DisplacementConstraint):
70
+ return IOUtils.create_vector_constraint_table_process_dict(self.domain, part_name, parameters,
71
+ "DISPLACEMENT")
72
+ elif isinstance(parameters, RotationConstraint):
73
+ return IOUtils.create_vector_constraint_table_process_dict(self.domain, part_name, parameters,
74
+ "ROTATION")
75
+ elif isinstance(parameters, AbsorbingBoundary):
76
+ return self.__create_absorbing_boundary_dict(part_name, parameters)
77
+ else:
78
+ raise NotImplementedError