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