precice-case-generate 0.1.0__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 (42) hide show
  1. precice_case_generate-0.1.0/LICENSE +21 -0
  2. precice_case_generate-0.1.0/PKG-INFO +239 -0
  3. precice_case_generate-0.1.0/README.md +216 -0
  4. precice_case_generate-0.1.0/precice_case_generate.egg-info/PKG-INFO +239 -0
  5. precice_case_generate-0.1.0/precice_case_generate.egg-info/SOURCES.txt +40 -0
  6. precice_case_generate-0.1.0/precice_case_generate.egg-info/dependency_links.txt +1 -0
  7. precice_case_generate-0.1.0/precice_case_generate.egg-info/entry_points.txt +2 -0
  8. precice_case_generate-0.1.0/precice_case_generate.egg-info/requires.txt +9 -0
  9. precice_case_generate-0.1.0/precice_case_generate.egg-info/top_level.txt +1 -0
  10. precice_case_generate-0.1.0/precicecasegenerate/cli.py +72 -0
  11. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/myutils/UT_PCErrorLogging.py +20 -0
  12. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/myutils/__init__.py +1 -0
  13. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/precice_struct/PS_CouplingScheme.py +568 -0
  14. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/precice_struct/PS_Mesh.py +45 -0
  15. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/precice_struct/PS_ParticipantSolver.py +251 -0
  16. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/precice_struct/PS_PreCICEConfig.py +632 -0
  17. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/precice_struct/PS_QuantityCoupled.py +125 -0
  18. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/precice_struct/__init__.py +8 -0
  19. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/ui_struct/UI_Coupling.py +89 -0
  20. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/ui_struct/UI_Participant.py +46 -0
  21. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/ui_struct/UI_SimulationInfo.py +40 -0
  22. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/ui_struct/UI_UserInput.py +272 -0
  23. precice_case_generate-0.1.0/precicecasegenerate/controller_utils/ui_struct/__init__.py +2 -0
  24. precice_case_generate-0.1.0/precicecasegenerate/generation_utils/__init__.py +8 -0
  25. precice_case_generate-0.1.0/precicecasegenerate/generation_utils/adapter_config_generator.py +194 -0
  26. precice_case_generate-0.1.0/precicecasegenerate/generation_utils/config_generator.py +71 -0
  27. precice_case_generate-0.1.0/precicecasegenerate/generation_utils/file_generator.py +125 -0
  28. precice_case_generate-0.1.0/precicecasegenerate/generation_utils/format_precice_config.py +467 -0
  29. precice_case_generate-0.1.0/precicecasegenerate/generation_utils/logger.py +71 -0
  30. precice_case_generate-0.1.0/precicecasegenerate/generation_utils/other_files_generator.py +80 -0
  31. precice_case_generate-0.1.0/precicecasegenerate/generation_utils/readme_generator.py +124 -0
  32. precice_case_generate-0.1.0/precicecasegenerate/generation_utils/structure_handler.py +110 -0
  33. precice_case_generate-0.1.0/precicecasegenerate/schemas/README.md +127 -0
  34. precice_case_generate-0.1.0/precicecasegenerate/schemas/topology-schema.json +228 -0
  35. precice_case_generate-0.1.0/precicecasegenerate/templates/adapter-config-template.json +12 -0
  36. precice_case_generate-0.1.0/precicecasegenerate/templates/metaConfiguratorSettings.json +115 -0
  37. precice_case_generate-0.1.0/precicecasegenerate/templates/template_README.md +104 -0
  38. precice_case_generate-0.1.0/precicecasegenerate/templates/template_clean.sh +199 -0
  39. precice_case_generate-0.1.0/precicecasegenerate/templates/template_run.sh +20 -0
  40. precice_case_generate-0.1.0/pyproject.toml +58 -0
  41. precice_case_generate-0.1.0/setup.cfg +4 -0
  42. precice_case_generate-0.1.0/tests/test_examples.py +35 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Karlo Blazevic Thore Schweikert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: precice-case-generate
