Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions flow360/component/simulation/meshing_param/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
17 changes: 9 additions & 8 deletions flow360/component/simulation/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from flow360.exceptions import Flow360TranslationError


def unifrom_refinement_translator(obj: UniformRefinement):
def uniform_refinement_translator(obj: UniformRefinement):
"""
Translate UniformRefinement.

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
74 changes: 40 additions & 34 deletions flow360/component/simulation/validation/validation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from flow360.component.simulation.entity_info import DraftEntityTypes
from flow360.component.simulation.primitives import (
Surface,
_SurfaceEntityBase,
_VolumeEntityBase,
)
Expand Down Expand Up @@ -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

Expand All @@ -96,28 +97,33 @@ 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


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
Expand Down
9 changes: 5 additions & 4 deletions tests/simulation/params/test_automated_farfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Loading