Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/smesh.git] / src / SMESH_SWIG / ex12_grid17partition.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 # Geometry
28 # ========
29
30 # grid compound of 17 x 17 elements
31 # an element is compound of 3 concentric cylinders
32 # an element is centered in a square of the grid
33
34 # prism the grid, and mesh it in hexahedral way
35
36 # Values
37 # ------
38
39 g_x = 0
40 g_y = 0
41 g_z = 0
42
43 g_arete   = 50
44 g_hauteur = 30
45
46 g_rayon1 = 20
47 g_rayon2 = 30
48 g_rayon3 = 40
49
50 g_grid = 17
51
52 g_trim = 1000
53
54 # Solids and rotation to prevent repair
55 # -------------------------------------
56
57 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)
58
59 s_pi4     = 3.141592653/4
60 s_hauteur = 2*g_hauteur
61 s_centre  = MakeVertex(g_x, g_y-g_hauteur, g_z)
62 s_dir     = MakeVectorDXDYDZ(0, 1, 0)
63
64 s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon3, s_hauteur)
65 s_cyl1 = MakeRotation(s_cyl0, s_dir, s_pi4)
66
67 s_blo1 = MakeCut(s_boite, s_cyl1)
68
69 s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon2, s_hauteur)
70 s_cyl2 = MakeRotation(s_cyl0, s_dir, s_pi4)
71
72 s_blo2 = MakeCut(s_cyl1, s_cyl2)
73
74 s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon1, s_hauteur)
75 s_cyl3 = MakeRotation(s_cyl0, s_dir, s_pi4)
76
77 s_blo3 = MakeCut(s_cyl2, s_cyl3)
78
79 s_arete = g_rayon1/2
80
81 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)
82
83 s_blo5 = MakeCut(s_cyl3, s_blo4)
84
85 # Partition
86 # ---------
87
88 p_tools = []
89 p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim))
90 p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim))
91
92 p_partie = MakePartition([s_blo1, s_blo2, s_blo3, s_blo5], p_tools, [], [], ShapeType["SOLID"])
93
94 # Compound and glue
95 # -----------------
96
97 c_blocs = SubShapeAll(p_partie, ShapeType["SOLID"])
98 c_blocs.append(s_blo4)
99
100 c_cpd = MakeCompound(c_blocs)
101
102 c_element = MakeGlueFaces(c_cpd, 1e-4)
103
104 # Grid
105 # ----
106
107 piece = MakeMultiTranslation2D(c_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
108
109 # Add in study
110 # ------------
111
112 piece_id = addToStudy(piece, "ex12_grid17partition")
113
114 # Meshing
115 # =======
116
117 # Create a hexahedral mesh
118 # ------------------------
119
120 hexa = smesh.Mesh(piece, "ex12_grid17partition:hexa")
121
122 algo = hexa.Segment()
123 algo.NumberOfSegments(2)
124
125 hexa.Quadrangle()
126
127 hexa.Hexahedron()
128
129 # Mesh calculus
130 # -------------
131
132 hexa.Compute()