]> SALOME platform Git repositories - modules/hexablock.git/blob - src/TEST_PY/test_unit/tuyau_v5.py
Salome HOME
Merge from V6_main 01/04/2013
[modules/hexablock.git] / src / TEST_PY / test_unit / tuyau_v5.py
1 # -*- coding: latin-1 -*-
2 # Copyright (C) 2009-2013  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.
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 # Francis KLOSS : 2012 : CEA-Saclay, DEN, DM2S, SFME, LGLS, F-91191 Gif-sur-Yvette, France
22 # ========================================================================================
23
24 import geompy
25 import hexablock
26
27 # Charger la geometrie
28 # ====================
29
30 nom = "tuyau"
31
32 geometrie = geompy.ImportBREP(nom+".brep")
33
34 # Selectionner des sous-parties de la geometrie
35 # ---------------------------------------------
36
37 aretes  = geompy.SubShapeAllSortedCentres    (geometrie, geompy.ShapeType["EDGE"])
38 edge_id = geompy.SubShapeAllSortedCentresIDs (geometrie, geompy.ShapeType["EDGE"])
39 faces   = geompy.SubShapeAllSortedCentres    (geometrie, geompy.ShapeType["FACE"])
40 face_id = geompy.SubShapeAllSortedCentresIDs (geometrie, geompy.ShapeType["FACE"])
41
42 subid_arc_int_bas  = 30
43 subid_arc_int_haut = 34
44 subid_arc_ext_bas  = 12
45 subid_arc_ext_haut = 16
46
47 arc_int_bas  = aretes[12]
48 arc_int_haut = aretes[13]
49 arc_ext_bas  = aretes[11]
50 arc_ext_haut = aretes[14]
51
52 subid_ell_int_bas  = 21
53 subid_ell_int_haut = 33
54 subid_ell_ext_bas  =  8
55 subid_ell_ext_haut = 15
56
57 ell_int_bas  = aretes[2]
58 ell_int_haut = aretes[3]
59 ell_ext_bas  = aretes[1]
60 ell_ext_haut = aretes[4]
61
62 subid_gen_int_avan = 26
63 subid_gen_int_arri = 28
64 subid_gen_ext_avan =  5
65 subid_gen_ext_arri = 10
66
67 gen_int_avan = aretes[8]
68 gen_int_arri = aretes[7]
69 gen_ext_avan = aretes[9]
70 gen_ext_arri = aretes[6]
71
72 subid_face_int_bas  = 24
73 subid_face_int_haut = 31
74 subid_face_ext_bas  =  3
75 subid_face_ext_haut = 13
76
77 face_int_bas  = faces[4]
78 face_int_haut = faces[5]
79 face_ext_bas  = faces[2]
80 face_ext_haut = faces[3]
81
82 # Construire le modele de bloc
83 # ============================
84
85 doc = hexablock.addDocument(nom)
86
87 # Definir le tuyau
88 # ----------------
89
90 base = doc.addVertex(0, 0, 0)
91
92 direction = doc.addVector(1, 0, 0)
93
94 tuyau = doc.addPipe(base, direction, 1, 2, 10)
95
96 # Construire le modele de blocs du tuyau
97 # --------------------------------------
98
99 depart = doc.addVector(0, 1, 0)
100
101 modele = doc.makePipe(tuyau, depart, 1, 4, 1)
102
103 # Associer le modele de bloc a la geometrie
104 # =========================================
105
106 sh_tuyau = doc.addShape(geometrie,nom)
107 doc.clearAssociation()
108
109 # Associer les cercles
110 # --------------------
111
112 cer_int_dep = modele.getVertexIJK(0, 0, 1)
113 cer_ext_dep = modele.getVertexIJK(1, 0, 1)
114
115 cer_int = []
116 cer_ext = []
117 for j in xrange(4):
118     a = modele.getEdgeJ(0, j, 1)
119     cer_int.append(a)
120
121     a = modele.getEdgeJ(1, j, 1)
122     cer_ext.append(a)
123
124 doc.associateClosedLine(cer_int_dep, cer_int, [sh_tuyau], [34,30], 1, True)
125 doc.associateClosedLine(cer_ext_dep, cer_ext, [sh_tuyau], [16,12], 1, True)
126
127 # Associer les ellipses
128 # ---------------------
129
130 ell_int_dep = modele.getVertexIJK(0, 0, 0)
131 ell_ext_dep = modele.getVertexIJK(1, 0, 0)
132
133 ell_int = []
134 ell_ext = []
135 for j in xrange(4):
136     a = modele.getEdgeJ(0, j, 0)
137     ell_int.append(a)
138
139     a = modele.getEdgeJ(1, j, 0)
140     ell_ext.append(a)
141
142 doc.associateClosedLine(ell_int_dep, ell_int, [sh_tuyau], [33,21], 1, True)
143 doc.associateClosedLine(ell_ext_dep, ell_ext, [sh_tuyau], [15, 8], 1, True)
144
145 # Associer les generatrices
146 # -------------------------
147
148 def generatrice(face):
149     n = 10
150     l = []
151     for i in xrange(0, n+1):
152         v = float(i) / n
153         s = geompy.MakeVertexOnSurface(face, 0.5, v)
154         l.append(s)
155
156     return geompy.MakeInterpol(l)
157
158 gen = []
159 gen_int_haut = generatrice(face_int_haut)
160 gen_ext_haut = generatrice(face_ext_haut)
161 gen_int_bas  = generatrice(face_int_bas )
162 gen_ext_bas  = generatrice(face_ext_bas )
163 gen.append(gen_int_haut)
164 gen.append(gen_ext_haut)
165 gen.append(gen_int_bas)
166 gen.append(gen_ext_bas)
167
168 generatrices = geompy.MakeCompound(gen)
169 sh_gen = doc.addShape(generatrices,"generatrices")
170
171 modele.getEdgeK(0, 0, 0).addAssociation(sh_tuyau, 28, 0, 1)
172 modele.getEdgeK(1, 0, 0).addAssociation(sh_tuyau, 10, 0, 1)
173
174 modele.getEdgeK(0, 1, 0).addAssociation(sh_gen  ,  2, 0, 1)
175 modele.getEdgeK(1, 1, 0).addAssociation(sh_gen  ,  5, 0, 1)
176
177 modele.getEdgeK(0, 2, 0).addAssociation(sh_tuyau, 26, 0, 1)
178 modele.getEdgeK(1, 2, 0).addAssociation(sh_tuyau,  5, 0, 1)
179
180 modele.getEdgeK(0, 3, 0).addAssociation(sh_gen  ,  8, 0, 1)
181 modele.getEdgeK(1, 3, 0).addAssociation(sh_gen  , 11, 0, 1)
182
183 # Associer les faces courbees
184 # ---------------------------
185
186 modele.getQuadJK(0, 0, 0).addAssociation(sh_tuyau, 31)
187 modele.getQuadJK(0, 1, 0).addAssociation(sh_tuyau, 31)
188 modele.getQuadJK(0, 2, 0).addAssociation(sh_tuyau, 24)
189 modele.getQuadJK(0, 3, 0).addAssociation(sh_tuyau, 24)
190
191 modele.getQuadJK(1, 0, 0).addAssociation(sh_tuyau, 13)
192 modele.getQuadJK(1, 1, 0).addAssociation(sh_tuyau, 13)
193 modele.getQuadJK(1, 2, 0).addAssociation(sh_tuyau,  3)
194 modele.getQuadJK(1, 3, 0).addAssociation(sh_tuyau,  3)
195
196 # Mailler le modele de bloc
197 # =========================
198
199 # Definir 3 groupes d'aretes
200 # --------------------------
201
202 groupe_cercles      = doc.addEdgeGroup("Cercles")
203 groupe_ellipses     = doc.addEdgeGroup("Ellipses")
204 groupe_generatrices = doc.addEdgeGroup("Generatrices")
205
206 # Definir 4 groupes de faces
207 # --------------------------
208
209 groupe_couronne  = doc.addQuadGroup("Couronne")
210 groupe_ovale     = doc.addQuadGroup("Ovale")
211 groupe_interieur = doc.addQuadGroup("Interieur")
212 groupe_exterieur = doc.addQuadGroup("Exterieur")
213
214 # Constituer les groupes d'aretes
215 # -------------------------------
216
217 for i in xrange(2):
218     for j in xrange(4):
219         arete = modele.getEdgeJ(i, j, 1)
220         groupe_cercles.addElement(arete)
221
222         arete = modele.getEdgeJ(i, j, 0)
223         groupe_ellipses.addElement(arete)
224
225         arete = modele.getEdgeK(i, j, 0)
226         groupe_generatrices.addElement(arete)
227
228 # Constituer les groupes de faces
229 # -------------------------------
230
231 for j in xrange(4):
232     quad = modele.getQuadIJ(0, j, 1)
233     groupe_couronne.addElement(quad)
234
235     quad = modele.getQuadIJ(0, j, 0)
236     groupe_ovale.addElement(quad)
237
238     quad = modele.getQuadJK(0, j, 0)
239     groupe_interieur.addElement(quad)
240
241     quad = modele.getQuadJK(1, j, 0)
242     groupe_exterieur.addElement(quad)
243
244 # Mailler le modele de bloc avec ses associations
245 # -----------------------------------------------
246
247 ##########  hexablock.addLaws(doc, 0.7, True) Ne marche pas
248
249 law = doc.addLaw("Uniform", 4)
250 for j in range(doc.countPropagation()):
251     propa = doc.getPropagation(j)
252     propa.setLaw(law)
253
254 doc.save("tuyau_v5")
255 doc.setName("tuyau_v5")
256 hexablock.addToStudy(doc)
257
258 blocs = hexablock.mesh(doc)
259
260 muv, mue, muq, muh = hexablock.dump(doc, blocs)