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,157 @@
1
+ # lambda_config.py
2
+ """
3
+ Configuration for lambda field (λ) initialization.
4
+ Based on OpenFOAM volScalarField format for lambda boundary conditions.
5
+ Lambda is often used for level set functions, phase fields, or other scalar transport.
6
+ """
7
+
8
+ # =============================================================================
9
+ # *** Configuration for lambda field (λ) ***
10
+ # =============================================================================
11
+
12
+ # --- Master Control ---
13
+ # Set to True to write '0/lambda' field file.
14
+ WRITE_LAMBDA_FIELD = True
15
+
16
+ # --- Lambda Field Configuration ---
17
+ # Internal field lambda value (dimensionless)
18
+ INTERNAL_LAMBDA = 0.0
19
+
20
+ # --- Boundary Conditions ---
21
+ # Boundary conditions are now read from patches.csv
22
+ # Available boundary condition types:
23
+ # "fixedValue": Fixed lambda value
24
+ # "zeroGradient": Zero gradient (natural condition)
25
+ # "calculated": Calculated value
26
+ # "symmetry": Symmetry condition
27
+ # "empty": Empty condition (for 2D cases)
28
+
29
+ # Note: Boundary conditions are automatically loaded from patches.csv
30
+ # The CSV file should have columns: RegionName, PatchName, PatchType, lambda, lambda-value
31
+
32
+ # --- Advanced Configuration ---
33
+ # Lambda dimensions (typically dimensionless)
34
+ LAMBDA_DIMENSIONS = [0, 0, 0, 0, 0, 0, 0]
35
+
36
+ # --- Lambda Field Types ---
37
+ # Predefined lambda configurations for different applications
38
+ LAMBDA_TYPES = {
39
+ "level_set": {
40
+ "internal_lambda": 0.0,
41
+ "description": "Level set function for interface tracking",
42
+ "range": [-1.0, 1.0]
43
+ },
44
+ "phase_field": {
45
+ "internal_lambda": 0.0,
46
+ "description": "Phase field variable",
47
+ "range": [0.0, 1.0]
48
+ },
49
+ "scalar_transport": {
50
+ "internal_lambda": 0.0,
51
+ "description": "General scalar transport variable",
52
+ "range": [0.0, 1.0]
53
+ },
54
+ "temperature_normalized": {
55
+ "internal_lambda": 0.0,
56
+ "description": "Normalized temperature field",
57
+ "range": [0.0, 1.0]
58
+ },
59
+ "concentration": {
60
+ "internal_lambda": 0.0,
61
+ "description": "Species concentration field",
62
+ "range": [0.0, 1.0]
63
+ },
64
+ "porosity": {
65
+ "internal_lambda": 1.0,
66
+ "description": "Porosity field",
67
+ "range": [0.0, 1.0]
68
+ }
69
+ }
70
+
71
+ # --- Template Configurations ---
72
+ # Predefined configurations for common scenarios
73
+ TEMPLATE_CONFIGS = {
74
+ "level_set_interface": {
75
+ "internal_lambda": 0.0,
76
+ "boundary_conditions": {
77
+ "walls": {"type": "zeroGradient"},
78
+ "inlet": {"type": "fixedValue", "value": -1.0},
79
+ "outlet": {"type": "zeroGradient"}
80
+ }
81
+ },
82
+ "phase_field_evolution": {
83
+ "internal_lambda": 0.0,
84
+ "boundary_conditions": {
85
+ "walls": {"type": "zeroGradient"},
86
+ "inlet": {"type": "fixedValue", "value": 1.0},
87
+ "outlet": {"type": "zeroGradient"}
88
+ }
89
+ },
90
+ "scalar_transport": {
91
+ "internal_lambda": 0.0,
92
+ "boundary_conditions": {
93
+ "walls": {"type": "zeroGradient"},
94
+ "inlet": {"type": "fixedValue", "value": 1.0},
95
+ "outlet": {"type": "zeroGradient"}
96
+ }
97
+ },
98
+ "porous_medium": {
99
+ "internal_lambda": 1.0,
100
+ "boundary_conditions": {
101
+ "walls": {"type": "fixedValue", "value": 0.0},
102
+ "inlet": {"type": "fixedValue", "value": 1.0},
103
+ "outlet": {"type": "fixedValue", "value": 1.0}
104
+ }
105
+ },
106
+ "two_phase_flow": {
107
+ "internal_lambda": 0.0,
108
+ "boundary_conditions": {
109
+ "walls": {"type": "zeroGradient"},
110
+ "inlet": {"type": "fixedValue", "value": 1.0},
111
+ "outlet": {"type": "zeroGradient"}
112
+ }
113
+ }
114
+ }
115
+
116
+ # Select template (set to None to use custom configuration above)
117
+ SELECTED_TEMPLATE = None # Options: None, "level_set_interface", "phase_field_evolution", "scalar_transport", "porous_medium", "two_phase_flow"
118
+
119
+ # --- Custom Field Configuration ---
120
+ # Additional field properties
121
+ FIELD_PROPERTIES = {
122
+ "include_initial_conditions": False, # Include initial conditions file
123
+ "include_constraint_types": False, # Include constraint types
124
+ "include_environment": False, # Include environment settings
125
+ "use_regex_patches": False, # Use regex for patch matching
126
+ "version": "v2510" # OpenFOAM version for header
127
+ }
128
+
129
+ # --- Lambda Field Initialization ---
130
+ # For complex initial conditions
131
+ LAMBDA_INITIALIZATION = {
132
+ "enabled": False,
133
+ "initialization_type": "uniform", # uniform, linear, parabolic, custom
134
+ "custom_function": None, # Custom initialization function
135
+ "region_based": False, # Initialize based on regions
136
+ "regions": [] # List of regions for initialization
137
+ }
138
+
139
+ # --- Physical Properties ---
140
+ # Physical meaning and constraints
141
+ PHYSICAL_PROPERTIES = {
142
+ "field_meaning": "General scalar field",
143
+ "conserved_quantity": False, # Whether lambda represents a conserved quantity
144
+ "boundary_conditions_natural": True, # Whether zeroGradient is natural
145
+ "initialization_critical": True, # Whether initialization is critical
146
+ "solver_coupling": "none" # Coupling with other solvers
147
+ }
148
+
149
+ # --- Comments and Documentation ---
150
+ FIELD_DESCRIPTION = "Lambda field initialization for scalar transport or interface tracking"
151
+ FIELD_NOTES = [
152
+ "Lambda is a general scalar field used for various purposes",
153
+ "Common applications: level set functions, phase fields, scalar transport",
154
+ "Zero gradient is typically natural for most boundaries",
155
+ "Initial conditions are often critical for lambda field evolution",
156
+ "Consider physical meaning when setting boundary conditions"
157
+ ]
@@ -0,0 +1,97 @@
1
+ # p_config.py
2
+ """
3
+ Configuration for pressure field (p) initialization.
4
+ Based on OpenFOAM volScalarField format for pressure boundary conditions.
5
+ """
6
+
7
+ # =============================================================================
8
+ # *** Configuration for pressure field (p) ***
9
+ # =============================================================================
10
+
11
+ # --- Master Control ---
12
+ # Set to True to write '0/p' field file.
13
+ WRITE_P_FIELD = True
14
+
15
+ # --- Pressure Field Configuration ---
16
+ # Internal field pressure value (Pa)
17
+ INTERNAL_PRESSURE = 0.0
18
+
19
+ # --- Boundary Conditions ---
20
+ # Boundary conditions are now read from patches.csv
21
+ # Available boundary condition types:
22
+ # "fixedValue": Fixed pressure value
23
+ # "zeroGradient": Zero gradient (natural outflow)
24
+ # "fixedGradient": Fixed pressure gradient
25
+ # "timeVaryingMappedFixedValue": Time-varying mapped value
26
+ # "slip": Slip condition (for symmetry)
27
+ # "noSlip": No-slip condition (for walls)
28
+
29
+ # Note: Boundary conditions are automatically loaded from patches.csv
30
+ # The CSV file should have columns: RegionName, PatchName, PatchType, p, p-value
31
+
32
+ # --- Advanced Configuration ---
33
+ # Reference pressure cell and value for pressure correction
34
+ REF_PRESSURE_CELL = 0
35
+ REF_PRESSURE_VALUE = 0.0
36
+
37
+ # Pressure dimensions [mass length^-1 time^-2]
38
+ PRESSURE_DIMENSIONS = [0, 2, -2, 0, 0, 0, 0]
39
+
40
+ # --- Template Configurations ---
41
+ # Predefined configurations for common scenarios
42
+ TEMPLATE_CONFIGS = {
43
+ "channel_flow": {
44
+ "internal_pressure": 0.0,
45
+ "boundary_conditions": {
46
+ "inlet": {"type": "zeroGradient"},
47
+ "outlet": {"type": "fixedValue", "value": 0.0},
48
+ "walls": {"type": "zeroGradient"}
49
+ }
50
+ },
51
+ "cavity_flow": {
52
+ "internal_pressure": 0.0,
53
+ "boundary_conditions": {
54
+ "movingWall": {"type": "zeroGradient"},
55
+ "fixedWalls": {"type": "zeroGradient"}
56
+ }
57
+ },
58
+ "pipe_flow": {
59
+ "internal_pressure": 0.0,
60
+ "boundary_conditions": {
61
+ "inlet": {"type": "zeroGradient"},
62
+ "outlet": {"type": "fixedValue", "value": 0.0},
63
+ "wall": {"type": "zeroGradient"}
64
+ }
65
+ },
66
+ "backward_facing_step": {
67
+ "internal_pressure": 0.0,
68
+ "boundary_conditions": {
69
+ "inlet": {"type": "zeroGradient"},
70
+ "outlet": {"type": "fixedValue", "value": 0.0},
71
+ "step": {"type": "zeroGradient"},
72
+ "walls": {"type": "zeroGradient"}
73
+ }
74
+ }
75
+ }
76
+
77
+ # Select template (set to None to use custom configuration above)
78
+ SELECTED_TEMPLATE = None # Options: None, "channel_flow", "cavity_flow", "pipe_flow", "backward_facing_step"
79
+
80
+ # --- Custom Field Configuration ---
81
+ # Additional field properties
82
+ FIELD_PROPERTIES = {
83
+ "include_initial_conditions": False, # Include initial conditions file
84
+ "include_constraint_types": False, # Include constraint types
85
+ "include_environment": False, # Include environment settings
86
+ "use_regex_patches": False, # Use regex for patch matching
87
+ "version": "v2510" # OpenFOAM version for header
88
+ }
89
+
90
+ # --- Comments and Documentation ---
91
+ FIELD_DESCRIPTION = "Pressure field initialization for CFD simulation"
92
+ FIELD_NOTES = [
93
+ "Pressure is typically set to 0 Pa (gauge pressure) at atmospheric conditions",
94
+ "Use zeroGradient for natural outflow boundaries",
95
+ "Use fixedValue for specified pressure boundaries",
96
+ "Reference pressure cell is used for pressure correction in solvers"
97
+ ]
@@ -1,18 +1,30 @@
1
- """
2
- Core functionality for OpenFOAM case development.
3
-
4
- This module contains the main classes for managing OpenFOAM cases,
5
- including mesh generation, control setup, and case management.
6
- """
7
-
8
- from .block_mesh_developer import BlockMeshDeveloper
9
- from .control_dict_writer import ControlDictWriter
10
- from .turbulence_properties_writer import TurbulencePropertiesWriter
11
- from .foam_case_manager import FoamCaseManager
12
-
13
- __all__ = [
14
- "BlockMeshDeveloper",
15
- "ControlDictWriter",
16
- "TurbulencePropertiesWriter",
17
- "FoamCaseManager",
18
- ]
1
+ """
2
+ Core functionality for OpenFOAM case development.
3
+
4
+ This module contains the main classes for managing OpenFOAM cases,
5
+ including mesh generation, control setup, and case management.
6
+ """
7
+
8
+ from .block_mesh_developer import BlockMeshDeveloper
9
+ from .cad_block_mesh_developer import CADBlockMeshDeveloper
10
+ from .foam_case_manager import FoamCaseManager
11
+ from .case_builder import (
12
+ CaseComponent,
13
+ GeometryComponent,
14
+ ControlComponent,
15
+ TurbulenceComponent,
16
+ DynamicMeshComponent,
17
+ HFDIBDEMComponent
18
+ )
19
+
20
+ __all__ = [
21
+ "BlockMeshDeveloper",
22
+ "CADBlockMeshDeveloper",
23
+ "FoamCaseManager",
24
+ "CaseComponent",
25
+ "GeometryComponent",
26
+ "ControlComponent",
27
+ "TurbulenceComponent",
28
+ "DynamicMeshComponent",
29
+ "HFDIBDEMComponent",
30
+ ]
@@ -1,6 +1,6 @@
1
1
  # block_mesh_developer.py
2
2
 
3
- from ..writers.block_mesh_writer import BlockMeshWriter
3
+ from ..writers.system.block_mesh_writer import BlockMeshWriter
4
4
 
5
5
  class BlockMeshDeveloper:
6
6
  """