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
16 changes: 15 additions & 1 deletion flow360/component/simulation/framework/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from flow360.log import log
from flow360.version import __version__

DEFAULT_PLANAR_FACE_TOLERANCE = 1e-6


def _to_24_11_1(params_as_dict):
# Check and remove the 'meshing' node if conditions are met
Expand Down Expand Up @@ -284,6 +286,17 @@ def _to_25_6_2(params_as_dict):
return params_as_dict


def _to_25_6_4(params_as_dict):
if params_as_dict.get("meshing") is None:
return params_as_dict
if "defaults" not in params_as_dict["meshing"]:
return params_as_dict
meshing_defaults = params_as_dict["meshing"].get("defaults", {})
if meshing_defaults.get("planar_face_tolerance") is None:
meshing_defaults["planar_face_tolerance"] = DEFAULT_PLANAR_FACE_TOLERANCE
return params_as_dict


VERSION_MILESTONES = [
(Flow360Version("24.11.1"), _to_24_11_1),
(Flow360Version("24.11.7"), _to_24_11_7),
Expand All @@ -292,7 +305,8 @@ def _to_25_6_2(params_as_dict):
(Flow360Version("25.2.1"), _to_25_2_1),
(Flow360Version("25.2.3"), _to_25_2_3),
(Flow360Version("25.4.1"), _to_25_4_1),
(Flow360Version("25.6.4"), _to_25_6_2),
(Flow360Version("25.6.2"), _to_25_6_2),
(Flow360Version("25.6.4"), _to_25_6_4),
] # A list of the Python API version tuple with there corresponding updaters.


Expand Down
3 changes: 2 additions & 1 deletion flow360/component/simulation/meshing_param/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import flow360.component.simulation.units as u
from flow360.component.simulation.framework.base_model import Flow360BaseModel
from flow360.component.simulation.framework.updater import DEFAULT_PLANAR_FACE_TOLERANCE
from flow360.component.simulation.meshing_param.edge_params import SurfaceEdgeRefinement
from flow360.component.simulation.meshing_param.face_params import (
BoundaryLayer,
Expand Down Expand Up @@ -105,7 +106,7 @@ class MeshingDefaults(Flow360BaseModel):
)

planar_face_tolerance: pd.NonNegativeFloat = pd.Field(
1e-6,
DEFAULT_PLANAR_FACE_TOLERANCE,
description="Tolerance used for detecting planar faces in the input surface mesh / geometry"
" that need to be remeshed, such as symmetry planes."
" This tolerance is non-dimensional, and represents a distance"
Expand Down
4 changes: 2 additions & 2 deletions flow360/component/simulation/models/surface_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from flow360.component.simulation.validation.validation_utils import (
check_deleted_surface_in_entity_list,
check_deleted_surface_pair,
check_symmetric_boundary_existence_for_inhouse,
check_symmetric_boundary_existence,
)

# pylint: disable=fixme
Expand All @@ -57,7 +57,7 @@ class EntityListAllowingGhost(EntityList): # Define EntityList to include valid
@classmethod
def ghost_entity_validator(cls, value):
"""Run all validators"""
return check_symmetric_boundary_existence_for_inhouse(value)
return check_symmetric_boundary_existence(value)


class BoundaryBase(Flow360BaseModel, metaclass=ABCMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def check_deleted_surface_pair(value):
return value


def check_symmetric_boundary_existence_for_inhouse(stored_entities):
def check_symmetric_boundary_existence(stored_entities):
"""Check according to the criteria if the symmetric plane exists."""
validation_info = get_validation_info()

Expand Down
7 changes: 2 additions & 5 deletions tests/simulation/service/test_services_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,10 +985,7 @@ def test_front_end_JSON_with_multi_constructor():
def test_generate_process_json():
params_data = {
"meshing": {
"defaults": {
# "boundary_layer_first_layer_thickness": "1*m",
# "surface_max_edge_length": "1*m",
},
"defaults": {},
"volume_zones": [
{
"method": "auto",
Expand Down Expand Up @@ -1062,7 +1059,7 @@ def test_generate_process_json():
with pytest.raises(
ValueError,
match=re.escape(
"[{'type': 'missing', 'loc': ('meshing', 'surface_max_edge_length'), 'msg': 'Field required', 'input': None, 'ctx': {'relevant_for': ['SurfaceMesh']}, 'url': 'https://errors.pydantic.dev/2.11/v/missing'}]"
"[{'type': 'missing', 'loc': ('meshing', 'defaults', 'surface_max_edge_length'), 'msg': 'Field required', 'input': None, 'ctx': {'relevant_for': ['SurfaceMesh']}, 'url': 'https://errors.pydantic.dev/2.11/v/missing'}]"
),
):
res1, res2, res3 = services.generate_process_json(
Expand Down
20 changes: 19 additions & 1 deletion tests/simulation/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def test_updater_to_25_6_2():
def _update_to_25_6_2(pre_update_param_as_dict, version_from):
params_new = updater(
version_from=version_from,
version_to=f"25.6.4",
version_to=f"25.6.2",
params_as_dict=pre_update_param_as_dict,
)
return params_new
Expand Down Expand Up @@ -711,3 +711,21 @@ def test_deserialization_with_updater():
validated_by=ValidationCalledBy.LOCAL,
validation_level=ALL,
)


def test_updater_to_25_6_4():
with open("../data/simulation/simulation_pre_25_4_1.json", "r") as fp:
params_as_dict = json.load(fp)

params_new = updater(
version_from="25.4.0b1",
version_to=f"25.6.4",
params_as_dict=params_as_dict,
)
assert params_new["meshing"]["defaults"]["planar_face_tolerance"] == 1e-6
params_new, _, _ = validate_model(
params_as_dict=params_new,
validated_by=ValidationCalledBy.LOCAL,
root_item_type="Geometry",
)
assert params_new
Loading