diff --git a/flow360/component/simulation/meshing_param/params.py b/flow360/component/simulation/meshing_param/params.py index 9c431a98c..49de5c730 100644 --- a/flow360/component/simulation/meshing_param/params.py +++ b/flow360/component/simulation/meshing_param/params.py @@ -38,7 +38,7 @@ UniformRefinement, UserDefinedFarfield, WindTunnelFarfield, - _FarfieldBase, + _FarfieldAllowingEnclosedEntities, ) from flow360.component.simulation.primitives import ( AxisymmetricBody, @@ -121,9 +121,11 @@ def _collect_rotation_entity_names(zones, param_info, zone_types): def _validate_farfield_enclosed_entities( zones, rotation_entity_names, has_custom_volumes, param_info ): - """Validate farfield enclosed_entities: require CustomVolumes and rotation-volume association.""" + """Validate farfield enclosed_entities: require CustomVolumes and rotation-volume association. + Only applies to farfield types that support enclosed_entities (Automated, WindTunnel). + """ for zone in zones: - if not isinstance(zone, _FarfieldBase): + if not isinstance(zone, _FarfieldAllowingEnclosedEntities): continue if zone.enclosed_entities is None: @@ -269,10 +271,8 @@ def _check_volume_zones_has_farfield(cls, v): ) for volume_zone in v ) - if total_farfield == 0 and not _collect_all_custom_volumes(v): - raise ValueError( - "A farfield zone or `CustomVolume` entities are required in `volume_zones`." - ) + if total_farfield == 0: + raise ValueError("Farfield zone is required in `volume_zones`.") if total_farfield > 1: raise ValueError("Only one farfield zone is allowed in `volume_zones`.") @@ -507,7 +507,6 @@ def _warn_multi_zone_remove_hidden_geometry(self) -> Self: def farfield_method(self): """Returns the farfield method used.""" if self.volume_zones: - has_custom_zones = False for zone in self.volume_zones: # pylint: disable=not-an-iterable if isinstance(zone, AutomatedFarfield): return zone.method @@ -515,10 +514,6 @@ def farfield_method(self): return "wind-tunnel" if isinstance(zone, UserDefinedFarfield): return "user-defined" - if isinstance(zone, CustomZones): - has_custom_zones = True - if has_custom_zones: # CV + no FF => implicit UD - return "user-defined" return None diff --git a/flow360/component/simulation/meshing_param/volume_params.py b/flow360/component/simulation/meshing_param/volume_params.py index 15b059d6c..607d9b834 100644 --- a/flow360/component/simulation/meshing_param/volume_params.py +++ b/flow360/component/simulation/meshing_param/volume_params.py @@ -563,59 +563,6 @@ class _FarfieldBase(Flow360BaseModel): ) ) - enclosed_entities: Optional[ - EntityList[Surface, Cylinder, AxisymmetricBody, Sphere, CustomVolume] - ] = pd.Field( - None, - description=""" - The surfaces/surface groups that are the interior boundaries of the `farfield` zone when defining custom volumes. - - Only allowed when using one or more `CustomZone`(s) to define volume zone(s) in meshing parameters - - Cylinder, AxisymmetricBody, Sphere entities must be associated with `RotationVolume`(s) - """, - ) - - @contextual_model_validator(mode="after") - def _validate_enclosed_entities_no_intersection(self, param_info: ParamsValidationInfo): - """Check that no CustomVolume's bounding_entities overlap with sibling entities.""" - if self.enclosed_entities is None: - return self - expanded = param_info.expand_entity_list(self.enclosed_entities) - - custom_volumes_in_list = [e for e in expanded if isinstance(e, CustomVolume)] - if not custom_volumes_in_list: - return self - - non_cv_names = {e.name for e in expanded if not isinstance(e, CustomVolume)} - - for cv in custom_volumes_in_list: - cv_child_names = {e.name for e in param_info.expand_entity_list(cv.bounding_entities)} - overlap = cv_child_names & non_cv_names - if overlap: - raise ValueError( - f"`CustomVolume` `{cv.name}` shares bounding entities " - f"({sorted(overlap)}) with sibling `CustomVolume`. " - f"A `CustomVolume`'s bounding entities must be disjoint from its siblings." - ) - - return self - - @contextual_field_validator("enclosed_entities", mode="after") - @classmethod - def _validate_enclosed_entities_beta_mesher_only(cls, value, param_info: ParamsValidationInfo): - """Ensure enclosed_entities is only used with the beta mesher.""" - if value is None: - return value - if param_info.is_beta_mesher: - return value - - raise ValueError("`enclosed_entities` is only supported with the beta mesher.") - - @contextual_field_validator("enclosed_entities", mode="after") - @classmethod - def _validate_enclosed_entity_existence(cls, value, param_info: ParamsValidationInfo): - """Ensure all boundaries will be present after mesher.""" - return validate_entity_list_surface_existence(value, param_info) - @contextual_field_validator("domain_type", mode="after") @classmethod def _validate_only_in_beta_mesher(cls, value, param_info: ParamsValidationInfo): @@ -679,7 +626,65 @@ def _validate_domain_type_bbox(cls, value): raise ValueError(message) -class AutomatedFarfield(_FarfieldBase): +class _FarfieldAllowingEnclosedEntities(_FarfieldBase): + """Intermediate class for farfield types that support enclosed_entities (Automated, WindTunnel).""" + + enclosed_entities: Optional[ + EntityList[Surface, Cylinder, AxisymmetricBody, Sphere, CustomVolume] + ] = pd.Field( + None, + description=""" + The surfaces/surface groups that are the interior boundaries of the `farfield` zone when defining custom volumes. + - Only allowed when using one or more `CustomZone`(s) to define volume zone(s) in meshing parameters + - Cylinder, AxisymmetricBody, Sphere entities must be associated with `RotationVolume`(s) + """, + ) + + @contextual_field_validator("enclosed_entities", mode="after") + @classmethod + def _validate_enclosed_entities_no_intersection(cls, value, param_info: ParamsValidationInfo): + """Check that no CustomVolume's bounding_entities overlap with sibling entities.""" + if value is None: + return value + expanded = param_info.expand_entity_list(value) + + custom_volumes_in_list = [e for e in expanded if isinstance(e, CustomVolume)] + if not custom_volumes_in_list: + return value + + non_cv_names = {e.name for e in expanded if not isinstance(e, CustomVolume)} + + for cv in custom_volumes_in_list: + cv_child_names = {e.name for e in param_info.expand_entity_list(cv.bounding_entities)} + overlap = cv_child_names & non_cv_names + if overlap: + raise ValueError( + f"`CustomVolume` `{cv.name}` shares bounding entities " + f"({sorted(overlap)}) with sibling `CustomVolume`. " + f"A `CustomVolume`'s bounding entities must be disjoint from its siblings." + ) + + return value + + @contextual_field_validator("enclosed_entities", mode="after") + @classmethod + def _validate_enclosed_entities_beta_mesher_only(cls, value, param_info: ParamsValidationInfo): + """Ensure enclosed_entities is only used with the beta mesher.""" + if value is None: + return value + if param_info.is_beta_mesher: + return value + + raise ValueError("`enclosed_entities` is only supported with the beta mesher.") + + @contextual_field_validator("enclosed_entities", mode="after") + @classmethod + def _validate_enclosed_entity_existence(cls, value, param_info: ParamsValidationInfo): + """Ensure all boundaries will be present after mesher.""" + return validate_entity_list_surface_existence(value, param_info) + + +class AutomatedFarfield(_FarfieldAllowingEnclosedEntities): """ Settings for automatic farfield volume zone generation. @@ -898,7 +903,7 @@ def _validate_wheel_belt_ranges(self): # pylint: disable=no-member -class WindTunnelFarfield(_FarfieldBase): +class WindTunnelFarfield(_FarfieldAllowingEnclosedEntities): """ Settings for analytic wind tunnel farfield generation. The user only needs to provide tunnel dimensions and floor type and dimensions, rather than a geometry. diff --git a/flow360/component/simulation/translator/volume_meshing_translator.py b/flow360/component/simulation/translator/volume_meshing_translator.py index 94506e978..66a893c7f 100644 --- a/flow360/component/simulation/translator/volume_meshing_translator.py +++ b/flow360/component/simulation/translator/volume_meshing_translator.py @@ -23,7 +23,7 @@ UniformRefinement, UserDefinedFarfield, WindTunnelFarfield, - _FarfieldBase, + _FarfieldAllowingEnclosedEntities, ) from flow360.component.simulation.primitives import ( AxisymmetricBody, @@ -262,13 +262,16 @@ def rotation_volume_entity_injector( def _build_farfield_zone(volume_zones: list): - """Build the farfield zone dict from enclosed_entities on any farfield type. + """Build the farfield zone dict from enclosed_entities on any farfield type supporting it. CustomVolume entities are unwrapped into their constituent bounding_entities, each translated via _translate_enclosed_entity_name. Final patches are deduplicated. """ for zone in volume_zones: - if isinstance(zone, _FarfieldBase) and zone.enclosed_entities is not None: + if ( + isinstance(zone, _FarfieldAllowingEnclosedEntities) + and zone.enclosed_entities is not None + ): patch_names: set[str] = set() for entity in zone.enclosed_entities.stored_entities: if isinstance(entity, CustomVolume): diff --git a/flow360/component/simulation/validation/validation_context.py b/flow360/component/simulation/validation/validation_context.py index b57fee675..f8460b736 100644 --- a/flow360/component/simulation/validation/validation_context.py +++ b/flow360/component/simulation/validation/validation_context.py @@ -156,6 +156,7 @@ class ParamsValidationInfo: # pylint:disable=too-few-public-methods,too-many-in @classmethod def _get_farfield_method_(cls, param_as_dict: dict): meshing = param_as_dict.get("meshing") + modular = False if meshing is None: # No meshing info. return None @@ -164,8 +165,8 @@ def _get_farfield_method_(cls, param_as_dict: dict): volume_zones = meshing.get("volume_zones") else: volume_zones = meshing.get("zones") + modular = True if volume_zones: - has_custom_zones = False for zone in volume_zones: if zone["type"] == "AutomatedFarfield": return zone["method"] @@ -173,10 +174,15 @@ def _get_farfield_method_(cls, param_as_dict: dict): return "user-defined" if zone["type"] == "WindTunnelFarfield": return "wind-tunnel" - if zone["type"] in ("CustomZones", "SeedpointVolume"): - has_custom_zones = True - if has_custom_zones: # CV + no FF => implicit UD - return "user-defined" + if ( + zone["type"] + in [ + "CustomZones", + "SeedpointVolume", + ] + and modular + ): + return "user-defined" return None @@ -444,7 +450,6 @@ def _get_farfield_enclosed_entities(self, param_as_dict: dict) -> dict[str, str] for zone in volume_zones: if zone.get("type") not in ( "AutomatedFarfield", - "UserDefinedFarfield", "WindTunnelFarfield", ): continue diff --git a/flow360/component/simulation/validation/validation_simulation_params.py b/flow360/component/simulation/validation/validation_simulation_params.py index d3045f9ed..138afdd6c 100644 --- a/flow360/component/simulation/validation/validation_simulation_params.py +++ b/flow360/component/simulation/validation/validation_simulation_params.py @@ -457,9 +457,12 @@ def _collect_asset_boundary_entities(params, param_info: ParamsValidationInfo) - if param_info.will_generate_forced_symmetry_plane(): asset_boundary_entities += [item for item in ghost_entities if item.name == "symmetric"] # pylint: disable=protected-access + wind_tunnel = next( + z for z in params.meshing.volume_zones if isinstance(z, WindTunnelFarfield) + ) asset_boundary_entities += WindTunnelFarfield._get_valid_ghost_surfaces( - params.meshing.volume_zones[0].floor_type.type_name, - params.meshing.volume_zones[0].domain_type, + wind_tunnel.floor_type.type_name, + wind_tunnel.domain_type, ) return asset_boundary_entities, has_missing_private_attributes diff --git a/tests/simulation/params/meshing_validation/test_meshing_param_validation.py b/tests/simulation/params/meshing_validation/test_meshing_param_validation.py index db5c29177..9dafe82bc 100644 --- a/tests/simulation/params/meshing_validation/test_meshing_param_validation.py +++ b/tests/simulation/params/meshing_validation/test_meshing_param_validation.py @@ -2507,6 +2507,7 @@ def test_multi_zone_remove_hidden_geometry_warning(): remove_hidden_geometry=True, ), volume_zones=[ + UserDefinedFarfield(), CustomZones( name="custom_zones", entities=[ @@ -2551,9 +2552,7 @@ def test_multi_zone_remove_hidden_geometry_warning(): remove_hidden_geometry=True, ), volume_zones=[ - UserDefinedFarfield( - enclosed_entities=[Surface(name="face1"), Surface(name="face2")] - ), + UserDefinedFarfield(), CustomZones( name="custom_zones", entities=[ @@ -2590,9 +2589,7 @@ def test_multi_zone_remove_hidden_geometry_warning(): remove_hidden_geometry=True, ), volume_zones=[ - UserDefinedFarfield( - enclosed_entities=[Surface(name="face1"), Surface(name="face2")] - ), + UserDefinedFarfield(), CustomZones( name="custom_zones", entities=[ @@ -2637,6 +2634,7 @@ def test_multi_zone_remove_hidden_geometry_warning(): remove_hidden_geometry=True, ), volume_zones=[ + UserDefinedFarfield(), CustomZones( name="custom_zones", entities=[ diff --git a/tests/simulation/params/test_farfield_enclosed_entities.py b/tests/simulation/params/test_farfield_enclosed_entities.py index 34680cb7b..6694307b5 100644 --- a/tests/simulation/params/test_farfield_enclosed_entities.py +++ b/tests/simulation/params/test_farfield_enclosed_entities.py @@ -27,9 +27,6 @@ ) from flow360.component.simulation.simulation_params import SimulationParams from flow360.component.simulation.unit_system import SI_unit_system -from flow360.component.simulation.validation.validation_context import ( - ParamsValidationInfo, -) @pytest.fixture(autouse=True) @@ -41,8 +38,7 @@ def reset_context(): # Helpers # --------------------------------------------------------------------------- -FARFIELD_TYPES_ALL = [AutomatedFarfield, UserDefinedFarfield, WindTunnelFarfield] -FARFIELD_TYPES_REQUIRING_CUSTOM_ZONES = [UserDefinedFarfield, WindTunnelFarfield] +FARFIELD_TYPES_WITH_ENCLOSED = [AutomatedFarfield, WindTunnelFarfield] def _make_farfield(farfield_cls, **kwargs): @@ -107,7 +103,7 @@ def _make_rotor_disk(): # --------------------------------------------------------------------------- -@pytest.mark.parametrize("farfield_cls", FARFIELD_TYPES_ALL, ids=lambda c: c.__name__) +@pytest.mark.parametrize("farfield_cls", FARFIELD_TYPES_WITH_ENCLOSED, ids=lambda c: c.__name__) def test_enclosed_entities_beta_mesher_positive(farfield_cls): """enclosed_entities with beta mesher should pass validation.""" with SI_unit_system: @@ -133,7 +129,7 @@ def test_enclosed_entities_beta_mesher_positive(farfield_cls): # --------------------------------------------------------------------------- -@pytest.mark.parametrize("farfield_cls", FARFIELD_TYPES_ALL, ids=lambda c: c.__name__) +@pytest.mark.parametrize("farfield_cls", FARFIELD_TYPES_WITH_ENCLOSED, ids=lambda c: c.__name__) def test_enclosed_entities_beta_mesher_negative(farfield_cls): """enclosed_entities with legacy mesher should fail validation.""" with SI_unit_system: @@ -158,7 +154,7 @@ def test_enclosed_entities_beta_mesher_negative(farfield_cls): # --------------------------------------------------------------------------- -@pytest.mark.parametrize("farfield_cls", FARFIELD_TYPES_ALL, ids=lambda c: c.__name__) +@pytest.mark.parametrize("farfield_cls", FARFIELD_TYPES_WITH_ENCLOSED, ids=lambda c: c.__name__) def test_enclosed_entities_rotation_volume_association_negative(farfield_cls): """Cylinder in enclosed_entities without a RotationVolume should fail.""" rotor_disk = _make_rotor_disk() @@ -198,7 +194,7 @@ def test_enclosed_entities_rotation_volume_association_negative(farfield_cls): # --------------------------------------------------------------------------- -@pytest.mark.parametrize("farfield_cls", FARFIELD_TYPES_ALL, ids=lambda c: c.__name__) +@pytest.mark.parametrize("farfield_cls", FARFIELD_TYPES_WITH_ENCLOSED, ids=lambda c: c.__name__) def test_enclosed_entities_rotation_volume_association_positive(farfield_cls): """Cylinder in enclosed_entities that is also in a RotationVolume should pass.""" rotor_disk = _make_rotor_disk() @@ -235,24 +231,21 @@ def test_enclosed_entities_rotation_volume_association_positive(farfield_cls): # --------------------------------------------------------------------------- -# Group E: enclosed_entities without CustomZones = FAIL (UserDefined/WindTunnel only) +# Group E: enclosed_entities without CustomZones = FAIL (WindTunnel only) # --------------------------------------------------------------------------- -@pytest.mark.parametrize( - "farfield_cls", FARFIELD_TYPES_REQUIRING_CUSTOM_ZONES, ids=lambda c: c.__name__ -) -def test_enclosed_entities_requires_custom_zones(farfield_cls): - """enclosed_entities without CustomZones should fail.""" +def test_enclosed_entities_requires_custom_zones(): + """WindTunnelFarfield enclosed_entities without CustomZones should fail.""" with SI_unit_system: params = SimulationParams( meshing=MeshingParams( - defaults=_make_defaults(farfield_cls), + defaults=_make_defaults(WindTunnelFarfield), volume_zones=[ - _make_farfield(farfield_cls, enclosed_entities=[Surface(name="face1")]), + _make_farfield(WindTunnelFarfield, enclosed_entities=[Surface(name="face1")]), ], ), - private_attribute_asset_cache=_make_asset_cache(farfield_cls), + private_attribute_asset_cache=_make_asset_cache(WindTunnelFarfield), ) _, errors, _ = _validate(params) assert errors is not None @@ -260,7 +253,7 @@ def test_enclosed_entities_requires_custom_zones(farfield_cls): # --------------------------------------------------------------------------- -# AutomatedFarfield-specific tests (not parameterizable) +# AutomatedFarfield-specific tests — has separate validator with additional checks # --------------------------------------------------------------------------- @@ -297,6 +290,36 @@ def test_enclosed_entities_surfaces_only_no_rotation_volume_needed(): assert errors is None +# --------------------------------------------------------------------------- +# UserDefinedFarfield: no enclosed_entities support +# --------------------------------------------------------------------------- + + +def test_udf_rejects_enclosed_entities(): + """UserDefinedFarfield should not accept enclosed_entities.""" + import pydantic as pd + + with pytest.raises(pd.ValidationError, match="Extra inputs are not permitted"): + UserDefinedFarfield(enclosed_entities=[Surface(name="face1")]) + + +def test_udf_with_custom_volume_no_enclosed_entities(): + """UDF + CustomVolume without enclosed_entities should pass validation.""" + with SI_unit_system: + params = SimulationParams( + meshing=MeshingParams( + defaults=MeshingDefaults(boundary_layer_first_layer_thickness=1e-4), + volume_zones=[ + _make_custom_zones_with_volume(), + UserDefinedFarfield(), + ], + ), + private_attribute_asset_cache=AssetCache(use_inhouse_mesher=True), + ) + _, errors, _ = _validate(params) + assert errors is None + + # --------------------------------------------------------------------------- # CustomVolume bounding_entities + rotation association tests # --------------------------------------------------------------------------- @@ -484,51 +507,3 @@ def test_farfield_custom_volume_no_intersection_negative(): assert errors is not None assert any("shares bounding entities" in e["msg"] for e in errors) assert any("shared" in e["msg"] for e in errors) - - -# --------------------------------------------------------------------------- -# CustomZones without farfield zone -# --------------------------------------------------------------------------- - - -def test_custom_zones_without_farfield(): - """CustomZones only (no farfield zone) should pass and resolve farfield_method to user-defined.""" - with SI_unit_system: - params = SimulationParams( - meshing=MeshingParams( - defaults=MeshingDefaults(boundary_layer_first_layer_thickness=1e-4), - volume_zones=[ - _make_custom_zones_with_volume(), - ], - ), - private_attribute_asset_cache=AssetCache(use_inhouse_mesher=True), - ) - _, errors, _ = _validate(params) - assert errors is None - - farfield_method = ParamsValidationInfo._get_farfield_method_(params.model_dump(mode="json")) - assert farfield_method == "user-defined" - assert params.meshing.farfield_method == "user-defined" - - -@pytest.mark.parametrize( - "farfield_cls", - [UserDefinedFarfield, WindTunnelFarfield], - ids=lambda c: c.__name__, -) -def test_farfield_with_custom_volumes_requires_enclosed_entities(farfield_cls): - """Explicit farfield + CustomZones but no enclosed_entities should fail.""" - with SI_unit_system: - params = SimulationParams( - meshing=MeshingParams( - defaults=_make_defaults(farfield_cls), - volume_zones=[ - _make_custom_zones_with_volume(), - _make_farfield(farfield_cls), - ], - ), - private_attribute_asset_cache=_make_asset_cache(farfield_cls), - ) - _, errors, _ = _validate(params) - assert errors is not None - assert any("`enclosed_entities` for farfield must be specified" in e["msg"] for e in errors) diff --git a/tests/simulation/params/test_validators_params.py b/tests/simulation/params/test_validators_params.py index c34979740..3bfa6b08a 100644 --- a/tests/simulation/params/test_validators_params.py +++ b/tests/simulation/params/test_validators_params.py @@ -2529,9 +2529,7 @@ def test_beta_mesher_only_features(mock_validation_context): ) ], ), - UserDefinedFarfield( - enclosed_entities=[Surface(name="face1"), Surface(name="face2")], - ), + UserDefinedFarfield(), ], ), private_attribute_asset_cache=AssetCache(use_inhouse_mesher=False), @@ -2542,16 +2540,12 @@ def test_beta_mesher_only_features(mock_validation_context): root_item_type="SurfaceMesh", validation_level="VolumeMesh", ) - assert len(errors) == 2 + assert len(errors) == 1 assert ( errors[0]["msg"] == "Value error, CustomVolume is supported only when the beta mesher is enabled " + "and an automated, user-defined, or wind tunnel farfield is enabled." ) - assert ( - errors[1]["msg"] - == "Value error, `enclosed_entities` is only supported with the beta mesher." - ) # Unique volume zone names beta_mesher_context = ParamsValidationInfo({}, []) @@ -2595,12 +2589,7 @@ def test_beta_mesher_only_features(mock_validation_context): ), ], ), - UserDefinedFarfield( - enclosed_entities=[ - Surface(name="face1"), - Surface(name="face2"), - ], - ), + UserDefinedFarfield(), ], ), private_attribute_asset_cache=AssetCache(use_inhouse_mesher=True), @@ -2633,9 +2622,7 @@ def test_beta_mesher_only_features(mock_validation_context): ) ], ), - UserDefinedFarfield( - enclosed_entities=[Surface(name="face1")], - ), + UserDefinedFarfield(), ], ), private_attribute_asset_cache=AssetCache(use_inhouse_mesher=True), @@ -2659,9 +2646,7 @@ def test_beta_mesher_only_features(mock_validation_context): ) ], ), - UserDefinedFarfield( - enclosed_entities=[Surface(name="face1"), Surface(name="face2")], - ), + UserDefinedFarfield(), ], ), models=[ @@ -2933,9 +2918,7 @@ def test_check_custom_volume_in_volume_zones(): CustomVolume(name="zone1", bounding_entities=[Surface(name="face1")]) ], ), - UserDefinedFarfield( - enclosed_entities=[Surface(name="face1")], - ), + UserDefinedFarfield(), ], ), models=[ diff --git a/tests/simulation/params/test_validators_solid.py b/tests/simulation/params/test_validators_solid.py index 5bfbd6e04..a0f959507 100644 --- a/tests/simulation/params/test_validators_solid.py +++ b/tests/simulation/params/test_validators_solid.py @@ -45,9 +45,7 @@ def _build_params_with_custom_volume(element_type: str): entities=[zone], element_type=element_type, ), - UserDefinedFarfield( - enclosed_entities=[Surface(name="face1")], - ), + UserDefinedFarfield(), ], ), models=[ diff --git a/tests/simulation/ref/simulation_with_project_variables.json b/tests/simulation/ref/simulation_with_project_variables.json index b8e3132b8..4248743ef 100644 --- a/tests/simulation/ref/simulation_with_project_variables.json +++ b/tests/simulation/ref/simulation_with_project_variables.json @@ -418,5 +418,5 @@ "name": "SI" }, "user_defined_fields": [], - "version": "25.9.2b1" + "version": "25.9.3b1" } diff --git a/tests/simulation/translator/test_solver_translator.py b/tests/simulation/translator/test_solver_translator.py index 3e6b004fb..d91ea401b 100644 --- a/tests/simulation/translator/test_solver_translator.py +++ b/tests/simulation/translator/test_solver_translator.py @@ -1544,9 +1544,7 @@ def test_custom_volume_translation(): zone_2, ], ), - UserDefinedFarfield( - enclosed_entities=[Surface(name="face1"), Surface(name="face2")], - ), + UserDefinedFarfield(), ], ), operating_condition=AerospaceCondition(velocity_magnitude=10), diff --git a/tests/simulation/translator/test_volume_meshing_translator.py b/tests/simulation/translator/test_volume_meshing_translator.py index 3a630d692..ec874cd83 100644 --- a/tests/simulation/translator/test_volume_meshing_translator.py +++ b/tests/simulation/translator/test_volume_meshing_translator.py @@ -754,6 +754,7 @@ def test_custom_zones_element_type_tetrahedra(get_surface_mesh): assert "zones" in translated assert len(translated["zones"]) == 1 assert translated["zones"][0]["name"] == "tetrahedral_zone" + assert "farfield" not in {z["name"] for z in translated["zones"]} assert "enforceTetrahedralElements" in translated["zones"][0] assert translated["zones"][0]["enforceTetrahedralElements"] is True @@ -1583,41 +1584,6 @@ def test_automated_farfield_enclosed_entities(get_surface_mesh): assert sorted(zones_by_name["farfield"]["patches"]) == ["left1", "right1"] -def test_user_defined_farfield_enclosed_entities(get_surface_mesh): - """UserDefinedFarfield.enclosed_entities should create a 'farfield' zone in translated output.""" - left1 = Surface(name="left1") - right1 = Surface(name="right1") - with SI_unit_system: - params = SimulationParams( - meshing=MeshingParams( - defaults=MeshingDefaults( - boundary_layer_first_layer_thickness=1e-4, - ), - volume_zones=[ - CustomZones( - name="interior_zone", - entities=[ - CustomVolume( - name="inner", - bounding_entities=[left1, right1], - ), - ], - ), - UserDefinedFarfield( - enclosed_entities=[left1, right1], - ), - ], - ), - private_attribute_asset_cache=AssetCache(use_inhouse_mesher=True), - ) - - translated = get_volume_meshing_json(params, get_surface_mesh.mesh_unit) - assert "zones" in translated - zones_by_name = {z["name"]: z for z in translated["zones"]} - assert "farfield" in zones_by_name - assert sorted(zones_by_name["farfield"]["patches"]) == ["left1", "right1"] - - def test_farfield_enclosed_entities_with_cylinder(get_surface_mesh): """Cylinder in farfield enclosed_entities should translate to slidingInterface- prefix.""" face1 = Surface(name="face1")