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,89 @@
|
|
1
|
+
# f_field_writer.py
|
2
|
+
|
3
|
+
"""
|
4
|
+
Force Field Writer for OpenFOAM cases.
|
5
|
+
|
6
|
+
This writer handles the creation of force field (f) files in the 0 directory
|
7
|
+
with support for various body force configurations.
|
8
|
+
"""
|
9
|
+
|
10
|
+
from ..foam_writer import FoamWriter
|
11
|
+
|
12
|
+
|
13
|
+
class FFieldWriter(FoamWriter):
|
14
|
+
"""
|
15
|
+
A class to write an OpenFOAM force field (f) file.
|
16
|
+
|
17
|
+
This writer supports various body forces including gravity, buoyancy,
|
18
|
+
centrifugal, electromagnetic, and other force configurations.
|
19
|
+
"""
|
20
|
+
|
21
|
+
def __init__(self, file_path, internal_force, boundary_conditions,
|
22
|
+
force_dimensions=[0, 1, -2, 0, 0, 0, 0]):
|
23
|
+
"""
|
24
|
+
Initialize the FFieldWriter.
|
25
|
+
|
26
|
+
Args:
|
27
|
+
file_path (str): The full path to the output file '0/f'.
|
28
|
+
internal_force (tuple): Internal field force vector (fx, fy, fz).
|
29
|
+
boundary_conditions (dict): Boundary conditions for each patch.
|
30
|
+
force_dimensions (list): Force field dimensions.
|
31
|
+
"""
|
32
|
+
super().__init__(file_path, foam_class="volVectorField", foam_object="f")
|
33
|
+
self.internal_force = internal_force
|
34
|
+
self.boundary_conditions = boundary_conditions
|
35
|
+
self.force_dimensions = force_dimensions
|
36
|
+
|
37
|
+
def _write_dimensions(self):
|
38
|
+
"""Write the dimensions section."""
|
39
|
+
dims_str = ' '.join(map(str, self.force_dimensions))
|
40
|
+
self.file_handle.write(f"dimensions [{dims_str}];\n\n")
|
41
|
+
|
42
|
+
def _write_internal_field(self):
|
43
|
+
"""Write the internal field section."""
|
44
|
+
force_str = ' '.join(map(str, self.internal_force))
|
45
|
+
self.file_handle.write(f"internalField uniform ({force_str});\n\n")
|
46
|
+
|
47
|
+
def _write_boundary_field(self):
|
48
|
+
"""Write the boundary field section."""
|
49
|
+
self.file_handle.write("boundaryField\n")
|
50
|
+
self.file_handle.write("{\n")
|
51
|
+
|
52
|
+
for patch_name, bc in self.boundary_conditions.items():
|
53
|
+
self.file_handle.write(f" {patch_name}\n")
|
54
|
+
self.file_handle.write(" {\n")
|
55
|
+
self.file_handle.write(f" type {bc['type']};\n")
|
56
|
+
|
57
|
+
if 'value' in bc:
|
58
|
+
if isinstance(bc['value'], (list, tuple)):
|
59
|
+
val_str = ' '.join(map(str, bc['value']))
|
60
|
+
self.file_handle.write(f" value uniform ({val_str});\n")
|
61
|
+
else:
|
62
|
+
self.file_handle.write(f" value uniform {bc['value']};\n")
|
63
|
+
|
64
|
+
self.file_handle.write(" }\n")
|
65
|
+
|
66
|
+
self.file_handle.write("}\n\n")
|
67
|
+
|
68
|
+
def _write_properties(self):
|
69
|
+
"""Write the main content of the force field file."""
|
70
|
+
self._write_dimensions()
|
71
|
+
self._write_internal_field()
|
72
|
+
self._write_boundary_field()
|
73
|
+
|
74
|
+
def write(self):
|
75
|
+
"""
|
76
|
+
Writes the complete force field file.
|
77
|
+
"""
|
78
|
+
print(f"Writing force field (f) to: {self.file_path}")
|
79
|
+
with open(self.file_path, 'w') as f:
|
80
|
+
self.file_handle = f
|
81
|
+
self._write_header()
|
82
|
+
self._write_foamfile_dict()
|
83
|
+
self._write_separator()
|
84
|
+
|
85
|
+
self._write_properties()
|
86
|
+
|
87
|
+
self._write_footer()
|
88
|
+
self.file_handle = None
|
89
|
+
print("...Done")
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# lambda_field_writer.py
|
2
|
+
|
3
|
+
"""
|
4
|
+
Lambda Field Writer for OpenFOAM cases.
|
5
|
+
|
6
|
+
This writer handles the creation of lambda field (λ) files in the 0 directory
|
7
|
+
with support for level set functions, phase fields, and scalar transport.
|
8
|
+
"""
|
9
|
+
|
10
|
+
from ..foam_writer import FoamWriter
|
11
|
+
|
12
|
+
|
13
|
+
class LambdaFieldWriter(FoamWriter):
|
14
|
+
"""
|
15
|
+
A class to write an OpenFOAM lambda field (λ) file.
|
16
|
+
|
17
|
+
This writer supports various scalar field configurations including
|
18
|
+
level set functions, phase fields, and general scalar transport.
|
19
|
+
"""
|
20
|
+
|
21
|
+
def __init__(self, file_path, internal_lambda, boundary_conditions,
|
22
|
+
lambda_dimensions=[0, 0, 0, 0, 0, 0, 0]):
|
23
|
+
"""
|
24
|
+
Initialize the LambdaFieldWriter.
|
25
|
+
|
26
|
+
Args:
|
27
|
+
file_path (str): The full path to the output file '0/lambda'.
|
28
|
+
internal_lambda (float): Internal field lambda value.
|
29
|
+
boundary_conditions (dict): Boundary conditions for each patch.
|
30
|
+
lambda_dimensions (list): Lambda field dimensions.
|
31
|
+
"""
|
32
|
+
super().__init__(file_path, foam_class="volScalarField", foam_object="lambda")
|
33
|
+
self.internal_lambda = internal_lambda
|
34
|
+
self.boundary_conditions = boundary_conditions
|
35
|
+
self.lambda_dimensions = lambda_dimensions
|
36
|
+
|
37
|
+
def _write_dimensions(self):
|
38
|
+
"""Write the dimensions section."""
|
39
|
+
dims_str = ' '.join(map(str, self.lambda_dimensions))
|
40
|
+
self.file_handle.write(f"dimensions [{dims_str}];\n\n")
|
41
|
+
|
42
|
+
def _write_internal_field(self):
|
43
|
+
"""Write the internal field section."""
|
44
|
+
self.file_handle.write(f"internalField uniform {self.internal_lambda};\n\n")
|
45
|
+
|
46
|
+
def _write_boundary_field(self):
|
47
|
+
"""Write the boundary field section."""
|
48
|
+
self.file_handle.write("boundaryField\n")
|
49
|
+
self.file_handle.write("{\n")
|
50
|
+
|
51
|
+
for patch_name, bc in self.boundary_conditions.items():
|
52
|
+
self.file_handle.write(f" {patch_name}\n")
|
53
|
+
self.file_handle.write(" {\n")
|
54
|
+
self.file_handle.write(f" type {bc['type']};\n")
|
55
|
+
|
56
|
+
if 'value' in bc:
|
57
|
+
self.file_handle.write(f" value uniform {bc['value']};\n")
|
58
|
+
|
59
|
+
self.file_handle.write(" }\n")
|
60
|
+
|
61
|
+
self.file_handle.write("}\n\n")
|
62
|
+
|
63
|
+
def _write_properties(self):
|
64
|
+
"""Write the main content of the lambda field file."""
|
65
|
+
self._write_dimensions()
|
66
|
+
self._write_internal_field()
|
67
|
+
self._write_boundary_field()
|
68
|
+
|
69
|
+
def write(self):
|
70
|
+
"""
|
71
|
+
Writes the complete lambda field file.
|
72
|
+
"""
|
73
|
+
print(f"Writing lambda field (λ) to: {self.file_path}")
|
74
|
+
with open(self.file_path, 'w') as f:
|
75
|
+
self.file_handle = f
|
76
|
+
self._write_header()
|
77
|
+
self._write_foamfile_dict()
|
78
|
+
self._write_separator()
|
79
|
+
|
80
|
+
self._write_properties()
|
81
|
+
|
82
|
+
self._write_footer()
|
83
|
+
self.file_handle = None
|
84
|
+
print("...Done")
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# p_field_writer.py
|
2
|
+
|
3
|
+
"""
|
4
|
+
Pressure Field Writer for OpenFOAM cases.
|
5
|
+
|
6
|
+
This writer handles the creation of pressure field (p) files in the 0 directory
|
7
|
+
with support for various boundary conditions and field configurations.
|
8
|
+
"""
|
9
|
+
|
10
|
+
from ..foam_writer import FoamWriter
|
11
|
+
|
12
|
+
|
13
|
+
class PFieldWriter(FoamWriter):
|
14
|
+
"""
|
15
|
+
A class to write an OpenFOAM pressure field (p) file.
|
16
|
+
|
17
|
+
This writer supports various boundary conditions including fixedValue,
|
18
|
+
zeroGradient, and other pressure-specific conditions.
|
19
|
+
"""
|
20
|
+
|
21
|
+
def __init__(self, file_path, internal_pressure, boundary_conditions,
|
22
|
+
ref_pressure_cell=0, ref_pressure_value=0.0,
|
23
|
+
pressure_dimensions=[0, 2, -2, 0, 0, 0, 0]):
|
24
|
+
"""
|
25
|
+
Initialize the PFieldWriter.
|
26
|
+
|
27
|
+
Args:
|
28
|
+
file_path (str): The full path to the output file '0/p'.
|
29
|
+
internal_pressure (float): Internal field pressure value.
|
30
|
+
boundary_conditions (dict): Boundary conditions for each patch.
|
31
|
+
ref_pressure_cell (int): Reference pressure cell for pressure correction.
|
32
|
+
ref_pressure_value (float): Reference pressure value.
|
33
|
+
pressure_dimensions (list): Pressure field dimensions.
|
34
|
+
"""
|
35
|
+
super().__init__(file_path, foam_class="volScalarField", foam_object="p")
|
36
|
+
self.internal_pressure = internal_pressure
|
37
|
+
self.boundary_conditions = boundary_conditions
|
38
|
+
self.ref_pressure_cell = ref_pressure_cell
|
39
|
+
self.ref_pressure_value = ref_pressure_value
|
40
|
+
self.pressure_dimensions = pressure_dimensions
|
41
|
+
|
42
|
+
def _write_dimensions(self):
|
43
|
+
"""Write the dimensions section."""
|
44
|
+
dims_str = ' '.join(map(str, self.pressure_dimensions))
|
45
|
+
self.file_handle.write(f"dimensions [{dims_str}];\n\n")
|
46
|
+
|
47
|
+
def _write_internal_field(self):
|
48
|
+
"""Write the internal field section."""
|
49
|
+
self.file_handle.write(f"internalField uniform {self.internal_pressure};\n\n")
|
50
|
+
|
51
|
+
def _write_boundary_field(self):
|
52
|
+
"""Write the boundary field section."""
|
53
|
+
self.file_handle.write("boundaryField\n")
|
54
|
+
self.file_handle.write("{\n")
|
55
|
+
|
56
|
+
for patch_name, bc in self.boundary_conditions.items():
|
57
|
+
self.file_handle.write(f" {patch_name}\n")
|
58
|
+
self.file_handle.write(" {\n")
|
59
|
+
self.file_handle.write(f" type {bc['type']};\n")
|
60
|
+
|
61
|
+
if 'value' in bc:
|
62
|
+
self.file_handle.write(f" value uniform {bc['value']};\n")
|
63
|
+
|
64
|
+
self.file_handle.write(" }\n")
|
65
|
+
|
66
|
+
self.file_handle.write("}\n\n")
|
67
|
+
|
68
|
+
def _write_properties(self):
|
69
|
+
"""Write the main content of the pressure field file."""
|
70
|
+
self._write_dimensions()
|
71
|
+
self._write_internal_field()
|
72
|
+
self._write_boundary_field()
|
73
|
+
|
74
|
+
def write(self):
|
75
|
+
"""
|
76
|
+
Writes the complete pressure field file.
|
77
|
+
"""
|
78
|
+
print(f"Writing pressure field (p) to: {self.file_path}")
|
79
|
+
with open(self.file_path, 'w') as f:
|
80
|
+
self.file_handle = f
|
81
|
+
self._write_header()
|
82
|
+
self._write_foamfile_dict()
|
83
|
+
self._write_separator()
|
84
|
+
|
85
|
+
self._write_properties()
|
86
|
+
|
87
|
+
self._write_footer()
|
88
|
+
self.file_handle = None
|
89
|
+
print("...Done")
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# u_field_writer.py
|
2
|
+
|
3
|
+
"""
|
4
|
+
Velocity Field Writer for OpenFOAM cases.
|
5
|
+
|
6
|
+
This writer handles the creation of velocity field (U) files in the 0 directory
|
7
|
+
with support for various boundary conditions and flow configurations.
|
8
|
+
"""
|
9
|
+
|
10
|
+
from ..foam_writer import FoamWriter
|
11
|
+
|
12
|
+
|
13
|
+
class UFieldWriter(FoamWriter):
|
14
|
+
"""
|
15
|
+
A class to write an OpenFOAM velocity field (U) file.
|
16
|
+
|
17
|
+
This writer supports various boundary conditions including fixedValue,
|
18
|
+
noSlip, slip, inletOutlet, and other velocity-specific conditions.
|
19
|
+
"""
|
20
|
+
|
21
|
+
def __init__(self, file_path, internal_velocity, boundary_conditions,
|
22
|
+
velocity_dimensions=[0, 1, -1, 0, 0, 0, 0]):
|
23
|
+
"""
|
24
|
+
Initialize the UFieldWriter.
|
25
|
+
|
26
|
+
Args:
|
27
|
+
file_path (str): The full path to the output file '0/U'.
|
28
|
+
internal_velocity (tuple): Internal field velocity vector (Ux, Uy, Uz).
|
29
|
+
boundary_conditions (dict): Boundary conditions for each patch.
|
30
|
+
velocity_dimensions (list): Velocity field dimensions.
|
31
|
+
"""
|
32
|
+
super().__init__(file_path, foam_class="volVectorField", foam_object="U")
|
33
|
+
self.internal_velocity = internal_velocity
|
34
|
+
self.boundary_conditions = boundary_conditions
|
35
|
+
self.velocity_dimensions = velocity_dimensions
|
36
|
+
|
37
|
+
def _write_dimensions(self):
|
38
|
+
"""Write the dimensions section."""
|
39
|
+
dims_str = ' '.join(map(str, self.velocity_dimensions))
|
40
|
+
self.file_handle.write(f"dimensions [{dims_str}];\n\n")
|
41
|
+
|
42
|
+
def _write_internal_field(self):
|
43
|
+
"""Write the internal field section."""
|
44
|
+
vel_str = ' '.join(map(str, self.internal_velocity))
|
45
|
+
self.file_handle.write(f"internalField uniform ({vel_str});\n\n")
|
46
|
+
|
47
|
+
def _write_boundary_field(self):
|
48
|
+
"""Write the boundary field section."""
|
49
|
+
self.file_handle.write("boundaryField\n")
|
50
|
+
self.file_handle.write("{\n")
|
51
|
+
|
52
|
+
for patch_name, bc in self.boundary_conditions.items():
|
53
|
+
self.file_handle.write(f" {patch_name}\n")
|
54
|
+
self.file_handle.write(" {\n")
|
55
|
+
self.file_handle.write(f" type {bc['type']};\n")
|
56
|
+
|
57
|
+
if 'value' in bc:
|
58
|
+
if isinstance(bc['value'], (list, tuple)):
|
59
|
+
val_str = ' '.join(map(str, bc['value']))
|
60
|
+
self.file_handle.write(f" value uniform ({val_str});\n")
|
61
|
+
else:
|
62
|
+
self.file_handle.write(f" value uniform {bc['value']};\n")
|
63
|
+
|
64
|
+
if 'inletValue' in bc:
|
65
|
+
if isinstance(bc['inletValue'], (list, tuple)):
|
66
|
+
val_str = ' '.join(map(str, bc['inletValue']))
|
67
|
+
self.file_handle.write(f" inletValue uniform ({val_str});\n")
|
68
|
+
else:
|
69
|
+
self.file_handle.write(f" inletValue uniform {bc['inletValue']};\n")
|
70
|
+
|
71
|
+
self.file_handle.write(" }\n")
|
72
|
+
|
73
|
+
self.file_handle.write("}\n\n")
|
74
|
+
|
75
|
+
def _write_properties(self):
|
76
|
+
"""Write the main content of the velocity field file."""
|
77
|
+
self._write_dimensions()
|
78
|
+
self._write_internal_field()
|
79
|
+
self._write_boundary_field()
|
80
|
+
|
81
|
+
def write(self):
|
82
|
+
"""
|
83
|
+
Writes the complete velocity field file.
|
84
|
+
"""
|
85
|
+
print(f"Writing velocity field (U) to: {self.file_path}")
|
86
|
+
with open(self.file_path, 'w') as f:
|
87
|
+
self.file_handle = f
|
88
|
+
self._write_header()
|
89
|
+
self._write_foamfile_dict()
|
90
|
+
self._write_separator()
|
91
|
+
|
92
|
+
self._write_properties()
|
93
|
+
|
94
|
+
self._write_footer()
|
95
|
+
self.file_handle = None
|
96
|
+
print("...Done")
|