Salome HOME
147618bf2afc10512326ff16dfc72088b1be12a2
[modules/hexablock.git] / src / TEST_PY / test_unit / test_cylinders.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_cylindricals
30 def test_cylindricals () :
31
32     doc  = hexablock.addDocument ("cyl:hexas")
33
34     orig = doc.addVertex (0, 0, 0)
35     vz   = doc.addVector (0, 0, 1)
36     vx   = doc.addVector (1 ,0, 0)
37
38
39     tdr = [ 1, 1, 1, 1 ]
40     tda = [ 45, 45,  45, 45,  45, 45,  45, 45 ]
41     tdl = [ 1, 1, 1  ]
42
43     tdr = [ 1, 2, 0.5 ]
44     tda = [ 30, 30, 30, 10, 10, 10,  10, 10, 10,  10, 10, 10, 
45             30, 30, 30, 10, 10, 10,  10, 10, 10,  10, 10, 10 ]
46     tdl = [ 1, 2, 3  ]
47
48
49     c1 = doc.makeCylindricals (orig, vx,vz, tdr, tda, tdl, False)
50
51     doc.saveVtk ("cylindricals.vtk")
52     return doc
53
54 # ======================================================= test_cylindrical
55 def test_cylindrical () :
56
57     doc  = hexablock.addDocument ("cyl:hexas")
58
59     orig = doc.addVertex (0, 0, 0)
60     vz   = doc.addVector (0, 0, 1)
61     vx   = doc.addVector (1 ,0, 0)
62
63     nr = 3
64     na = 8
65     nl = 3
66     c1 = doc.makeCylindrical (orig, vx,vz, 1.0, 360.0, 1.0, nr,na,nl, False)
67
68
69     doc.saveVtk ("cylindricals.vtk")
70     return doc
71
72
73 # ======================================================= test_cone
74 def test_cone () :
75
76     doc  = hexablock.addDocument ("cyl:hexas")
77
78     orig = doc.addVertex (0, 0, 0)
79     ori2 = doc.addVertex (0, 0, 10)
80     vz   = doc.addVector (0, 0, 1)
81     vx   = doc.addVector (1 ,0, 0)
82
83     nr = 2
84     na = 8
85     nl = 1
86     c1 = doc.makeCylindrical (orig, vx,vz, 2.0, 360.0, 5.0, nr,na,nl, False)
87     c2 = doc.makeCylindrical (ori2, vx,vz, 1.0, 360.0, 5.0, nr,na,nl, False)
88
89     vh0 = c2.getVertexIJK (0, 0, 0)
90     vh1 = c2.getVertexIJK (1, 0, 0)
91
92     vb0 = c1.getVertexIJK (0, 0, nl)
93     vb1 = c1.getVertexIJK (1, 0, nl)
94
95     qcible = c2.getQuadIJ (0, 0, 0)
96     qliste = []
97     for ni in range (nr) :
98         for nj in range (na) :
99             quad = c1.getQuadIJ (ni, nj, nl)
100             qliste.append (quad)
101             quad .setColor (3);
102
103     qcible.setColor (3);
104     vb0.setColor (5);
105     vh0.setColor (5);
106     vb1.setColor (5);
107     vh1.setColor (5);
108
109     doc.joinQuads  (qliste, qcible, vb0, vh0, vb1, vh1, 1)
110
111     doc.saveVtk ("cone.vtk")
112     return doc
113
114 # ================================================================= Begin
115
116 ####  doc = test_cylindricals  ()
117 ####  doc = test_cylindrical  ()
118 doc = test_cone  ()
119
120 law = doc.addLaw("Uniform", 4)
121
122 for j in range(doc.countPropagation()):
123     propa = doc.getPropagation(j)
124     propa.setLaw(law) 
125
126 mesh_hexas = hexablock.mesh(doc)
127
128