Salome HOME
Mise a jour M.Barry
[modules/hexablock.git] / src / TEST_PY / test_unit / test_bugs.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 # ======================================================= bug_quad2
31 def bug_quad2 () :
32
33     doc  = hexablock.addDocument ("default")
34
35     ori  = doc.addVertex ( 0, 0, 0)
36     vz   = doc.addVector ( 0, 0, 1)
37     vx   = doc.addVector ( 1 ,0, 0)
38
39     dr = 1;
40     dl = 1;
41     phi = 360;
42     nr = 1;
43     na = 8;
44     nl = 1;
45
46     c1 = doc.makeCylindrical (ori, vx,vz,dr, phi,dl, nr,na,nl, False);
47     nvtk = 0;
48     nom = "bugs_hexas";
49     doc.saveVtk ("bugs_hexa_ab1.vtk")
50
51     qa = c1.getQuadJK (0, 0, 0);
52     qb = c1.getQuadJK (0, 4, 0);
53     hexa = doc.addHexa2Quads (qa, qb);
54
55  
56     doc.setFile (nom);
57     doc.saveFile ();
58     doc.saveVtk ("bugs_hexa_ab2.vtk")
59     return doc
60
61 # ======================================================= bug_quad3
62 def bug_quad3 () :
63
64     doc  = hexablock.addDocument("quad3")
65
66     ori  = doc.addVertex ( 0, 0, 0)
67     vz   = doc.addVector ( 0, 0, 1)
68     vx   = doc.addVector ( 1 ,0, 0)
69
70     dr = 1;
71     dl = 1;
72     phi = 360;
73     nr = 1;
74     na = 8;
75     nl = 1;
76
77     c1 = doc.makeCylindrical (ori, vx,vz,dr, phi,dl, nr,na,nl, False);
78     nvtk = 0;
79     nom = "bugs_hexas";
80     doc.saveVtk ("bugs_hexa_acd1.vtk")
81
82     qc = c1.getQuadJK (0, 0, 0);
83     qa = c1.getQuadJK (0, 1, 0);
84     qd = c1.getQuadJK (0, 2, 0);
85
86     hexa = doc.addHexa3Quads (qa, qc, qd);
87
88  
89     doc.setFile (nom);
90     doc.saveFile ();
91     doc.saveVtk ("bugs_hexa_acd2.vtk")
92     return doc
93
94
95 # ======================================================= bug_quad3
96 def bug_quad1 () :
97
98     doc  = hexablock.addDocument("quad1")
99     centre     = doc.addVertex(0, 0, 0)
100     vecteur_px = doc.addVector(1, 0, 0)
101     vecteur_pz = doc.addVector(0, 0, 1)
102
103     grille = doc.makeCylindrical(centre, vecteur_px, vecteur_pz,  1, 360, 1,  3, 8, 1,  False)
104
105     quad_1 = grille.getQuadIK(0, 1, 0)
106     quad_5 = grille.getQuadIK(0, 5, 0)
107
108     quad_1 = grille.getQuadJK(0, 1, 0)
109     quad_5 = grille.getQuadJK(0, 4, 0)
110     quad_1.setScalar (5)
111
112     doc.saveVtk ("bugs_hexa_ab1.vtk")
113     doc.addHexa2Quads(quad_1, quad_5)
114     doc.saveVtk ("bugs_hexa_ab2.vtk")
115  
116     return doc
117
118 # ================================================================= Begin
119
120 doc = bug_quad1  ()
121
122 law = doc.addLaw("Uniform", 4)
123
124 for j in range(doc.countPropagation()):
125     propa = doc.getPropagation(j)
126     propa.setLaw(law) 
127
128 mesh_hexas = hexablock.mesh(doc, "maillage:hexas")