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
@@ -0,0 +1,241 @@
1
+ # snappy_hex_mesh_config.py
2
+
3
+ # =============================================================================
4
+ # *** User Input for snappyHexMeshDict ***
5
+ # =============================================================================
6
+ #
7
+ # This file defines the mesh generation parameters for snappyHexMesh.
8
+ # snappyHexMesh is used for complex geometry meshing with automatic
9
+ # boundary layer generation and mesh refinement.
10
+ #
11
+
12
+ # `WRITE_SNAPPY_HEX_MESH_DICT`: Set to True to enable writing of the snappyHexMeshDict file.
13
+ # If False, this component will be skipped.
14
+ WRITE_SNAPPY_HEX_MESH_DICT = True
15
+
16
+ # --- Step Control ---
17
+ # Which steps of snappyHexMesh to run
18
+ CASTELLATED_MESH = True # Initial mesh generation and refinement
19
+ SNAP = True # Snap mesh to geometry surfaces
20
+ ADD_LAYERS = False # Add boundary layers (can be computationally expensive)
21
+
22
+ # --- Geometry Definition ---
23
+ # `GEOMETRY`: Dictionary containing all geometry files and analytical shapes.
24
+ # Each entry maps a geometry name to its definition.
25
+ # Supports both STL/OBJ files and analytical shapes (box, sphere, cylinder, etc.)
26
+ GEOMETRY = {
27
+ # Surface mesh files (STL, OBJ, etc.)
28
+ "motorBike": {
29
+ "type": "triSurfaceMesh",
30
+ "file": "motorBike.obj"
31
+ },
32
+
33
+ # Analytical shapes for refinement regions
34
+ "refinementBox": {
35
+ "type": "box",
36
+ "min": [-1.0, -0.7, 0.0],
37
+ "max": [8.0, 0.7, 2.5]
38
+ },
39
+
40
+ # Example of cylinder for pipe flows
41
+ # "pipe": {
42
+ # "type": "cylinder",
43
+ # "point1": [0, 0, 0],
44
+ # "point2": [0, 0, 1],
45
+ # "radius": 0.1
46
+ # },
47
+
48
+ # Example of sphere for bluff body flows
49
+ # "sphere": {
50
+ # "type": "sphere",
51
+ # "centre": [0, 0, 0],
52
+ # "radius": 0.05
53
+ # }
54
+ }
55
+
56
+ # --- Castellated Mesh Controls ---
57
+ # `CASTELLATED_MESH_CONTROLS`: Controls for the initial mesh generation phase.
58
+ CASTELLATED_MESH_CONTROLS = {
59
+ # Refinement parameters
60
+ "maxLocalCells": 100000, # Max cells per processor before balancing
61
+ "maxGlobalCells": 8000000, # Total cell limit (approximate)
62
+ "minRefinementCells": 10, # Stop if fewer cells selected for refinement
63
+ "maxLoadUnbalance": 0.10, # Allow imbalance during refinement (0=perfect balance)
64
+ "nCellsBetweenLevels": 3, # Buffer layers between refinement levels
65
+
66
+ # Feature edge refinement (from .eMesh files)
67
+ "features": [
68
+ {
69
+ "file": "motorBike.eMesh",
70
+ "level": 7 # Refinement level for feature edges
71
+ }
72
+ ],
73
+
74
+ # Surface-based refinement
75
+ "refinementSurfaces": {
76
+ "motorBike": {
77
+ "level": (7, 7), # (minLevel, maxLevel) for surface refinement
78
+ "patchInfo": {
79
+ "type": "wall",
80
+ "inGroups": ["motorBikeGroup"]
81
+ }
82
+ }
83
+ },
84
+
85
+ # Sharp angle resolution
86
+ "resolveFeatureAngle": 30, # Degrees - resolve angles sharper than this
87
+
88
+ # Region-wise refinement (distance-based, inside, or outside)
89
+ "refinementRegions": {
90
+ "refinementBox": {
91
+ "mode": "inside",
92
+ "levels": ((1e15, 4)) # (distance, level) pairs
93
+ }
94
+ },
95
+
96
+ # Mesh selection point (must be inside the domain)
97
+ "locationInMesh": [3.0001, 3.0001, 0.43],
98
+
99
+ # Zone face handling
100
+ "allowFreeStandingZoneFaces": True
101
+ }
102
+
103
+ # --- Snap Controls ---
104
+ # `SNAP_CONTROLS`: Controls for the mesh snapping phase to geometry.
105
+ SNAP_CONTROLS = {
106
+ # Patch smoothing iterations before surface correspondence
107
+ "nSmoothPatch": 3,
108
+
109
+ # Relative distance for surface feature attraction
110
+ "tolerance": 2.0,
111
+
112
+ # Mesh displacement relaxation iterations
113
+ "nSolveIter": 30,
114
+
115
+ # Maximum snapping relaxation iterations
116
+ "nRelaxIter": 5,
117
+
118
+ # Feature snapping iterations
119
+ "nFeatureSnapIter": 10,
120
+
121
+ # Feature detection methods
122
+ "implicitFeatureSnap": False, # Detect features by surface sampling
123
+ "explicitFeatureSnap": True, # Use features from castellatedMeshControls
124
+ "multiRegionFeatureSnap": False # Detect points on multiple surfaces
125
+ }
126
+
127
+ # --- Add Layers Controls ---
128
+ # `ADD_LAYERS_CONTROLS`: Controls for boundary layer generation.
129
+ ADD_LAYERS_CONTROLS = {
130
+ # Thickness parameters relative to cell size outside layer
131
+ "relativeSizes": True,
132
+
133
+ # Layer definitions per patch (using regex patterns)
134
+ "layers": {
135
+ "(lowerWall|motorBike).*": {
136
+ "nSurfaceLayers": 1 # Number of boundary layers
137
+ }
138
+ },
139
+
140
+ # Layer expansion ratio (thickness growth)
141
+ "expansionRatio": 1.0,
142
+
143
+ # Final layer thickness (relative to cell size)
144
+ "finalLayerThickness": 0.3,
145
+
146
+ # Minimum layer thickness
147
+ "minThickness": 0.1,
148
+
149
+ # Connected face growth for convergence
150
+ "nGrow": 0,
151
+
152
+ # Advanced settings
153
+ "featureAngle": 60, # Angle threshold for layer termination
154
+ "nRelaxIter": 5, # Relaxation iterations
155
+ "nSmoothSurfaceNormals": 1, # Surface normal smoothing
156
+ "nSmoothNormals": 3, # Normal smoothing iterations
157
+ "nSmoothThickness": 10, # Thickness smoothing iterations
158
+ "maxFaceThicknessRatio": 0.5, # Max face thickness ratio
159
+ "maxThicknessToMedialRatio": 0.3, # Max thickness to medial ratio
160
+ "minMedianAxisAngle": 90, # Min median axis angle
161
+ "nBufferCellsNoExtrude": 0, # Buffer cells without extrusion
162
+ "nLayerIter": 50, # Layer addition iterations
163
+ "nRelaxedIter": 20 # Relaxed iterations
164
+ }
165
+
166
+ # --- Mesh Quality Controls ---
167
+ # `MESH_QUALITY_CONTROLS`: Controls for mesh quality optimization.
168
+ MESH_QUALITY_CONTROLS = {
169
+ # Orthogonality and skewness
170
+ "maxNonOrtho": 65, # Maximum non-orthogonality
171
+ "maxBoundarySkewness": 20, # Maximum boundary face skewness
172
+ "maxInternalSkewness": 4, # Maximum internal face skewness
173
+ "maxConcave": 80, # Maximum concavity
174
+
175
+ # Volume and area constraints
176
+ "minFlatness": 0.5, # Minimum face flatness
177
+ "minVol": 1e-13, # Minimum cell volume
178
+ "minTetQuality": 1e-30, # Minimum tetrahedron quality
179
+ "minArea": -1, # Minimum face area (-1 = no limit)
180
+
181
+ # Twist and determinant
182
+ "minTwist": 0.02, # Minimum face twist
183
+ "minDeterminant": 0.001, # Minimum determinant
184
+ "minFaceWeight": 0.02, # Minimum face weight
185
+ "minVolRatio": 0.01, # Minimum volume ratio
186
+ "minTriangleTwist": -1, # Minimum triangle twist
187
+
188
+ # Smoothing parameters
189
+ "nSmoothScale": 4, # Number of smoothing scale iterations
190
+ "errorReduction": 0.75, # Error reduction factor
191
+
192
+ # Relaxed quality criteria (for difficult meshes)
193
+ "relaxed": {
194
+ "maxNonOrtho": 75,
195
+ "maxBoundarySkewness": 30,
196
+ "maxInternalSkewness": 8,
197
+ "maxConcave": 85,
198
+ "minFlatness": 0.3,
199
+ "minVol": 1e-12,
200
+ "minTetQuality": 1e-25,
201
+ "minArea": -1,
202
+ "minTwist": 0.01,
203
+ "minDeterminant": 0.0001,
204
+ "minFaceWeight": 0.01,
205
+ "minVolRatio": 0.005,
206
+ "minTriangleTwist": -1
207
+ }
208
+ }
209
+
210
+ # --- Advanced Options ---
211
+ # `MERGED_PATCHES`: List of patches to be merged.
212
+ # Used for creating periodic boundaries or connecting patches
213
+ MERGED_PATCHES = []
214
+
215
+ # `WRITE_FLAGS`: Control what files are written during meshing.
216
+ WRITE_FLAGS = {
217
+ "writeMesh": True, # Write final mesh
218
+ "writeSets": True, # Write cell/face sets
219
+ "writeZones": True # Write cell/face zones
220
+ }
221
+
222
+ # --- Predefined Templates ---
223
+ # `TEMPLATE`: Select a predefined snappyHexMesh template
224
+ # Options: 'none', 'motorcycle', 'room', 'turbine', 'car', 'airfoil'
225
+ TEMPLATE = "none"
226
+
227
+ # `TEMPLATE_PARAMETERS`: Parameters for the selected template
228
+ TEMPLATE_PARAMETERS = {
229
+ "motorcycle": {
230
+ "geometry_file": "motorBike.obj",
231
+ "feature_file": "motorBike.eMesh",
232
+ "refinement_levels": (7, 7),
233
+ "boundary_layers": False
234
+ },
235
+ "room": {
236
+ "geometry_files": ["room.stl", "desk.stl", "door.stl"],
237
+ "refinement_levels": (2, 3),
238
+ "boundary_layers": False
239
+ }
240
+ }
241
+
@@ -0,0 +1,135 @@
1
+ # U_config.py
2
+ """
3
+ Configuration for velocity field (U) initialization.
4
+ Based on OpenFOAM volVectorField format for velocity boundary conditions.
5
+ """
6
+
7
+ # =============================================================================
8
+ # *** Configuration for velocity field (U) ***
9
+ # =============================================================================
10
+
11
+ # --- Master Control ---
12
+ # Set to True to write '0/U' field file.
13
+ WRITE_U_FIELD = True
14
+
15
+ # --- Velocity Field Configuration ---
16
+ # Internal field velocity vector (m/s) [Ux, Uy, Uz]
17
+ INTERNAL_VELOCITY = (0.0, 0.0, 0.0)
18
+
19
+ # --- Boundary Conditions ---
20
+ # Boundary conditions are now read from patches.csv
21
+ # Available boundary condition types:
22
+ # "fixedValue": Fixed velocity value
23
+ # "zeroGradient": Zero gradient (natural outflow)
24
+ # "inletOutlet": Inlet/outlet condition
25
+ # "noSlip": No-slip condition (for walls)
26
+ # "slip": Slip condition (for symmetry)
27
+ # "cyclic": Cyclic boundary condition
28
+ # "timeVaryingMappedFixedValue": Time-varying mapped value
29
+
30
+ # Note: Boundary conditions are automatically loaded from patches.csv
31
+ # The CSV file should have columns: RegionName, PatchName, PatchType, U, U-value
32
+
33
+ # --- Advanced Configuration ---
34
+ # Velocity dimensions [length time^-1]
35
+ VELOCITY_DIMENSIONS = [0, 1, -1, 0, 0, 0, 0]
36
+
37
+ # --- Flow Profile Configurations ---
38
+ # Predefined velocity profiles for different inlet conditions
39
+ FLOW_PROFILES = {
40
+ "uniform": {
41
+ "type": "fixedValue",
42
+ "value": (1.0, 0.0, 0.0),
43
+ "description": "Uniform velocity profile"
44
+ },
45
+ "parabolic": {
46
+ "type": "timeVaryingMappedFixedValue",
47
+ "description": "Parabolic velocity profile (requires profile data)"
48
+ },
49
+ "turbulent": {
50
+ "type": "fixedValue",
51
+ "value": (1.0, 0.0, 0.0),
52
+ "description": "Turbulent inlet (requires turbulence fields)"
53
+ },
54
+ "zero": {
55
+ "type": "fixedValue",
56
+ "value": (0.0, 0.0, 0.0),
57
+ "description": "Zero velocity (resting fluid)"
58
+ }
59
+ }
60
+
61
+ # --- Template Configurations ---
62
+ # Predefined configurations for common scenarios
63
+ TEMPLATE_CONFIGS = {
64
+ "channel_flow": {
65
+ "internal_velocity": (0.0, 0.0, 0.0),
66
+ "boundary_conditions": {
67
+ "inlet": {"type": "fixedValue", "value": (1.0, 0.0, 0.0)},
68
+ "outlet": {"type": "inletOutlet", "inletValue": (0.0, 0.0, 0.0)},
69
+ "walls": {"type": "noSlip"}
70
+ }
71
+ },
72
+ "cavity_flow": {
73
+ "internal_velocity": (0.0, 0.0, 0.0),
74
+ "boundary_conditions": {
75
+ "movingWall": {"type": "fixedValue", "value": (1.0, 0.0, 0.0)},
76
+ "fixedWalls": {"type": "noSlip"}
77
+ }
78
+ },
79
+ "pipe_flow": {
80
+ "internal_velocity": (0.0, 0.0, 0.0),
81
+ "boundary_conditions": {
82
+ "inlet": {"type": "fixedValue", "value": (1.0, 0.0, 0.0)},
83
+ "outlet": {"type": "inletOutlet", "inletValue": (0.0, 0.0, 0.0)},
84
+ "wall": {"type": "noSlip"}
85
+ }
86
+ },
87
+ "backward_facing_step": {
88
+ "internal_velocity": (0.0, 0.0, 0.0),
89
+ "boundary_conditions": {
90
+ "inlet": {"type": "fixedValue", "value": (1.0, 0.0, 0.0)},
91
+ "outlet": {"type": "inletOutlet", "inletValue": (0.0, 0.0, 0.0)},
92
+ "step": {"type": "noSlip"},
93
+ "walls": {"type": "noSlip"}
94
+ }
95
+ },
96
+ "lid_driven_cavity": {
97
+ "internal_velocity": (0.0, 0.0, 0.0),
98
+ "boundary_conditions": {
99
+ "movingWall": {"type": "fixedValue", "value": (1.0, 0.0, 0.0)},
100
+ "fixedWalls": {"type": "noSlip"}
101
+ }
102
+ }
103
+ }
104
+
105
+ # Select template (set to None to use custom configuration above)
106
+ SELECTED_TEMPLATE = None # Options: None, "channel_flow", "cavity_flow", "pipe_flow", "backward_facing_step", "lid_driven_cavity"
107
+
108
+ # --- Custom Field Configuration ---
109
+ # Additional field properties
110
+ FIELD_PROPERTIES = {
111
+ "include_initial_conditions": False, # Include initial conditions file
112
+ "include_constraint_types": False, # Include constraint types
113
+ "include_environment": False, # Include environment settings
114
+ "use_regex_patches": False, # Use regex for patch matching
115
+ "version": "v2510" # OpenFOAM version for header
116
+ }
117
+
118
+ # --- Turbulence Inlet Configuration ---
119
+ # For cases with turbulence modeling
120
+ TURBULENCE_INLET = {
121
+ "enabled": False,
122
+ "turbulence_intensity": 0.05, # 5% turbulence intensity
123
+ "length_scale": 0.01, # Turbulence length scale
124
+ "profile_type": "uniform" # uniform, parabolic, turbulent
125
+ }
126
+
127
+ # --- Comments and Documentation ---
128
+ FIELD_DESCRIPTION = "Velocity field initialization for CFD simulation"
129
+ FIELD_NOTES = [
130
+ "Velocity is typically initialized to zero for most cases",
131
+ "Use fixedValue for specified velocity inlets",
132
+ "Use inletOutlet for natural outflow boundaries",
133
+ "Use noSlip for wall boundaries",
134
+ "Consider turbulence inlet conditions for RANS/LES simulations"
135
+ ]
@@ -0,0 +1,22 @@
1
+ # 0/__init__.py
2
+ """
3
+ Zero directory configuration modules.
4
+
5
+ This package contains configuration modules for OpenFOAM 0 directory field files:
6
+ - p (pressure field)
7
+ - U (velocity field)
8
+ - f (force field)
9
+ - lambda (scalar field)
10
+ """
11
+
12
+ from . import p_config
13
+ from . import U_config
14
+ from . import f_config
15
+ from . import lambda_config
16
+
17
+ __all__ = [
18
+ 'p_config',
19
+ 'U_config',
20
+ 'f_config',
21
+ 'lambda_config'
22
+ ]
@@ -0,0 +1,140 @@
1
+ # f_config.py
2
+ """
3
+ Configuration for force field (f) initialization.
4
+ Based on OpenFOAM volVectorField format for body force boundary conditions.
5
+ """
6
+
7
+ # =============================================================================
8
+ # *** Configuration for force field (f) ***
9
+ # =============================================================================
10
+
11
+ # --- Master Control ---
12
+ # Set to True to write '0/f' field file.
13
+ WRITE_F_FIELD = True
14
+
15
+ # --- Force Field Configuration ---
16
+ # Internal field force vector (N/kg or m/s²) [fx, fy, fz]
17
+ INTERNAL_FORCE = (0.0, 0.0, 0.0)
18
+
19
+ # --- Boundary Conditions ---
20
+ # Boundary conditions are now read from patches.csv
21
+ # Available boundary condition types:
22
+ # "fixedValue": Fixed force value
23
+ # "zeroGradient": Zero gradient (natural condition)
24
+ # "calculated": Calculated value
25
+ # "symmetry": Symmetry condition
26
+
27
+ # Note: Boundary conditions are automatically loaded from patches.csv
28
+ # The CSV file should have columns: RegionName, PatchName, PatchType, f, f-value
29
+
30
+ # --- Advanced Configuration ---
31
+ # Force dimensions [length time^-2] (acceleration units)
32
+ FORCE_DIMENSIONS = [0, 1, -2, 0, 0, 0, 0]
33
+
34
+ # --- Force Types ---
35
+ # Predefined force configurations for different physics
36
+ FORCE_TYPES = {
37
+ "none": {
38
+ "internal_force": (0.0, 0.0, 0.0),
39
+ "description": "No body forces"
40
+ },
41
+ "gravity": {
42
+ "internal_force": (0.0, 0.0, -9.81),
43
+ "description": "Gravitational force (downward)"
44
+ },
45
+ "buoyancy": {
46
+ "internal_force": (0.0, 0.0, 9.81),
47
+ "description": "Buoyancy force (upward)"
48
+ },
49
+ "centrifugal": {
50
+ "internal_force": (1.0, 0.0, 0.0),
51
+ "description": "Centrifugal force"
52
+ },
53
+ "coriolis": {
54
+ "internal_force": (0.0, 0.0, 0.0),
55
+ "description": "Coriolis force (requires rotation)"
56
+ },
57
+ "electromagnetic": {
58
+ "internal_force": (0.0, 0.0, 0.0),
59
+ "description": "Electromagnetic body force"
60
+ }
61
+ }
62
+
63
+ # --- Template Configurations ---
64
+ # Predefined configurations for common scenarios
65
+ TEMPLATE_CONFIGS = {
66
+ "natural_convection": {
67
+ "internal_force": (0.0, 0.0, -9.81),
68
+ "boundary_conditions": {
69
+ "walls": {"type": "zeroGradient"},
70
+ "inlet": {"type": "zeroGradient"},
71
+ "outlet": {"type": "zeroGradient"}
72
+ }
73
+ },
74
+ "forced_convection": {
75
+ "internal_force": (0.0, 0.0, 0.0),
76
+ "boundary_conditions": {
77
+ "walls": {"type": "zeroGradient"},
78
+ "inlet": {"type": "zeroGradient"},
79
+ "outlet": {"type": "zeroGradient"}
80
+ }
81
+ },
82
+ "rotating_frame": {
83
+ "internal_force": (1.0, 0.0, 0.0),
84
+ "boundary_conditions": {
85
+ "walls": {"type": "zeroGradient"},
86
+ "inlet": {"type": "zeroGradient"},
87
+ "outlet": {"type": "zeroGradient"}
88
+ }
89
+ },
90
+ "magnetohydrodynamics": {
91
+ "internal_force": (0.0, 0.0, 0.0),
92
+ "boundary_conditions": {
93
+ "walls": {"type": "zeroGradient"},
94
+ "inlet": {"type": "zeroGradient"},
95
+ "outlet": {"type": "zeroGradient"}
96
+ }
97
+ },
98
+ "free_surface": {
99
+ "internal_force": (0.0, 0.0, -9.81),
100
+ "boundary_conditions": {
101
+ "walls": {"type": "zeroGradient"},
102
+ "inlet": {"type": "zeroGradient"},
103
+ "outlet": {"type": "zeroGradient"},
104
+ "atmosphere": {"type": "zeroGradient"}
105
+ }
106
+ }
107
+ }
108
+
109
+ # Select template (set to None to use custom configuration above)
110
+ SELECTED_TEMPLATE = None # Options: None, "natural_convection", "forced_convection", "rotating_frame", "magnetohydrodynamics", "free_surface"
111
+
112
+ # --- Custom Field Configuration ---
113
+ # Additional field properties
114
+ FIELD_PROPERTIES = {
115
+ "include_initial_conditions": False, # Include initial conditions file
116
+ "include_constraint_types": False, # Include constraint types
117
+ "include_environment": False, # Include environment settings
118
+ "use_regex_patches": False, # Use regex for patch matching
119
+ "version": "v2510" # OpenFOAM version for header
120
+ }
121
+
122
+ # --- Force Source Configuration ---
123
+ # For spatially varying or time-dependent forces
124
+ FORCE_SOURCES = {
125
+ "enabled": False,
126
+ "source_type": "uniform", # uniform, linear, parabolic, custom
127
+ "custom_function": None, # Custom force function
128
+ "region_based": False, # Apply forces only to specific regions
129
+ "regions": [] # List of regions for region-based forces
130
+ }
131
+
132
+ # --- Comments and Documentation ---
133
+ FIELD_DESCRIPTION = "Body force field initialization for CFD simulation"
134
+ FIELD_NOTES = [
135
+ "Force field represents body forces per unit mass (acceleration units)",
136
+ "Common applications: gravity, buoyancy, centrifugal, electromagnetic forces",
137
+ "Zero gradient is typically used for all boundaries",
138
+ "Force field is often used with Boussinesq approximation for natural convection",
139
+ "Consider coordinate system when defining force directions"
140
+ ]