Salome HOME
Rename tests without test_ prefix
[plugins/hybridplugin.git] / tests / advanced_text_option.py
1 # -*- coding: utf-8 -*-
2
3 import sys
4 import salome
5
6 salome.salome_init()
7 theStudy = salome.myStudy
8
9 ###
10 ### GEOM component
11 ###
12
13 import GEOM
14 from salome.geom import geomBuilder
15 import math
16 import SALOMEDS
17
18
19 geompy = geomBuilder.New(theStudy)
20
21 O = geompy.MakeVertex(0, 0, 0)
22 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
23 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
24 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
25 O_1 = geompy.MakeVertex(0, 0, 0)
26 OX_1 = geompy.MakeVectorDXDYDZ(1, 0, 0)
27 OY_1 = geompy.MakeVectorDXDYDZ(0, 1, 0)
28 OZ_1 = geompy.MakeVectorDXDYDZ(0, 0, 1)
29 Cylinder_1 = geompy.MakeCylinderRH(0.5, 5)
30 Cylinder_2 = geompy.MakeCylinderRH(0.3, 3)
31 Rotation_1 = geompy.MakeRotation(Cylinder_2, OY_1, -90*math.pi/180.0)
32 Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, 1.5)
33 piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True)
34 [Outlet] = geompy.SubShapes(piquage, [15])
35 [Inlet_z,Inlet_x] = geompy.SubShapes(piquage, [3, 22])
36 [corner] = geompy.SubShapes(piquage, [14])
37 [geomObj_1] = geompy.SubShapeAll(Outlet, geompy.ShapeType["FACE"])
38 [geomObj_2] = geompy.SubShapeAll(Inlet_z, geompy.ShapeType["FACE"])
39 [geomObj_3] = geompy.SubShapeAll(Inlet_x, geompy.ShapeType["FACE"])
40 geomObj_4 = geompy.MakeVertex(0, 0, 0)
41 geomObj_5 = geompy.MakeVectorDXDYDZ(1, 0, 0)
42 geomObj_6 = geompy.MakeVectorDXDYDZ(0, 1, 0)
43 geomObj_7 = geompy.MakeVectorDXDYDZ(0, 0, 1)
44 Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"])
45 geompy.UnionIDs(Wall, [7, 17])
46 [geomObj_8,geomObj_9] = geompy.SubShapeAll(Wall, geompy.ShapeType["SHAPE"])
47 [geomObj_10,geomObj_11] = geompy.SubShapeAll(Wall, geompy.ShapeType["SHAPE"])
48 [geomObj_12,geomObj_13] = geompy.SubShapeAll(Wall, geompy.ShapeType["FACE"])
49 [geomObj_14,geomObj_15] = geompy.SubShapeAll(Wall, geompy.ShapeType["SHAPE"])
50 geompy.addToStudy( O, 'O' )
51 geompy.addToStudy( OX, 'OX' )
52 geompy.addToStudy( OY, 'OY' )
53 geompy.addToStudy( OZ, 'OZ' )
54 geompy.addToStudy( O_1, 'O' )
55 geompy.addToStudy( OX_1, 'OX' )
56 geompy.addToStudy( OY_1, 'OY' )
57 geompy.addToStudy( OZ_1, 'OZ' )
58 geompy.addToStudy( Cylinder_1, 'Cylinder_1' )
59 geompy.addToStudy( Cylinder_2, 'Cylinder_2' )
60 geompy.addToStudy( Rotation_1, 'Rotation_1' )
61 geompy.addToStudy( Translation_1, 'Translation_1' )
62 geompy.addToStudy( piquage, 'piquage' )
63 geompy.addToStudyInFather( piquage, Outlet, 'Outlet' )
64 geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' )
65 geompy.addToStudyInFather( piquage, Inlet_x, 'Inlet_x' )
66 geompy.addToStudyInFather( piquage, corner, 'corner' )
67 geompy.addToStudyInFather( piquage, Wall, 'Wall' )
68
69 ###
70 ### SMESH component
71 ###
72
73 import  SMESH, SALOMEDS
74 from salome.smesh import smeshBuilder
75
76 smesh = smeshBuilder.New(theStudy)
77
78 Mesh_with_imprinting_set_by_groups = smesh.Mesh(piquage)
79 NETGEN_2D_1 = Mesh_with_imprinting_set_by_groups.Triangle(algo=smeshBuilder.NETGEN_1D2D)
80 NETGEN_Parameters_2D = NETGEN_2D_1.Parameters()
81 NETGEN_Parameters_2D.SetMinSize( 0.01 )
82 NETGEN_Parameters_2D.SetLocalSizeOnShape(corner, 0.01)
83 NETGEN_Parameters_2D.SetFineness( 5 )
84 NETGEN_Parameters_2D.SetGrowthRate( 0.1 )
85 NETGEN_Parameters_2D.SetNbSegPerEdge( 2 )
86 NETGEN_Parameters_2D.SetNbSegPerRadius( 3 )
87 #Mesh_with_imprinting_set_by_groups.Triangle(algo=smeshBuilder.MG_CADSurf)
88 HYBRID_3D_2_2 = Mesh_with_imprinting_set_by_groups.Tetrahedron(algo=smeshBuilder.HYBRID)
89 HYBRID_Parameters_2 = HYBRID_3D_2_2.Parameters()
90 HYBRID_Parameters_2.SetElementGeneration( 0 )
91 HYBRID_Parameters_2.SetHeightFirstLayer( 0.01 )
92 HYBRID_Parameters_2.SetBoundaryLayersProgression( 1.1 )
93 HYBRID_Parameters_2.SetNbOfBoundaryLayers( 3 )
94 HYBRID_Parameters_2.SetFacesWithLayers( [ 7, 17 ] )
95 HYBRID_Parameters_2.SetFacesWithImprinting( [ 22, 3, 15 ] )
96 HYBRID_Parameters_2.SetLayersOnAllWrap( 0 )
97 isDone = Mesh_with_imprinting_set_by_groups.Compute()
98
99 if not isDone:
100   raise Exception("Problem in mesh generation")
101
102 Nb_elems_0 = Mesh_with_imprinting_set_by_groups.NbVolumes()
103
104 print "Nb_elems_0: ", Nb_elems_0
105
106 Inlet_x_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Inlet_x,'Inlet_x',SMESH.FACE)
107 Inlet_z_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Inlet_z,'Inlet_z',SMESH.FACE)
108 Outlet_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Outlet,'Outlet',SMESH.FACE)
109 Wall_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Wall,'Wall',SMESH.FACE)
110
111 # Add an advanced option as text
112 HYBRID_Parameters_2.SetAdvancedOption( '--boundary_layer_height_relative_to_local_surface_size yes' )
113 isDone = Mesh_with_imprinting_set_by_groups.Compute()
114
115 if not isDone:
116   raise Exception("Problem in mesh generation")
117
118 Nb_elems_1 = Mesh_with_imprinting_set_by_groups.NbVolumes()
119
120 print "Nb_elems_1: ", Nb_elems_1
121
122 # Check that the number of elements is changed by the option
123 assert Nb_elems_1> 1.5*Nb_elems_0, "Advanced option as text does not work"
124
125 if salome.sg.hasDesktop():
126   salome.sg.updateObjBrowser(True)