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
@@ -1,26 +1,69 @@
|
|
1
|
-
"""
|
2
|
-
Configuration files for OpenFOAM case setup.
|
3
|
-
|
4
|
-
This module provides configuration files for different aspects of
|
5
|
-
OpenFOAM case setup, including geometry, control, and turbulence settings.
|
6
|
-
Each config file contains detailed comments explaining all parameters.
|
7
|
-
|
8
|
-
Usage:
|
9
|
-
from pycphy.foamCaseDeveloper.config import global_config
|
10
|
-
from pycphy.foamCaseDeveloper.config import block_mesh_config
|
11
|
-
from pycphy.foamCaseDeveloper.config import control_config
|
12
|
-
from pycphy.foamCaseDeveloper.config import turbulence_config
|
13
|
-
"""
|
14
|
-
|
15
|
-
# Import all config modules
|
16
|
-
from . import global_config
|
17
|
-
from . import
|
18
|
-
from . import
|
19
|
-
from . import
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
1
|
+
"""
|
2
|
+
Configuration files for OpenFOAM case setup.
|
3
|
+
|
4
|
+
This module provides configuration files for different aspects of
|
5
|
+
OpenFOAM case setup, including geometry, control, and turbulence settings.
|
6
|
+
Each config file contains detailed comments explaining all parameters.
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
from pycphy.foamCaseDeveloper.config import global_config
|
10
|
+
from pycphy.foamCaseDeveloper.config import block_mesh_config
|
11
|
+
from pycphy.foamCaseDeveloper.config import control_config
|
12
|
+
from pycphy.foamCaseDeveloper.config import turbulence_config
|
13
|
+
"""
|
14
|
+
|
15
|
+
# Import all config modules
|
16
|
+
from . import global_config
|
17
|
+
from . import config_hfdibdem
|
18
|
+
from . import cad_mesh_config
|
19
|
+
from . import csv_boundary_reader
|
20
|
+
|
21
|
+
# Import config modules from subdirectories
|
22
|
+
from .constant import (
|
23
|
+
turbulence_config,
|
24
|
+
transport_properties_config,
|
25
|
+
dynamic_mesh_config,
|
26
|
+
gravity_field_config
|
27
|
+
)
|
28
|
+
|
29
|
+
from .system import (
|
30
|
+
block_mesh_config,
|
31
|
+
control_config,
|
32
|
+
fv_schemes_config,
|
33
|
+
fv_options_config,
|
34
|
+
set_fields_config,
|
35
|
+
decompose_par_config,
|
36
|
+
snappy_hex_mesh_config
|
37
|
+
)
|
38
|
+
|
39
|
+
from .zero import (
|
40
|
+
p_config,
|
41
|
+
U_config,
|
42
|
+
f_config,
|
43
|
+
lambda_config
|
44
|
+
)
|
45
|
+
|
46
|
+
__all__ = [
|
47
|
+
"global_config",
|
48
|
+
"config_hfdibdem",
|
49
|
+
"cad_mesh_config",
|
50
|
+
"csv_boundary_reader",
|
51
|
+
# Zero directory configs
|
52
|
+
"p_config",
|
53
|
+
"U_config",
|
54
|
+
"f_config",
|
55
|
+
"lambda_config",
|
56
|
+
# Constant directory configs
|
57
|
+
"turbulence_config",
|
58
|
+
"transport_properties_config",
|
59
|
+
"dynamic_mesh_config",
|
60
|
+
"gravity_field_config",
|
61
|
+
# System directory configs
|
62
|
+
"block_mesh_config",
|
63
|
+
"control_config",
|
64
|
+
"fv_schemes_config",
|
65
|
+
"fv_options_config",
|
66
|
+
"set_fields_config",
|
67
|
+
"decompose_par_config",
|
68
|
+
"snappy_hex_mesh_config",
|
69
|
+
]
|
@@ -0,0 +1,62 @@
|
|
1
|
+
"""
|
2
|
+
Configuration classes for CAD-based mesh generation.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from typing import Dict, List, Optional
|
6
|
+
from dataclasses import dataclass
|
7
|
+
|
8
|
+
|
9
|
+
@dataclass
|
10
|
+
class BlockParameter:
|
11
|
+
"""Configuration for a single block in the mesh."""
|
12
|
+
block_id: str
|
13
|
+
cells_x: int
|
14
|
+
cells_y: int
|
15
|
+
cells_z: int
|
16
|
+
grading: str
|
17
|
+
description: Optional[str] = None
|
18
|
+
|
19
|
+
|
20
|
+
@dataclass
|
21
|
+
class PatchParameter:
|
22
|
+
"""Configuration for a patch boundary condition."""
|
23
|
+
region_name: str
|
24
|
+
patch_name: str
|
25
|
+
patch_type: str
|
26
|
+
|
27
|
+
|
28
|
+
@dataclass
|
29
|
+
class CADMeshConfig:
|
30
|
+
"""Configuration for CAD-based mesh generation."""
|
31
|
+
|
32
|
+
# File paths
|
33
|
+
blocks_csv_file: str = "Inputs/blocks.csv"
|
34
|
+
patches_csv_file: str = "Inputs/patches.csv"
|
35
|
+
output_path: str = "system/blockMeshDict"
|
36
|
+
|
37
|
+
# XData configuration
|
38
|
+
block_xdata_app_name: str = "BLOCKDATA"
|
39
|
+
region_xdata_app_name: str = "REGIONDATA"
|
40
|
+
|
41
|
+
# Processing parameters
|
42
|
+
tolerance: float = 1e-6
|
43
|
+
|
44
|
+
# Mesh parameters
|
45
|
+
scale: float = 1.0
|
46
|
+
|
47
|
+
# Block parameters (can be loaded from CSV or set directly)
|
48
|
+
block_parameters: Optional[Dict[str, BlockParameter]] = None
|
49
|
+
|
50
|
+
# Patch parameters (can be loaded from CSV or set directly)
|
51
|
+
patch_parameters: Optional[Dict[str, PatchParameter]] = None
|
52
|
+
|
53
|
+
def __post_init__(self):
|
54
|
+
"""Initialize default values after dataclass creation."""
|
55
|
+
if self.block_parameters is None:
|
56
|
+
self.block_parameters = {}
|
57
|
+
if self.patch_parameters is None:
|
58
|
+
self.patch_parameters = {}
|
59
|
+
|
60
|
+
|
61
|
+
# Default configuration instance
|
62
|
+
default_cad_mesh_config = CADMeshConfig()
|
@@ -0,0 +1,193 @@
|
|
1
|
+
# config_hfdibdem.py
|
2
|
+
|
3
|
+
# =============================================================================
|
4
|
+
# *** User Input for HFDIBDEMDict ***
|
5
|
+
# =============================================================================
|
6
|
+
|
7
|
+
# --- Master Control ---
|
8
|
+
# Set to True to write 'constant/HFDIBDEMDict'.
|
9
|
+
WRITE_HFDIBDEM_DICT = True
|
10
|
+
|
11
|
+
|
12
|
+
# =============================================================================
|
13
|
+
# --- 1. Global Simulation Settings ---
|
14
|
+
# =============================================================================
|
15
|
+
GLOBAL_SETTINGS = {
|
16
|
+
# `interpolationSchemes`: How fields are interpolated from mesh to IB points.
|
17
|
+
"interpolationSchemes": {
|
18
|
+
"U": "cell", # Options: 'cell', 'cellPointFace'
|
19
|
+
# "method": "line" # Optional, for some schemes
|
20
|
+
},
|
21
|
+
|
22
|
+
# `surfaceThreshold`: VOF value defining the fluid/solid interface.
|
23
|
+
"surfaceThreshold": 1e-4,
|
24
|
+
|
25
|
+
# `stepDEM`: Time step for the DEM solver. Usually smaller than fluid deltaT.
|
26
|
+
"stepDEM": 0.01,
|
27
|
+
|
28
|
+
# `geometricD`: Directions considered for collision (1=active, 0=ignore, -1=2D).
|
29
|
+
# e.g., (1 1 -1) for a 2D simulation in XY plane.
|
30
|
+
"geometricD": (1, 1, 1),
|
31
|
+
|
32
|
+
# `recordSimulation`: Master switch to save IB/DEM data.
|
33
|
+
"recordSimulation": True,
|
34
|
+
"recordFirstTimeStep": False,
|
35
|
+
|
36
|
+
# `nSolidsInDomain`: Max limit on particles. Optional, defaults to 1000 if omitted.
|
37
|
+
"nSolidsInDomain": 5000,
|
38
|
+
|
39
|
+
# `outputSetup`: Fine-grained control over what data is written.
|
40
|
+
"outputSetup": {
|
41
|
+
"basic": False,
|
42
|
+
"iB": False, # Immersed Boundary data
|
43
|
+
"DEM": False, # Discrete Element Method data
|
44
|
+
"addModel": False, # Particle insertion data
|
45
|
+
"parallelDEM": False
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
# `virtualMesh`: Settings for the background mesh used for particle tracking.
|
50
|
+
VIRTUAL_MESH_SETTINGS = {
|
51
|
+
"level": 4, # Refinement level of the virtual mesh.
|
52
|
+
"charCellSize": 0.001, # Characteristic cell size.
|
53
|
+
"recordContact": False # Record particle-particle/wall contacts.
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
# =============================================================================
|
58
|
+
# --- 2. DEM Physics & Environment ---
|
59
|
+
# =============================================================================
|
60
|
+
DEM_SETTINGS = {
|
61
|
+
"LcCoeff": 4.0, # Collision length scale coefficient.
|
62
|
+
|
63
|
+
# Optional rotation model (e.g., 'chen2012', 'mindlin1953'). Uncomment to use.
|
64
|
+
# "rotationModel": "chen2012",
|
65
|
+
|
66
|
+
# `materials`: Material properties for particles and walls.
|
67
|
+
"materials": {
|
68
|
+
"particleMat1": {
|
69
|
+
"Y": 5e8, # Young's Modulus (Pa)
|
70
|
+
"nu": 0.5, # Poisson's Ratio
|
71
|
+
"mu": 1.0, # Friction Coefficient
|
72
|
+
"adhN": 0, # Normal Adhesion Energy
|
73
|
+
"eps": 0.75 # Coefficient of Restitution
|
74
|
+
},
|
75
|
+
"wallMat": {
|
76
|
+
"Y": 1e10, "nu": 0.5, "mu": 1.0, "adhN": 0, "eps": 0.75
|
77
|
+
}
|
78
|
+
},
|
79
|
+
|
80
|
+
# `collisionPatches`: planar walls defined by normal & point.
|
81
|
+
"collisionPatches": {
|
82
|
+
"floor": {
|
83
|
+
"material": "wallMat", # Must match a name in 'materials'
|
84
|
+
"nVec": (0, 1.0, 0), # Normal vector pointing INTO domain
|
85
|
+
"planePoint": (0, 0, 0)
|
86
|
+
},
|
87
|
+
# Add more walls as needed (e.g., ceiling, side walls)
|
88
|
+
# "ceiling": { ... }
|
89
|
+
},
|
90
|
+
|
91
|
+
# `cyclicPatches`: For periodic boundaries in DEM.
|
92
|
+
"cyclicPatches": {
|
93
|
+
# "outlet": {
|
94
|
+
# "material": "wallMat",
|
95
|
+
# "nVec": (0, -1, 0),
|
96
|
+
# "planePoint": (0, -0.1, 0),
|
97
|
+
# "neighbourPatch": "inlet"
|
98
|
+
# },
|
99
|
+
# "inlet": { ... neighbourPatch "outlet" ... }
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
# =============================================================================
|
105
|
+
# --- 3. Body Definitions (The "Library" of Bodies) ---
|
106
|
+
# =============================================================================
|
107
|
+
# Define all potential bodies here. You select which ones to use below.
|
108
|
+
AVAILABLE_BODIES = {
|
109
|
+
# --- Example A: A single falling sphere ---
|
110
|
+
"singleFallingSphere": {
|
111
|
+
# Body Type: 'fullyCoupledBody', 'staticBody', 'prescribedTransRotBody'
|
112
|
+
"fullyCoupledBody": {
|
113
|
+
"velocity": (0, -1.0, 0) # Initial velocity
|
114
|
+
},
|
115
|
+
|
116
|
+
# Properties with units defined explicitly in the string
|
117
|
+
"rho": "rho [1 -3 0 0 0 0 0] 2500", # Density kg/m^3
|
118
|
+
"refineMC": 5, # Marching Cubes refinement
|
119
|
+
"U": {"BC": "noSlip"}, # Boundary Condition on body surface
|
120
|
+
"material": "particleMat1", # Link to DEM.materials
|
121
|
+
"updateTorque": True,
|
122
|
+
|
123
|
+
# Geometry definition
|
124
|
+
"bodyGeom": "sphere", # 'sphere', 'convex', 'nonConvex'
|
125
|
+
"sphere": {
|
126
|
+
"radius": 0.04,
|
127
|
+
"startPosition": (0, 0.2, 0)
|
128
|
+
},
|
129
|
+
|
130
|
+
# Particle insertion model
|
131
|
+
"bodyAddition": {
|
132
|
+
"addModel": "once", # 'once', 'onceScatter', 'distribution'
|
133
|
+
"onceCoeffs": {} # No extra coeffs for simple 'once'
|
134
|
+
},
|
135
|
+
|
136
|
+
"timesToSetStatic": -1 # -1 = never become static
|
137
|
+
},
|
138
|
+
|
139
|
+
# --- Example B: A cloud of particles ("onceScatter") ---
|
140
|
+
"particleCloud": {
|
141
|
+
"fullyCoupledBody": {}, # Zero initial velocity
|
142
|
+
"rho": "rho [1 -3 0 0 0 0 0] 4000",
|
143
|
+
"material": "particleMat1",
|
144
|
+
|
145
|
+
# For complex shapes read from STL (implied by nonConvex/convex)
|
146
|
+
"bodyGeom": "convex",
|
147
|
+
|
148
|
+
"bodyAddition": {
|
149
|
+
"addModel": "onceScatter",
|
150
|
+
"onceScatterCoeffs": {
|
151
|
+
"addMode": "fieldBased", # Insert based on a field value (e.g. VOF)
|
152
|
+
"fieldBasedCoeffs": {
|
153
|
+
"fieldName": "lambda", # The field name
|
154
|
+
"fieldValue": 0.3 # Threshold value
|
155
|
+
},
|
156
|
+
"addDomain": "boundBox", # Region to insert into
|
157
|
+
"boundBoxCoeffs": {
|
158
|
+
"minBound": (-0.1, 0.0, -0.1),
|
159
|
+
"maxBound": ( 0.1, 0.5, 0.1)
|
160
|
+
},
|
161
|
+
"scalingMode": "noScaling", "noScalingCoeffs": {},
|
162
|
+
"rotationMode": "randomRotation", "randomRotationCoeffs": {}
|
163
|
+
}
|
164
|
+
},
|
165
|
+
"nParticles": 500, # Optional hint, sometimes used by the solver
|
166
|
+
"timesToSetStatic": 1500 # Become static after this many steps
|
167
|
+
},
|
168
|
+
|
169
|
+
# --- Example C: A prescribed motion rotor ---
|
170
|
+
"rotor": {
|
171
|
+
"prescribedTransRotBody": {
|
172
|
+
"velocity": (0,0,0),
|
173
|
+
"axis": (0, 1, 0), # Y-axis rotation
|
174
|
+
"omega": 50.0 # Rad/s
|
175
|
+
},
|
176
|
+
"rho": "rho [1 -3 0 0 0 0 0] 1000",
|
177
|
+
"material": "wallMat", # Acts like a moving wall
|
178
|
+
"bodyGeom": "nonConvex", # Read from STL (e.g., rotor.stl)
|
179
|
+
"bodyAddition": { "addModel": "once", "onceCoeffs": {} }
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
|
184
|
+
# =============================================================================
|
185
|
+
# --- 4. Case Selection ---
|
186
|
+
# =============================================================================
|
187
|
+
# Select which bodies from AVAILABLE_BODIES to include in this simulation.
|
188
|
+
# The names here MUST exist as keys in the AVAILABLE_BODIES dictionary above.
|
189
|
+
SELECTED_BODY_NAMES = [
|
190
|
+
"singleFallingSphere",
|
191
|
+
# "particleCloud",
|
192
|
+
# "rotor"
|
193
|
+
]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# constant/__init__.py
|
2
|
+
"""
|
3
|
+
Constant directory configuration modules.
|
4
|
+
|
5
|
+
This package contains configuration modules for OpenFOAM constant directory files:
|
6
|
+
- turbulenceProperties
|
7
|
+
- transportProperties
|
8
|
+
- dynamicMeshDict
|
9
|
+
- gravity field (g)
|
10
|
+
- HFDIBDEMDict
|
11
|
+
"""
|
12
|
+
|
13
|
+
from . import turbulence_config
|
14
|
+
from . import transport_properties_config
|
15
|
+
from . import dynamic_mesh_config
|
16
|
+
from . import gravity_field_config
|
17
|
+
|
18
|
+
__all__ = [
|
19
|
+
'turbulence_config',
|
20
|
+
'transport_properties_config',
|
21
|
+
'dynamic_mesh_config',
|
22
|
+
'gravity_field_config'
|
23
|
+
]
|
@@ -0,0 +1,208 @@
|
|
1
|
+
# config_dynamic_mesh.py
|
2
|
+
|
3
|
+
# =============================================================================
|
4
|
+
# *** User Input for dynamicMeshDict ***
|
5
|
+
# =============================================================================
|
6
|
+
|
7
|
+
# --- Master Control ---
|
8
|
+
# Set this to True to include a dynamicMeshDict in the case setup,
|
9
|
+
# or False to skip it for a static mesh simulation.
|
10
|
+
WRITE_DYNAMIC_MESH_DICT = True
|
11
|
+
|
12
|
+
# --- Mesh Type Selection ---
|
13
|
+
# Choose the type of dynamic mesh behavior you want to configure.
|
14
|
+
# The selected dictionary below will be written to the file.
|
15
|
+
# Options:
|
16
|
+
# "solidBodyMotion": For rigid body motion of a mesh zone (e.g., rotating fan).
|
17
|
+
# "multiBodyOverset": For overset meshes with multiple moving bodies.
|
18
|
+
# "adaptiveRefinement": For Adaptive Mesh Refinement (AMR) based on a field.
|
19
|
+
# "morphingMesh": For deforming mesh using splines (e.g., shape optimization).
|
20
|
+
MESH_TYPE = "solidBodyMotion"
|
21
|
+
|
22
|
+
|
23
|
+
# =============================================================================
|
24
|
+
# *** Pre-configured Mesh Property Dictionaries ***
|
25
|
+
# =============================================================================
|
26
|
+
|
27
|
+
# --- 1. Solid Body Motion ---
|
28
|
+
# Use this for cases where a part of the mesh moves as a rigid body without deforming,
|
29
|
+
# such as a propeller, fan, or stirrer.
|
30
|
+
SOLID_BODY_MOTION_PROPS = {
|
31
|
+
# `dynamicFvMesh`: The top-level dynamic mesh class.
|
32
|
+
# Options:
|
33
|
+
# 'dynamicMotionSolverFvMesh': The standard choice for mesh motion or deformation
|
34
|
+
# driven by a specified motion solver.
|
35
|
+
"dynamicFvMesh": "dynamicMotionSolverFvMesh",
|
36
|
+
|
37
|
+
# `solver`: The specific type of motion solver.
|
38
|
+
# Options:
|
39
|
+
# 'solidBody': Moves a specified cellZone as a rigid body. Mesh does not deform.
|
40
|
+
# 'displacementLaplacian': A common choice for deforming meshes where boundary
|
41
|
+
# motion is propagated through the mesh by solving a
|
42
|
+
# Laplacian equation for diffusivity.
|
43
|
+
# 'velocityComponentLaplacian': Similar, but solves for velocity instead of displacement.
|
44
|
+
"solver": "solidBody",
|
45
|
+
|
46
|
+
# `solidBodyCoeffs`: A sub-dictionary containing settings for the `solidBody` solver.
|
47
|
+
"solidBodyCoeffs": {
|
48
|
+
# `cellZone`: The name of the cell zone in the mesh that will move.
|
49
|
+
# This zone must be defined during meshing (e.g., in blockMeshDict or snappyHexMesh).
|
50
|
+
"cellZone": "rotatingZone",
|
51
|
+
|
52
|
+
# `solidBodyMotionFunction`: The type of rigid motion to apply.
|
53
|
+
# Options:
|
54
|
+
# 'rotatingMotion': Pure rotation around an axis.
|
55
|
+
# 'linearMotion': Constant velocity translation.
|
56
|
+
# 'oscillatingLinearMotion': Sinusoidal back-and-forth linear movement.
|
57
|
+
# 'oscillatingRotatingMotion': Sinusoidal rocking/pitching motion.
|
58
|
+
# 'tabulated6DoFMotion': Reads 6-DoF motion (translation/rotation) from an
|
59
|
+
# external text file. Very powerful for complex prescribed motions.
|
60
|
+
# 'multiMotion': Allows for combining multiple motion functions.
|
61
|
+
"solidBodyMotionFunction": "rotatingMotion",
|
62
|
+
|
63
|
+
# `rotatingMotionCoeffs`: Sub-dictionary for the chosen motion function.
|
64
|
+
# Each motion function has its own `...Coeffs` dictionary.
|
65
|
+
"rotatingMotionCoeffs": {
|
66
|
+
# `origin`: The center of rotation as a vector (x y z).
|
67
|
+
"origin": (0, 0, 0),
|
68
|
+
# `axis`: The axis of rotation as a vector (x y z). Does not need to be a unit vector.
|
69
|
+
"axis": (0, 0, 1),
|
70
|
+
# `omega`: The rotational speed in radians per second. Can be a number, or a Foam::DataEntry.
|
71
|
+
"omega": 10.5
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
# --- 2. Multi-Body Overset Motion ---
|
77
|
+
# Use this for overset (or Chimera) meshes where multiple independent bodies
|
78
|
+
# move through a background mesh.
|
79
|
+
MULTI_BODY_OVERSET_PROPS = {
|
80
|
+
# `dynamicFvMesh`: The required class for overset functionality.
|
81
|
+
# Options:
|
82
|
+
# 'dynamicOversetFvMesh': For cases where the overset components move.
|
83
|
+
# 'staticOversetFvMesh': For cases where overset zones are stationary,
|
84
|
+
# but mesh connectivity still needs to be computed.
|
85
|
+
"dynamicFvMesh": "dynamicOversetFvMesh",
|
86
|
+
|
87
|
+
# `solver`: The motion solver.
|
88
|
+
# Options:
|
89
|
+
# 'multiSolidBodyMotionSolver': Handles the motion of one or more named bodies,
|
90
|
+
# each with its own motion function. Ideal for complex scenes.
|
91
|
+
# 'solidBody': Can be used if only a single overset zone is moving.
|
92
|
+
# 'displacementLaplacian': Can be used to deform the overset mesh component.
|
93
|
+
"solver": "multiSolidBodyMotionSolver",
|
94
|
+
|
95
|
+
# `multiSolidBodyMotionSolverCoeffs`: Sub-dictionary defining each moving body.
|
96
|
+
"multiSolidBodyMotionSolverCoeffs": {
|
97
|
+
# Each entry in this dictionary is a separate moving body. The key name
|
98
|
+
# ('movingZone1', 'propeller', etc.) must match a cellZone in the mesh.
|
99
|
+
"movingZone1": {
|
100
|
+
# `solidBodyMotionFunction`: See the list of functions in the SOLID_BODY_MOTION section.
|
101
|
+
"solidBodyMotionFunction": "oscillatingLinearMotion",
|
102
|
+
"oscillatingLinearMotionCoeffs": {
|
103
|
+
"amplitude": (0.035, 0, 0),
|
104
|
+
"omega": 2.094
|
105
|
+
}
|
106
|
+
},
|
107
|
+
"movingZone2": {
|
108
|
+
"solidBodyMotionFunction": "rotatingMotion",
|
109
|
+
"rotatingMotionCoeffs": {
|
110
|
+
"origin": (0.1, 0, 0),
|
111
|
+
"axis": (0, 0, 1),
|
112
|
+
"omega": -50.0
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
# --- 3. Adaptive Mesh Refinement (AMR) ---
|
119
|
+
# Use this to automatically refine and unrefine the mesh in specific regions
|
120
|
+
# during the simulation, based on a scalar field.
|
121
|
+
ADAPTIVE_REFINEMENT_PROPS = {
|
122
|
+
# `dynamicFvMesh`: The required class for AMR.
|
123
|
+
"dynamicFvMesh": "dynamicRefineFvMesh",
|
124
|
+
|
125
|
+
# `refineInterval`: How often (in number of time steps) the refinement criteria are checked.
|
126
|
+
# A value of 1 checks every time step. Larger values are more efficient but less responsive.
|
127
|
+
"refineInterval": 1,
|
128
|
+
|
129
|
+
# `field`: The name of the volScalarField that will drive the refinement. This field
|
130
|
+
# must exist in your case.
|
131
|
+
# Examples: 'alpha.water' (for VOF free surface), 'p' (pressure), 'magU' (velocity magnitude),
|
132
|
+
# a custom field calculated with functionObjects.
|
133
|
+
"field": "alpha.water",
|
134
|
+
|
135
|
+
# `lowerRefineLevel`: If the field value in a cell is below this, the
|
136
|
+
# cell and its neighbors will be considered for un-refinement (coarsening).
|
137
|
+
"lowerRefineLevel": 0.001,
|
138
|
+
|
139
|
+
# `upperRefineLevel`: If the field value in a cell is above this, the
|
140
|
+
# cell will be flagged for refinement (splitting).
|
141
|
+
"upperRefineLevel": 0.999,
|
142
|
+
|
143
|
+
# `unrefineLevel`: A tolerance used during the un-refinement (coarsening) step.
|
144
|
+
# Cells marked for coarsening will only be merged if the field value difference
|
145
|
+
# between them is small. This prevents coarsening across sharp gradients.
|
146
|
+
"unrefineLevel": 0.0001,
|
147
|
+
|
148
|
+
# `nBufferLayers`: Number of extra cell layers to keep refined around the primary refinement zone.
|
149
|
+
# This is crucial for stability, preventing refinement/unrefinement from
|
150
|
+
# happening right at a sharp interface.
|
151
|
+
"nBufferLayers": 2,
|
152
|
+
|
153
|
+
# `maxRefinement`: The maximum number of times an initial grid cell can be split.
|
154
|
+
# Level 0 = no refinement. Level 1 = split once. Level 2 = split twice (1 cell -> 8 in 3D).
|
155
|
+
"maxRefinement": 2,
|
156
|
+
|
157
|
+
# `maxCells`: An approximate hard limit on the total number of cells to prevent
|
158
|
+
# runaway refinement from using all available memory.
|
159
|
+
"maxCells": 200000,
|
160
|
+
|
161
|
+
# `correctFluxes`: A list of surfaceScalarFields (fluxes) that need to be corrected
|
162
|
+
# when cell faces are created or destroyed by AMR. This is critical
|
163
|
+
# for conservation. The format is a list of lists.
|
164
|
+
"correctFluxes": [("phi", "U"), ("phi_0", "none")]
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
# --- 4. Morphing Mesh (Volumetric B-Splines) ---
|
169
|
+
# Use for cases where the mesh deforms smoothly, often for shape optimization
|
170
|
+
# or simulating structural deformation.
|
171
|
+
MORPHING_MESH_PROPS = {
|
172
|
+
# `solver`: The motion solver for mesh deformation.
|
173
|
+
# Options:
|
174
|
+
# 'volumetricBSplinesMotionSolver': A powerful and smooth morphing tool based on a
|
175
|
+
# control-point lattice.
|
176
|
+
# 'laplacianMotionSolver': A simpler morphing solver based on solving a Laplacian
|
177
|
+
# equation for mesh displacement.
|
178
|
+
"solver": "volumetricBSplinesMotionSolver",
|
179
|
+
|
180
|
+
# `volumetricBSplinesMotionSolverCoeffs`: Sub-dictionary for the B-splines solver.
|
181
|
+
"volumetricBSplinesMotionSolverCoeffs": {
|
182
|
+
# Each entry is a named "control point volume" that controls a region of the mesh.
|
183
|
+
"airfoil": {
|
184
|
+
# `type`: The coordinate system for the control points.
|
185
|
+
# Options: 'cartesian', 'cylindrical'.
|
186
|
+
"type": "cartesian",
|
187
|
+
# `nCPsU/V/W`: Number of control points in each direction (U,V,W map to X,Y,Z for cartesian).
|
188
|
+
"nCPsU": 6,
|
189
|
+
"nCPsV": 4,
|
190
|
+
"nCPsW": 3,
|
191
|
+
# `degreeU/V/W`: The polynomial degree of the spline curves. Higher degrees are smoother.
|
192
|
+
"degreeU": 3,
|
193
|
+
"degreeV": 3,
|
194
|
+
"degreeW": 2,
|
195
|
+
# `controlPointsDefinition`: How the initial control point positions are defined.
|
196
|
+
# Options:
|
197
|
+
# 'axisAligned': Automatically creates a grid of points within the bounds below.
|
198
|
+
# 'fromFile': Reads control point coordinates from a file.
|
199
|
+
"controlPointsDefinition": "axisAligned",
|
200
|
+
# `lowerCpBounds`/`upperCpBounds`: The bounding box for the 'axisAligned' control points.
|
201
|
+
"lowerCpBounds": (0.1, -0.25, -0.1),
|
202
|
+
"upperCpBounds": (0.9, 0.25, 1.1),
|
203
|
+
# `confine...`: Boolean flags to restrict movement of control points.
|
204
|
+
"confineWMovement": "true",
|
205
|
+
"confineBoundaryControlPoints": "true",
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|