3
+ Version: 0.1.0
4
+ Summary: Generates File and Folder Structure, including all of the necessary files to quickly kickstart a simulation
5
+ Author-email: VanLaareN <vanlaren@example.com>, Toddelismyname <116207910+Toddelismyname@users.noreply.github.com>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/precice-forschungsprojekt/precice-generator
8
+ Project-URL: Issues, https://github.com/precice-forschungsprojekt/precice-generator/issues
9
+ Project-URL: Documentation, https://github.com/precice-forschungsprojekt/precice-generator/blob/main/README.md
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: attrs>=25.3
14
+ Requires-Dist: jsonschema>=4.23
15
+ Requires-Dist: jsonschema-specifications>=2024.10
16
+ Requires-Dist: lxml>=5.3
17
+ Requires-Dist: ruamel_yaml
18
+ Requires-Dist: referencing>=0.36
19
+ Requires-Dist: rpds-py>=0.24
20
+ Requires-Dist: termcolor>=3
21
+ Requires-Dist: typing_extensions>=4.13
22
+ Dynamic: license-file
23
+
24
+ # precice-generator
25
+
26
+ ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/precice/case-generate/check.yml?label=Examples%20generation%20and%20validation%20using%20config-checker)
27
+
28
+ ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/precice/case-generate/installation.yml?label=Installation%20Checker)
29
+
30
+ ![GitHub License](https://img.shields.io/github/license/precice/case-generate)
31
+
32
+ ## Project Overview
33
+
34
+ The preCICE case-generate package is a Python-based utility designed to automate the generation of preCICE configuration files from
35
+ simple YAML topology descriptions. This tool simplifies the process of setting up multi-physics simulations by transforming
36
+ user-defined YAML configurations into preCICE-compatible XML configuration files.
37
+
38
+ ## Key Features
39
+
40
+ - Automated preCICE configuration generation
41
+ - YAML-based input parsing
42
+ - Flexible topology description support
43
+ - Comprehensive error logging and handling
44
+ - Simple command-line interface
45
+
46
+ ## Installation
47
+
48
+ ### Prerequisites
49
+
50
+ - Python 3.9 or
51
+ higher ([workflow validated](https://github.com/precice/case-generate/actions/workflows/installation.yml)
52
+ with 3.9, 3.10, 3.11 and 3.12)
53
+ - pip
54
+ - venv
55
+ - (preCICE library)
56
+
57
+ ### Manual Installation
58
+
59
+ 1. Clone the repository
60
+
61
+ ```bash
62
+ git clone https://github.com/precice/case-generate.git
63
+ cd precice-generator
64
+ ```
65
+
66
+ 2. Create a virtual environment
67
+
68
+ ```bash
69
+ # On Unix/macOS
70
+ python -m venv venv
71
+ source venv/bin/activate
72
+
73
+ # On Windows
74
+ python -m venv venv
75
+ .\venv\Scripts\activate
76
+ ```
77
+
78
+ 3. Install the project
79
+
80
+ ```bash
81
+ # Upgrade pip and install build tools
82
+ python -m pip install --upgrade pip
83
+ pip install build
84
+
85
+ # Install the project in editable mode
86
+ pip install -e .
87
+ ```
88
+
89
+ ### Using Setup Scripts
90
+
91
+ #### Unix/macOS
92
+
93
+ ```bash
94
+ ./setup_scripts/install_dependencies.sh
95
+ ```
96
+
97
+ #### Windows
98
+
99
+ ```powershell
100
+ .\setup_scripts\install_dependencies.ps1
101
+ ```
102
+
103
+ ### Verifying Installation
104
+
105
+ - Test the CLI tool
106
+
107
+ ```bash
108
+ precice-case-generate --help
109
+ ```
110
+
111
+ ## Usage
112
+
113
+ ### Command-Line Interface
114
+
115
+ Generate a preCICE configuration file from a YAML topology called `topology.yaml`:
116
+
117
+ ```bash
118
+ precice-case-generate
119
+ ```
120
+
121
+ or pass a topology file via argument;
122
+
123
+ ```bash
124
+ precice-case-generate -f path/to/your/topology.yaml
125
+ ```
126
+
127
+ The `precice-case-generate` tool supports the following optional parameters:
128
+
129
+ - `-f, --input-file`: Path to the input topology.yaml file.
130
+ - **Default**: `./topology.yaml`
131
+ - **Description**: Specify a custom topology file for configuration generation.
132
+
133
+ - `-o, --output-path`: Destination path for the generated folder.
134
+ - **Default**: `./_generated/`
135
+ - **Description**: Choose a specific output location for generated files.
136
+
137
+ - `-v, --verbose`: Enable verbose logging.
138
+ - **Default**: Disabled
139
+ - **Description**: Provides detailed logging information during execution.
140
+
141
+ - `--validate-topology`: Validate the input topology.yaml against the preCICE topology schema.
142
+ - **Default**: Enabled
143
+ - **Description**: Ensures the topology file meets the required schema specifications.
144
+
145
+ Example usage:
146
+ ```bash
147
+ precice-case-generate -f custom_topology.yaml -o /path/to/output -v
148
+ ```
149
+
150
+ > [!NOTE]
151
+ > You should validate your files by running them through precice-tools and the
152
+ > preCICE [config-checker](https://github.com/precice/case-generate) to avoid errors.
153
+
154
+ ### Configuration
155
+
156
+ 1. Prepare a YAML topology file describing your multi-physics simulation setup.
157
+ 2. Use the command-line interface to generate the preCICE configuration.
158
+ 3. The tool will create the necessary configuration files in the `_generated/` directory.
159
+
160
+ ## Creating Topology with MetaConfigurator
161
+
162
+ You can create a topology for your preCICE simulation using the online MetaConfigurator.
163
+ We provide a preloaded schema to help you get started:
164
+
165
+ 1. Open the MetaConfigurator with the preloaded
166
+ schema: [MetaConfigurator Link](https://metaconfigurator.github.io/meta-configurator/?schema=https://github.com/precice/case-generate/blob/main/schemas/topology-schema.json&settings=https://github.com/precice/case-generate/blob/main/templates/metaConfiguratorSettings.json)
167
+
168
+ 2. Use the interactive interface to define your topology:
169
+ - The preloaded schema provides a structured way to describe your simulation components
170
+ - Add configuration details on the right side of the screen
171
+
172
+ 3. Once complete, export your topology as a YAML file
173
+ - Save the generated YAML file
174
+ - Use this file with the `precice-generator` tool to create your preCICE configuration
175
+ - Validate the generated preCICE config
176
+ with [config-checker](https://github.com/precice/config-check)
177
+ - Use `precice-config-checker` and/or `precice-tools check` to validate the generated preCICE config
178
+
179
+ ### Benefits of Using MetaConfigurator
180
+
181
+ - Visual, user-friendly interface
182
+ - Real-time validation against our predefined schema
183
+ - Reduces manual configuration errors
184
+ - Simplifies topology creation process
185
+
186
+ ## Example Configurations
187
+
188
+ ### Normal Examples (0-5)
189
+
190
+ Our project provides a set of progressively complex example configurations to help you get started with preCICE
191
+ simulations:
192
+
193
+ - Located in `examples/0` through `examples/5`
194
+ - Designed for beginners and intermediate users
195
+ - Each example includes:
196
+ - A `topology.yaml` file defining the simulation setup
197
+ - A `precice-config.xml` file
198
+ - Subdirectories for different simulation components
199
+ - Showcase simple, linear multi-physics scenarios
200
+ - Ideal for learning basic preCICE configuration concepts
201
+
202
+ ### Expert Examples
203
+
204
+ For advanced users, we offer more sophisticated configuration examples:
205
+
206
+ - Located in `examples/expert`
207
+ - Contain more advanced usage of topology options but extend the according example with the same number
208
+ - Demonstrate advanced coupling strategies and intricate topology configurations
209
+ - Targeted at users with a better understanding of preCICE
210
+
211
+ > [!TIP]
212
+ > Start with normal examples (0-5) and progress to expert examples as you become more comfortable with preCICE
213
+ > configurations.
214
+
215
+ ## Documentation
216
+
217
+ The template for our `topology.yaml` file can be found in the `schemas` folder.
218
+
219
+ Alongside it, you will find `README.md`, which explains the topology's parameters.
220
+
221
+ ## Contributing
222
+
223
+ 1. Fork the repository
224
+ 2. Create a feature branch (`git checkout -b feature/new-feature`)
225
+ 3. Commit your changes (`git commit -m 'Add new feature'`)
226
+ 4. Push to the branch (`git push origin feature/new-feature`)
227
+ 5. Open a Pull Request
228
+
229
+ ## Troubleshooting
230
+
231
+ - Ensure all dependencies are correctly installed
232
+ - Verify the format of your input YAML file
233
+ - Check the generated logs for detailed error information
234
+
235
+ ## Acknowledgements
236
+
237
+ This project was started with code from the [preCICE controller](https://github.com/precice/controller) repository.
238
+ The file `format_precice_config.py` was taken
239
+ from [preCICE pre-commit hook file](https://github.com/precice/precice-pre-commit-hooks/blob/main/format_precice_config/format_precice_config.py)
@@ -0,0 +1,216 @@
1
+ # precice-generator
2
+
3
+ ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/precice/case-generate/check.yml?label=Examples%20generation%20and%20validation%20using%20config-checker)
4
+
5
+ ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/precice/case-generate/installation.yml?label=Installation%20Checker)
6
+
7
+ ![GitHub License](https://img.shields.io/github/license/precice/case-generate)
8
+
9
+ ## Project Overview
10
+
11
+ The preCICE case-generate package is a Python-based utility designed to automate the generation of preCICE configuration files from
12
+ simple YAML topology descriptions. This tool simplifies the process of setting up multi-physics simulations by transforming
13
+ user-defined YAML configurations into preCICE-compatible XML configuration files.
14
+
15
+ ## Key Features
16
+
17
+ - Automated preCICE configuration generation
18
+ - YAML-based input parsing
19
+ - Flexible topology description support
20
+ - Comprehensive error logging and handling
21
+ - Simple command-line interface
22
+
23
+ ## Installation
24
+
25
+ ### Prerequisites
26
+
27
+ - Python 3.9 or
28
+ higher ([workflow validated](https://github.com/precice/case-generate/actions/workflows/installation.yml)
29
+ with 3.9, 3.10, 3.11 and 3.12)
30
+ - pip
31
+ - venv
32
+ - (preCICE library)
33
+
34
+ ### Manual Installation
35
+
36
+ 1. Clone the repository
37
+
38
+ ```bash
39
+ git clone https://github.com/precice/case-generate.git
40
+ cd precice-generator
41
+ ```
42
+
43
+ 2. Create a virtual environment
44
+
45
+ ```bash
46
+ # On Unix/macOS
47
+ python -m venv venv
48
+ source venv/bin/activate
49
+
50
+ # On Windows
51
+ python -m venv venv
52
+ .\venv\Scripts\activate
53
+ ```
54
+
55
+ 3. Install the project
56
+
57
+ ```bash
58
+ # Upgrade pip and install build tools
59
+ python -m pip install --upgrade pip
60
+ pip install build
61
+
62
+ # Install the project in editable mode
63
+ pip install -e .
64
+ ```
65
+
66
+ ### Using Setup Scripts
67
+
68
+ #### Unix/macOS
69
+
70
+ ```bash
71
+ ./setup_scripts/install_dependencies.sh
72
+ ```
73
+
74
+ #### Windows
75
+
76
+ ```powershell
77
+ .\setup_scripts\install_dependencies.ps1
78
+ ```
79
+
80
+ ### Verifying Installation
81
+
82
+ - Test the CLI tool
83
+
84
+ ```bash
85
+ precice-case-generate --help
86
+ ```
87
+
88
+ ## Usage
89
+
90
+ ### Command-Line Interface
91
+
92
+ Generate a preCICE configuration file from a YAML topology called `topology.yaml`:
93
+
94
+ ```bash
95
+ precice-case-generate
96
+ ```
97
+
98
+ or pass a topology file via argument;
99
+
100
+ ```bash
101
+ precice-case-generate -f path/to/your/topology.yaml
102
+ ```
103
+
104
+ The `precice-case-generate` tool supports the following optional parameters:
105
+
106
+ - `-f, --input-file`: Path to the input topology.yaml file.
107
+ - **Default**: `./topology.yaml`
108
+ - **Description**: Specify a custom topology file for configuration generation.
109
+
110
+ - `-o, --output-path`: Destination path for the generated folder.
111
+ - **Default**: `./_generated/`
112
+ - **Description**: Choose a specific output location for generated files.
113
+
114
+ - `-v, --verbose`: Enable verbose logging.
115
+ - **Default**: Disabled
116
+ - **Description**: Provides detailed logging information during execution.
117
+
118
+ - `--validate-topology`: Validate the input topology.yaml against the preCICE topology schema.
119
+ - **Default**: Enabled
120
+ - **Description**: Ensures the topology file meets the required schema specifications.
121
+
122
+ Example usage:
123
+ ```bash
124
+ precice-case-generate -f custom_topology.yaml -o /path/to/output -v
125
+ ```
126
+
127
+ > [!NOTE]
128
+ > You should validate your files by running them through precice-tools and the
129
+ > preCICE [config-checker](https://github.com/precice/case-generate) to avoid errors.
130
+
131
+ ### Configuration
132
+
133
+ 1. Prepare a YAML topology file describing your multi-physics simulation setup.
134
+ 2. Use the command-line interface to generate the preCICE configuration.
135
+ 3. The tool will create the necessary configuration files in the `_generated/` directory.
136
+
137
+ ## Creating Topology with MetaConfigurator
138
+
139
+ You can create a topology for your preCICE simulation using the online MetaConfigurator.
140
+ We provide a preloaded schema to help you get started:
141
+
142
+ 1. Open the MetaConfigurator with the preloaded
143
+ schema: [MetaConfigurator Link](https://metaconfigurator.github.io/meta-configurator/?schema=https://github.com/precice/case-generate/blob/main/schemas/topology-schema.json&settings=https://github.com/precice/case-generate/blob/main/templates/metaConfiguratorSettings.json)
144
+
145
+ 2. Use the interactive interface to define your topology:
146
+ - The preloaded schema provides a structured way to describe your simulation components
147
+ - Add configuration details on the right side of the screen
148
+
149
+ 3. Once complete, export your topology as a YAML file
150
+ - Save the generated YAML file
151
+ - Use this file with the `precice-generator` tool to create your preCICE configuration
152
+ - Validate the generated preCICE config
153
+ with [config-checker](https://github.com/precice/config-check)
154
+ - Use `precice-config-checker` and/or `precice-tools check` to validate the generated preCICE config
155
+
156
+ ### Benefits of Using MetaConfigurator
157
+
158
+ - Visual, user-friendly interface
159
+ - Real-time validation against our predefined schema
160
+ - Reduces manual configuration errors
161
+ - Simplifies topology creation process
162
+
163
+ ## Example Configurations
164
+
165
+ ### Normal Examples (0-5)
166
+
167
+ Our project provides a set of progressively complex example configurations to help you get started with preCICE
168
+ simulations:
169
+
170
+ - Located in `examples/0` through `examples/5`
171
+ - Designed for beginners and intermediate users
172
+ - Each example includes:
173
+ - A `topology.yaml` file defining the simulation setup
174
+ - A `precice-config.xml` file
175
+ - Subdirectories for different simulation components
176
+ - Showcase simple, linear multi-physics scenarios
177
+ - Ideal for learning basic preCICE configuration concepts
178
+
179
+ ### Expert Examples
180
+
181
+ For advanced users, we offer more sophisticated configuration examples:
182
+
183
+ - Located in `examples/expert`
184
+ - Contain more advanced usage of topology options but extend the according example with the same number
185
+ - Demonstrate advanced coupling strategies and intricate topology configurations
186
+ - Targeted at users with a better understanding of preCICE
187
+
188
+ > [!TIP]
189
+ > Start with normal examples (0-5) and progress to expert examples as you become more comfortable with preCICE
190
+ > configurations.
191
+
192
+ ## Documentation
193
+
194
+ The template for our `topology.yaml` file can be found in the `schemas` folder.
195
+
196
+ Alongside it, you will find `README.md`, which explains the topology's parameters.
197
+
198
+ ## Contributing
199
+
200
+ 1. Fork the repository
201
+ 2. Create a feature branch (`git checkout -b feature/new-feature`)
202
+ 3. Commit your changes (`git commit -m 'Add new feature'`)
203
+ 4. Push to the branch (`git push origin feature/new-feature`)
204
+ 5. Open a Pull Request
205
+
206
+ ## Troubleshooting
207
+
208
+ - Ensure all dependencies are correctly installed
209
+ - Verify the format of your input YAML file
210
+ - Check the generated logs for detailed error information
211
+
212
+ ## Acknowledgements
213
+
214
+ This project was started with code from the [preCICE controller](https://github.com/precice/controller) repository.
215
+ The file `format_precice_config.py` was taken
216
+ from [preCICE pre-commit hook file](https://github.com/precice/precice-pre-commit-hooks/blob/main/format_precice_config/format_precice_config.py)