|
7 | 7 |
|
8 | 8 | import flow360.component.simulation.units as u |
9 | 9 | from flow360.component.simulation.entity_info import ( |
| 10 | + GeometryEntityInfo, |
10 | 11 | SurfaceMeshEntityInfo, |
11 | 12 | VolumeMeshEntityInfo, |
12 | 13 | ) |
@@ -1843,6 +1844,7 @@ def test_beta_mesher_only_features(): |
1843 | 1844 |
|
1844 | 1845 |
|
1845 | 1846 | def test_geometry_AI_only_features(): |
| 1847 | + # * Test GAI guardrails |
1846 | 1848 | with SI_unit_system: |
1847 | 1849 | params = SimulationParams( |
1848 | 1850 | meshing=MeshingParams( |
@@ -1903,6 +1905,61 @@ def test_geometry_AI_only_features(): |
1903 | 1905 | errors[0]["msg"] == "Value error, Geometry accuracy is required when geometry AI is used." |
1904 | 1906 | ) |
1905 | 1907 |
|
| 1908 | + # * Test geometry_accuracy and planar_face_tolerance compatibility |
| 1909 | + with SI_unit_system: |
| 1910 | + params_original = SimulationParams( |
| 1911 | + meshing=MeshingParams( |
| 1912 | + defaults=MeshingDefaults( |
| 1913 | + geometry_accuracy=1e-5 * u.m, |
| 1914 | + planar_face_tolerance=1e-10, |
| 1915 | + boundary_layer_first_layer_thickness=10, |
| 1916 | + surface_max_edge_length=1e-2, |
| 1917 | + ), |
| 1918 | + ), |
| 1919 | + private_attribute_asset_cache=AssetCache( |
| 1920 | + project_length_unit=1 * u.cm, |
| 1921 | + use_inhouse_mesher=True, |
| 1922 | + use_geometry_AI=True, |
| 1923 | + project_entity_info=GeometryEntityInfo( |
| 1924 | + global_bounding_box=[[-100, -100, -100], [100, 1e-12, 100]], |
| 1925 | + ), |
| 1926 | + ), |
| 1927 | + ) |
| 1928 | + params, errors, _ = validate_model( |
| 1929 | + params_as_dict=params_original.model_dump(mode="json"), |
| 1930 | + validated_by=ValidationCalledBy.LOCAL, |
| 1931 | + root_item_type="Geometry", |
| 1932 | + validation_level="VolumeMesh", |
| 1933 | + ) |
| 1934 | + assert len(errors) == 1 |
| 1935 | + # Largest dim = 200 cm |
| 1936 | + # with planar face tolerance = 1e-10 |
| 1937 | + # largest geometry accuracy = 1e-10 * 200 cm = 2e-8 cm |
| 1938 | + # with geometry accuracy = 1e-5m |
| 1939 | + # minimum planar face tolerance = 1e-5m / 200 cm = 5e-06 |
| 1940 | + assert errors[0]["msg"] == ( |
| 1941 | + "Value error, geometry_accuracy is too large for the planar_face_tolerance to take effect. " |
| 1942 | + "Reduce geometry_accuracy to at most 2e-08 cm or increase the planar_face_tolerance to at least 5e-06." |
| 1943 | + ) |
| 1944 | + params_original.meshing.defaults.geometry_accuracy = 2e-08 * u.cm |
| 1945 | + params, _, _ = validate_model( |
| 1946 | + params_as_dict=params_original.model_dump(mode="json"), |
| 1947 | + validated_by=ValidationCalledBy.LOCAL, |
| 1948 | + root_item_type="Geometry", |
| 1949 | + validation_level="VolumeMesh", |
| 1950 | + ) |
| 1951 | + assert params |
| 1952 | + |
| 1953 | + params_original.meshing.defaults.geometry_accuracy = 1e-5 * u.m |
| 1954 | + params_original.meshing.defaults.planar_face_tolerance = 5e-06 |
| 1955 | + params, _, _ = validate_model( |
| 1956 | + params_as_dict=params_original.model_dump(mode="json"), |
| 1957 | + validated_by=ValidationCalledBy.LOCAL, |
| 1958 | + root_item_type="Geometry", |
| 1959 | + validation_level="VolumeMesh", |
| 1960 | + ) |
| 1961 | + assert params |
| 1962 | + |
1906 | 1963 |
|
1907 | 1964 | def test_redefined_user_defined_fields(): |
1908 | 1965 |
|
|
0 commit comments