Skip to content
Open
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: 16 additions & 0 deletions flow360/component/simulation/meshing_param/snappy/snappy_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ class QualityMetrics(Flow360BaseModel):
le=1,
description="Error reduction factor. Used in combination with n_smooth_scale. Must be between 0 and 1.",
)
zmetric_threshold: Union[pd.NonNegativeFloat, Literal[False]] = pd.Field(
alias="zfactor_threshold",
default=0.8,
le=2,
description=(
"Threshold for z-factor limiting during mesh quality checks and smoothing. "
"Set to False to disable this metric."
),
)
feature_edge_deduplication_tolerance: Union[pd.NonNegativeFloat, Literal[False]] = pd.Field(
default=0.2,
description=(
"Relative tolerance to deduplicate feature edges when snapping and smoothing. "
"Set to False to disable this metric."
),
)
min_volume_collapse_ratio: Union[float, Literal[False]] = pd.Field(
default=0,
alias="min_vol_collapse_ratio",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,16 @@ def snappy_mesher_json(input_params: SimulationParams):
"errorReduction": (
quality_settings.error_reduction if quality_settings.error_reduction else 0
),
"zMetricThreshold": (
0
if quality_settings.zmetric_threshold is False
else quality_settings.zmetric_threshold
),
"featureEdgeDeduplicationTolerance": (
0
if quality_settings.feature_edge_deduplication_tolerance is False
else quality_settings.feature_edge_deduplication_tolerance
),
"minVolCollapseRatio": (
quality_settings.min_volume_collapse_ratio
if quality_settings.min_volume_collapse_ratio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,18 @@ def test_snappy_quality_metrics_validation():
with SI_unit_system, pytest.raises(pd.ValidationError):
snappy.QualityMetrics(max_internal_skewness=-2 * u.deg)

snappy.QualityMetrics(max_boundary_skewness=23 * u.deg, max_internal_skewness=89 * u.deg)
snappy.QualityMetrics(
max_boundary_skewness=23 * u.deg,
max_internal_skewness=89 * u.deg,
zmetric_threshold=0.9,
feature_edge_deduplication_tolerance=0.1,
)
with pytest.raises(pd.ValidationError):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add "free" lines that will not throw an error to ensure normal usage is fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in 0503aca

snappy.QualityMetrics(zmetric_threshold=-0.1)
with pytest.raises(pd.ValidationError):
snappy.QualityMetrics(feature_edge_deduplication_tolerance=-0.1)

snappy.QualityMetrics(zmetric_threshold=False, feature_edge_deduplication_tolerance=False)


def test_modular_workflow_zones_validation():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
"minTriangleTwist": -1,
"nSmoothScale": 4,
"errorReduction": 0.75,
"zMetricThreshold": 0.8,
"featureEdgeDeduplicationTolerance": 0.2,
"minVolCollapseRatio": 0
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"minTriangleTwist": -1,
"nSmoothScale": 4,
"errorReduction": 0.75,
"zMetricThreshold": 0.8,
"featureEdgeDeduplicationTolerance": 0.2,
"minVolCollapseRatio": 0
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
"minTriangleTwist": -1,
"nSmoothScale": 4,
"errorReduction": 0.75,
"zMetricThreshold": 0.8,
"featureEdgeDeduplicationTolerance": 0.2,
"minVolCollapseRatio": 0
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
"minTriangleTwist": -1,
"nSmoothScale": 4,
"errorReduction": 0.75,
"zMetricThreshold": 0.8,
"featureEdgeDeduplicationTolerance": 0.2,
"minVolCollapseRatio": 0
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
"minTriangleTwist": -1,
"nSmoothScale": 4,
"errorReduction": 0.75,
"zMetricThreshold": 0.8,
"featureEdgeDeduplicationTolerance": 0.2,
"minVolCollapseRatio": 0
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
"minTriangleTwist": 0.1,
"nSmoothScale": 6,
"errorReduction": 0.4,
"zMetricThreshold": 0.9,
"featureEdgeDeduplicationTolerance": 0.25,
"minVolCollapseRatio": 0.5
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
"minTriangleTwist": -1,
"nSmoothScale": 4,
"errorReduction": 0.75,
"zMetricThreshold": 0,
"featureEdgeDeduplicationTolerance": 0,
"minVolCollapseRatio": 0
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,8 @@ def snappy_settings():
min_triangle_twist=0.1,
n_smooth_scale=6,
error_reduction=0.4,
zmetric_threshold=0.9,
feature_edge_deduplication_tolerance=0.25,
min_volume_collapse_ratio=0.5,
),
snap_controls=snappy.SnapControls(
Expand Down Expand Up @@ -937,6 +939,8 @@ def snappy_settings_off_position():
min_vol_ratio=False,
min_face_weight=False,
min_triangle_twist=False,
zmetric_threshold=False,
feature_edge_deduplication_tolerance=False,
min_vol_collapse_ratio=False,
),
snap_controls=snappy.SnapControls(
Expand Down
Loading