pycphy 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl

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 (67) hide show
  1. pycphy/__init__.py +11 -0
  2. pycphy/cli.py +145 -0
  3. pycphy/config_manager.py +373 -0
  4. pycphy/foamCaseDeveloper/__init__.py +60 -41
  5. pycphy/foamCaseDeveloper/config/__init__.py +69 -26
  6. pycphy/foamCaseDeveloper/config/cad_mesh_config.py +62 -0
  7. pycphy/foamCaseDeveloper/config/config_hfdibdem.py +193 -0
  8. pycphy/foamCaseDeveloper/config/constant/__init__.py +23 -0
  9. pycphy/foamCaseDeveloper/config/constant/dynamic_mesh_config.py +208 -0
  10. pycphy/foamCaseDeveloper/config/constant/gravity_field_config.py +379 -0
  11. pycphy/foamCaseDeveloper/config/constant/transport_properties_config.py +225 -0
  12. pycphy/foamCaseDeveloper/config/constant/turbulence_config.py +617 -0
  13. pycphy/foamCaseDeveloper/config/csv_boundary_reader.py +219 -0
  14. pycphy/foamCaseDeveloper/config/system/__init__.py +31 -0
  15. pycphy/foamCaseDeveloper/config/system/block_mesh_config.py +184 -0
  16. pycphy/foamCaseDeveloper/config/{control_config.py → system/control_config.py} +113 -1
  17. pycphy/foamCaseDeveloper/config/system/decompose_par_config.py +525 -0
  18. pycphy/foamCaseDeveloper/config/system/fv_options_config.py +575 -0
  19. pycphy/foamCaseDeveloper/config/system/fv_schemes_config.py +363 -0
  20. pycphy/foamCaseDeveloper/config/system/set_fields_config.py +640 -0
  21. pycphy/foamCaseDeveloper/config/system/snappy_hex_mesh_config.py +241 -0
  22. pycphy/foamCaseDeveloper/config/zero/U_config.py +135 -0
  23. pycphy/foamCaseDeveloper/config/zero/__init__.py +22 -0
  24. pycphy/foamCaseDeveloper/config/zero/f_config.py +140 -0
  25. pycphy/foamCaseDeveloper/config/zero/lambda_config.py +157 -0
  26. pycphy/foamCaseDeveloper/config/zero/p_config.py +97 -0
  27. pycphy/foamCaseDeveloper/core/__init__.py +30 -18
  28. pycphy/foamCaseDeveloper/core/block_mesh_developer.py +1 -1
  29. pycphy/foamCaseDeveloper/core/cad_block_mesh_developer.py +463 -0
  30. pycphy/foamCaseDeveloper/core/case_builder.py +1217 -0
  31. pycphy/foamCaseDeveloper/core/foam_case_manager.py +370 -111
  32. pycphy/foamCaseDeveloper/develop_case.py +640 -0
  33. pycphy/foamCaseDeveloper/main.py +260 -260
  34. pycphy/foamCaseDeveloper/utils/myAutoCAD.py +418 -0
  35. pycphy/foamCaseDeveloper/writers/__init__.py +37 -4
  36. pycphy/foamCaseDeveloper/writers/constant/__init__.py +25 -0
  37. pycphy/foamCaseDeveloper/writers/constant/dynamic_mesh_dict_writer.py +75 -0
  38. pycphy/foamCaseDeveloper/writers/constant/gravity_field_writer.py +88 -0
  39. pycphy/foamCaseDeveloper/writers/constant/hfdibdem_dict_writer.py +81 -0
  40. pycphy/foamCaseDeveloper/writers/constant/transport_properties_writer.py +202 -0
  41. pycphy/foamCaseDeveloper/writers/{turbulence_properties_writer.py → constant/turbulence_properties_writer.py} +49 -1
  42. pycphy/foamCaseDeveloper/writers/system/__init__.py +31 -0
  43. pycphy/foamCaseDeveloper/writers/{block_mesh_writer.py → system/block_mesh_writer.py} +1 -1
  44. pycphy/foamCaseDeveloper/writers/{control_dict_writer.py → system/control_dict_writer.py} +37 -1
  45. pycphy/foamCaseDeveloper/writers/system/decompose_par_writer.py +228 -0
  46. pycphy/foamCaseDeveloper/writers/system/fv_options_writer.py +188 -0
  47. pycphy/foamCaseDeveloper/writers/system/fv_schemes_writer.py +155 -0
  48. pycphy/foamCaseDeveloper/writers/system/set_fields_writer.py +191 -0
  49. pycphy/foamCaseDeveloper/writers/system/snappy_hex_mesh_writer.py +123 -0
  50. pycphy/foamCaseDeveloper/writers/zero/__init__.py +24 -0
  51. pycphy/foamCaseDeveloper/writers/zero/f_field_writer.py +89 -0
  52. pycphy/foamCaseDeveloper/writers/zero/lambda_field_writer.py +84 -0
  53. pycphy/foamCaseDeveloper/writers/zero/p_field_writer.py +89 -0
  54. pycphy/foamCaseDeveloper/writers/zero/u_field_writer.py +96 -0
  55. pycphy/foamCaseDeveloper/writers/zero/zero_field_factory.py +388 -0
  56. {pycphy-0.1.0.dist-info → pycphy-0.2.0.dist-info}/METADATA +154 -6
  57. pycphy-0.2.0.dist-info/RECORD +63 -0
  58. pycphy-0.2.0.dist-info/entry_points.txt +3 -0
  59. pycphy/foamCaseDeveloper/config/block_mesh_config.py +0 -90
  60. pycphy/foamCaseDeveloper/config/turbulence_config.py +0 -187
  61. pycphy/foamCaseDeveloper/core/control_dict_writer.py +0 -55
  62. pycphy/foamCaseDeveloper/core/turbulence_properties_writer.py +0 -68
  63. pycphy-0.1.0.dist-info/RECORD +0 -24
  64. pycphy-0.1.0.dist-info/entry_points.txt +0 -2
  65. {pycphy-0.1.0.dist-info → pycphy-0.2.0.dist-info}/WHEEL +0 -0
  66. {pycphy-0.1.0.dist-info → pycphy-0.2.0.dist-info}/licenses/LICENSE +0 -0
  67. {pycphy-0.1.0.dist-info → pycphy-0.2.0.dist-info}/top_level.txt +0 -0
