]> SALOME platform Git repositories - plugins/blsurfplugin.git/blob - tests/quadrangles_gradation.py
Salome HOME
dc7b1a141cf1ba0ccf599cfdf64b1a5962b60e38
[plugins/blsurfplugin.git] / tests / quadrangles_gradation.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2015-2019  CEA/DEN, EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21
22 import sys
23 import salome
24
25 salome.salome_init()
26 theStudy = salome.myStudy
27
28 ###
29 ### GEOM component
30 ###
31
32 import GEOM
33 from salome.geom import geomBuilder
34 geompy = geomBuilder.New()
35
36 import math
37 import SALOMEDS
38
39
40 geompy = geomBuilder.New(theStudy)
41
42 h = 5
43
44 O = geompy.MakeVertex(0, 0, 0)
45 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
46 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
47 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
48 Cylinder_1 = geompy.MakeCylinderRH(1, h)
49 Sphere_1 = geompy.MakeSphereR(1.5)
50 Translation_1 = geompy.MakeTranslation(Sphere_1, 0, 0, h)
51 Fuse_1 = geompy.MakeFuseList([Cylinder_1, Sphere_1, Translation_1], False, True)
52 geompy.addToStudy( O, 'O' )
53 geompy.addToStudy( OX, 'OX' )
54 geompy.addToStudy( OY, 'OY' )
55 geompy.addToStudy( OZ, 'OZ' )
56 geompy.addToStudy( Cylinder_1, 'Cylinder_1' )
57 geompy.addToStudy( Sphere_1, 'Sphere_1' )
58 geompy.addToStudy( Translation_1, 'Translation_1' )
59 geompy.addToStudy( Fuse_1, 'Fuse_1' )
60
61 ###
62 ### SMESH component
63 ###
64
65 import  SMESH, SALOMEDS
66 from salome.smesh import smeshBuilder
67
68 from salome.BLSURFPlugin import BLSURFPluginBuilder
69
70 smesh = smeshBuilder.New()
71
72 # First mesh with quadrangle-dominant gradation
73 Mesh_1 = smesh.Mesh(Fuse_1, "Mesh_1")
74 MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
75 MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
76 MG_CADSurf_Parameters_1.SetElementType( BLSURFPluginBuilder.QuadrangleDominant )
77 MG_CADSurf_Parameters_1.SetPhySize( 1 )
78 MG_CADSurf_Parameters_1.SetMaxSize( 1 )
79 MG_CADSurf_Parameters_1.SetGradation( 1.05 )
80 MG_CADSurf_Parameters_1.SetAngleMesh( 4 )
81 isDone = Mesh_1.Compute()
82
83 min_1, max_1 = Mesh_1.GetMinMax(SMESH.FT_Area)
84
85 # Check that min and max areas are not too far
86 assert max_1/min_1 < 6
87
88 # Second mesh with anisotropy (which disable gradation)
89 Mesh_2 = smesh.Mesh(Fuse_1, "Mesh_2")
90 MG_CADSurf = Mesh_2.Triangle(algo=smeshBuilder.MG_CADSurf)
91 MG_CADSurf_Parameters_2 = MG_CADSurf.Parameters()
92 MG_CADSurf_Parameters_2.SetElementType( BLSURFPluginBuilder.QuadrangleDominant )
93 MG_CADSurf_Parameters_2.SetPhySize( 1 )
94 MG_CADSurf_Parameters_2.SetMaxSize( 1 )
95 MG_CADSurf_Parameters_2.SetGradation( 1.05 )
96 MG_CADSurf_Parameters_2.SetAngleMesh( 4 )
97 MG_CADSurf_Parameters_2.SetAnisotropic( True )
98 isDone = Mesh_2.Compute()
99
100 min_2, max_2 = Mesh_2.GetMinMax(SMESH.FT_Area)
101
102 # Check that min and max ration increase with anisotropy
103 assert max_2/min_2 > 20
104
105 if salome.sg.hasDesktop():
106   salome.sg.updateObjBrowser()
107
108