Skip to content

Commit 9446003

Browse files
[FXC-4322] feat: wind tunnel farfield Python interface (#1582)
* initial progress (flow360) * progress * json parsing mostly done, w/ test * changes in pipeline to allow wind tunnel farfield * formatted * fix linting * black issue caused by merge conflict * added floor type defaults, pd.Field descriptions * addressed some comments, validation wip * ghost surfaces * parameter validation testcases * is -> isinstance bug fix * added valid test case * updated pipeline to support wind tunnel compatibility with solver (one check temp disabled) * switched schema to tuple * worked WindTunnelGhostSurface into pipeline * formatting * fix test break * added translation tests * formatting * minor changes; unifying allowed surfaces list next * made get_valid_ghost_surfaces consistent with @propertys * added staticmethod for getting boundaries w/o validation * checked left, right, symmetric plane for half body wind tunnel * Fixed linting * minor fixes * pylint duplicate code * addressed feedback --------- Co-authored-by: Ben <106089368+benflexcompute@users.noreply.github.com> Co-authored-by: benflexcompute <ben@flexcompute.com>
1 parent 90f35d9 commit 9446003

22 files changed

+2350
-28
lines changed

flow360/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@
3838
from flow360.component.simulation.meshing_param.volume_params import (
3939
AutomatedFarfield,
4040
AxisymmetricRefinement,
41+
CentralBelt,
4142
CustomZones,
43+
FullyMovingFloor,
4244
MeshSliceOutput,
4345
RotationCylinder,
4446
RotationVolume,
47+
StaticFloor,
4548
StructuredBoxRefinement,
4649
UniformRefinement,
4750
UserDefinedFarfield,
51+
WheelBelts,
52+
WindTunnelFarfield,
4853
)
4954
from flow360.component.simulation.models.material import (
5055
Air,
@@ -337,6 +342,11 @@
337342
"ImportedSurface",
338343
"OctreeSpacing",
339344
"RunControl",
345+
"WindTunnelFarfield",
346+
"StaticFloor",
347+
"FullyMovingFloor",
348+
"CentralBelt",
349+
"WheelBelts",
340350
]
341351

342352
_warn_prerelease()

flow360/component/simulation/entity_info.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
GhostSphere,
3030
SnappyBody,
3131
Surface,
32+
WindTunnelGhostSurface,
3233
)
3334
from flow360.component.simulation.unit_system import LengthType
3435
from flow360.component.simulation.utils import BoundingBoxType, model_attribute_unlock
@@ -53,11 +54,11 @@
5354
class EntityInfoModel(Flow360BaseModel, metaclass=ABCMeta):
5455
"""Base model for asset entity info JSON"""
5556

56-
# entities that appear in simulation JSON but did not appear in EntityInfo)
57+
# entities that appear in simulation JSON but did not appear in EntityInfo
5758
draft_entities: List[DraftEntityTypes] = pd.Field([])
5859
ghost_entities: List[
5960
Annotated[
60-
Union[GhostSphere, GhostCircularPlane],
61+
Union[GhostSphere, GhostCircularPlane, WindTunnelGhostSurface],
6162
pd.Field(discriminator="private_attribute_entity_type_name"),
6263
]
6364
] = pd.Field([])

flow360/component/simulation/meshing_param/params.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
StructuredBoxRefinement,
3131
UniformRefinement,
3232
UserDefinedFarfield,
33+
WindTunnelFarfield,
3334
)
3435
from flow360.component.simulation.primitives import SeedpointVolume
3536
from flow360.component.simulation.validation.validation_context import (
@@ -60,6 +61,7 @@
6061
AutomatedFarfield,
6162
UserDefinedFarfield,
6263
CustomZones,
64+
WindTunnelFarfield,
6365
],
6466
pd.Field(discriminator="type"),
6567
]
@@ -162,13 +164,14 @@ class MeshingParams(Flow360BaseModel):
162164

163165
@pd.field_validator("volume_zones", mode="after")
164166
@classmethod
165-
def _check_volume_zones_has_farfied(cls, v):
167+
def _check_volume_zones_has_farfield(cls, v):
166168
if v is None:
167169
# User did not put anything in volume_zones so may not want to use volume meshing
168170
return v
169171

170172
total_farfield = sum(
171-
isinstance(volume_zone, (AutomatedFarfield, UserDefinedFarfield)) for volume_zone in v
173+
isinstance(volume_zone, (AutomatedFarfield, WindTunnelFarfield, UserDefinedFarfield))
174+
for volume_zone in v
172175
)
173176
if total_farfield == 0:
174177
raise ValueError("Farfield zone is required in `volume_zones`.")
@@ -275,11 +278,13 @@ def _check_no_reused_volume_entities(self) -> Self:
275278

276279
@property
277280
def farfield_method(self):
278-
"""Returns the farfield method used."""
281+
"""Returns the farfield method used."""
279282
if self.volume_zones:
280283
for zone in self.volume_zones: # pylint: disable=not-an-iterable
281284
if isinstance(zone, AutomatedFarfield):
282285
return zone.method
286+
if isinstance(zone, WindTunnelFarfield):
287+
return "wind-tunnel"
283288
if isinstance(zone, UserDefinedFarfield):
284289
return "user-defined"
285290
return None

0 commit comments

Comments
 (0)