@@ -1,260 +1,260 @@
1
- # main.py
2
-
3
- """
4
- Main entry point for the foamCaseDeveloper module.
5
-
6
- This script provides a command-line interface for creating OpenFOAM cases
7
- using the foamCaseDeveloper tools.
8
- """
9
-
10
- import argparse
11
- import sys
12
- import os
13
-
14
- from .core import FoamCaseManager
15
- from .config import global_config, block_mesh_config, control_config, turbulence_config
16
-
17
- def create_example_case():
18
- """
19
- Create an example OpenFOAM case with default settings from config files.
20
-
21
- Returns:
22
- bool: True if successful, False otherwise.
23
- """
24
- print("Creating example OpenFOAM case from config files...")
25
-
26
- # Initialize case manager with global config
27
- case_manager = FoamCaseManager(global_config.case_name)
28
-
29
- # Set up geometry from config file
30
- case_manager.setup_geometry(
31
- p0=block_mesh_config.p0,
32
- p1=block_mesh_config.p1,
33
- cells=block_mesh_config.cells,
34
- patch_names=block_mesh_config.patch_names,
35
- scale=block_mesh_config.scale
36
- )
37
-
38
- # Set up control from config file
39
- case_manager.setup_control(control_config.control_params)
40
-
41
- # Set up turbulence from config file
42
- sim_type = turbulence_config.SIMULATION_TYPE
43
- if sim_type == "RAS":
44
- model_props = turbulence_config.RAS_PROPERTIES
45
- elif sim_type == "LES":
46
- model_props = turbulence_config.LES_PROPERTIES
47
- elif sim_type == "laminar":
48
- model_props = turbulence_config.LAMINAR_PROPERTIES
49
- else:
50
- print(f"Warning: Unknown simulation type '{sim_type}'. Using laminar.")
51
- sim_type = "laminar"
52
- model_props = {}
53
-
54
- case_manager.setup_turbulence(
55
- simulation_type=sim_type,
56
- model_properties=model_props
57
- )
58
-
59
- # Create the complete case
60
- return case_manager.create_full_case()
61
-
62
- def create_custom_case(case_name, geometry_file=None, control_file=None, turbulence_file=None):
63
- """
64
- Create a custom OpenFOAM case from configuration files.
65
-
66
- Args:
67
- case_name (str): Name of the case directory.
68
- geometry_file (str): Path to geometry configuration file.
69
- control_file (str): Path to control configuration file.
70
- turbulence_file (str): Path to turbulence configuration file.
71
-
72
- Returns:
73
- bool: True if successful, False otherwise.
74
- """
75
- print(f"Creating custom OpenFOAM case '{case_name}'...")
76
-
77
- # Initialize case manager
78
- case_manager = FoamCaseManager(case_name)
79
-
80
- # Load geometry configuration
81
- if geometry_file and os.path.exists(geometry_file):
82
- try:
83
- # Import the geometry configuration
84
- import importlib.util
85
- spec = importlib.util.spec_from_file_location("geometry_config", geometry_file)
86
- geometry_module = importlib.util.module_from_spec(spec)
87
- spec.loader.exec_module(geometry_module)
88
-
89
- geometry_config = BlockMeshConfig(
90
- p0=geometry_module.p0,
91
- p1=geometry_module.p1,
92
- cells=geometry_module.cells,
93
- patch_names=geometry_module.patch_names,
94
- scale=getattr(geometry_module, 'scale', 1.0)
95
- )
96
-
97
- case_manager.setup_geometry(
98
- p0=geometry_config.p0,
99
- p1=geometry_config.p1,
100
- cells=geometry_config.cells,
101
- patch_names=geometry_config.patch_names,
102
- scale=geometry_config.scale
103
- )
104
-
105
- except Exception as e:
106
- print(f"Error loading geometry configuration: {e}")
107
- return False
108
- else:
109
- print("No geometry configuration file provided, using defaults.")
110
- geometry_config = BlockMeshConfig()
111
- case_manager.setup_geometry(
112
- p0=geometry_config.p0,
113
- p1=geometry_config.p1,
114
- cells=geometry_config.cells,
115
- patch_names=geometry_config.patch_names,
116
- scale=geometry_config.scale
117
- )
118
-
119
- # Load control configuration
120
- if control_file and os.path.exists(control_file):
121
- try:
122
- # Import the control configuration
123
- import importlib.util
124
- spec = importlib.util.spec_from_file_location("control_config", control_file)
125
- control_module = importlib.util.module_from_spec(spec)
126
- spec.loader.exec_module(control_module)
127
-
128
- case_manager.setup_control(control_module.control_params)
129
-
130
- except Exception as e:
131
- print(f"Error loading control configuration: {e}")
132
- return False
133
- else:
134
- print("No control configuration file provided, using defaults.")
135
- control_config = ControlConfig()
136
- case_manager.setup_control(control_config.get_parameters())
137
-
138
- # Load turbulence configuration
139
- if turbulence_file and os.path.exists(turbulence_file):
140
- try:
141
- # Import the turbulence configuration
142
- import importlib.util
143
- spec = importlib.util.spec_from_file_location("turbulence_config", turbulence_file)
144
- turbulence_module = importlib.util.module_from_spec(spec)
145
- spec.loader.exec_module(turbulence_module)
146
-
147
- sim_type = turbulence_module.SIMULATION_TYPE
148
- if sim_type == "RAS":
149
- model_props = turbulence_module.RAS_PROPERTIES
150
- elif sim_type == "LES":
151
- model_props = turbulence_module.LES_PROPERTIES
152
- elif sim_type == "laminar":
153
- model_props = turbulence_module.LAMINAR_PROPERTIES
154
- else:
155
- print(f"Warning: Unknown simulation type '{sim_type}'. Using laminar.")
156
- sim_type = "laminar"
157
- model_props = {}
158
-
159
- case_manager.setup_turbulence(
160
- simulation_type=sim_type,
161
- model_properties=model_props
162
- )
163
-
164
- except Exception as e:
165
- print(f"Error loading turbulence configuration: {e}")
166
- return False
167
- else:
168
- print("No turbulence configuration file provided, using defaults.")
169
- turbulence_config = TurbulenceConfig()
170
- case_manager.setup_turbulence(
171
- simulation_type=turbulence_config.get_simulation_type(),
172
- model_properties=turbulence_config.get_model_properties()
173
- )
174
-
175
- # Create the complete case
176
- return case_manager.create_full_case()
177
-
178
- def main():
179
- """
180
- Main entry point for the command-line interface.
181
- """
182
- parser = argparse.ArgumentParser(
183
- description="OpenFOAM Case Developer - Create OpenFOAM cases with Python",
184
- formatter_class=argparse.RawDescriptionHelpFormatter,
185
- epilog="""
186
- Examples:
187
- # Create an example case
188
- pycphy-foam --example
189
-
190
- # Create a custom case from configuration files
191
- pycphy-foam --case myCase --geometry configBlockMesh.py --control configControl.py --turbulence configTurbulence.py
192
-
193
- # Create a case with just geometry configuration
194
- pycphy-foam --case myCase --geometry configBlockMesh.py
195
- """
196
- )
197
-
198
- parser.add_argument(
199
- "--example",
200
- action="store_true",
201
- help="Create an example OpenFOAM case with default settings"
202
- )
203
-
204
- parser.add_argument(
205
- "--case",
206
- type=str,
207
- help="Name of the OpenFOAM case directory to create"
208
- )
209
-
210
- parser.add_argument(
211
- "--geometry",
212
- type=str,
213
- help="Path to geometry configuration file (Python module)"
214
- )
215
-
216
- parser.add_argument(
217
- "--control",
218
- type=str,
219
- help="Path to control configuration file (Python module)"
220
- )
221
-
222
- parser.add_argument(
223
- "--turbulence",
224
- type=str,
225
- help="Path to turbulence configuration file (Python module)"
226
- )
227
-
228
- args = parser.parse_args()
229
-
230
- # Validate arguments
231
- if args.example and args.case:
232
- print("Error: Cannot specify both --example and --case options.")
233
- sys.exit(1)
234
-
235
- if not args.example and not args.case:
236
- print("Error: Must specify either --example or --case option.")
237
- sys.exit(1)
238
-
239
- # Create the case
240
- success = False
241
-
242
- if args.example:
243
- success = create_example_case()
244
- else:
245
- success = create_custom_case(
246
- case_name=args.case,
247
- geometry_file=args.geometry,
248
- control_file=args.control,
249
- turbulence_file=args.turbulence
250
- )
251
-
252
- if success:
253
- print("\nOpenFOAM case creation completed successfully!")
254
- sys.exit(0)
255
- else:
256
- print("\nOpenFOAM case creation failed!")
257
- sys.exit(1)
258
-
259
- if __name__ == "__main__":
260
- main()
1
+ # main.py
2
+
3
+ """
4
+ Main entry point for the foamCaseDeveloper module.
5
+
6
+ This script provides a command-line interface for creating OpenFOAM cases
7
+ using the foamCaseDeveloper tools.
8
+ """
9
+
10
+ import argparse
11
+ import sys
12
+ import os
13
+
14
+ from .core import FoamCaseManager
15
+ from .config import global_config, block_mesh_config, control_config, turbulence_config
16
+
17
+ def create_example_case():
18
+ """
19
+ Create an example OpenFOAM case with default settings from config files.
20
+
21
+ Returns:
22
+ bool: True if successful, False otherwise.
23
+ """
24
+ print("Creating example OpenFOAM case from config files...")
25
+
26
+ # Initialize case manager with global config
27
+ case_manager = FoamCaseManager(global_config.case_name)
28
+
29
+ # Set up geometry from config file
30
+ case_manager.setup_geometry(
31
+ p0=block_mesh_config.p0,
32
+ p1=block_mesh_config.p1,
33
+ cells=block_mesh_config.cells,
34
+ patch_names=block_mesh_config.patch_names,
35
+ scale=block_mesh_config.scale
36
+ )
37
+
38
+ # Set up control from config file
39
+ case_manager.setup_control(control_config.control_params)
40
+
41
+ # Set up turbulence from config file
42
+ sim_type = turbulence_config.SIMULATION_TYPE
43
+ if sim_type == "RAS":
44
+ model_props = turbulence_config.RAS_PROPERTIES
45
+ elif sim_type == "LES":
46
+ model_props = turbulence_config.LES_PROPERTIES
47
+ elif sim_type == "laminar":
48
+ model_props = turbulence_config.LAMINAR_PROPERTIES
49
+ else:
50
+ print(f"Warning: Unknown simulation type '{sim_type}'. Using laminar.")
51
+ sim_type = "laminar"
52
+ model_props = {}
53
+
54
+ case_manager.setup_turbulence(
55
+ simulation_type=sim_type,
56
+ model_properties=model_props
57
+ )
58
+
59
+ # Create the complete case
60
+ return case_manager.create_full_case()
61
+
62
+ def create_custom_case(case_name, geometry_file=None, control_file=None, turbulence_file=None):
63
+ """
64
+ Create a custom OpenFOAM case from configuration files.
65
+
66
+ Args:
67
+ case_name (str): Name of the case directory.
68
+ geometry_file (str): Path to geometry configuration file.
69
+ control_file (str): Path to control configuration file.
70
+ turbulence_file (str): Path to turbulence configuration file.
71
+
72
+ Returns:
73
+ bool: True if successful, False otherwise.
74
+ """
75
+ print(f"Creating custom OpenFOAM case '{case_name}'...")
76
+
77
+ # Initialize case manager
78
+ case_manager = FoamCaseManager(case_name)
79
+
80
+ # Load geometry configuration
81
+ if geometry_file and os.path.exists(geometry_file):
82
+ try:
83
+ # Import the geometry configuration
84
+ import importlib.util
85
+ spec = importlib.util.spec_from_file_location("geometry_config", geometry_file)
86
+ geometry_module = importlib.util.module_from_spec(spec)
87
+ spec.loader.exec_module(geometry_module)
88
+
89
+ geometry_config = BlockMeshConfig(
90
+ p0=geometry_module.p0,
91
+ p1=geometry_module.p1,
92
+ cells=geometry_module.cells,
93
+ patch_names=geometry_module.patch_names,
94
+ scale=getattr(geometry_module, 'scale', 1.0)
95
+ )
96
+
97
+ case_manager.setup_geometry(
98
+ p0=geometry_config.p0,
99
+ p1=geometry_config.p1,
100
+ cells=geometry_config.cells,
101
+ patch_names=geometry_config.patch_names,
102
+ scale=geometry_config.scale
103
+ )
104
+
105
+ except Exception as e:
106
+ print(f"Error loading geometry configuration: {e}")
107
+ return False
108
+ else:
109
+ print("No geometry configuration file provided, using defaults.")
110
+ geometry_config = BlockMeshConfig()
111
+ case_manager.setup_geometry(
112
+ p0=geometry_config.p0,
113
+ p1=geometry_config.p1,
114
+ cells=geometry_config.cells,
115
+ patch_names=geometry_config.patch_names,
116
+ scale=geometry_config.scale
117
+ )
118
+
119
+ # Load control configuration
120
+ if control_file and os.path.exists(control_file):
121
+ try:
122
+ # Import the control configuration
123
+ import importlib.util
124
+ spec = importlib.util.spec_from_file_location("control_config", control_file)
125
+ control_module = importlib.util.module_from_spec(spec)
126
+ spec.loader.exec_module(control_module)
127
+
128
+ case_manager.setup_control(control_module.control_params)
129
+
130
+ except Exception as e:
131
+ print(f"Error loading control configuration: {e}")
132
+ return False
133
+ else:
134
+ print("No control configuration file provided, using defaults.")
135
+ control_config = ControlConfig()
136
+ case_manager.setup_control(control_config.get_parameters())
137
+
138
+ # Load turbulence configuration
139
+ if turbulence_file and os.path.exists(turbulence_file):
140
+ try:
141
+ # Import the turbulence configuration
142
+ import importlib.util
143
+ spec = importlib.util.spec_from_file_location("turbulence_config", turbulence_file)
144
+ turbulence_module = importlib.util.module_from_spec(spec)
145
+ spec.loader.exec_module(turbulence_module)
146
+
147
+ sim_type = turbulence_module.SIMULATION_TYPE
148
+ if sim_type == "RAS":
149
+ model_props = turbulence_module.RAS_PROPERTIES
150
+ elif sim_type == "LES":
151
+ model_props = turbulence_module.LES_PROPERTIES
152
+ elif sim_type == "laminar":
153
+ model_props = turbulence_module.LAMINAR_PROPERTIES
154
+ else:
155
+ print(f"Warning: Unknown simulation type '{sim_type}'. Using laminar.")
156
+ sim_type = "laminar"
157
+ model_props = {}
158
+
159
+ case_manager.setup_turbulence(
160
+ simulation_type=sim_type,
161
+ model_properties=model_props
162
+ )
163
+
164
+ except Exception as e:
165
+ print(f"Error loading turbulence configuration: {e}")
166
+ return False
167
+ else:
168
+ print("No turbulence configuration file provided, using defaults.")
169
+ turbulence_config = TurbulenceConfig()
170
+ case_manager.setup_turbulence(
171
+ simulation_type=turbulence_config.get_simulation_type(),
172
+ model_properties=turbulence_config.get_model_properties()
173
+ )
174
+
175
+ # Create the complete case
176
+ return case_manager.create_full_case()
177
+
178
+ def main():
179
+ """
180
+ Main entry point for the command-line interface.
181
+ """
182
+ parser = argparse.ArgumentParser(
183
+ description="OpenFOAM Case Developer - Create OpenFOAM cases with Python",
184
+ formatter_class=argparse.RawDescriptionHelpFormatter,
185
+ epilog="""
186
+ Examples:
187
+ # Create an example case
188
+ pycphy-foam --example
189
+
190
+ # Create a custom case from configuration files
191
+ pycphy-foam --case myCase --geometry configBlockMesh.py --control configControl.py --turbulence configTurbulence.py
192
+
193
+ # Create a case with just geometry configuration
194
+ pycphy-foam --case myCase --geometry configBlockMesh.py
195
+ """
196
+ )
197
+
198
+ parser.add_argument(
199
+ "--example",
200
+ action="store_true",
201
+ help="Create an example OpenFOAM case with default settings"
202
+ )
203
+
204
+ parser.add_argument(
205
+ "--case",
206
+ type=str,
207
+ help="Name of the OpenFOAM case directory to create"
208
+ )
209
+
210
+ parser.add_argument(
211
+ "--geometry",
212
+ type=str,
213
+ help="Path to geometry configuration file (Python module)"
214
+ )
215
+
216
+ parser.add_argument(
217
+ "--control",
218
+ type=str,
219
+ help="Path to control configuration file (Python module)"
220
+ )
221
+
222
+ parser.add_argument(
223
+ "--turbulence",
224
+ type=str,
225
+ help="Path to turbulence configuration file (Python module)"
226
+ )
227
+
228
+ args = parser.parse_args()
229
+
230
+ # Validate arguments
231
+ if args.example and args.case:
232
+ print("Error: Cannot specify both --example and --case options.")
233
+ sys.exit(1)
234
+
235
+ if not args.example and not args.case:
236
+ print("Error: Must specify either --example or --case option.")
237
+ sys.exit(1)
238
+
239
+ # Create the case
240
+ success = False
241
+
242
+ if args.example:
243
+ success = create_example_case()
244
+ else:
245
+ success = create_custom_case(
246
+ case_name=args.case,
247
+ geometry_file=args.geometry,
248
+ control_file=args.control,
249
+ turbulence_file=args.turbulence
250
+ )
251
+
252
+ if success:
253
+ print("\nOpenFOAM case creation completed successfully!")
254
+ sys.exit(0)
255
+ else:
256
+ print("\nOpenFOAM case creation failed!")
257
+ sys.exit(1)
258
+
259
+ if __name__ == "__main__":
260
+ main()