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
pycphy/__init__.py CHANGED
@@ -1,3 +1,14 @@
1
+ """
2
+ pycphy package root exports.
3
+ """
4
+
5
+ from .config_manager import ConfigManager, create_config_from_template # re-export for convenience
6
+
7
+ __all__ = [
8
+ "ConfigManager",
9
+ "create_config_from_template",
10
+ ]
11
+
1
12
  """
2
13
  pycphy - Python: Computational Physics
3
14
 
pycphy/cli.py ADDED
@@ -0,0 +1,145 @@
1
+ """
2
+ Command Line Interface for pycphy.
3
+
4
+ Provides commands to scaffold config files, summarize configs, and run a case.
5
+ """
6
+
7
+ import argparse
8
+ import sys
9
+ from pathlib import Path
10
+
11
+ from .config_manager import ConfigManager, create_config_from_template
12
+ from .foamCaseDeveloper import FoamCaseManager
13
+
14
+
15
+ def cmd_init_configs(args: argparse.Namespace) -> int:
16
+ output_dir = args.output_dir
17
+ Path(output_dir).mkdir(parents=True, exist_ok=True)
18
+ created = True
19
+ for name in [
20
+ "global_config.py",
21
+ "block_mesh_config.py",
22
+ "control_config.py",
23
+ "turbulence_config.py",
24
+ "dynamic_mesh_config.py",
25
+ "config_hfdibdem.py",
26
+ "transport_properties_config.py",
27
+ "fv_schemes_config.py",
28
+ "fv_options_config.py",
29
+ "gravity_field_config.py",
30
+ "set_fields_config.py",
31
+ "decompose_par_config.py",
32
+ "snappy_hex_mesh_config.py",
33
+ ]:
34
+ ok = create_config_from_template(name, output_dir)
35
+ created = created and ok
36
+ return 0 if created else 1
37
+
38
+
39
+ def cmd_summary(args: argparse.Namespace) -> int:
40
+ cm = ConfigManager(config_dir=args.config_dir)
41
+ if not cm.validate_configs():
42
+ return 1
43
+ cm.print_config_summary()
44
+ return 0
45
+
46
+
47
+ def cmd_run(args: argparse.Namespace) -> int:
48
+ cm = ConfigManager(config_dir=args.config_dir)
49
+ if not cm.validate_configs():
50
+ return 1
51
+
52
+ gc = cm.get_global_config()
53
+ bmc = cm.get_geometry_config()
54
+ cc = cm.get_control_config()
55
+ tc = cm.get_turbulence_config()
56
+ dmc = cm.get_dynamic_mesh_config()
57
+ hfd = cm.get_hfdibdem_config()
58
+
59
+ case_name = args.case_name or getattr(gc, "case_name", "pycphyCase")
60
+ manager = FoamCaseManager(case_name)
61
+
62
+ # Geometry
63
+ manager.setup_geometry(
64
+ p0=getattr(bmc, "p0"),
65
+ p1=getattr(bmc, "p1"),
66
+ cells=getattr(bmc, "cells"),
67
+ patch_names=getattr(bmc, "patch_names"),
68
+ scale=getattr(bmc, "scale", 1.0),
69
+ )
70
+
71
+ # Control
72
+ manager.setup_control(getattr(cc, "control_params"))
73
+
74
+ # Turbulence
75
+ sim_type = getattr(tc, "SIMULATION_TYPE", "laminar")
76
+ if sim_type == "RAS":
77
+ model_props = getattr(tc, "RAS_PROPERTIES", {})
78
+ elif sim_type == "LES":
79
+ model_props = getattr(tc, "LES_PROPERTIES", {})
80
+ else:
81
+ model_props = getattr(tc, "LAMINAR_PROPERTIES", {})
82
+ manager.setup_turbulence(simulation_type=sim_type, model_properties=model_props)
83
+
84
+ # Dynamic mesh
85
+ if getattr(dmc, "WRITE_DYNAMIC_MESH_DICT", False):
86
+ mesh_type = getattr(dmc, "MESH_TYPE")
87
+ props_map = {
88
+ "solidBodyMotion": getattr(dmc, "SOLID_BODY_MOTION_PROPS", {}),
89
+ "multiBodyOverset": getattr(dmc, "MULTI_BODY_OVERSET_PROPS", {}),
90
+ "adaptiveRefinement": getattr(dmc, "ADAPTIVE_REFINEMENT_PROPS", {}),
91
+ "morphingMesh": getattr(dmc, "MORPHING_MESH_PROPS", {}),
92
+ }
93
+ manager.setup_dynamic_mesh(
94
+ write_dynamic_mesh_dict=True,
95
+ mesh_type=mesh_type,
96
+ mesh_properties=props_map.get(mesh_type, {}),
97
+ )
98
+
99
+ # HFDIBDEM
100
+ if getattr(hfd, "WRITE_HFDIBDEM_DICT", False):
101
+ props = getattr(hfd, "GLOBAL_SETTINGS", {}).copy()
102
+ selected = getattr(hfd, "SELECTED_BODY_NAMES", [])
103
+ props["bodyNames"] = selected
104
+ props["DEM"] = getattr(hfd, "DEM_SETTINGS", {})
105
+ props["virtualMesh"] = getattr(hfd, "VIRTUAL_MESH_SETTINGS", {})
106
+ available = getattr(hfd, "AVAILABLE_BODIES", {})
107
+ for name in selected:
108
+ if name in available:
109
+ props[name] = available[name]
110
+ manager.setup_hfdibdem(True, props)
111
+
112
+ success = manager.create_full_case()
113
+ return 0 if success else 2
114
+
115
+
116
+ def build_parser() -> argparse.ArgumentParser:
117
+ parser = argparse.ArgumentParser(prog="pycphy", description="pycphy CLI")
118
+ sub = parser.add_subparsers(dest="command", required=True)
119
+
120
+ p_init = sub.add_parser("init-configs", help="Create editable config files in a directory")
121
+ p_init.add_argument("output_dir", nargs="?", default="./pycphy-configs", help="Directory to write config templates")
122
+ p_init.set_defaults(func=cmd_init_configs)
123
+
124
+ p_sum = sub.add_parser("summary", help="Print a summary of loaded configs")
125
+ p_sum.add_argument("--config-dir", dest="config_dir", default=None, help="Directory with user config .py files")
126
+ p_sum.set_defaults(func=cmd_summary)
127
+
128
+ p_run = sub.add_parser("run", help="Build a case using configs")
129
+ p_run.add_argument("--config-dir", dest="config_dir", default=None, help="Directory with user config .py files")
130
+ p_run.add_argument("--case-name", dest="case_name", default=None, help="Override case name from configs")
131
+ p_run.set_defaults(func=cmd_run)
132
+
133
+ return parser
134
+
135
+
136
+ def main(argv=None) -> int:
137
+ parser = build_parser()
138
+ args = parser.parse_args(argv)
139
+ return args.func(args)
140
+
141
+
142
+ if __name__ == "__main__":
143
+ sys.exit(main())
144
+
145
+
@@ -0,0 +1,373 @@
1
+ # config_manager.py
2
+
3
+ """
4
+ Configuration manager for pycphy package.
5
+
6
+ This module provides utilities for loading and managing configuration files
7
+ from user-specified directories or the package's default configurations.
8
+ """
9
+
10
+ from pathlib import Path
11
+ from typing import Optional
12
+ import importlib.util
13
+
14
+
15
+ class ConfigManager:
16
+ """
17
+ Manager for loading and accessing configuration files.
18
+
19
+ This class handles loading configuration modules from user directories
20
+ or falling back to package defaults.
21
+ """
22
+
23
+ def __init__(self, config_dir: Optional[str] = None):
24
+ """
25
+ Initialize the configuration manager.
26
+
27
+ Args:
28
+ config_dir (str, optional): Directory containing user config files.
29
+ """
30
+ self.config_dir = Path(config_dir) if config_dir else None
31
+ self.configs = {}
32
+ self._load_configs()
33
+
34
+ def _load_configs(self):
35
+ """Load all available configuration modules."""
36
+ # List of required config modules
37
+ config_modules = [
38
+ 'global_config',
39
+ 'block_mesh_config',
40
+ 'control_config',
41
+ 'turbulence_config',
42
+ 'dynamic_mesh_config',
43
+ 'config_hfdibdem',
44
+ 'transport_properties_config',
45
+ 'fv_schemes_config',
46
+ 'fv_options_config',
47
+ 'gravity_field_config',
48
+ 'set_fields_config',
49
+ 'decompose_par_config',
50
+ 'snappy_hex_mesh_config'
51
+ ]
52
+
53
+ for module_name in config_modules:
54
+ self._load_config_module(module_name)
55
+
56
+ def _load_config_module(self, module_name: str):
57
+ """
58
+ Load a specific configuration module.
59
+
60
+ Args:
61
+ module_name (str): Name of the configuration module.
62
+ """
63
+ # Try to load from user config directory first
64
+ if self.config_dir:
65
+ config_file = self.config_dir / f"{module_name}.py"
66
+ if config_file.exists():
67
+ try:
68
+ spec = importlib.util.spec_from_file_location(module_name, config_file)
69
+ module = importlib.util.module_from_spec(spec)
70
+ spec.loader.exec_module(module)
71
+ self.configs[module_name] = module
72
+ return
73
+ except Exception as e:
74
+ print(f"Warning: Could not load {config_file}: {e}")
75
+
76
+ # Fall back to package default
77
+ try:
78
+ from pycphy.foamCaseDeveloper.config import (
79
+ global_config,
80
+ config_hfdibdem,
81
+ # Constant directory configs
82
+ turbulence_config,
83
+ transport_properties_config,
84
+ dynamic_mesh_config,
85
+ gravity_field_config,
86
+ # System directory configs
87
+ block_mesh_config,
88
+ control_config,
89
+ fv_schemes_config,
90
+ fv_options_config,
91
+ set_fields_config,
92
+ decompose_par_config,
93
+ snappy_hex_mesh_config,
94
+ # Zero directory configs
95
+ p_config,
96
+ U_config,
97
+ f_config,
98
+ lambda_config
99
+ )
100
+
101
+ config_map = {
102
+ 'global_config': global_config,
103
+ 'config_hfdibdem': config_hfdibdem,
104
+ # Constant directory configs
105
+ 'turbulence_config': turbulence_config,
106
+ 'transport_properties_config': transport_properties_config,
107
+ 'dynamic_mesh_config': dynamic_mesh_config,
108
+ 'gravity_field_config': gravity_field_config,
109
+ # System directory configs
110
+ 'block_mesh_config': block_mesh_config,
111
+ 'control_config': control_config,
112
+ 'fv_schemes_config': fv_schemes_config,
113
+ 'fv_options_config': fv_options_config,
114
+ 'set_fields_config': set_fields_config,
115
+ 'decompose_par_config': decompose_par_config,
116
+ 'snappy_hex_mesh_config': snappy_hex_mesh_config,
117
+ # Zero directory configs
118
+ 'p_config': p_config,
119
+ 'u_config': U_config,
120
+ 'f_config': f_config,
121
+ 'lambda_config': lambda_config
122
+ }
123
+
124
+ if module_name in config_map:
125
+ self.configs[module_name] = config_map[module_name]
126
+
127
+ except ImportError as e:
128
+ print(f"Warning: Could not load default {module_name}: {e}")
129
+
130
+ def get_config(self, config_name: str):
131
+ """
132
+ Get a configuration module.
133
+
134
+ Args:
135
+ config_name (str): Name of the configuration module.
136
+
137
+ Returns:
138
+ Configuration module object.
139
+ """
140
+ if config_name not in self.configs:
141
+ self._load_config_module(config_name)
142
+ return self.configs.get(config_name)
143
+
144
+ def get_geometry_config(self):
145
+ """Get geometry configuration."""
146
+ return self.get_config('block_mesh_config')
147
+
148
+ def get_control_config(self):
149
+ """Get control configuration."""
150
+ return self.get_config('control_config')
151
+
152
+ def get_turbulence_config(self):
153
+ """Get turbulence configuration."""
154
+ return self.get_config('turbulence_config')
155
+
156
+ def get_dynamic_mesh_config(self):
157
+ """Get dynamic mesh configuration."""
158
+ return self.get_config('dynamic_mesh_config')
159
+
160
+ def get_hfdibdem_config(self):
161
+ """Get HFDIBDEM configuration."""
162
+ return self.get_config('config_hfdibdem')
163
+
164
+ def get_global_config(self):
165
+ """Get global configuration."""
166
+ return self.get_config('global_config')
167
+
168
+ def validate_configs(self) -> bool:
169
+ """
170
+ Validate all loaded configurations.
171
+
172
+ Returns:
173
+ bool: True if all configs are valid, False otherwise.
174
+ """
175
+ valid = True
176
+
177
+ # Check required configs
178
+ required_configs = ['global_config', 'block_mesh_config', 'control_config', 'turbulence_config']
179
+ for config_name in required_configs:
180
+ if config_name not in self.configs:
181
+ print(f"Error: Required configuration '{config_name}' not found")
182
+ valid = False
183
+
184
+ return valid
185
+
186
+ def print_config_summary(self):
187
+ """Print a summary of loaded configurations."""
188
+ print("Configuration Summary:")
189
+ print("=" * 50)
190
+
191
+ for config_name, config in self.configs.items():
192
+ if config_name == 'global_config':
193
+ case_name = getattr(config, 'case_name', 'Unknown')
194
+ print(f"Global: Case name = '{case_name}'")
195
+ elif config_name == 'block_mesh_config':
196
+ p0 = getattr(config, 'p0', 'Unknown')
197
+ p1 = getattr(config, 'p1', 'Unknown')
198
+ cells = getattr(config, 'cells', 'Unknown')
199
+ print(f"Geometry: Domain {p0} to {p1}, Cells {cells}")
200
+ elif config_name == 'control_config':
201
+ app = getattr(config, 'control_params', {}).get('application', 'Unknown')
202
+ print(f"Control: Solver = '{app}'")
203
+ elif config_name == 'turbulence_config':
204
+ sim_type = getattr(config, 'SIMULATION_TYPE', 'Unknown')
205
+ print(f"Turbulence: Type = '{sim_type}'")
206
+ elif config_name == 'dynamic_mesh_config':
207
+ enabled = getattr(config, 'WRITE_DYNAMIC_MESH_DICT', False)
208
+ mesh_type = getattr(config, 'MESH_TYPE', 'Unknown')
209
+ print(f"Dynamic Mesh: Enabled = {enabled}, Type = '{mesh_type}'")
210
+ elif config_name == 'config_hfdibdem':
211
+ enabled = getattr(config, 'WRITE_HFDIBDEM_DICT', False)
212
+ bodies = getattr(config, 'SELECTED_BODY_NAMES', [])
213
+ print(f"HFDIBDEM: Enabled = {enabled}, Bodies = {bodies}")
214
+
215
+ print("=" * 50)
216
+
217
+
218
+ def create_config_from_template(config_name: str, output_dir: str = ".") -> bool:
219
+ """
220
+ Create a configuration file from template.
221
+
222
+ Args:
223
+ config_name (str): Name of the configuration to create.
224
+ output_dir (str): Directory to create the file.
225
+
226
+ Returns:
227
+ bool: True if successful, False otherwise.
228
+ """
229
+ output_path = Path(output_dir)
230
+
231
+ templates = {
232
+ "global_config.py": """# Global configuration for OpenFOAM case
233
+ case_name = "myCase"
234
+ case_description = "My OpenFOAM simulation case"
235
+ author_name = "Your Name"
236
+ output_directory = "."
237
+ verbose_output = True
238
+ creation_date = "2025-01-09"
239
+ """,
240
+ "block_mesh_config.py": """# Geometry configuration for blockMeshDict
241
+ p0 = (0.0, 0.0, 0.0) # Minimum corner (x0, y0, z0)
242
+ p1 = (1.0, 0.5, 0.2) # Maximum corner (x1, y1, z1)
243
+ cells = (50, 25, 10) # Number of cells (nx, ny, nz)
244
+ patch_names = {
245
+ 'minX': 'inlet',
246
+ 'maxX': 'outlet',
247
+ 'minY': 'frontWall',
248
+ 'maxY': 'backWall',
249
+ 'minZ': 'floor',
250
+ 'maxZ': 'ceiling'
251
+ }
252
+ scale = 1.0
253
+ """,
254
+ "control_config.py": """# Control configuration for controlDict
255
+ control_params = {
256
+ 'application': 'simpleFoam',
257
+ 'startFrom': 'startTime',
258
+ 'startTime': 0,
259
+ 'stopAt': 'endTime',
260
+ 'endTime': 100,
261
+ 'deltaT': 0.001,
262
+ 'writeControl': 'timeStep',
263
+ 'writeInterval': 10,
264
+ 'purgeWrite': 2,
265
+ 'writeFormat': 'ascii',
266
+ 'writePrecision': 6,
267
+ 'writeCompression': 'off',
268
+ 'timeFormat': 'general',
269
+ 'timePrecision': 6,
270
+ 'runTimeModifiable': 'true',
271
+ 'maxCo': 0.5,
272
+ 'maxDeltaT': 0.001
273
+ }
274
+ """,
275
+ "turbulence_config.py": """# Turbulence configuration for turbulenceProperties
276
+ SIMULATION_TYPE = "RAS" # Options: "RAS", "LES", "laminar"
277
+ turbulenceOn = True
278
+
279
+ # RAS Model Properties
280
+ RAS_PROPERTIES = {
281
+ 'RASModel': 'kEpsilon',
282
+ 'turbulence': 'on',
283
+ 'printCoeffs': 'on'
284
+ }
285
+
286
+ # LES Model Properties
287
+ LES_PROPERTIES = {
288
+ 'LESModel': 'Smagorinsky',
289
+ 'turbulence': 'on',
290
+ 'printCoeffs': 'on'
291
+ }
292
+
293
+ # Laminar Properties
294
+ LAMINAR_PROPERTIES = {}
295
+ """,
296
+ "dynamic_mesh_config.py": """# Dynamic mesh configuration (optional)
297
+ WRITE_DYNAMIC_MESH_DICT = False # Set to True to enable
298
+ MESH_TYPE = "solidBodyMotion" # Options: "solidBodyMotion", "multiBodyOverset", "adaptiveRefinement", "morphingMesh"
299
+
300
+ # Example solid body motion configuration
301
+ SOLID_BODY_MOTION_PROPS = {
302
+ "dynamicFvMesh": "dynamicMotionSolverFvMesh",
303
+ "solver": "solidBody",
304
+ "solidBodyCoeffs": {
305
+ "cellZone": "rotatingZone",
306
+ "solidBodyMotionFunction": "rotatingMotion",
307
+ "rotatingMotionCoeffs": {
308
+ "origin": (0, 0, 0),
309
+ "axis": (0, 0, 1),
310
+ "omega": 10.5
311
+ }
312
+ }
313
+ }
314
+ """,
315
+ "config_hfdibdem.py": """# HFDIBDEM configuration (optional)
316
+ WRITE_HFDIBDEM_DICT = False # Set to True to enable
317
+
318
+ # Example configuration for a falling sphere
319
+ GLOBAL_SETTINGS = {
320
+ "interpolationSchemes": {"U": "cell"},
321
+ "surfaceThreshold": 1e-4,
322
+ "stepDEM": 0.01,
323
+ "geometricD": (1, 1, 1),
324
+ "recordSimulation": True,
325
+ "recordFirstTimeStep": False,
326
+ "nSolidsInDomain": 1000,
327
+ "outputSetup": {
328
+ "basic": False,
329
+ "iB": False,
330
+ "DEM": False,
331
+ "addModel": False,
332
+ "parallelDEM": False
333
+ }
334
+ }
335
+
336
+ SELECTED_BODY_NAMES = ["singleFallingSphere"]
337
+
338
+ AVAILABLE_BODIES = {
339
+ "singleFallingSphere": {
340
+ "fullyCoupledBody": {"velocity": (0, -1.0, 0)},
341
+ "rho": "rho [1 -3 0 0 0 0 0] 2500",
342
+ "refineMC": 5,
343
+ "U": {"BC": "noSlip"},
344
+ "material": "particleMat1",
345
+ "updateTorque": True,
346
+ "bodyGeom": "sphere",
347
+ "sphere": {
348
+ "radius": 0.04,
349
+ "startPosition": (0, 0.2, 0)
350
+ },
351
+ "bodyAddition": {
352
+ "addModel": "once",
353
+ "onceCoeffs": {}
354
+ },
355
+ "timesToSetStatic": -1
356
+ }
357
+ }
358
+ """
359
+ }
360
+
361
+ if config_name not in templates:
362
+ print(f"Error: Unknown configuration '{config_name}'")
363
+ return False
364
+
365
+ try:
366
+ file_path = output_path / f"{config_name}.py"
367
+ with open(file_path, 'w') as f:
368
+ f.write(templates[config_name])
369
+ print(f"Created {file_path}")
370
+ return True
371
+ except Exception as e:
372
+ print(f"Error creating {config_name}: {e}")
373
+ return False
@@ -1,41 +1,60 @@
1
- """
2
- foamCaseDeveloper - OpenFOAM Case Development Tools
3
-
4
- This module provides tools for creating and managing OpenFOAM simulation cases,
5
- including mesh generation, control dictionary setup, and turbulence properties
6
- configuration.
7
-
8
- Author: Sanjeev Bashyal
9
- """
10
-
11
- from .core import (
12
- BlockMeshDeveloper,
13
- ControlDictWriter,
14
- TurbulencePropertiesWriter,
15
- FoamCaseManager
16
- )
17
- from .writers import (
18
- BlockMeshWriter,
19
- FoamWriter
20
- )
21
- from .config import (
22
- global_config,
23
- block_mesh_config,
24
- control_config,
25
- turbulence_config
26
- )
27
-
28
- __version__ = "0.1.0"
29
-
30
- __all__ = [
31
- "BlockMeshDeveloper",
32
- "ControlDictWriter",
33
- "TurbulencePropertiesWriter",
34
- "FoamCaseManager",
35
- "BlockMeshWriter",
36
- "FoamWriter",
37
- "global_config",
38
- "block_mesh_config",
39
- "control_config",
40
- "turbulence_config",
41
- ]
1
+ """
2
+ foamCaseDeveloper - OpenFOAM Case Development Tools
3
+
4
+ This module provides tools for creating and managing OpenFOAM simulation cases,
5
+ including mesh generation, control dictionary setup, and turbulence properties
6
+ configuration.
7
+
8
+ Author: Sanjeev Bashyal
9
+ """
10
+
11
+ from .core import (
12
+ BlockMeshDeveloper,
13
+ CADBlockMeshDeveloper,
14
+ FoamCaseManager
15
+ )
16
+ from .writers import (
17
+ FoamWriter,
18
+ BlockMeshWriter,
19
+ ControlDictWriter,
20
+ TurbulencePropertiesWriter,
21
+ DynamicMeshDictWriter,
22
+ HFDIBDEMDictWriter
23
+ )
24
+ from .config import (
25
+ global_config,
26
+ block_mesh_config,
27
+ control_config,
28
+ turbulence_config,
29
+ dynamic_mesh_config,
30
+ config_hfdibdem,
31
+ cad_mesh_config
32
+ )
33
+ from ..config_manager import ConfigManager, create_config_from_template
34
+
35
+ __version__ = "0.1.0"
36
+
37
+ __all__ = [
38
+ # Core functionality
39
+ "BlockMeshDeveloper",
40
+ "CADBlockMeshDeveloper",
41
+ "FoamCaseManager",
42
+ # Writers
43
+ "FoamWriter",
44
+ "BlockMeshWriter",
45
+ "ControlDictWriter",
46
+ "TurbulencePropertiesWriter",
47
+ "DynamicMeshDictWriter",
48
+ "HFDIBDEMDictWriter",
49
+ # Configuration
50
+ "global_config",
51
+ "block_mesh_config",
52
+ "control_config",
53
+ "turbulence_config",
54
+ "dynamic_mesh_config",
55
+ "config_hfdibdem",
56
+ "cad_mesh_config",
57
+ # Config manager utilities
58
+ "ConfigManager",
59
+ "create_config_from_template",
60
+ ]