1111from flow360 .component .simulation .meshing_param .edge_params import SurfaceEdgeRefinement
1212from flow360 .component .simulation .meshing_param .face_params import (
1313 BoundaryLayer ,
14+ GeometryRefinement ,
1415 PassiveSpacing ,
1516 SurfaceRefinement ,
1617)
3536 Union [
3637 SurfaceEdgeRefinement ,
3738 SurfaceRefinement ,
39+ GeometryRefinement ,
3840 BoundaryLayer ,
3941 PassiveSpacing ,
4042 UniformRefinement ,
@@ -70,7 +72,8 @@ class MeshingDefaults(Flow360BaseModel):
7072 geometry_accuracy : Optional [LengthType .Positive ] = pd .Field (
7173 None ,
7274 description = "The smallest length scale that will be resolved accurately by the surface meshing process. "
73- "This parameter is only valid when using geometry AI." ,
75+ "This parameter is only valid when using geometry AI."
76+ "It can be overridden with class: ~flow360.GeometryRefinement." ,
7477 )
7578
7679 ##:: Default surface edge settings
@@ -105,7 +108,7 @@ class MeshingDefaults(Flow360BaseModel):
105108 " This is only supported by the beta mesher and can not be overridden per face." ,
106109 )
107110
108- planar_face_tolerance : pd .NonNegativeFloat = pd .Field (
111+ planar_face_tolerance : Optional [ pd .NonNegativeFloat ] = pd .Field (
109112 DEFAULT_PLANAR_FACE_TOLERANCE ,
110113 description = "Tolerance used for detecting planar faces in the input surface mesh / geometry"
111114 " that need to be remeshed, such as symmetry planes."
@@ -121,7 +124,21 @@ class MeshingDefaults(Flow360BaseModel):
121124 " This can be overridden with :class:`~flow360.SurfaceRefinement`." ,
122125 context = SURFACE_MESH ,
123126 )
124- curvature_resolution_angle : AngleType .Positive = ContextField (
127+
128+ surface_max_aspect_ratio : Optional [pd .PositiveFloat ] = ConditionalField (
129+ 10.0 ,
130+ description = "Maximum aspect ratio for surface cells for the GAI surface mesher."
131+ " This cannot be overridden per face" ,
132+ context = SURFACE_MESH ,
133+ )
134+
135+ surface_max_adaptation_iterations : Optional [pd .NonNegativeInt ] = ConditionalField (
136+ 50 ,
137+ description = "Maximum adaptation iterations for the GAI surface mesher." ,
138+ context = SURFACE_MESH ,
139+ )
140+
141+ curvature_resolution_angle : Optional [AngleType .Positive ] = ContextField (
125142 12 * u .deg ,
126143 description = (
127144 "Default maximum angular deviation in degrees. This value will restrict:"
@@ -161,6 +178,24 @@ def invalid_geometry_accuracy(cls, value):
161178 raise ValueError ("Geometry accuracy is required when geometry AI is used." )
162179 return value
163180
181+ @pd .field_validator (
182+ "surface_max_aspect_ratio" , "surface_max_adaptation_iterations" , mode = "after"
183+ )
184+ @classmethod
185+ def invalid_geometry_ai_features (cls , value , info ):
186+ """Ensure surface max aspect ratio is not specified when GAI is not used"""
187+ validation_info = get_validation_info ()
188+
189+ if validation_info is None :
190+ return value
191+
192+ # pylint: disable=unsubscriptable-object
193+ default_value = cls .model_fields [info .field_name ].default
194+ if value != default_value and not validation_info .use_geometry_AI :
195+ raise ValueError (f"{ info .field_name } is only supported when geometry AI is used." )
196+
197+ return value
198+
164199
165200class MeshingParams (Flow360BaseModel ):
166201 """
@@ -200,6 +235,7 @@ class MeshingParams(Flow360BaseModel):
200235 + "and first layer thickness will be adjusted to generate `r`-times"
201236 + " finer mesh where r is the refinement_factor value." ,
202237 )
238+
203239 gap_treatment_strength : Optional [float ] = ContextField (
204240 default = 0 ,
205241 ge = 0 ,
0 commit comments