Skip to content

Commit c044d79

Browse files
Added local and global options for preserve_thin_geometry (#1423)
* Added local and global options for preserve_thin_geometry * Fix translation of surface meshing json --------- Co-authored-by: Chaitanya Talnikar <chaitanya@flexcompute.com>
1 parent 216e7fe commit c044d79

File tree

7 files changed

+51
-29
lines changed

7 files changed

+51
-29
lines changed

flow360/component/simulation/meshing_param/face_params.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,15 @@ class GeometryRefinement(Flow360BaseModel):
6666
entities: EntityList[Surface] = pd.Field(alias="faces")
6767
# pylint: disable=no-member
6868

69-
geometry_accuracy: LengthType.Positive = pd.Field(
70-
description="The smallest length scale that will be resolved accurately by the surface meshing process. "
69+
geometry_accuracy: Optional[LengthType.Positive] = pd.Field(
70+
None,
71+
description="The smallest length scale that will be resolved accurately by the surface meshing process. ",
72+
)
73+
74+
preserve_thin_geometry: Optional[bool] = pd.Field(
75+
False,
76+
description="Flag to specify whether thin geometry features with thickness roughly equal "
77+
+ "to geometry_accuracy should be resolved accurately during the surface meshing process.",
7178
)
7279

7380
@pd.field_validator("entities", mode="after")

flow360/component/simulation/meshing_param/params.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ class MeshingDefaults(Flow360BaseModel):
152152
context=SURFACE_MESH,
153153
)
154154

155+
preserve_thin_geometry: Optional[bool] = pd.Field(
156+
False,
157+
description="Flag to specify whether thin geometry features with thickness roughly equal "
158+
+ "to geometry_accuracy should be resolved accurately during the surface meshing process."
159+
+ "This can be overridden with class: ~flow360.GeometryRefinement",
160+
)
161+
155162
@pd.field_validator("number_of_boundary_layers", mode="after")
156163
@classmethod
157164
def invalid_number_of_boundary_layers(cls, value):
@@ -182,11 +189,14 @@ def invalid_geometry_accuracy(cls, value):
182189
return value
183190

184191
@pd.field_validator(
185-
"surface_max_aspect_ratio", "surface_max_adaptation_iterations", mode="after"
192+
"surface_max_aspect_ratio",
193+
"surface_max_adaptation_iterations",
194+
"preserve_thin_geometry",
195+
mode="after",
186196
)
187197
@classmethod
188198
def invalid_geometry_ai_features(cls, value, info):
189-
"""Ensure surface max aspect ratio is not specified when GAI is not used"""
199+
"""Ensure GAI features are not specified when GAI is not used"""
190200
validation_info = get_validation_info()
191201

192202
if validation_info is None:

flow360/component/simulation/translator/surface_meshing_translator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def _get_surface_refinements(refinement_list: list[dict]):
154154
"curvature_resolution_angle": None,
155155
"surface_edge_growth_rate": None,
156156
"geometry_accuracy": None,
157+
"preserve_thin_geometry": None,
157158
"surface_max_aspect_ratio": None,
158159
"surface_max_adaptation_iterations": None,
159160
},

