Salome HOME
Merge from V6_main 01/04/2013
[modules/hexablock.git] / src / TEST_PY / test_unit / test_double_t.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 # Hexa : Creation d'hexaedres 
22
23 import hexablock
24 import os
25 import geompy
26
27 #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
28
29
30 # ======================================================= test_double_t
31 def test_double_t () :
32
33     doc  = hexablock.addDocument ("default")
34
35     ori1 = doc.addVertex ( 0, 0, 0)
36     ori2 = doc.addVertex (-5, 0, 5)
37     ori3 = doc.addVertex ( 0, 0, 12)
38     ori4 = doc.addVertex (-5, 0, 17)
39
40     vx   = doc.addVector ( 1 ,0, 0)
41     vz   = doc.addVector ( 0, 0, 1)
42
43     nl1 = 10
44     nl2 = 10
45
46     rsmall = 1
47     rmoy   = 2
48     rbig   = 3
49
50     cyl1  = doc.addCylinder (ori1, vz, rbig, nl1)
51     cyl2  = doc.addCylinder (ori2, vx, rmoy, nl2)
52
53     cyl3  = doc.addCylinder (ori3, vz, rbig, nl1)
54     cyl4  = doc.addCylinder (ori4, vx, rmoy, nl2)
55
56     grid1 = doc.makeCylinders (cyl1, cyl2)
57     grid2 = doc.makeCylinders (cyl4, cyl3)
58
59     nx_int = 0
60     nx_ext = 1
61     cyl_big   = 1
62     cyl_small = 0
63     S_E     = 0
64     S_NE    = 1
65     S_N     = 2
66     S_NW    = 3
67     S_MAXI  = 8
68                   ##    Cyl       i     j     k
69     qb = grid1. getQuadIJ (cyl_big, nx_ext, S_E, 4)
70     qh = grid2. getQuadIJ (cyl_big, nx_ext, S_E, 0) 
71
72     vb0 = grid1.getVertexIJK (cyl_big, 2, S_E,  4)  ## cible
73     vb1 = grid1.getVertexIJK (cyl_big, 2, S_NE, 4)
74     vh0 = grid2.getVertexIJK (cyl_big, 2, S_E,  0)   ## depart
75     vh1 = grid2.getVertexIJK (cyl_big, 2, S_NE, 0)
76
77     hliste = []
78
79     hliste.append (qh)
80     for ny in range (S_MAXI) :
81         if ny != S_E :
82           hliste.append (grid2.getQuadIJ (cyl_big, nx_ext, ny, 0)) 
83
84     for ny in range (4) :
85         hliste.append (grid2.getQuadIJ (cyl_big, nx_int, ny, 0)) 
86
87     hauteur = 3
88     doc.joinQuads  (hliste, qb, vh0, vb0, vh1, vb1, hauteur)
89
90     doc.saveVtk ("double_t.vtk")
91     return doc
92
93 # ======================================================= test_lorraine
94 def test_lorraine () :
95
96     doc  = hexablock.addDocument ("default")
97
98     ori1 = doc.addVertex ( 0, 0, 0)
99     ori2 = doc.addVertex (-5, 0, 5)
100     ori3 = doc.addVertex ( 0, 0, 12)
101     ori4 = doc.addVertex (-5, 0, 17)
102
103     vx   = doc.addVector ( 1 ,0, 0)
104     vz   = doc.addVector ( 0, 0, 1)
105
106     nl1 = 10
107     nl2 = 10
108
109     rsmall = 1
110     rmoy   = 3
111     rbig   = 4
112
113     cyl1  = doc.addCylinder (ori1, vz, rmoy,   nl1)
114     cyl2  = doc.addCylinder (ori2, vx, rsmall, nl2)
115
116     cyl3  = doc.addCylinder (ori3, vz, rmoy, nl1)
117     cyl4  = doc.addCylinder (ori4, vx, rbig, nl2)
118
119     grid1 = doc.makeCylinders (cyl1, cyl2)
120     grid2 = doc.makeCylinders (cyl4, cyl3)
121
122     nx_int = 0
123     nx_ext = 1
124     cyl_big   = 1
125     cyl_small = 0
126     S_E     = 0
127     S_NE    = 1
128     S_N     = 2
129     S_NW    = 3
130     S_MAXI  = 8
131                   ##    Cyl       i     j     k
132     qb = grid1. getQuadIJ (cyl_big,   nx_ext, S_E, 4)
133     qh = grid2. getQuadIJ (cyl_small, nx_ext, S_N, 0) 
134
135     vb0 = grid1.getVertexIJK (cyl_big,   2, S_E,  4)  ## cible
136     vb1 = grid1.getVertexIJK (cyl_big,   2, S_NE, 4)
137     vh0 = grid2.getVertexIJK (cyl_small, 2, S_N,  0)   ## depart
138     vh1 = grid2.getVertexIJK (cyl_small, 2, S_NW, 0)
139
140     hliste = []
141
142     hliste.append (qh)
143     for ny in range (S_MAXI) :
144         if ny != S_N :
145           hliste.append (grid2.getQuadIJ (cyl_small, nx_ext, ny, 0)) 
146
147     for ny in range (4) :
148         hliste.append (grid2.getQuadIJ (cyl_small, nx_int, ny, 0)) 
149
150     hauteur = 3
151     doc.joinQuads  (hliste, qb, vh0, vb0, vh1, vb1, hauteur)
152
153     doc.saveVtk ("lorraine.vtk")
154     return doc
155
156 # ================================================================= Begin
157
158 doc = test_double_t  ()
159
160 law = doc.addLaw("Uniform", 4)
161
162 for j in range(doc.countPropagation()):
163     propa = doc.getPropagation(j)
164     propa.setLaw(law) 
165
166 mesh_hexas = hexablock.mesh(doc, "maillage:hexas")