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