Salome HOME
updated copyright message
[plugins/blsurfplugin.git] / tests / quadrangles_gradation.py
index dc7b1a141cf1ba0ccf599cfdf64b1a5962b60e38..759fc63389ba097365840a07927b70bad3dd06e8 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright (C) 2015-2019  CEA/DEN, EDF R&D
+# Copyright (C) 2015-2023  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -18,7 +18,9 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-
+# TA 24-04-2018 : quadrangle_gradation replaces 
+# new_1331_test_quadrangles_gradation.py as the starting geometrical part should
+# be 3D and not 2D. A 2D part does not constitute a representative case.
 import sys
 import salome
 
@@ -31,13 +33,11 @@ theStudy = salome.myStudy
 
 import GEOM
 from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
 import math
 import SALOMEDS
 
 
-geompy = geomBuilder.New(theStudy)
+geompy = geomBuilder.New()
 
 h = 5
 
@@ -83,7 +83,7 @@ isDone = Mesh_1.Compute()
 min_1, max_1 = Mesh_1.GetMinMax(SMESH.FT_Area)
 
 # Check that min and max areas are not too far
-assert max_1/min_1 < 6
+assert max_1/min_1 < 7
 
 # Second mesh with anisotropy (which disable gradation)
 Mesh_2 = smesh.Mesh(Fuse_1, "Mesh_2")
@@ -97,12 +97,27 @@ MG_CADSurf_Parameters_2.SetAngleMesh( 4 )
 MG_CADSurf_Parameters_2.SetAnisotropic( True )
 isDone = Mesh_2.Compute()
 
-min_2, max_2 = Mesh_2.GetMinMax(SMESH.FT_Area)
 
-# Check that min and max ration increase with anisotropy
-assert max_2/min_2 > 20
+errorMsg = ''
 
-if salome.sg.hasDesktop():
-  salome.sg.updateObjBrowser()
+# retrieve the 2D lengths
+length_1 = Mesh_1.GetMinMax(SMESH.FT_Length)[1]
+length_2 = Mesh_2.GetMinMax(SMESH.FT_Length)[1]
 
+# TEST: expecting the max length to be larger for Mesh_2
+if length_1 > length_2:
+  errorMsg += '\n' + ' -> Inconsistent max lengths comparison: Mesh_1 = {} Mesh_2 = {}'.format(length_1,length_2)
 
+# retrieve the max aspect ratio for the meshes
+aspectRatio_1 = Mesh_1.GetMinMax(SMESH.FT_AspectRatio)[1]
+aspectRatio_2 = Mesh_2.GetMinMax(SMESH.FT_AspectRatio)[1]
+
+# TEST: expecting the max value for the aspect ratio to be larger for Mesh_2 
+if aspectRatio_1 > aspectRatio_2:
+  errorMsg += '\n' + ' -> Inconsistent Aspect ratios comparison: Mesh_1 = {} Mesh_2 = {}'.format(aspectRatio_1,aspectRatio_2)
+
+if errorMsg != '':
+  raise RuntimeError("Aspect ratio check the isotropic option with MG-CADSURF algo. The test is KO." + errorMsg )
+
+if salome.sg.hasDesktop():
+  salome.sg.updateObjBrowser()