Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/smesh.git] / src / SMESH_SWIG / ex12_grid17partition.py
1 #  -*- coding: iso-8859-1 -*-
2 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 #  This library is free software; you can redistribute it and/or
8 #  modify it under the terms of the GNU Lesser General Public
9 #  License as published by the Free Software Foundation; either
10 #  version 2.1 of the License.
11 #
12 #  This library is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 #  Lesser General Public License for more details.
16 #
17 #  You should have received a copy of the GNU Lesser General Public
18 #  License along with this library; if not, write to the Free Software
19 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23 # =======================================
24 #
25 from geompy import *
26
27 import smesh
28
29 # Geometry
30 # ========
31
32 # grid compound of 17 x 17 elements
33 # an element is compound of 3 concentric cylinders
34 # an element is centered in a square of the grid
35
36 # prism the grid, and mesh it in hexahedral way
37
38 # Values
39 # ------
40
41 g_x = 0
42 g_y = 0
43 g_z = 0
44
45 g_arete   = 50
46 g_hauteur = 30
47
48 g_rayon1 = 20
49 g_rayon2 = 30
50 g_rayon3 = 40
51
52 g_grid = 17
53
54 g_trim = 1000
55
56 # Solids and rotation to prevent repair
57 # -------------------------------------
58
59 s_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete,  g_x+g_arete, g_y+g_hauteur, g_z+g_arete)
60
61 s_pi4     = 3.141592653/4
62 s_hauteur = 2*g_hauteur
63 s_centre  = MakeVertex(g_x, g_y-g_hauteur, g_z)
64 s_dir     = MakeVectorDXDYDZ(0, 1, 0)
65
66 s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon3, s_hauteur)
67 s_cyl1 = MakeRotation(s_cyl0, s_dir, s_pi4)
68
69 s_blo1 = MakeCut(s_boite, s_cyl1)
70
71 s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon2, s_hauteur)
72 s_cyl2 = MakeRotation(s_cyl0, s_dir, s_pi4)
73
74 s_blo2 = MakeCut(s_cyl1, s_cyl2)
75
76 s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon1, s_hauteur)
77 s_cyl3 = MakeRotation(s_cyl0, s_dir, s_pi4)
78
79 s_blo3 = MakeCut(s_cyl2, s_cyl3)
80
81 s_arete = g_rayon1/2
82
83 s_blo4 = MakeBox(g_x-s_arete, g_y-g_hauteur, g_z-s_arete,  g_x+s_arete, g_y+g_hauteur, g_z+s_arete)
84
85 s_blo5 = MakeCut(s_cyl3, s_blo4)
86
87 # Partition
88 # ---------
89
90 p_tools = []
91 p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim))
92 p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim))
93
94 p_partie = MakePartition([s_blo1, s_blo2, s_blo3, s_blo5], p_tools, [], [], ShapeType["SOLID"])
95
96 # Compound and glue
97 # -----------------
98
99 c_blocs = SubShapeAll(p_partie, ShapeType["SOLID"])
100 c_blocs.append(s_blo4)
101
102 c_cpd = MakeCompound(c_blocs)
103
104 c_element = MakeGlueFaces(c_cpd, 1e-4)
105
106 # Grid
107 # ----
108
109 piece = MakeMultiTranslation2D(c_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
110
111 # Add in study
112 # ------------
113
114 piece_id = addToStudy(piece, "ex12_grid17partition")
115
116 # Meshing
117 # =======
118
119 # Create a hexahedral mesh
120 # ------------------------
121
122 hexa = smesh.Mesh(piece, "ex12_grid17partition:hexa")
123
124 algo = hexa.Segment()
125 algo.NumberOfSegments(2)
126
127 hexa.Quadrangle()
128
129 hexa.Hexahedron()
130
131 # Mesh calculus
132 # -------------
133
134 hexa.Compute()