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