Skip to content

Commit cf6d85e

Browse files
benflexcomputeflow360-auto-hotfix-bot
authored andcommitted
[FXC-2059] Added planar_face_tolerance translator for legacy mesher and also unified the validation (#1329)
* [FSC-2006] Disable boundary completness and deletion validation * Fix unit test * [FXC-2059] Added planar_face_tolerance translator for legacy mesher and also unified the validaiton
1 parent b479e80 commit cf6d85e

File tree

6 files changed

+20
-36
lines changed

6 files changed

+20
-36
lines changed

flow360/component/simulation/meshing_param/params.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -144,23 +144,6 @@ def invalid_number_of_boundary_layers(cls, value):
144144
raise ValueError("Number of boundary layers is only supported by the beta mesher.")
145145
return value
146146

147-
@pd.field_validator("planar_face_tolerance", mode="after")
148-
@classmethod
149-
def invalid_planar_face_tolerance(cls, value):
150-
"""Ensure planar face tolerance is not specified"""
151-
validation_info = get_validation_info()
152-
153-
if validation_info is None:
154-
return value
155-
156-
# pylint:disable = unsubscriptable-object
157-
if (
158-
value != cls.model_fields["planar_face_tolerance"].default
159-
and not validation_info.is_beta_mesher
160-
):
161-
raise ValueError("Planar face tolerance is only supported by the beta mesher.")
162-
return value
163-
164147
@pd.field_validator("geometry_accuracy", mode="after")
165148
@classmethod
166149
def invalid_geometry_accuracy(cls, value):

flow360/component/simulation/primitives.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -623,17 +623,16 @@ def _get_existence_dependency(self, validation_info):
623623
def exists(self, validation_info) -> bool:
624624
"""Mesher logic for symmetric plane existence."""
625625

626-
if (
627-
validation_info is None
628-
or not validation_info.is_beta_mesher
629-
or self.name != "symmetric"
630-
):
631-
# Non-beta mesher mode, then symmetric plane existence is handled upstream.
626+
if self.name != "symmetric":
627+
# Quasi-3D mode, no need to check existence.
632628
return True
633629

630+
if validation_info is None:
631+
raise ValueError("Validation info is required for GhostCircularPlane existence check.")
632+
634633
if validation_info.global_bounding_box is None:
635-
# This likely means the user try to use in-house mesher on old cloud resources.
636-
# We cannot validate if symmetric exists so will let it pass. Pipeline will error out.
634+
# This likely means the user try to use mesher on old cloud resources.
635+
# We cannot validate if symmetric exists so will let it pass. Pipeline will error out anyway.
637636
return True
638637

639638
y_min, y_max, tolerance, _ = self._get_existence_dependency(validation_info)

flow360/component/simulation/translator/volume_meshing_translator.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from flow360.exceptions import Flow360TranslationError
2424

2525

26-
def unifrom_refinement_translator(obj: UniformRefinement):
26+
def uniform_refinement_translator(obj: UniformRefinement):
2727
"""
2828
Translate UniformRefinement.
2929
@@ -94,7 +94,7 @@ def rotation_cylinder_translator(obj: RotationCylinder, rotor_disk_names: list):
9494
return setting
9595

9696

97-
def refinement_entitity_injector(entity_obj):
97+
def refinement_entity_injector(entity_obj):
9898
"""Injector for UniformRefinement entity [box & cylinder]."""
9999
if isinstance(entity_obj, Cylinder):
100100
return {
@@ -188,7 +188,10 @@ def get_volume_meshing_json(input_params: SimulationParams, mesh_units):
188188
break
189189

190190
if isinstance(zone, AutomatedFarfield):
191-
translated["farfield"] = {"type": zone.method}
191+
translated["farfield"] = {
192+
"type": zone.method,
193+
"planarFaceTolerance": meshing_params.defaults.planar_face_tolerance,
194+
}
192195
break
193196

194197
if "farfield" not in translated:
@@ -231,9 +234,9 @@ def get_volume_meshing_json(input_params: SimulationParams, mesh_units):
231234
uniform_refinement_list = translate_setting_and_apply_to_all_entities(
232235
meshing_params.refinements,
233236
UniformRefinement,
234-
unifrom_refinement_translator,
237+
uniform_refinement_translator,
235238
to_list=True,
236-
entity_injection_func=refinement_entitity_injector,
239+
entity_injection_func=refinement_entity_injector,
237240
)
238241
rotor_disk_refinement = translate_setting_and_apply_to_all_entities(
239242
meshing_params.refinements,

flow360/component/simulation/validation/validation_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ def check_deleted_surface_pair(value):
120120
def check_symmetric_boundary_existence_for_inhouse(stored_entities):
121121
"""Check according to the criteria if the symmetric plane exists."""
122122
validation_info = get_validation_info()
123-
if validation_info is None or validation_info.is_beta_mesher is False:
123+
124+
if validation_info is None:
124125
return stored_entities
126+
125127
for item in stored_entities:
126128
if item.private_attribute_entity_type_name != "GhostCircularPlane":
127129
continue

tests/simulation/params/test_validators_params.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,10 +1845,7 @@ def test_beta_mesher_only_features():
18451845
root_item_type="Geometry",
18461846
validation_level="VolumeMesh",
18471847
)
1848-
assert len(errors) == 1
1849-
assert errors[0]["msg"] == (
1850-
"Value error, Planar face tolerance is only supported by the beta mesher."
1851-
)
1848+
assert errors is None
18521849

18531850

18541851
def test_geometry_AI_only_features():

tests/simulation/translator/test_volume_meshing_translator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def test_param_to_json(get_test_param, get_surface_mesh):
202202

203203
ref_dict = {
204204
"refinementFactor": 1.45,
205-
"farfield": {"type": "auto"},
205+
"farfield": {"type": "auto", "planarFaceTolerance": 1e-6},
206206
"volume": {
207207
"firstLayerThickness": 1.35e-06,
208208
"growthRate": 1.04,

0 commit comments

Comments
 (0)