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.
- pycphy/__init__.py +11 -0
- pycphy/cli.py +145 -0
- pycphy/config_manager.py +373 -0
- pycphy/foamCaseDeveloper/__init__.py +60 -41
- pycphy/foamCaseDeveloper/config/__init__.py +69 -26
- pycphy/foamCaseDeveloper/config/cad_mesh_config.py +62 -0
- pycphy/foamCaseDeveloper/config/config_hfdibdem.py +193 -0
- pycphy/foamCaseDeveloper/config/constant/__init__.py +23 -0
- pycphy/foamCaseDeveloper/config/constant/dynamic_mesh_config.py +208 -0
- pycphy/foamCaseDeveloper/config/constant/gravity_field_config.py +379 -0
- pycphy/foamCaseDeveloper/config/constant/transport_properties_config.py +225 -0
- pycphy/foamCaseDeveloper/config/constant/turbulence_config.py +617 -0
- pycphy/foamCaseDeveloper/config/csv_boundary_reader.py +219 -0
- pycphy/foamCaseDeveloper/config/system/__init__.py +31 -0
- pycphy/foamCaseDeveloper/config/system/block_mesh_config.py +184 -0
- pycphy/foamCaseDeveloper/config/{control_config.py → system/control_config.py} +113 -1
- pycphy/foamCaseDeveloper/config/system/decompose_par_config.py +525 -0
- pycphy/foamCaseDeveloper/config/system/fv_options_config.py +575 -0
- pycphy/foamCaseDeveloper/config/system/fv_schemes_config.py +363 -0
- pycphy/foamCaseDeveloper/config/system/set_fields_config.py +640 -0
- pycphy/foamCaseDeveloper/config/system/snappy_hex_mesh_config.py +241 -0
- pycphy/foamCaseDeveloper/config/zero/U_config.py +135 -0
- pycphy/foamCaseDeveloper/config/zero/__init__.py +22 -0
- pycphy/foamCaseDeveloper/config/zero/f_config.py +140 -0
- pycphy/foamCaseDeveloper/config/zero/lambda_config.py +157 -0
- pycphy/foamCaseDeveloper/config/zero/p_config.py +97 -0
- pycphy/foamCaseDeveloper/core/__init__.py +30 -18
- pycphy/foamCaseDeveloper/core/block_mesh_developer.py +1 -1
- pycphy/foamCaseDeveloper/core/cad_block_mesh_developer.py +463 -0
- pycphy/foamCaseDeveloper/core/case_builder.py +1217 -0
- pycphy/foamCaseDeveloper/core/foam_case_manager.py +370 -111
- pycphy/foamCaseDeveloper/develop_case.py +640 -0
- pycphy/foamCaseDeveloper/main.py +260 -260
- pycphy/foamCaseDeveloper/utils/myAutoCAD.py +418 -0
- pycphy/foamCaseDeveloper/writers/__init__.py +37 -4
- pycphy/foamCaseDeveloper/writers/constant/__init__.py +25 -0
- pycphy/foamCaseDeveloper/writers/constant/dynamic_mesh_dict_writer.py +75 -0
- pycphy/foamCaseDeveloper/writers/constant/gravity_field_writer.py +88 -0
- pycphy/foamCaseDeveloper/writers/constant/hfdibdem_dict_writer.py +81 -0
- pycphy/foamCaseDeveloper/writers/constant/transport_properties_writer.py +202 -0
- pycphy/foamCaseDeveloper/writers/{turbulence_properties_writer.py → constant/turbulence_properties_writer.py} +49 -1
- pycphy/foamCaseDeveloper/writers/system/__init__.py +31 -0
- pycphy/foamCaseDeveloper/writers/{block_mesh_writer.py → system/block_mesh_writer.py} +1 -1
- pycphy/foamCaseDeveloper/writers/{control_dict_writer.py → system/control_dict_writer.py} +37 -1
- pycphy/foamCaseDeveloper/writers/system/decompose_par_writer.py +228 -0
- pycphy/foamCaseDeveloper/writers/system/fv_options_writer.py +188 -0
- pycphy/foamCaseDeveloper/writers/system/fv_schemes_writer.py +155 -0
- pycphy/foamCaseDeveloper/writers/system/set_fields_writer.py +191 -0
- pycphy/foamCaseDeveloper/writers/system/snappy_hex_mesh_writer.py +123 -0
- pycphy/foamCaseDeveloper/writers/zero/__init__.py +24 -0
- pycphy/foamCaseDeveloper/writers/zero/f_field_writer.py +89 -0
- pycphy/foamCaseDeveloper/writers/zero/lambda_field_writer.py +84 -0
- pycphy/foamCaseDeveloper/writers/zero/p_field_writer.py +89 -0
- pycphy/foamCaseDeveloper/writers/zero/u_field_writer.py +96 -0
- pycphy/foamCaseDeveloper/writers/zero/zero_field_factory.py +388 -0
- {pycphy-0.1.0.dist-info → pycphy-0.2.0.dist-info}/METADATA +154 -6
- pycphy-0.2.0.dist-info/RECORD +63 -0
- pycphy-0.2.0.dist-info/entry_points.txt +3 -0
- pycphy/foamCaseDeveloper/config/block_mesh_config.py +0 -90
- pycphy/foamCaseDeveloper/config/turbulence_config.py +0 -187
- pycphy/foamCaseDeveloper/core/control_dict_writer.py +0 -55
- pycphy/foamCaseDeveloper/core/turbulence_properties_writer.py +0 -68
- pycphy-0.1.0.dist-info/RECORD +0 -24
- pycphy-0.1.0.dist-info/entry_points.txt +0 -2
- {pycphy-0.1.0.dist-info → pycphy-0.2.0.dist-info}/WHEEL +0 -0
- {pycphy-0.1.0.dist-info → pycphy-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {pycphy-0.1.0.dist-info → pycphy-0.2.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,388 @@
|
|
1
|
+
"""
|
2
|
+
Zero Field Factory for OpenFOAM cases.
|
3
|
+
|
4
|
+
This factory creates zero field writers using configuration files and optionally
|
5
|
+
CSV boundary conditions. It determines which fields to write based on CSV content.
|
6
|
+
"""
|
7
|
+
|
8
|
+
import os
|
9
|
+
from typing import Dict, Any, Optional, List
|
10
|
+
from ..foam_writer import FoamWriter
|
11
|
+
|
12
|
+
|
13
|
+
class ZeroFieldFactory:
|
14
|
+
"""
|
15
|
+
Factory class to create zero field writers using config files and CSV data.
|
16
|
+
"""
|
17
|
+
|
18
|
+
def __init__(self, output_dir: str = "0", csv_file_path: str = "Inputs/patches.csv"):
|
19
|
+
"""
|
20
|
+
Initialize the zero field factory.
|
21
|
+
|
22
|
+
Args:
|
23
|
+
output_dir: Directory where to write the zero field files
|
24
|
+
csv_file_path: Path to the patches.csv file
|
25
|
+
"""
|
26
|
+
self.output_dir = output_dir
|
27
|
+
self.csv_file_path = csv_file_path
|
28
|
+
self.csv_boundary_reader = None
|
29
|
+
|
30
|
+
# Ensure output directory exists
|
31
|
+
os.makedirs(output_dir, exist_ok=True)
|
32
|
+
|
33
|
+
# Load CSV boundary conditions if file exists
|
34
|
+
self._load_csv_boundary_conditions()
|
35
|
+
|
36
|
+
def _load_csv_boundary_conditions(self):
|
37
|
+
"""Load boundary conditions from CSV file if it exists."""
|
38
|
+
try:
|
39
|
+
from ...config.csv_boundary_reader import CSVBoundaryReader
|
40
|
+
self.csv_boundary_reader = CSVBoundaryReader(self.csv_file_path)
|
41
|
+
print(f"Loaded CSV boundary conditions from {self.csv_file_path}")
|
42
|
+
except Exception as e:
|
43
|
+
print(f"Could not load CSV boundary conditions: {e}")
|
44
|
+
self.csv_boundary_reader = None
|
45
|
+
|
46
|
+
def _get_csv_boundary_conditions(self, field_name: str) -> Optional[Dict[str, Any]]:
|
47
|
+
"""
|
48
|
+
Get boundary conditions for a specific field from CSV.
|
49
|
+
|
50
|
+
Args:
|
51
|
+
field_name: Name of the field (p, U, f, lambda)
|
52
|
+
|
53
|
+
Returns:
|
54
|
+
Dictionary of boundary conditions or None if not available
|
55
|
+
"""
|
56
|
+
if not self.csv_boundary_reader:
|
57
|
+
return None
|
58
|
+
|
59
|
+
if field_name == 'p':
|
60
|
+
return self.csv_boundary_reader.get_pressure_boundary_conditions()
|
61
|
+
elif field_name == 'U':
|
62
|
+
return self.csv_boundary_reader.get_velocity_boundary_conditions()
|
63
|
+
elif field_name == 'f':
|
64
|
+
return self.csv_boundary_reader.get_force_boundary_conditions()
|
65
|
+
elif field_name == 'lambda':
|
66
|
+
return self.csv_boundary_reader.get_lambda_boundary_conditions()
|
67
|
+
|
68
|
+
return None
|
69
|
+
|
70
|
+
def _check_field_in_csv(self, field_name: str) -> bool:
|
71
|
+
"""
|
72
|
+
Check if a field is defined in the CSV file.
|
73
|
+
|
74
|
+
Args:
|
75
|
+
field_name: Name of the field to check
|
76
|
+
|
77
|
+
Returns:
|
78
|
+
True if field is defined in CSV, False otherwise
|
79
|
+
"""
|
80
|
+
if not self.csv_boundary_reader:
|
81
|
+
return False
|
82
|
+
|
83
|
+
patches = self.csv_boundary_reader.get_patch_names()
|
84
|
+
if not patches:
|
85
|
+
return False
|
86
|
+
|
87
|
+
# Check if any patch has non-empty values for this field
|
88
|
+
for patch_name in patches:
|
89
|
+
patch_info = self.csv_boundary_reader.get_patch_info(patch_name)
|
90
|
+
if patch_info:
|
91
|
+
if field_name == 'p' and patch_info.p_type and patch_info.p_type.strip():
|
92
|
+
return True
|
93
|
+
elif field_name == 'U' and patch_info.u_type and patch_info.u_type.strip():
|
94
|
+
return True
|
95
|
+
elif field_name == 'f' and patch_info.f_type and patch_info.f_type.strip():
|
96
|
+
return True
|
97
|
+
elif field_name == 'lambda' and patch_info.lambda_type and patch_info.lambda_type.strip():
|
98
|
+
return True
|
99
|
+
|
100
|
+
return False
|
101
|
+
|
102
|
+
def create_pressure_writer(self, use_csv_boundaries: bool = True) -> Optional[Any]:
|
103
|
+
"""
|
104
|
+
Create a pressure field writer using config and optionally CSV boundaries.
|
105
|
+
|
106
|
+
Args:
|
107
|
+
use_csv_boundaries: If True, use CSV boundary conditions if available
|
108
|
+
|
109
|
+
Returns:
|
110
|
+
PFieldWriter instance or None if pressure field not configured
|
111
|
+
"""
|
112
|
+
from ...config.zero import p_config
|
113
|
+
|
114
|
+
# Check if pressure field should be written
|
115
|
+
if not p_config.WRITE_P_FIELD:
|
116
|
+
return None
|
117
|
+
|
118
|
+
# Check if field is defined in CSV (if using CSV boundaries)
|
119
|
+
if use_csv_boundaries and not self._check_field_in_csv('p'):
|
120
|
+
print("Pressure field not found in CSV, skipping...")
|
121
|
+
return None
|
122
|
+
|
123
|
+
# Import the writer
|
124
|
+
from .p_field_writer import PFieldWriter
|
125
|
+
|
126
|
+
# Get boundary conditions
|
127
|
+
if use_csv_boundaries and self.csv_boundary_reader:
|
128
|
+
boundary_conditions = self._get_csv_boundary_conditions('p')
|
129
|
+
if boundary_conditions:
|
130
|
+
print(f"Using CSV boundary conditions for pressure field ({len(boundary_conditions)} patches)")
|
131
|
+
else:
|
132
|
+
print("No CSV boundary conditions found for pressure field, using config defaults")
|
133
|
+
boundary_conditions = {} # Will use template or default
|
134
|
+
else:
|
135
|
+
boundary_conditions = {} # Will use template or default
|
136
|
+
|
137
|
+
# Use template if no boundary conditions and template is selected
|
138
|
+
if not boundary_conditions and p_config.SELECTED_TEMPLATE:
|
139
|
+
template = p_config.TEMPLATE_CONFIGS.get(p_config.SELECTED_TEMPLATE)
|
140
|
+
if template:
|
141
|
+
boundary_conditions = template.get('boundary_conditions', {})
|
142
|
+
print(f"Using template '{p_config.SELECTED_TEMPLATE}' for pressure field")
|
143
|
+
|
144
|
+
# Create writer
|
145
|
+
file_path = os.path.join(self.output_dir, "p")
|
146
|
+
writer = PFieldWriter(
|
147
|
+
file_path=file_path,
|
148
|
+
internal_pressure=p_config.INTERNAL_PRESSURE,
|
149
|
+
boundary_conditions=boundary_conditions,
|
150
|
+
ref_pressure_cell=p_config.REF_PRESSURE_CELL,
|
151
|
+
ref_pressure_value=p_config.REF_PRESSURE_VALUE,
|
152
|
+
pressure_dimensions=p_config.PRESSURE_DIMENSIONS
|
153
|
+
)
|
154
|
+
|
155
|
+
return writer
|
156
|
+
|
157
|
+
def create_velocity_writer(self, use_csv_boundaries: bool = True) -> Optional[Any]:
|
158
|
+
"""
|
159
|
+
Create a velocity field writer using config and optionally CSV boundaries.
|
160
|
+
|
161
|
+
Args:
|
162
|
+
use_csv_boundaries: If True, use CSV boundary conditions if available
|
163
|
+
|
164
|
+
Returns:
|
165
|
+
UFieldWriter instance or None if velocity field not configured
|
166
|
+
"""
|
167
|
+
from ...config.zero import U_config
|
168
|
+
|
169
|
+
# Check if velocity field should be written
|
170
|
+
if not U_config.WRITE_U_FIELD:
|
171
|
+
return None
|
172
|
+
|
173
|
+
# Check if field is defined in CSV (if using CSV boundaries)
|
174
|
+
if use_csv_boundaries and not self._check_field_in_csv('U'):
|
175
|
+
print("Velocity field not found in CSV, skipping...")
|
176
|
+
return None
|
177
|
+
|
178
|
+
# Import the writer
|
179
|
+
from .u_field_writer import UFieldWriter
|
180
|
+
|
181
|
+
# Get boundary conditions
|
182
|
+
if use_csv_boundaries and self.csv_boundary_reader:
|
183
|
+
boundary_conditions = self._get_csv_boundary_conditions('U')
|
184
|
+
if boundary_conditions:
|
185
|
+
print(f"Using CSV boundary conditions for velocity field ({len(boundary_conditions)} patches)")
|
186
|
+
else:
|
187
|
+
print("No CSV boundary conditions found for velocity field, using config defaults")
|
188
|
+
boundary_conditions = {}
|
189
|
+
else:
|
190
|
+
boundary_conditions = {}
|
191
|
+
|
192
|
+
# Use template if no boundary conditions and template is selected
|
193
|
+
if not boundary_conditions and U_config.SELECTED_TEMPLATE:
|
194
|
+
template = U_config.TEMPLATE_CONFIGS.get(U_config.SELECTED_TEMPLATE)
|
195
|
+
if template:
|
196
|
+
boundary_conditions = template.get('boundary_conditions', {})
|
197
|
+
print(f"Using template '{U_config.SELECTED_TEMPLATE}' for velocity field")
|
198
|
+
|
199
|
+
# Create writer
|
200
|
+
file_path = os.path.join(self.output_dir, "U")
|
201
|
+
writer = UFieldWriter(
|
202
|
+
file_path=file_path,
|
203
|
+
internal_velocity=U_config.INTERNAL_VELOCITY,
|
204
|
+
boundary_conditions=boundary_conditions,
|
205
|
+
velocity_dimensions=U_config.VELOCITY_DIMENSIONS
|
206
|
+
)
|
207
|
+
|
208
|
+
return writer
|
209
|
+
|
210
|
+
def create_force_writer(self, use_csv_boundaries: bool = True) -> Optional[Any]:
|
211
|
+
"""
|
212
|
+
Create a force field writer using config and optionally CSV boundaries.
|
213
|
+
|
214
|
+
Args:
|
215
|
+
use_csv_boundaries: If True, use CSV boundary conditions if available
|
216
|
+
|
217
|
+
Returns:
|
218
|
+
FFieldWriter instance or None if force field not configured
|
219
|
+
"""
|
220
|
+
from ...config.zero import f_config
|
221
|
+
|
222
|
+
# Check if force field should be written
|
223
|
+
if not f_config.WRITE_F_FIELD:
|
224
|
+
return None
|
225
|
+
|
226
|
+
# Check if field is defined in CSV (if using CSV boundaries)
|
227
|
+
if use_csv_boundaries and not self._check_field_in_csv('f'):
|
228
|
+
print("Force field not found in CSV, skipping...")
|
229
|
+
return None
|
230
|
+
|
231
|
+
# Import the writer
|
232
|
+
from .f_field_writer import FFieldWriter
|
233
|
+
|
234
|
+
# Get boundary conditions
|
235
|
+
if use_csv_boundaries and self.csv_boundary_reader:
|
236
|
+
boundary_conditions = self._get_csv_boundary_conditions('f')
|
237
|
+
if boundary_conditions:
|
238
|
+
print(f"Using CSV boundary conditions for force field ({len(boundary_conditions)} patches)")
|
239
|
+
else:
|
240
|
+
print("No CSV boundary conditions found for force field, using config defaults")
|
241
|
+
boundary_conditions = {}
|
242
|
+
else:
|
243
|
+
boundary_conditions = {}
|
244
|
+
|
245
|
+
# Use template if no boundary conditions and template is selected
|
246
|
+
if not boundary_conditions and f_config.SELECTED_TEMPLATE:
|
247
|
+
template = f_config.TEMPLATE_CONFIGS.get(f_config.SELECTED_TEMPLATE)
|
248
|
+
if template:
|
249
|
+
boundary_conditions = template.get('boundary_conditions', {})
|
250
|
+
print(f"Using template '{f_config.SELECTED_TEMPLATE}' for force field")
|
251
|
+
|
252
|
+
# Create writer
|
253
|
+
file_path = os.path.join(self.output_dir, "f")
|
254
|
+
writer = FFieldWriter(
|
255
|
+
file_path=file_path,
|
256
|
+
internal_force=f_config.INTERNAL_FORCE,
|
257
|
+
boundary_conditions=boundary_conditions,
|
258
|
+
force_dimensions=f_config.FORCE_DIMENSIONS
|
259
|
+
)
|
260
|
+
|
261
|
+
return writer
|
262
|
+
|
263
|
+
def create_lambda_writer(self, use_csv_boundaries: bool = True) -> Optional[Any]:
|
264
|
+
"""
|
265
|
+
Create a lambda field writer using config and optionally CSV boundaries.
|
266
|
+
|
267
|
+
Args:
|
268
|
+
use_csv_boundaries: If True, use CSV boundary conditions if available
|
269
|
+
|
270
|
+
Returns:
|
271
|
+
LambdaFieldWriter instance or None if lambda field not configured
|
272
|
+
"""
|
273
|
+
from ...config.zero import lambda_config
|
274
|
+
|
275
|
+
# Check if lambda field should be written
|
276
|
+
if not lambda_config.WRITE_LAMBDA_FIELD:
|
277
|
+
return None
|
278
|
+
|
279
|
+
# Check if field is defined in CSV (if using CSV boundaries)
|
280
|
+
if use_csv_boundaries and not self._check_field_in_csv('lambda'):
|
281
|
+
print("Lambda field not found in CSV, skipping...")
|
282
|
+
return None
|
283
|
+
|
284
|
+
# Import the writer
|
285
|
+
from .lambda_field_writer import LambdaFieldWriter
|
286
|
+
|
287
|
+
# Get boundary conditions
|
288
|
+
if use_csv_boundaries and self.csv_boundary_reader:
|
289
|
+
boundary_conditions = self._get_csv_boundary_conditions('lambda')
|
290
|
+
if boundary_conditions:
|
291
|
+
print(f"Using CSV boundary conditions for lambda field ({len(boundary_conditions)} patches)")
|
292
|
+
else:
|
293
|
+
print("No CSV boundary conditions found for lambda field, using config defaults")
|
294
|
+
boundary_conditions = {}
|
295
|
+
else:
|
296
|
+
boundary_conditions = {}
|
297
|
+
|
298
|
+
# Use template if no boundary conditions and template is selected
|
299
|
+
if not boundary_conditions and lambda_config.SELECTED_TEMPLATE:
|
300
|
+
template = lambda_config.TEMPLATE_CONFIGS.get(lambda_config.SELECTED_TEMPLATE)
|
301
|
+
if template:
|
302
|
+
boundary_conditions = template.get('boundary_conditions', {})
|
303
|
+
print(f"Using template '{lambda_config.SELECTED_TEMPLATE}' for lambda field")
|
304
|
+
|
305
|
+
# Create writer
|
306
|
+
file_path = os.path.join(self.output_dir, "lambda")
|
307
|
+
writer = LambdaFieldWriter(
|
308
|
+
file_path=file_path,
|
309
|
+
internal_lambda=lambda_config.INTERNAL_LAMBDA,
|
310
|
+
boundary_conditions=boundary_conditions,
|
311
|
+
lambda_dimensions=lambda_config.LAMBDA_DIMENSIONS
|
312
|
+
)
|
313
|
+
|
314
|
+
return writer
|
315
|
+
|
316
|
+
def write_all_fields(self, use_csv_boundaries: bool = True) -> List[str]:
|
317
|
+
"""
|
318
|
+
Write all configured zero field files.
|
319
|
+
|
320
|
+
Args:
|
321
|
+
use_csv_boundaries: If True, use CSV boundary conditions if available
|
322
|
+
|
323
|
+
Returns:
|
324
|
+
List of field names that were written
|
325
|
+
"""
|
326
|
+
written_fields = []
|
327
|
+
|
328
|
+
print("Writing zero field files using config + CSV boundary conditions...")
|
329
|
+
print("=" * 60)
|
330
|
+
|
331
|
+
# Write pressure field
|
332
|
+
p_writer = self.create_pressure_writer(use_csv_boundaries)
|
333
|
+
if p_writer:
|
334
|
+
p_writer.write()
|
335
|
+
written_fields.append('p')
|
336
|
+
|
337
|
+
# Write velocity field
|
338
|
+
u_writer = self.create_velocity_writer(use_csv_boundaries)
|
339
|
+
if u_writer:
|
340
|
+
u_writer.write()
|
341
|
+
written_fields.append('U')
|
342
|
+
|
343
|
+
# Write force field
|
344
|
+
f_writer = self.create_force_writer(use_csv_boundaries)
|
345
|
+
if f_writer:
|
346
|
+
f_writer.write()
|
347
|
+
written_fields.append('f')
|
348
|
+
|
349
|
+
# Write lambda field
|
350
|
+
lambda_writer = self.create_lambda_writer(use_csv_boundaries)
|
351
|
+
if lambda_writer:
|
352
|
+
lambda_writer.write()
|
353
|
+
written_fields.append('lambda')
|
354
|
+
|
355
|
+
print("=" * 60)
|
356
|
+
print(f"Written {len(written_fields)} zero field files: {', '.join(written_fields)}")
|
357
|
+
|
358
|
+
return written_fields
|
359
|
+
|
360
|
+
def get_available_fields(self) -> Dict[str, bool]:
|
361
|
+
"""
|
362
|
+
Get information about which fields are available in CSV and config.
|
363
|
+
|
364
|
+
Returns:
|
365
|
+
Dictionary with field availability information
|
366
|
+
"""
|
367
|
+
return {
|
368
|
+
'p': {
|
369
|
+
'csv_available': self._check_field_in_csv('p'),
|
370
|
+
'config_enabled': False, # Will be set by checking config
|
371
|
+
'boundary_conditions': self._get_csv_boundary_conditions('p')
|
372
|
+
},
|
373
|
+
'U': {
|
374
|
+
'csv_available': self._check_field_in_csv('U'),
|
375
|
+
'config_enabled': False,
|
376
|
+
'boundary_conditions': self._get_csv_boundary_conditions('U')
|
377
|
+
},
|
378
|
+
'f': {
|
379
|
+
'csv_available': self._check_field_in_csv('f'),
|
380
|
+
'config_enabled': False,
|
381
|
+
'boundary_conditions': self._get_csv_boundary_conditions('f')
|
382
|
+
},
|
383
|
+
'lambda': {
|
384
|
+
'csv_available': self._check_field_in_csv('lambda'),
|
385
|
+
'config_enabled': False,
|
386
|
+
'boundary_conditions': self._get_csv_boundary_conditions('lambda')
|
387
|
+
}
|
388
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pycphy
|
3
|
-
Version: 0.
|
4
|
-
Summary: Python: Computational Physics - Tools for physics dynamics simulation
|
3
|
+
Version: 0.2.0
|
4
|
+
Summary: Python: Computational Physics - Tools for physics dynamics simulation with CAD-based OpenFOAM case generation
|
5
5
|
Home-page: https://github.com/SanjeevBashyal/pycphy
|
6
6
|
Author: Sanjeev Bashyal
|
7
7
|
Author-email: Sanjeev Bashyal <sanjeev.bashyal@example.com>
|
@@ -11,10 +11,10 @@ Project-URL: Homepage, https://github.com/SanjeevBashyal/pycphy
|
|
11
11
|
Project-URL: Repository, https://github.com/SanjeevBashyal/pycphy
|
12
12
|
Project-URL: Documentation, https://github.com/SanjeevBashyal/pycphy#readme
|
13
13
|
Project-URL: Bug Tracker, https://github.com/SanjeevBashyal/pycphy/issues
|
14
|
-
Keywords: computational physics,simulation,openfoam,cfd,physics
|
14
|
+
Keywords: computational physics,simulation,openfoam,cfd,physics,autocad,cad,mesh generation,blockmesh
|
15
15
|
Classifier: Development Status :: 3 - Alpha
|
16
16
|
Classifier: Intended Audience :: Science/Research
|
17
|
-
Classifier: Operating System ::
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
18
18
|
Classifier: Programming Language :: Python :: 3
|
19
19
|
Classifier: Programming Language :: Python :: 3.7
|
20
20
|
Classifier: Programming Language :: Python :: 3.8
|
@@ -23,12 +23,15 @@ Classifier: Programming Language :: Python :: 3.10
|
|
23
23
|
Classifier: Programming Language :: Python :: 3.11
|
24
24
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
25
25
|
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
27
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
26
28
|
Requires-Python: >=3.7
|
27
29
|
Description-Content-Type: text/markdown
|
28
30
|
License-File: LICENSE
|
29
31
|
Requires-Dist: numpy>=1.19.0
|
30
32
|
Requires-Dist: scipy>=1.6.0
|
31
33
|
Requires-Dist: matplotlib>=3.3.0
|
34
|
+
Requires-Dist: pandas>=1.3.0
|
32
35
|
Provides-Extra: dev
|
33
36
|
Requires-Dist: pytest>=6.0; extra == "dev"
|
34
37
|
Requires-Dist: pytest-cov; extra == "dev"
|
@@ -38,6 +41,12 @@ Requires-Dist: mypy; extra == "dev"
|
|
38
41
|
Provides-Extra: docs
|
39
42
|
Requires-Dist: sphinx; extra == "docs"
|
40
43
|
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
44
|
+
Provides-Extra: cad
|
45
|
+
Requires-Dist: pyautocad>=0.2.0; extra == "cad"
|
46
|
+
Requires-Dist: pywin32>=304; extra == "cad"
|
47
|
+
Provides-Extra: all
|
48
|
+
Requires-Dist: pyautocad>=0.2.0; extra == "all"
|
49
|
+
Requires-Dist: pywin32>=304; extra == "all"
|
41
50
|
Dynamic: author
|
42
51
|
Dynamic: home-page
|
43
52
|
Dynamic: license-file
|
@@ -63,8 +72,10 @@ A comprehensive Python package for computational physics simulations and tools,
|
|
63
72
|
The `foamCaseDeveloper` module provides:
|
64
73
|
|
65
74
|
- **BlockMesh Generation**: Create OpenFOAM blockMeshDict files with custom geometries
|
75
|
+
- **CAD-based Mesh Generation**: Generate blockMeshDict directly from AutoCAD CAD files with XData annotations
|
66
76
|
- **Control Dictionary Setup**: Configure solver settings, time control, and output parameters
|
67
77
|
- **Turbulence Model Configuration**: Set up RAS, LES, and laminar turbulence models
|
78
|
+
- **Zero Field Generation**: Create initial field files (p, U, f, lambda) with CSV-based boundary conditions
|
68
79
|
- **Complete Case Management**: Automatically create complete OpenFOAM case directories
|
69
80
|
- **Validation and Error Checking**: Built-in validation for all configuration parameters
|
70
81
|
|
@@ -78,6 +89,14 @@ cd pycphy
|
|
78
89
|
pip install -e .
|
79
90
|
```
|
80
91
|
|
92
|
+
### With CAD Support (Recommended)
|
93
|
+
|
94
|
+
```bash
|
95
|
+
git clone https://github.com/SanjeevBashyal/pycphy.git
|
96
|
+
cd pycphy
|
97
|
+
pip install -e ".[cad]"
|
98
|
+
```
|
99
|
+
|
81
100
|
### Development Installation
|
82
101
|
|
83
102
|
```bash
|
@@ -86,16 +105,39 @@ cd pycphy
|
|
86
105
|
pip install -e ".[dev]"
|
87
106
|
```
|
88
107
|
|
108
|
+
### Full Installation (All Features)
|
109
|
+
|
110
|
+
```bash
|
111
|
+
git clone https://github.com/SanjeevBashyal/pycphy.git
|
112
|
+
cd pycphy
|
113
|
+
pip install -e ".[all]"
|
114
|
+
```
|
115
|
+
|
89
116
|
## Quick Start
|
90
117
|
|
91
118
|
### Using the Command Line Interface
|
92
119
|
|
93
120
|
```bash
|
94
|
-
# Create an example case
|
121
|
+
# Create an example case (traditional CLI)
|
95
122
|
pycphy-foam --example
|
96
123
|
|
97
|
-
# Create a custom case from configuration files
|
124
|
+
# Create a custom case from configuration files (traditional CLI)
|
98
125
|
pycphy-foam --case myCase --geometry configBlockMesh.py --control configControl.py --turbulence configTurbulence.py
|
126
|
+
|
127
|
+
# Create a case with CAD-based mesh generation (default behavior)
|
128
|
+
python pycphy/foamCaseDeveloper/develop_case.py
|
129
|
+
# OR after installation:
|
130
|
+
pycphy-develop
|
131
|
+
|
132
|
+
# Create a case with traditional config-based generation
|
133
|
+
python pycphy/foamCaseDeveloper/develop_case.py --config-mode
|
134
|
+
# OR after installation:
|
135
|
+
pycphy-develop --config-mode
|
136
|
+
|
137
|
+
# Create a case with CAD-based mesh generation and debug output
|
138
|
+
python pycphy/foamCaseDeveloper/develop_case.py --cad-debug --cad-tolerance 1e-6
|
139
|
+
# OR after installation:
|
140
|
+
pycphy-develop --cad-debug --cad-tolerance 1e-6
|
99
141
|
```
|
100
142
|
|
101
143
|
### Using Python API
|
@@ -148,6 +190,32 @@ case_manager.setup_turbulence(
|
|
148
190
|
case_manager.create_full_case()
|
149
191
|
```
|
150
192
|
|
193
|
+
### CAD-based Mesh Generation
|
194
|
+
|
195
|
+
```python
|
196
|
+
from pycphy.foamCaseDeveloper import CADBlockMeshDeveloper, cad_mesh_config
|
197
|
+
|
198
|
+
# Create CAD-based mesh developer
|
199
|
+
cad_developer = CADBlockMeshDeveloper(
|
200
|
+
blocks_csv_file="Inputs/blocks.csv",
|
201
|
+
patches_csv_file="Inputs/patches.csv",
|
202
|
+
tolerance=1e-6,
|
203
|
+
block_xdata_app_name="BLOCKDATA",
|
204
|
+
region_xdata_app_name="REGIONDATA"
|
205
|
+
)
|
206
|
+
|
207
|
+
# Process CAD file and generate complete OpenFOAM case
|
208
|
+
success = cad_developer.process_cad_file(
|
209
|
+
output_path="system/blockMeshDict",
|
210
|
+
debug=True
|
211
|
+
)
|
212
|
+
|
213
|
+
if success:
|
214
|
+
summary = cad_developer.get_summary()
|
215
|
+
print(f"Generated mesh with {summary['total_blocks']} blocks and {summary['total_patches']} patches")
|
216
|
+
print("Zero field files created with CSV boundary conditions")
|
217
|
+
```
|
218
|
+
|
151
219
|
## Package Structure
|
152
220
|
|
153
221
|
```
|
@@ -279,11 +347,91 @@ case_manager.create_full_case()
|
|
279
347
|
|
280
348
|
## Requirements
|
281
349
|
|
350
|
+
### Basic Requirements
|
282
351
|
- Python >= 3.7
|
283
352
|
- NumPy >= 1.19.0
|
284
353
|
- SciPy >= 1.6.0
|
285
354
|
- Matplotlib >= 3.3.0
|
286
355
|
|
356
|
+
### CAD-based Generation Requirements
|
357
|
+
- AutoCAD (with COM automation support)
|
358
|
+
- Windows operating system (for AutoCAD COM interface)
|
359
|
+
- pyautocad >= 0.2.0
|
360
|
+
- win32com (included with pywin32)
|
361
|
+
|
362
|
+
### CAD Setup for Mesh Generation
|
363
|
+
|
364
|
+
To use CAD-based mesh generation:
|
365
|
+
|
366
|
+
1. **Prepare your CAD file**:
|
367
|
+
- Create 3DSOLID entities for mesh blocks
|
368
|
+
- Create REGION entities for boundary patches
|
369
|
+
- Add XData to entities with block/patch information
|
370
|
+
|
371
|
+
2. **Create CSV configuration files**:
|
372
|
+
- `blocks.csv`: Define block parameters (ID, cells, grading, etc.)
|
373
|
+
- `patches.csv`: Define boundary conditions for each patch
|
374
|
+
|
375
|
+
3. **XData Format**:
|
376
|
+
- Blocks: Use "BLOCKDATA" app with block ID and description
|
377
|
+
- Regions: Use "REGIONDATA" app with region name
|
378
|
+
|
379
|
+
4. **Run the generation**:
|
380
|
+
```bash
|
381
|
+
# CAD-based case generation with all OpenFOAM files (default)
|
382
|
+
python pycphy/foamCaseDeveloper/develop_case.py
|
383
|
+
# OR after installation:
|
384
|
+
pycphy-develop
|
385
|
+
|
386
|
+
# Traditional config-based case generation
|
387
|
+
python pycphy/foamCaseDeveloper/develop_case.py --config-mode
|
388
|
+
# OR after installation:
|
389
|
+
pycphy-develop --config-mode
|
390
|
+
```
|
391
|
+
|
392
|
+
## Integrated Workflow
|
393
|
+
|
394
|
+
The `develop_case.py` script now supports both traditional config-based and CAD-based OpenFOAM case generation:
|
395
|
+
|
396
|
+
### CAD-based Generation
|
397
|
+
- **Mesh**: Generated directly from AutoCAD CAD files using XData annotations
|
398
|
+
- **Zero fields**: Created with boundary conditions from CSV files
|
399
|
+
- **Other files**: Generated from configuration files (control, turbulence, etc.)
|
400
|
+
|
401
|
+
### Traditional Generation
|
402
|
+
- **Mesh**: Generated from geometry configuration files
|
403
|
+
- **Zero fields**: Generated from configuration files with hardcoded boundary conditions
|
404
|
+
- **Other files**: Generated from configuration files
|
405
|
+
|
406
|
+
### Command Line Options
|
407
|
+
|
408
|
+
```bash
|
409
|
+
# Basic usage (CAD-based generation is now default)
|
410
|
+
python pycphy/foamCaseDeveloper/develop_case.py
|
411
|
+
# OR after installation:
|
412
|
+
pycphy-develop
|
413
|
+
|
414
|
+
# Traditional config-based generation
|
415
|
+
python pycphy/foamCaseDeveloper/develop_case.py --config-mode
|
416
|
+
# OR after installation:
|
417
|
+
pycphy-develop --config-mode
|
418
|
+
|
419
|
+
# CAD-based with custom CSV files
|
420
|
+
python pycphy/foamCaseDeveloper/develop_case.py --blocks-csv my_blocks.csv --patches-csv my_patches.csv
|
421
|
+
# OR after installation:
|
422
|
+
pycphy-develop --blocks-csv my_blocks.csv --patches-csv my_patches.csv
|
423
|
+
|
424
|
+
# CAD-based with debug output
|
425
|
+
python pycphy/foamCaseDeveloper/develop_case.py --cad-debug
|
426
|
+
# OR after installation:
|
427
|
+
pycphy-develop --cad-debug
|
428
|
+
|
429
|
+
# CAD-based with custom tolerance and XData app names
|
430
|
+
python pycphy/foamCaseDeveloper/develop_case.py --cad-tolerance 1e-5 --block-xdata-app MYBLOCKDATA --region-xdata-app MYREGIONDATA
|
431
|
+
# OR after installation:
|
432
|
+
pycphy-develop --cad-tolerance 1e-5 --block-xdata-app MYBLOCKDATA --region-xdata-app MYREGIONDATA
|
433
|
+
```
|
434
|
+
|
287
435
|
## Development
|
288
436
|
|
289
437
|
### Running Tests
|