Salome HOME
Change the shape to better illustrate anisotropy with quadrangles (check that gradati...
[plugins/blsurfplugin.git] / tests / quadrangles_gradation.py
1 # -*- coding: utf-8 -*-
2
3
4 import sys
5 import salome
6
7 salome.salome_init()
8 theStudy = salome.myStudy
9
10 ###
11 ### GEOM component
12 ###
13
14 import GEOM
15 from salome.geom import geomBuilder
16 import math
17 import SALOMEDS
18
19
20 geompy = geomBuilder.New(theStudy)
21
22 h = 5
23
24 O = geompy.MakeVertex(0, 0, 0)
25 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
26 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
27 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
28 Cylinder_1 = geompy.MakeCylinderRH(1, h)
29 Sphere_1 = geompy.MakeSphereR(1.5)
30 Translation_1 = geompy.MakeTranslation(Sphere_1, 0, 0, h)
31 Fuse_1 = geompy.MakeFuseList([Cylinder_1, Sphere_1, Translation_1], False, True)
32 geompy.addToStudy( O, 'O' )
33 geompy.addToStudy( OX, 'OX' )
34 geompy.addToStudy( OY, 'OY' )
35 geompy.addToStudy( OZ, 'OZ' )
36 geompy.addToStudy( Cylinder_1, 'Cylinder_1' )
37 geompy.addToStudy( Sphere_1, 'Sphere_1' )
38 geompy.addToStudy( Translation_1, 'Translation_1' )
39 geompy.addToStudy( Fuse_1, 'Fuse_1' )
40
41 ###
42 ### SMESH component
43 ###
44
45 import  SMESH, SALOMEDS
46 from salome.smesh import smeshBuilder
47
48 from salome.BLSURFPlugin import BLSURFPluginBuilder
49
50 smesh = smeshBuilder.New(theStudy)
51
52 # First mesh with quadrangle-dominant gradation
53 Mesh_1 = smesh.Mesh(Fuse_1, "Mesh_1")
54 MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
55 MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
56 MG_CADSurf_Parameters_1.SetElementType( BLSURFPluginBuilder.QuadrangleDominant )
57 MG_CADSurf_Parameters_1.SetPhySize( 1 )
58 MG_CADSurf_Parameters_1.SetMaxSize( 1 )
59 MG_CADSurf_Parameters_1.SetGradation( 1.05 )
60 MG_CADSurf_Parameters_1.SetAngleMesh( 4 )
61 isDone = Mesh_1.Compute()
62
63 min_1, max_1 = Mesh_1.GetMinMax(SMESH.FT_Area)
64
65 # Check that min and max areas are not too far
66 assert max_1/min_1 < 6
67
68 # Second mesh with anisotropy (which disable gradation)
69 Mesh_2 = smesh.Mesh(Fuse_1, "Mesh_2")
70 MG_CADSurf = Mesh_2.Triangle(algo=smeshBuilder.MG_CADSurf)
71 MG_CADSurf_Parameters_2 = MG_CADSurf.Parameters()
72 MG_CADSurf_Parameters_2.SetElementType( BLSURFPluginBuilder.QuadrangleDominant )
73 MG_CADSurf_Parameters_2.SetPhySize( 1 )
74 MG_CADSurf_Parameters_2.SetMaxSize( 1 )
75 MG_CADSurf_Parameters_2.SetGradation( 1.05 )
76 MG_CADSurf_Parameters_2.SetAngleMesh( 4 )
77 MG_CADSurf_Parameters_2.SetAnisotropic( True )
78 isDone = Mesh_2.Compute()
79
80 min_2, max_2 = Mesh_2.GetMinMax(SMESH.FT_Area)
81
82 # Check that min and max ration increase with anisotropy
83 assert max_2/min_2 > 20
84
85 if salome.sg.hasDesktop():
86   salome.sg.updateObjBrowser(True)