1 # -*- coding: latin-1 -*-
2 # Copyright (C) 2009-2016 CEA/DEN, EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Hexa : Association par lignes
25 geompy = hexablock.geompy
27 #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
32 # 1 +----e18----+----e19----+
35 # 0 ed_west e13 o e17 ed_est
38 # -1 +----e14----+----e16----+
43 # +..........-2...........0...........2...............
45 global ed_west, ed_est, ed_nord1, ed_nord2, ed_sud1, ed_sud2
46 global v_sw, v_s , v_se, v_nw, v_n , v_ne
47 global p_w, p_e, p_n, p_s, p_n1, p_n2, p_s1, p_s2, p_nw, p_sw, p_ne, p_se
48 global arc_s, arc_e, arc_n, arc_w, arc_n1, arc_n2, arc_s1, arc_s2
51 # ======================================================= init_globale
52 def init_globale (name) :
54 global ed_west, ed_est, ed_nord1, ed_nord2, ed_sud1, ed_sud2
55 global v_sw, v_s , v_se, v_nw, v_n , v_ne
56 global p_w, p_e, p_n, p_s, p_n1, p_n2, p_s1, p_s2, p_nw, p_sw, p_ne, p_se
57 global arc_s, arc_e, arc_n, arc_w, arc_n1, arc_n2, arc_s1, arc_s2
60 doc = hexablock.addDocument (nom)
62 orig = doc.addVertex (-2, -1, -1)
63 vx = doc.addVector (2,0,0)
64 vy = doc.addVector (0,2,0)
65 vz = doc.addVector (0,0,2)
66 grid = doc.makeCartesian (orig, vx, vy, vz, 2, 1, 1)
71 ed_west = grid.getEdgeJ (0, 0, nz)
72 ed_est = grid.getEdgeJ (2, 0, nz)
73 ed_nord1 = grid.getEdgeI (0, 1, nz)
74 ed_nord2 = grid.getEdgeI (1, 1, nz)
75 ed_sud1 = grid.getEdgeI (0, 0, nz)
76 ed_sud2 = grid.getEdgeI (1, 0, nz)
78 v_sw = grid.getVertexIJK (0, 0, nz)
79 v_s = grid.getVertexIJK (1, 0, nz)
80 v_se = grid.getVertexIJK (2, 0, nz)
82 v_nw = grid.getVertexIJK (0, 1, nz)
83 v_n = grid.getVertexIJK (1, 1, nz)
84 v_ne = grid.getVertexIJK (2, 1, nz)
86 doc.saveVtk (nom + ".vtk");
87 ## ______________________________________________________________ Geom
89 p_w = geompy.MakeVertex (-2.55, 0, vz)
90 p_e = geompy.MakeVertex ( 2.55, 0, vz)
91 p_n = geompy.MakeVertex ( 0, 2.0, vz)
92 p_s = geompy.MakeVertex ( 0, -2.0, vz)
94 p_n1 = geompy.MakeVertex ( 0.5, 2.0, vz)
95 p_n2 = geompy.MakeVertex (-0.5, 2.0, vz)
96 p_s1 = geompy.MakeVertex (-0.5, -2.0, vz)
97 p_s2 = geompy.MakeVertex ( 0.5, -2.0, vz)
99 p_nw = geompy.MakeVertex (-2, 1, vz)
100 p_sw = geompy.MakeVertex (-2, -1, vz)
101 p_ne = geompy.MakeVertex ( 2, 1, vz)
102 p_se = geompy.MakeVertex ( 2, -1, vz)
104 arc_s = geompy.MakeArc (p_sw, p_s, p_se)
105 arc_e = geompy.MakeArc (p_se, p_e, p_ne)
106 arc_n = geompy.MakeArc (p_ne, p_n, p_nw)
107 arc_w = geompy.MakeArc (p_nw, p_w, p_sw)
109 arc_n1 = geompy.MakeArc (p_ne, p_n1, p_n)
110 arc_n2 = geompy.MakeArc (p_n, p_n2, p_nw)
111 arc_s1 = geompy.MakeArc (p_sw, p_s1, p_s)
112 arc_s2 = geompy.MakeArc (p_s, p_s2, p_se)
116 # ======================================================= test_asso_mano
117 def test_asso_mano () :
119 doc = init_globale ("asso_mano")
121 ed_west.addAssociation (arc_w, 0, 1)
122 ed_est .addAssociation (arc_e, 0, 1)
124 v_n.setAssociation (p_n)
125 ed_nord2.addAssociation (arc_n1, 0.0, 1.0)
126 ed_nord1.addAssociation (arc_n2, 0.0, 1.0)
128 v_s.setAssociation (p_s)
129 ## ed_sud1.addAssociation (arc_s, 0.0, 0.5)
130 ## ed_sud2.addAssociation (arc_s, 0.5, 1.0)
132 ed_sud1.addAssociation (arc_s1, 0.0, 1.0)
133 ed_sud2.addAssociation (arc_s2, 0.0, 1.0)
137 # ======================================================= test_asso_closed
138 def test_asso_closed () :
140 doc = init_globale ("asso_closed")
142 les_edges = [ ed_sud1, ed_sud2, ed_est, ed_nord1, ed_nord2, ed_west ]
143 les_arcs = [ arc_s1, arc_s2, arc_e, arc_n1, arc_n2, arc_w ]
145 doc.associateClosedLine (v_sw, les_edges[0], les_edges[1:],
146 les_arcs [0], 0.0, False, les_arcs[1:])
149 # ======================================================= test_asso_closed_inv
150 def test_asso_closed_inv () :
152 doc = init_globale ("asso_closed_inv")
154 les_edges = [ ed_sud1, ed_sud2, ed_est, ed_nord1, ed_nord2, ed_west ]
155 les_arcs = [ arc_s1, arc_s2, arc_e, arc_n1, arc_n2, arc_w ]
157 doc.associateClosedLine (v_s , les_edges[0], les_edges[1:],
158 les_arcs [0], 1.0, True, les_arcs[1:])
161 # ======================================================= test_asso_opened
162 def test_asso_opened () :
164 doc = init_globale ("asso_opened")
166 les_edges = [ ed_sud2, ed_est, ed_nord2 ]
167 les_arcs = [ arc_s, arc_e, arc_n ]
169 doc.associateOpenedLine (les_edges[0], les_edges[1:],
170 les_arcs [0], 0.5, les_arcs[1:], 0.5)
173 # ================================================================= Begin
175 doc = test_asso_closed_inv ()
177 law = doc.addLaw("Uniform", 3)
179 for j in range(doc.countPropagation()):
180 propa = doc.getPropagation(j)
183 mesh_hexas = hexablock.mesh (doc)