Skip to content

Commit 5030775

Browse files
[Hotfix Main]: [FXC-5125] fix(): Use inline model without private_attribute_id for computing processor hash (#1751)
Co-authored-by: Angran Li <[email protected]>
1 parent cbf14cd commit 5030775

File tree

4 files changed

+59
-5
lines changed

4 files changed

+59
-5
lines changed

flow360/component/simulation/translator/solver_translator.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
compute_udf_dimensionalization_factor,
1414
)
1515
from flow360.component.simulation.framework.entity_base import EntityList
16+
from flow360.component.simulation.framework.updater_utils import recursive_remove_key
1617
from flow360.component.simulation.models.material import Sutherland
1718
from flow360.component.simulation.models.solver_numerics import NoneSolver
1819
from flow360.component.simulation.models.surface_models import (
@@ -1693,13 +1694,32 @@ def require_external_postprocessing(params: SimulationParams):
16931694

16941695
def calculate_monitor_semaphore_hash(params: SimulationParams):
16951696
"""Get the hash for monitor processor's semaphore"""
1697+
1698+
def get_force_output_models(force_output: ForceOutput, params: SimulationParams):
1699+
force_output_model_ids = {
1700+
(model.private_attribute_id if hasattr(model, "private_attribute_id") else model)
1701+
for model in force_output.models
1702+
}
1703+
force_output_models = [
1704+
model for model in params.models if model.private_attribute_id in force_output_model_ids
1705+
]
1706+
return force_output_models
1707+
16961708
json_string_list = []
16971709
if params.outputs:
16981710
for output in params.outputs:
16991711
if not isinstance(output, get_args(get_args(MonitorOutputType)[0])):
17001712
continue
17011713
if isinstance(output, ForceOutput):
1702-
json_string_list.extend(list(sorted(output.models)))
1714+
force_output_models = get_force_output_models(output, params)
1715+
force_output_models_dict = []
1716+
for model in force_output_models:
1717+
model_dict = dump_dict(model)
1718+
recursive_remove_key(
1719+
model_dict, "privateAttributeId", "privateAttributeInputCache"
1720+
)
1721+
force_output_models_dict.append(json.dumps(model_dict))
1722+
json_string_list.extend(force_output_models_dict)
17031723
json_string_list.extend(output.output_fields.items)
17041724
if output.moving_statistic is not None:
17051725
json_string_list.append(json.dumps(dump_dict(output.moving_statistic)))

tests/simulation/translator/data/simulation_stopping_criterion.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,33 @@
247247
]
248248
},
249249
"name": "Freestream"
250+
},
251+
{
252+
"type": "Wall",
253+
"entities": {
254+
"stored_entities": [
255+
{
256+
"private_attribute_entity_type_name": "Surface",
257+
"name": "4",
258+
"private_attribute_id": "ef389961-e941-4a0a-a910-55c6d303f7e5",
259+
"private_attribute_sub_components": []
260+
}
261+
]
262+
},
263+
"private_attribute_id": "209302bf-9eeb-449b-b7c4-a4e5c04a5b17",
264+
"name": "wing",
265+
"use_wall_function": false,
266+
"heat_spec": {
267+
"value": {
268+
"value": 0.0,
269+
"units": "W/m**2"
270+
},
271+
"type_name": "HeatFlux"
272+
},
273+
"roughness_height": {
274+
"value": 0.0,
275+
"units": "m"
276+
}
250277
}
251278
],
252279
"time_stepping": {
@@ -432,7 +459,7 @@
432459
"private_attribute_id": "33333",
433460
"name": "force_wallBC",
434461
"models": [
435-
"wallBC"
462+
"209302bf-9eeb-449b-b7c4-a4e5c04a5b17"
436463
],
437464
"moving_statistic": {
438465
"moving_window_size": 10,

tests/simulation/translator/ref/Flow360_om6wing_stopping_criterion_and_moving_statistic.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
},
1111
"3": {
1212
"type": "Freestream"
13+
},
14+
"4": {
15+
"heatFlux": 0.0,
16+
"roughnessHeight": 0.0,
17+
"type": "NoSlipWall"
1318
}
1419
},
1520
"freestream": {
@@ -97,7 +102,7 @@
97102
},
98103
"runControl": {
99104
"externalProcessMonitorOutput": true,
100-
"monitorProcessorHash": "bc5ac70ee2692e2a051b0867dad9c0057ac1b6d58995389d41ca850fb6c39b5b",
105+
"monitorProcessorHash": "396038f897af72de2eb89b96a33c0d8d954bff330ce054f0714b06fe669c0744",
101106
"stoppingCriteria": [
102107
{
103108
"monitoredColumn": "point_legacy1_Point1_Helicity_mean",

tests/simulation/translator/test_solver_translator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import os
33
import unittest
4+
import uuid
45

56
import numpy as np
67
import pytest
@@ -472,7 +473,7 @@ def test_om6wing_with_stopping_criterion_and_moving_statistic(get_om6Wing_tutori
472473
monitor_field=mass_flow_rate,
473474
tolerance_window_size=3,
474475
)
475-
wallBC = Wall(name="wing", surfaces=[Surface(name="1")], private_attribute_id="wallBC")
476+
wallBC = Wall(name="wing", surfaces=[Surface(name="4", private_attribute_id=str(uuid.uuid4()))])
476477
force_output = ForceOutput(
477478
name="force_wallBC",
478479
models=[wallBC],
@@ -486,10 +487,11 @@ def test_om6wing_with_stopping_criterion_and_moving_statistic(get_om6Wing_tutori
486487
monitor_output=force_output,
487488
monitor_field="CL",
488489
)
490+
params.models.append(wallBC)
489491
params.run_control = RunControl(stopping_criteria=[criterion1, criterion2, criterion3])
490492
params.outputs.extend([probe_output, mass_flow_rate_integral, force_output])
491493
translate_and_compare(
492-
get_om6Wing_tutorial_param,
494+
params,
493495
mesh_unit=0.8059 * u.m,
494496
ref_json_file="Flow360_om6wing_stopping_criterion_and_moving_statistic.json",
495497
debug=False,

0 commit comments

Comments
 (0)