Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/smesh.git] / src / SMESH_SWIG / ex14_cyl1holed.py
1 #  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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 # CEA/LGLS 2004-2005, Francis KLOSS (OCC)
21 # =======================================
22
23 from geompy import *
24
25 import smesh
26
27 # Geometrie
28 # =========
29
30 # Creer un cylindre avec un trou cylindrique excentre, decoupage en hexahedre et mailler.
31
32 # Donnees
33 # -------
34
35 # unite: millimetre
36
37 g_ox = 0
38 g_oy = 0
39 g_oz = 0
40
41 g_cyl_rayon       = 1000
42 g_cyl_demiHauteur = 3000
43
44 g_trou_rayon       =   5
45 g_trou_centre      = 300
46
47 g_trim = 15000
48
49 # Construire le cylindre
50 # ----------------------
51
52 c_point    = MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
53 c_dir      = MakeVectorDXDYDZ(0, 0, 1)
54 c_hauteur  = 2*g_cyl_demiHauteur
55 c_cylindre = MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
56
57 # Trouer le cylindre par un minuscule cylindre excentre
58 # -----------------------------------------------------
59
60 t_hauteur = g_cyl_demiHauteur
61 t_point   = MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
62 t_trou    = MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
63
64 t_piece   = MakeCut(c_cylindre, t_trou)
65
66 # Geometrie hexahedrique
67 # ======================
68
69 # Decouper
70 # --------
71
72 h_outils = []
73 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(1, 0, 0), g_trim))
74 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(0, 1, 0), g_trim))
75
76 h_piece = MakePartition([t_piece], h_outils, [], [], ShapeType["SOLID"])
77
78 # Decouper pour les conditions locales
79 # ------------------------------------
80
81 l_outils = []
82 l_i = 1
83 l_n = 12
84 l_hauteur = c_hauteur/l_n
85
86 while l_i<l_n:
87     l_outils.append(MakePlane(MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur+l_i*l_hauteur), c_dir, g_trim))
88     l_i = l_i+1
89
90 piece = MakePartition([h_piece], l_outils, [], [], ShapeType["SOLID"])
91
92 # Ajouter la piece dans l'etude
93 # -----------------------------
94
95 piece_id = addToStudy(piece, "ex14_cyl1holed")
96
97 # Maillage
98 # ========
99
100 # Creer un maillage hexahedrique
101 # ------------------------------
102
103 hexa = smesh.Mesh(piece, "ex14_cyl1holed:hexa")
104
105 algo = hexa.Segment()
106 algo.NumberOfSegments(4)
107
108 hexa.Quadrangle()
109
110 hexa.Hexahedron()
111
112 # Poser les hypotheses locales
113 # ----------------------------
114
115 m_i = 0
116 m_n = 12
117 m_h = c_hauteur/m_n
118 m_d = [4, 6, 8, 10, 10, 9, 8, 7, 6, 5, 4, 3]
119
120 m_x = g_ox+g_cyl_rayon
121 m_y = g_oy
122 m_z = g_oz-g_cyl_demiHauteur+m_h/2
123
124 while m_i<m_n:
125     m_p = MakeVertex(m_x, m_y, m_z + m_i*m_h)
126     m_e = GetEdgeNearPoint(piece, m_p)
127     m_a = hexa.Segment(m_e)
128     m_a.NumberOfSegments(m_d[m_i])
129     m_a.Propagation()
130     m_i = m_i + 1
131
132 # Calculer le maillage
133 # --------------------
134
135 hexa.Compute()