]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESH_SWIG/ex09_grid4build.py
Salome HOME
0021806: [CEA 637] Wrap error message on Mesh Computation Failed Dialog
[modules/smesh.git] / src / SMESH_SWIG / ex09_grid4build.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2012  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 #
26 from geompy import *
27
28 import smesh
29
30 import math
31
32 # Geometry
33 # ========
34
35 # Element of a grid compound by a square with a cylinder on each vertex build by points, edges, faces and solids
36
37 # Values
38 # ------
39
40 ox = 0
41 oy = 0
42 oz = 0
43
44 arete   =  50
45 hauteur = 100
46
47 rayon = 10
48
49 demi = rayon/2
50 r3   = demi*math.sqrt(3)
51
52 # Points
53 # ------
54
55 piecePoint111 = MakeVertex(ox+rayon      , oy, oz)
56 piecePoint211 = MakeVertex(ox+arete-rayon, oy, oz)
57 piecePoint112 = MakeVertex(ox            , oy, oz+rayon)
58 piecePoint212 = MakeVertex(ox+arete      , oy, oz+rayon)
59 piecePoint113 = MakeVertex(ox            , oy, oz+arete-rayon)
60 piecePoint213 = MakeVertex(ox+arete      , oy, oz+arete-rayon)
61 piecePoint114 = MakeVertex(ox+rayon      , oy, oz+arete)
62 piecePoint214 = MakeVertex(ox+arete-rayon, oy, oz+arete)
63
64 pieceCenter1  = MakeVertex(ox            , oy, oz)
65 pieceCenter2  = MakeVertex(ox+arete      , oy, oz)
66 pieceCenter3  = MakeVertex(ox            , oy, oz+arete)
67 pieceCenter4  = MakeVertex(ox+arete      , oy, oz+arete)
68
69 piecePass1    = MakeVertex(ox+demi       , oy, oz+r3)
70 piecePass2    = MakeVertex(ox+arete-demi , oy, oz+r3)
71 piecePass3    = MakeVertex(ox+arete-demi , oy, oz+arete-r3)
72 piecePass4    = MakeVertex(ox+demi       , oy, oz+arete-r3)
73
74 # Edges
75 # -----
76
77 pieceEdgeSquare1   = MakeEdge(piecePoint111, piecePoint211)
78 pieceEdgeSquare2   = MakeEdge(piecePoint114, piecePoint214)
79 pieceEdgeSquare3   = MakeEdge(piecePoint112, piecePoint113)
80 pieceEdgeSquare4   = MakeEdge(piecePoint212, piecePoint213)
81
82 pieceEdgeDiagonal1 = MakeEdge(piecePoint111, piecePoint213)
83 pieceEdgeDiagonal2 = MakeEdge(piecePoint112, piecePoint214)
84
85 pieceEdgeArc1 = MakeArc(piecePoint111, piecePass1, piecePoint112)
86 pieceEdgeArc2 = MakeArc(piecePoint211, piecePass2, piecePoint212)
87 pieceEdgeArc3 = MakeArc(piecePoint213, piecePass3, piecePoint214)
88 pieceEdgeArc4 = MakeArc(piecePoint113, piecePass4, piecePoint114)
89
90 # Faces
91 # -----
92
93 pieceFace1 = MakeQuad(pieceEdgeSquare1, pieceEdgeArc2, pieceEdgeSquare4, pieceEdgeDiagonal1)
94 pieceFace2 = MakeQuad(pieceEdgeSquare2, pieceEdgeArc4, pieceEdgeSquare3, pieceEdgeDiagonal2)
95
96 pieceFace3 = MakeQuad(pieceEdgeArc1, pieceEdgeDiagonal1, pieceEdgeArc3, pieceEdgeDiagonal2)
97
98 # Solids
99 # ------
100
101 pieceVector = MakeVectorDXDYDZ(0, 1, 0)
102
103 pieceSolid1 = MakePrismVecH(pieceFace1, pieceVector, hauteur)
104 pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur)
105 pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur)
106
107 # Compound and glue
108 # -----------------
109
110 c_cpd = MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3])
111
112 piece = MakeGlueFaces(c_cpd, 1.e-5)
113
114 # Add in study
115 # ------------
116
117 piece_id = addToStudy(piece, "ex09_grid4build")
118
119 # Meshing
120 # =======
121
122 smesh.SetCurrentStudy(salome.myStudy)
123
124 # Create a hexahedral mesh
125 # ------------------------
126
127 hexa = smesh.Mesh(piece, "ex09_grid4build:hexa")
128
129 algo = hexa.Segment()
130 algo.NumberOfSegments(6)
131
132 hexa.Quadrangle()
133
134 hexa.Hexahedron()
135
136 # Mesh calculus
137 # -------------
138
139 hexa.Compute()