Skip to content

Commit f886c0d

Browse files
refactor(FXC-6541): default SurfaceOutput.name to None and write empty string to solver JSON
Change SurfaceOutput.name and TimeAverageSurfaceOutput.name default from a string label to None. The translator writes an empty string to the solver JSON when name is None, so the C++ solver falls back to the standard "surface" prefix. Non-None names are written as-is for disambiguation. Made-with: Cursor
1 parent d7ac5ba commit f886c0d

38 files changed

Lines changed: 52 additions & 51 deletions

flow360/component/simulation/outputs/outputs.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,10 @@ class SurfaceOutput(_AnimationAndFileFormatSettings, _OutputBase):
470470
# TODO: entities is None --> use all surfaces. This is not implemented yet.
471471

472472
name: Optional[FileNameString] = pd.Field(
473-
"Surface output",
474-
description="Name of the `SurfaceOutput`. Must be unique across all `SurfaceOutput` "
475-
"instances that share the same surface entity.",
473+
None,
474+
description="Name of the `SurfaceOutput`. Used as a suffix in output filenames to "
475+
"disambiguate when multiple outputs share the same surface entity. "
476+
"Must be unique across all instances that share the same surface.",
476477
)
477478
entities: EntityList[ # pylint: disable=duplicate-code
478479
Surface,
@@ -499,9 +500,8 @@ class SurfaceOutput(_AnimationAndFileFormatSettings, _OutputBase):
499500

500501
@property
501502
def has_default_name(self) -> bool:
502-
"""Whether this output still carries its Pydantic-defined default name."""
503-
# pylint: disable=unsubscriptable-object
504-
return self.name is None or self.name == type(self).model_fields["name"].default
503+
"""Whether this output has no custom name assigned."""
504+
return self.name is None
505505

506506
@contextual_field_validator("entities", mode="after")
507507
@classmethod
@@ -546,9 +546,10 @@ class TimeAverageSurfaceOutput(SurfaceOutput):
546546
"""
547547

548548
name: Optional[FileNameString] = pd.Field(
549-
"Time average surface output",
550-
description="Name of the `TimeAverageSurfaceOutput`. Must be unique across all "
551-
"`TimeAverageSurfaceOutput` instances that share the same surface entity.",
549+
None,
550+
description="Name of the `TimeAverageSurfaceOutput`. Used as a suffix in output filenames "
551+
"to disambiguate when multiple outputs share the same surface entity. "
552+
"Must be unique across all instances that share the same surface.",
552553
)
553554

554555
start_step: Union[pd.NonNegativeInt, Literal[-1]] = pd.Field(

flow360/component/simulation/translator/solver_translator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ def _translate_single_surface_output(
597597
),
598598
)
599599
surface_output["writeSingleFile"] = output_instance.write_single_file
600-
surface_output["name"] = output_instance.name
600+
surface_output["name"] = output_instance.name if output_instance.name is not None else ""
601601
return surface_output
602602

603603

tests/ref/simulation/service_init_geometry.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@
372372
},
373373
"frequency": -1,
374374
"frequency_offset": 0,
375-
"name": "Surface output",
375+
"name": null,
376376
"output_fields": {
377377
"items": [
378378
"Cp",

tests/ref/simulation/service_init_surface_mesh.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@
372372
},
373373
"frequency": -1,
374374
"frequency_offset": 0,
375-
"name": "Surface output",
375+
"name": null,
376376
"output_fields": {
377377
"items": [
378378
"Cp",

tests/ref/simulation/service_init_volume_mesh.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
},
328328
"frequency": -1,
329329
"frequency_offset": 0,
330-
"name": "Surface output",
330+
"name": null,
331331
"output_fields": {
332332
"items": [
333333
"Cp",

tests/simulation/ref/entity_expansion_service_ref_outputs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"frequency": -1,
4646
"frequency_offset": 0,
47-
"name": "Surface output",
47+
"name": null,
4848
"output_fields": {
4949
"items": [
5050
"Cp",

tests/simulation/translator/ref/Flow360_CHT_three_cylinders.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"animationFrequencyOffset": 0,
9898
"animationFrequencyTimeAverage": -1,
9999
"animationFrequencyTimeAverageOffset": 0,
100-
"name": "Surface output",
100+
"name": "",
101101
"outputFields": [],
102102
"outputFormat": "paraview",
103103
"startAverageIntegrationStep": -1,
@@ -137,7 +137,7 @@
137137
"animationFrequencyOffset": 0,
138138
"animationFrequencyTimeAverage": -1,
139139
"animationFrequencyTimeAverageOffset": 0,
140-
"name": "Surface output",
140+
"name": "",
141141
"outputFields": [],
142142
"outputFormat": "paraview",
143143
"startAverageIntegrationStep": -1,

tests/simulation/translator/ref/Flow360_NestedCylindersSRF.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"animationFrequencyOffset": 0,
7070
"animationFrequencyTimeAverage": -1,
7171
"animationFrequencyTimeAverageOffset": 0,
72-
"name": "Surface output",
72+
"name": "",
7373
"outputFields": [],
7474
"outputFormat": "paraview",
7575
"startAverageIntegrationStep": -1,

tests/simulation/translator/ref/Flow360_TurbFlatPlate137x97_BoxTrip.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"animationFrequencyOffset": 0,
7979
"animationFrequencyTimeAverage": -1,
8080
"animationFrequencyTimeAverageOffset": 0,
81-
"name": "Surface output",
81+
"name": "",
8282
"outputFields": [],
8383
"outputFormat": "paraview",
8484
"startAverageIntegrationStep": -1,

tests/simulation/translator/ref/Flow360_XV15HoverMRF.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"animationFrequencyOffset": 0,
6161
"animationFrequencyTimeAverage": -1,
6262
"animationFrequencyTimeAverageOffset": 0,
63-
"name": "Surface output",
63+
"name": "",
6464
"outputFields": [],
6565
"outputFormat": "paraview",
6666
"startAverageIntegrationStep": -1,

0 commit comments

Comments
 (0)