diff --git a/flow360/component/simulation/meshing_param/params.py b/flow360/component/simulation/meshing_param/params.py index c2dc0fe96..c95911d71 100644 --- a/flow360/component/simulation/meshing_param/params.py +++ b/flow360/component/simulation/meshing_param/params.py @@ -144,23 +144,6 @@ def invalid_number_of_boundary_layers(cls, value): raise ValueError("Number of boundary layers is only supported by the beta mesher.") return value - @pd.field_validator("planar_face_tolerance", mode="after") - @classmethod - def invalid_planar_face_tolerance(cls, value): - """Ensure planar face tolerance is not specified""" - validation_info = get_validation_info() - - if validation_info is None: - return value - - # pylint:disable = unsubscriptable-object - if ( - value != cls.model_fields["planar_face_tolerance"].default - and not validation_info.is_beta_mesher - ): - raise ValueError("Planar face tolerance is only supported by the beta mesher.") - return value - @pd.field_validator("geometry_accuracy", mode="after") @classmethod def invalid_geometry_accuracy(cls, value): diff --git a/flow360/component/simulation/primitives.py b/flow360/component/simulation/primitives.py index cb0b1f33e..4de03d2be 100644 --- a/flow360/component/simulation/primitives.py +++ b/flow360/component/simulation/primitives.py @@ -514,6 +514,8 @@ class Surface(_SurfaceEntityBase): private_attribute_sub_components: Optional[List[str]] = pd.Field( [], description="The face ids in geometry that composed into this `Surface`." ) + # pylint: disable=fixme + # TODO: This should be deprecated since it is not very useful or easy to use. private_attribute_potential_issues: List[_SurfaceIssueEnums] = pd.Field( [], description="Issues (not necessarily problems) found on this `Surface` after inspection by " @@ -621,17 +623,16 @@ def _get_existence_dependency(self, validation_info): def exists(self, validation_info) -> bool: """Mesher logic for symmetric plane existence.""" - if ( - validation_info is None - or not validation_info.is_beta_mesher - or self.name != "symmetric" - ): - # Non-beta mesher mode, then symmetric plane existence is handled upstream. + if self.name != "symmetric": + # Quasi-3D mode, no need to check existence. return True + if validation_info is None: + raise ValueError("Validation info is required for GhostCircularPlane existence check.") + if validation_info.global_bounding_box is None: - # This likely means the user try to use in-house mesher on old cloud resources. - # We cannot validate if symmetric exists so will let it pass. Pipeline will error out. + # This likely means the user try to use mesher on old cloud resources. + # We cannot validate if symmetric exists so will let it pass. Pipeline will error out anyway. return True y_min, y_max, tolerance, _ = self._get_existence_dependency(validation_info) diff --git a/flow360/component/simulation/translator/volume_meshing_translator.py b/flow360/component/simulation/translator/volume_meshing_translator.py index 66e9473a0..f449c2ecc 100644 --- a/flow360/component/simulation/translator/volume_meshing_translator.py +++ b/flow360/component/simulation/translator/volume_meshing_translator.py @@ -23,7 +23,7 @@ from flow360.exceptions import Flow360TranslationError -def unifrom_refinement_translator(obj: UniformRefinement): +def uniform_refinement_translator(obj: UniformRefinement): """ Translate UniformRefinement. @@ -94,7 +94,7 @@ def rotation_cylinder_translator(obj: RotationCylinder, rotor_disk_names: list): return setting -def refinement_entitity_injector(entity_obj): +def refinement_entity_injector(entity_obj): """Injector for UniformRefinement entity [box & cylinder].""" if isinstance(entity_obj, Cylinder): return { @@ -188,7 +188,10 @@ def get_volume_meshing_json(input_params: SimulationParams, mesh_units): break if isinstance(zone, AutomatedFarfield): - translated["farfield"] = {"type": zone.method} + translated["farfield"] = { + "type": zone.method, + "planarFaceTolerance": meshing_params.defaults.planar_face_tolerance, + } break if "farfield" not in translated: @@ -231,9 +234,9 @@ def get_volume_meshing_json(input_params: SimulationParams, mesh_units): uniform_refinement_list = translate_setting_and_apply_to_all_entities( meshing_params.refinements, UniformRefinement, - unifrom_refinement_translator, + uniform_refinement_translator, to_list=True, - entity_injection_func=refinement_entitity_injector, + entity_injection_func=refinement_entity_injector, ) rotor_disk_refinement = translate_setting_and_apply_to_all_entities( meshing_params.refinements, diff --git a/flow360/component/simulation/user_defined_dynamics/user_defined_dynamics.py b/flow360/component/simulation/user_defined_dynamics/user_defined_dynamics.py index b64c7f525..dda3667ce 100644 --- a/flow360/component/simulation/user_defined_dynamics/user_defined_dynamics.py +++ b/flow360/component/simulation/user_defined_dynamics/user_defined_dynamics.py @@ -8,9 +8,6 @@ from flow360.component.simulation.framework.entity_base import EntityList from flow360.component.simulation.framework.expressions import StringExpression from flow360.component.simulation.primitives import Cylinder, GenericVolume, Surface -from flow360.component.simulation.validation.validation_context import ( - get_validation_info, -) from flow360.component.simulation.validation.validation_utils import ( check_deleted_surface_in_entity_list, ) @@ -115,17 +112,19 @@ def ensure_surface_existence(cls, value): @classmethod def ensure_output_surface_existence(cls, value): """Ensure that the output target surface is not a deleted surface""" - validation_info = get_validation_info() - if validation_info is None or validation_info.auto_farfield_method is None: - # validation not necessary now. - return value - # - Check if the surfaces are deleted. - # pylint: disable=protected-access - if isinstance(value, Surface) and value._will_be_deleted_by_mesher( - validation_info.auto_farfield_method - ): - raise ValueError( - f"Boundary `{value.name}` will likely be deleted after mesh generation. Therefore it cannot be used." - ) + # --- Disabled for FXC-2006 + # validation_info = get_validation_info() + # if validation_info is None or validation_info.auto_farfield_method is None: + # # validation not necessary now. + # return value + + # # - Check if the surfaces are deleted. + # # pylint: disable=protected-access + # if isinstance(value, Surface) and value._will_be_deleted_by_mesher( + # validation_info.auto_farfield_method + # ): + # raise ValueError( + # f"Boundary `{value.name}` will likely be deleted after mesh generation. Therefore it cannot be used." + # ) return value diff --git a/flow360/component/simulation/validation/validation_simulation_params.py b/flow360/component/simulation/validation/validation_simulation_params.py index 8c2332e06..3267278e4 100644 --- a/flow360/component/simulation/validation/validation_simulation_params.py +++ b/flow360/component/simulation/validation/validation_simulation_params.py @@ -313,6 +313,10 @@ def _check_complete_boundary_condition_and_unknown_surface( ): # pylint:disable=too-many-branches ## Step 1: Get all boundaries patches from asset cache + return params + + # --- Disabled for FXC-2006 + # pylint: disable=unreachable current_lvls = get_validation_levels() if get_validation_levels() else [] if all(level not in current_lvls for level in (ALL, CASE)): return params diff --git a/flow360/component/simulation/validation/validation_utils.py b/flow360/component/simulation/validation/validation_utils.py index 74dd255df..6d6558c1e 100644 --- a/flow360/component/simulation/validation/validation_utils.py +++ b/flow360/component/simulation/validation/validation_utils.py @@ -7,7 +7,6 @@ from flow360.component.simulation.entity_info import DraftEntityTypes from flow360.component.simulation.primitives import ( - Surface, _SurfaceEntityBase, _VolumeEntityBase, ) @@ -68,25 +67,27 @@ def check_deleted_surface_in_entity_list(value): Check if any boundary is meant to be deleted value--> EntityList """ - validation_info = get_validation_info() - if ( - validation_info is None - or validation_info.auto_farfield_method is None - or validation_info.is_beta_mesher is True - ): - # validation not necessary now. - return value - - # - Check if the surfaces are deleted. - for surface in value.stored_entities: - if isinstance( - surface, Surface - ) and surface._will_be_deleted_by_mesher( # pylint:disable=protected-access - validation_info.auto_farfield_method - ): - raise ValueError( - f"Boundary `{surface.name}` will likely be deleted after mesh generation. Therefore it cannot be used." - ) + # --- Disabled for FXC-2006 + # validation_info = get_validation_info() + # if ( + # validation_info is None + # or validation_info.auto_farfield_method is None + # or validation_info.is_beta_mesher is True + # ): + # # validation not necessary now. + # return value + + # # - Check if the surfaces are deleted. + # for surface in value.stored_entities: + # if isinstance( + # surface, Surface + # ) and surface._will_be_deleted_by_mesher( # pylint:disable=protected-access + # validation_info.auto_farfield_method + # ): + # raise ValueError( + # f"Boundary `{surface.name}` will likely be deleted after mesh generation. " + # "Therefore it cannot be used." + # ) return value @@ -96,19 +97,22 @@ def check_deleted_surface_pair(value): Check if any boundary is meant to be deleted value--> SurfacePair """ - validation_info = get_validation_info() - if validation_info is None or validation_info.auto_farfield_method is None: - # validation not necessary now. - return value - - # - Check if the surfaces are deleted. - for surface in value.pair: - if surface._will_be_deleted_by_mesher( # pylint:disable=protected-access - validation_info.auto_farfield_method - ): - raise ValueError( - f"Boundary `{surface.name}` will likely be deleted after mesh generation. Therefore it cannot be used." - ) + + # --- Disabled for FXC-2006 + # validation_info = get_validation_info() + # if validation_info is None or validation_info.auto_farfield_method is None: + # # validation not necessary now. + # return value + + # # - Check if the surfaces are deleted. + # for surface in value.pair: + # if surface._will_be_deleted_by_mesher( # pylint:disable=protected-access + # validation_info.auto_farfield_method + # ): + # raise ValueError( + # f"Boundary `{surface.name}` will likely be deleted after mesh generation. " + # "Therefore it cannot be used." + # ) return value @@ -116,8 +120,10 @@ def check_deleted_surface_pair(value): def check_symmetric_boundary_existence_for_inhouse(stored_entities): """Check according to the criteria if the symmetric plane exists.""" validation_info = get_validation_info() - if validation_info is None or validation_info.is_beta_mesher is False: + + if validation_info is None: return stored_entities + for item in stored_entities: if item.private_attribute_entity_type_name != "GhostCircularPlane": continue diff --git a/tests/simulation/params/test_automated_farfield.py b/tests/simulation/params/test_automated_farfield.py index 785f7bce7..723d5917c 100644 --- a/tests/simulation/params/test_automated_farfield.py +++ b/tests/simulation/params/test_automated_farfield.py @@ -190,10 +190,11 @@ def _run_validation(params): # Valid Symmetric but did not use it errors = _run_validation(params) - assert len(errors) == 1 - assert ( - "The following boundaries do not have a boundary condition: symmetric." in errors[0]["msg"] - ) + # --- Disabled for FXC-2006 + # assert len(errors) == 1 + # assert ( + # "The following boundaries do not have a boundary condition: symmetric." in errors[0]["msg"] + # ) params.models.append(SymmetryPlane(surfaces=[farfield.symmetry_planes])) errors = _run_validation(params) diff --git a/tests/simulation/params/test_validators_params.py b/tests/simulation/params/test_validators_params.py index 42fef7d70..8c1cd9df8 100644 --- a/tests/simulation/params/test_validators_params.py +++ b/tests/simulation/params/test_validators_params.py @@ -582,12 +582,14 @@ def test_BC_geometry(): root_item_type="Geometry", validation_level="All", ) - assert len(errors) == 1 - assert errors[0]["loc"] == ("models", 3, "entities") - assert errors[0]["msg"] == ( - "Value error, Boundary `symmetry11` will likely be deleted after mesh generation. " - "Therefore it cannot be used." - ) + # --- Disabled for FXC-2006 + assert errors is None + # assert len(errors) == 1 + # assert errors[0]["loc"] == ("models", 3, "entities") + # assert errors[0]["msg"] == ( + # "Value error, Boundary `symmetry11` will likely be deleted after mesh generation. " + # "Therefore it cannot be used." + # ) ##### Ghost entities not used ##### with SI_unit_system: @@ -612,11 +614,14 @@ def test_BC_geometry(): root_item_type="Geometry", validation_level="All", ) - assert len(errors) == 1 - assert errors[0]["msg"] == ( - "Value error, The following boundaries do not have a boundary condition: farfield, symmetric." - " Please add them to a boundary condition model in the `models` section." - ) + + # --- Disabled for FXC-2006 + assert errors is None + # assert len(errors) == 1 + # assert errors[0]["msg"] == ( + # "Value error, The following boundaries do not have a boundary condition: farfield, symmetric." + # " Please add them to a boundary condition model in the `models` section." + # ) ##### QUASI 3D METHOD ##### auto_farfield = AutomatedFarfield(name="my_farfield", method="quasi-3d") @@ -646,17 +651,19 @@ def test_BC_geometry(): root_item_type="Geometry", validation_level="All", ) - assert len(errors) == 2 - assert errors[0]["loc"] == ("models", 3, "entities") - assert errors[0]["msg"] == ( - "Value error, Boundary `symmetry11` will likely be deleted after mesh generation. " - "Therefore it cannot be used." - ) - assert errors[1]["loc"] == ("models", 4, "entities") - assert errors[1]["msg"] == ( - "Value error, Boundary `symmetry22` will likely be deleted after mesh generation. " - "Therefore it cannot be used." - ) + # --- Disabled for FXC-2006 + assert errors is None + # assert len(errors) == 2 + # assert errors[0]["loc"] == ("models", 3, "entities") + # assert errors[0]["msg"] == ( + # "Value error, Boundary `symmetry11` will likely be deleted after mesh generation. " + # "Therefore it cannot be used." + # ) + # assert errors[1]["loc"] == ("models", 4, "entities") + # assert errors[1]["msg"] == ( + # "Value error, Boundary `symmetry22` will likely be deleted after mesh generation. " + # "Therefore it cannot be used." + # ) ##### Ghost entities not used ##### auto_farfield = AutomatedFarfield(name="my_farfield", method="quasi-3d") @@ -681,11 +688,13 @@ def test_BC_geometry(): root_item_type="Geometry", validation_level="All", ) - assert len(errors) == 1 - assert errors[0]["msg"] == ( - "Value error, The following boundaries do not have a boundary condition: farfield, " - "symmetric-1, symmetric-2. Please add them to a boundary condition model in the `models` section." - ) + # --- Disabled for FXC-2006 + assert errors is None + # assert len(errors) == 1 + # assert errors[0]["msg"] == ( + # "Value error, The following boundaries do not have a boundary condition: farfield, " + # "symmetric-1, symmetric-2. Please add them to a boundary condition model in the `models` section." + # ) # --------------------------------------------------------# # >>>>>>> Group sides of airfoil as SINGLE boundary <<<<<<< @@ -723,10 +732,12 @@ def test_BC_geometry(): root_item_type="Geometry", validation_level="All", ) - assert len(errors) == 1 - assert errors[0]["msg"] == ( - "Value error, Boundary `symmetry` will likely be deleted after mesh generation. Therefore it cannot be used." - ) + # --- Disabled for FXC-2006 + assert errors is None + # assert len(errors) == 1 + # assert errors[0]["msg"] == ( + # "Value error, Boundary `symmetry` will likely be deleted after mesh generation. Therefore it cannot be used." + # ) def test_incomplete_BC_volume_mesh(): @@ -745,59 +756,62 @@ def test_incomplete_BC_volume_mesh(): ), ) - with pytest.raises( - ValueError, - match=re.escape( - r"The following boundaries do not have a boundary condition: no_bc. Please add them to a boundary condition model in the `models` section." - ), - ): - with ValidationContext(ALL): - with SI_unit_system: - SimulationParams( - meshing=MeshingParams( - defaults=MeshingDefaults( - boundary_layer_first_layer_thickness=1e-10, - surface_max_edge_length=1e-10, - ) - ), - models=[ - Fluid(), - Wall(entities=wall_1), - Periodic(surface_pairs=(periodic_1, periodic_2), spec=Translational()), - SlipWall(entities=[i_exist]), - ], - private_attribute_asset_cache=asset_cache, - ) - with pytest.raises( - ValueError, - match=re.escape( - r"The following boundaries are not known `Surface` entities but appear in the `models` section: plz_dont_do_this." + # --- Disabled for FXC-2006 + # with pytest.raises( + # ValueError, + # match=re.escape( + # r"The following boundaries do not have a boundary condition: no_bc. Please add them to a boundary condition model in the `models` section." + # ), + # ): + with ValidationContext(ALL): + with SI_unit_system: + SimulationParams( + meshing=MeshingParams( + defaults=MeshingDefaults( + boundary_layer_first_layer_thickness=1e-10, + surface_max_edge_length=1e-10, + ) + ), + models=[ + Fluid(), + Wall(entities=wall_1), + Periodic(surface_pairs=(periodic_1, periodic_2), spec=Translational()), + SlipWall(entities=[i_exist]), + ], + private_attribute_asset_cache=asset_cache, + ) + + # --- Disabled for FXC-2006 + # with pytest.raises( + # ValueError, + # match=re.escape( + # r"The following boundaries are not known `Surface` entities but appear in the `models` section: plz_dont_do_this." + # ), + # ): + with ValidationContext( + ALL, + info=ParamsValidationInfo( + param_as_dict={}, + referenced_expressions=[], ), ): - with ValidationContext( - ALL, - info=ParamsValidationInfo( - param_as_dict={}, - referenced_expressions=[], - ), - ): - with SI_unit_system: - SimulationParams( - meshing=MeshingParams( - defaults=MeshingDefaults( - boundary_layer_first_layer_thickness=1e-10, - surface_max_edge_length=1e-10, - ) - ), - models=[ - Fluid(), - Wall(entities=[wall_1]), - Periodic(surface_pairs=(periodic_1, periodic_2), spec=Translational()), - SlipWall(entities=[i_exist]), - SlipWall(entities=[Surface(name="plz_dont_do_this"), no_bc]), - ], - private_attribute_asset_cache=asset_cache, - ) + with SI_unit_system: + SimulationParams( + meshing=MeshingParams( + defaults=MeshingDefaults( + boundary_layer_first_layer_thickness=1e-10, + surface_max_edge_length=1e-10, + ) + ), + models=[ + Fluid(), + Wall(entities=[wall_1]), + Periodic(surface_pairs=(periodic_1, periodic_2), spec=Translational()), + SlipWall(entities=[i_exist]), + SlipWall(entities=[Surface(name="plz_dont_do_this"), no_bc]), + ], + private_attribute_asset_cache=asset_cache, + ) def test_incomplete_BC_surface_mesh(): @@ -850,69 +864,72 @@ def test_incomplete_BC_surface_mesh(): private_attribute_asset_cache=asset_cache, ) - with pytest.raises( - ValueError, - match=re.escape( - r"The following boundaries do not have a boundary condition: no_bc. Please add them to a boundary condition model in the `models` section." + # --- Disabled for FXC-2006 + # with pytest.raises( + # ValueError, + # match=re.escape( + # r"The following boundaries do not have a boundary condition: no_bc. Please add them to a boundary condition model in the `models` section." + # ), + # ): + with ValidationContext( + ALL, + info=ParamsValidationInfo( + param_as_dict={}, + referenced_expressions=[], ), ): - with ValidationContext( - ALL, - info=ParamsValidationInfo( - param_as_dict={}, - referenced_expressions=[], - ), - ): - with SI_unit_system: - SimulationParams( - meshing=MeshingParams( - defaults=MeshingDefaults( - boundary_layer_first_layer_thickness=1e-10, - surface_max_edge_length=1e-10, - ), - volume_zones=[auto_farfield], + with SI_unit_system: + SimulationParams( + meshing=MeshingParams( + defaults=MeshingDefaults( + boundary_layer_first_layer_thickness=1e-10, + surface_max_edge_length=1e-10, ), - models=[ - Fluid(), - Wall(entities=wall_1), - Periodic(surface_pairs=(periodic_1, periodic_2), spec=Translational()), - SlipWall(entities=[i_exist]), - Freestream(entities=auto_farfield.farfield), - ], - private_attribute_asset_cache=asset_cache, - ) - with pytest.raises( - ValueError, - match=re.escape( - r"The following boundaries are not known `Surface` entities but appear in the `models` section: plz_dont_do_this." + volume_zones=[auto_farfield], + ), + models=[ + Fluid(), + Wall(entities=wall_1), + Periodic(surface_pairs=(periodic_1, periodic_2), spec=Translational()), + SlipWall(entities=[i_exist]), + Freestream(entities=auto_farfield.farfield), + ], + private_attribute_asset_cache=asset_cache, + ) + + # --- Disabled for FXC-2006 + # with pytest.raises( + # ValueError, + # match=re.escape( + # r"The following boundaries are not known `Surface` entities but appear in the `models` section: plz_dont_do_this." + # ), + # ): + with ValidationContext( + ALL, + info=ParamsValidationInfo( + param_as_dict={}, + referenced_expressions=[], ), ): - with ValidationContext( - ALL, - info=ParamsValidationInfo( - param_as_dict={}, - referenced_expressions=[], - ), - ): - with SI_unit_system: - SimulationParams( - meshing=MeshingParams( - defaults=MeshingDefaults( - boundary_layer_first_layer_thickness=1e-10, - surface_max_edge_length=1e-10, - ), - volume_zones=[auto_farfield], + with SI_unit_system: + SimulationParams( + meshing=MeshingParams( + defaults=MeshingDefaults( + boundary_layer_first_layer_thickness=1e-10, + surface_max_edge_length=1e-10, ), - models=[ - Fluid(), - Wall(entities=[wall_1]), - Periodic(surface_pairs=(periodic_1, periodic_2), spec=Translational()), - SlipWall(entities=[i_exist]), - Freestream(entities=auto_farfield.farfield), - SlipWall(entities=[Surface(name="plz_dont_do_this"), no_bc]), - ], - private_attribute_asset_cache=asset_cache, - ) + volume_zones=[auto_farfield], + ), + models=[ + Fluid(), + Wall(entities=[wall_1]), + Periodic(surface_pairs=(periodic_1, periodic_2), spec=Translational()), + SlipWall(entities=[i_exist]), + Freestream(entities=auto_farfield.farfield), + SlipWall(entities=[Surface(name="plz_dont_do_this"), no_bc]), + ], + private_attribute_asset_cache=asset_cache, + ) def test_duplicate_entities_in_models(): @@ -1524,11 +1541,14 @@ def test_deleted_surfaces(): root_item_type="Geometry", validation_level="All", ) - assert len(errors) == 1 - assert ( - errors[0]["msg"] == "Value error, Boundary `body0001_face0003` will likely" - " be deleted after mesh generation. Therefore it cannot be used." - ) + + # --- Disabled for FXC-2006 + assert errors is None + # assert len(errors) == 1 + # assert ( + # errors[0]["msg"] == "Value error, Boundary `body0001_face0003` will likely" + # " be deleted after mesh generation. Therefore it cannot be used." + # ) with SI_unit_system: params = SimulationParams( @@ -1555,12 +1575,14 @@ def test_deleted_surfaces(): root_item_type="Geometry", validation_level="All", ) - assert len(errors) == 1 - assert ( - errors[0]["msg"] == "Value error, Boundary `body0001_face0004` will likely" - " be deleted after mesh generation. Therefore it cannot be used." - ) - assert errors[0]["loc"] == ("models", 2, "entity_pairs") + # --- Disabled for FXC-2006 + assert errors is None + # assert len(errors) == 1 + # assert ( + # errors[0]["msg"] == "Value error, Boundary `body0001_face0004` will likely" + # " be deleted after mesh generation. Therefore it cannot be used." + # ) + # assert errors[0]["loc"] == ("models", 2, "entity_pairs") def test_validate_liquid_operating_condition(): @@ -1823,10 +1845,7 @@ def test_beta_mesher_only_features(): root_item_type="Geometry", validation_level="VolumeMesh", ) - assert len(errors) == 1 - assert errors[0]["msg"] == ( - "Value error, Planar face tolerance is only supported by the beta mesher." - ) + assert errors is None def test_geometry_AI_only_features(): diff --git a/tests/simulation/translator/test_volume_meshing_translator.py b/tests/simulation/translator/test_volume_meshing_translator.py index b894278dd..85ac5761a 100644 --- a/tests/simulation/translator/test_volume_meshing_translator.py +++ b/tests/simulation/translator/test_volume_meshing_translator.py @@ -202,7 +202,7 @@ def test_param_to_json(get_test_param, get_surface_mesh): ref_dict = { "refinementFactor": 1.45, - "farfield": {"type": "auto"}, + "farfield": {"type": "auto", "planarFaceTolerance": 1e-6}, "volume": { "firstLayerThickness": 1.35e-06, "growthRate": 1.04,