tests/ref/simulation/service_init_geometry.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
"refinement_factor": 1.0,
88
"gap_treatment_strength": 0.0,
99
"defaults": {
10-
"boundary_layer_growth_rate": 1.2,
11-
"curvature_resolution_angle": {
12-
"units": "degree",
13-
"value": 12.0
14-
},
1510
"surface_edge_growth_rate": 1.2,
11+
"boundary_layer_growth_rate": 1.2,
1612
"planar_face_tolerance": 1e-06,
13+
"surface_max_aspect_ratio": 10.0,
1714
"surface_max_adaptation_iterations": 50,
18-
"surface_max_aspect_ratio": 10.0
15+
"curvature_resolution_angle": {
16+
"value": 12.0,
17+
"units": "degree"
18+
},
19+
"preserve_thin_geometry": false
1920
},
2021
"refinements": [],
2122
"volume_zones": [
@@ -192,7 +193,6 @@
192193
}
193194
}
194195
},
195-
"type": "Fluid",
196196
"initial_condition": {
197197
"type_name": "NavierStokesInitialCondition",
198198
"rho": "rho",
@@ -201,6 +201,7 @@
201201
"w": "w",
202202
"p": "p"
203203
},
204+
"type": "Fluid",
204205
"navier_stokes_solver": {
205206
"absolute_tolerance": 1e-10,
206207
"relative_tolerance": 0.0,
@@ -268,13 +269,9 @@
268269
"convergence_limiting_factor": 0.25
269270
}
270271
},
272+
"user_defined_fields": [],
271273
"outputs": [
272274
{
273-
"frequency": -1,
274-
"frequency_offset": 0,
275-
"output_format": "paraview",
276-
"name": "Surface output",
277-
"write_single_file": false,
278275
"output_fields": {
279276
"items": [
280277
"Cp",
@@ -283,6 +280,10 @@
283280
"CfVec"
284281
]
285282
},
283+
"frequency": -1,
284+
"frequency_offset": 0,
285+
"output_format": "paraview",
286+
"name": "Surface output",
286287
"entities": {
287288
"stored_entities": [
288289
{
@@ -293,10 +294,10 @@
293294
}
294295
]
295296
},
297+
"write_single_file": false,
296298
"output_type": "SurfaceOutput"
297299
}
298300
],
299-
"user_defined_fields": [],
300301
"private_attribute_asset_cache": {
301302
"project_length_unit": {
302303
"value": 1.0,

tests/ref/simulation/service_init_surface_mesh.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
"surface_edge_growth_rate": 1.2,
1111
"boundary_layer_growth_rate": 1.2,
1212
"planar_face_tolerance": 1e-06,
13-
"surface_max_adaptation_iterations": 50,
1413
"surface_max_aspect_ratio": 10.0,
14+
"surface_max_adaptation_iterations": 50,
1515
"curvature_resolution_angle": {
1616
"value": 12.0,
1717
"units": "degree"
18-
}
18+
},
19+
"preserve_thin_geometry": false
1920
},
2021
"refinements": [],
2122
"volume_zones": [
@@ -271,6 +272,14 @@
271272
"user_defined_fields": [],
272273
"outputs": [
273274
{
275+
"output_fields": {
276+
"items": [
277+
"Cp",
278+
"yPlus",
279+
"Cf",
280+
"CfVec"
281+
]
282+
},
274283
"frequency": -1,
275284
"frequency_offset": 0,
276285
"output_format": "paraview",
@@ -286,14 +295,6 @@
286295
]
287296
},
288297
"write_single_file": false,
289-
"output_fields": {
290-
"items": [
291-
"Cp",
292-
"yPlus",
293-
"Cf",
294-
"CfVec"
295-
]
296-
},
297298
"output_type": "SurfaceOutput"
298299
}
299300
],

tests/simulation/params/test_unit_conversions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def test_operations_on_units():
169169
assert str(replaced.units) == "dimensionless"
170170

171171
replaced = params.operating_condition.velocity_magnitude**5 - (1 / 50 * (fl.u.km / fl.u.s) ** 5)
172-
assertions.assertAlmostEqual(replaced.value, 502472105493.3395)
172+
assertions.assertAlmostEqual(replaced.value, 502472105493.3395, 3)
173173
assert str(replaced.units) == "inch**5*m**5/(cm**5*s**5)"
174174

175175
replaced = (

tests/simulation/translator/ref/surface_meshing/gai_surface_mesher.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"value": 0.05,
1515
"units": "flow360_length_unit"
1616
},
17+
"preserve_thin_geometry": false,
1718
"surface_max_aspect_ratio": 0.01,
1819
"surface_max_adaptation_iterations": 19
1920
},
@@ -177,6 +178,7 @@
177178
}
178179
]
179180
},
181+
"preserve_thin_geometry": false,
180182
"geometry_accuracy": {
181183
"value": 0.05,
182184
"units": "flow360_length_unit"
@@ -629,4 +631,4 @@
629631
]
630632
}
631633
}
632-
}
634+
}

0 commit comments

Comments
 (0)