Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/smesh.git] / src / SMESH_SWIG / ex11_grid3partition.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 3 x 3 elements
33 # an element is compound of 3 cylinders concentriques
34 # an element is centered in a square of the grid
35 # the smaller cylinder is a hole
36
37 # prism the grid, and mesh it in hexahedral way
38
39 # Values
40 # ------
41
42 g_x = 0
43 g_y = 0
44 g_z = 0
45
46 g_arete   = 50
47 g_hauteur = 30
48
49 g_rayon1 = 20
50 g_rayon2 = 30
51 g_rayon3 = 40
52
53 g_grid = 3
54
55 g_trim = 1000
56
57 # Element
58 # -------
59
60 e_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)
61
62 e_hauteur = 2*g_hauteur
63 e_centre  = MakeVertex(g_x, g_y-g_hauteur, g_z)
64 e_dir     = MakeVectorDXDYDZ(0, 1, 0)
65
66 e_cyl1 = MakeCylinder(e_centre, e_dir, g_rayon3, e_hauteur)
67
68 e_blo1 = MakeCut(e_boite, e_cyl1)
69
70 e_cyl2 = MakeCylinder(e_centre, e_dir, g_rayon2, e_hauteur)
71
72 e_blo2 = MakeCut(e_cyl1, e_cyl2)
73
74 e_cyl3 = MakeCylinder(e_centre, e_dir, g_rayon1, e_hauteur)
75
76 e_blo3 = MakeCut(e_cyl2, e_cyl3)
77
78 # Partition and repair
79 # --------------------
80
81 p_tools = []
82 p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim))
83 p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim))
84
85 p_part = MakePartition([e_blo1, e_blo2, e_blo3], p_tools, [], [], ShapeType["SOLID"])
86
87 p_element = RemoveExtraEdges(p_part)
88
89 # Grid and glue
90 # -------------
91
92 grid = MakeMultiTranslation2D(p_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
93
94 piece = MakeGlueFaces(grid, 1e-5)
95
96 # Add in study
97 # ------------
98
99 piece_id = addToStudy(piece, "ex11_grid3partition")
100
101 # Meshing
102 # =======
103
104 # Create a hexahedral mesh
105 # ------------------------
106
107 hexa = smesh.Mesh(piece, "ex11_grid3partition:hexa")
108
109 algo = hexa.Segment()
110 algo.NumberOfSegments(3)
111
112 hexa.Quadrangle()
113
114 hexa.Hexahedron()
115
116 # Mesh calculus
117 # -------------
118
119 hexa.Compute()