Back to index

salome-smesh  6.5.0
ex01_cube2build.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 # =======================================
00025 #
00026 from geompy import *
00027 
00028 import smesh
00029 
00030 # Geometry
00031 # ========
00032 
00033 # A small cube centered and put on a great cube build by points, edges, faces and solids
00034 
00035 # Points
00036 # ------
00037 
00038 greatPoint111 = MakeVertex( 0,  0,  0)
00039 greatPoint211 = MakeVertex(10,  0,  0)
00040 greatPoint311 = MakeVertex(20,  0,  0)
00041 greatPoint411 = MakeVertex(30,  0,  0)
00042 
00043 greatPoint121 = MakeVertex( 0, 10,  0)
00044 greatPoint221 = MakeVertex(10, 10,  0)
00045 greatPoint321 = MakeVertex(20, 10,  0)
00046 greatPoint421 = MakeVertex(30, 10,  0)
00047 
00048 greatPoint112 = MakeVertex( 0,  0, 10)
00049 greatPoint212 = MakeVertex(10,  0, 10)
00050 greatPoint312 = MakeVertex(20,  0, 10)
00051 greatPoint412 = MakeVertex(30,  0, 10)
00052 
00053 greatPoint122 = MakeVertex( 0, 10, 10)
00054 greatPoint222 = MakeVertex(10, 10, 10)
00055 greatPoint322 = MakeVertex(20, 10, 10)
00056 greatPoint422 = MakeVertex(30, 10, 10)
00057 
00058 greatPoint113 = MakeVertex( 0,  0, 20)
00059 greatPoint213 = MakeVertex(10,  0, 20)
00060 greatPoint313 = MakeVertex(20,  0, 20)
00061 greatPoint413 = MakeVertex(30,  0, 20)
00062 
00063 greatPoint123 = MakeVertex( 0, 10, 20)
00064 greatPoint223 = MakeVertex(10, 10, 20)
00065 greatPoint323 = MakeVertex(20, 10, 20)
00066 greatPoint423 = MakeVertex(30, 10, 20)
00067 
00068 greatPoint114 = MakeVertex( 0,  0, 30)
00069 greatPoint214 = MakeVertex(10,  0, 30)
00070 greatPoint314 = MakeVertex(20,  0, 30)
00071 greatPoint414 = MakeVertex(30,  0, 30)
00072 
00073 greatPoint124 = MakeVertex( 0, 10, 30)
00074 greatPoint224 = MakeVertex(10, 10, 30)
00075 greatPoint324 = MakeVertex(20, 10, 30)
00076 greatPoint424 = MakeVertex(30, 10, 30)
00077 
00078 
00079 smallPoint111 = greatPoint222
00080 smallPoint211 = greatPoint322
00081 smallPoint121 = MakeVertex(10, 20, 10)
00082 smallPoint221 = MakeVertex(20, 20, 10)
00083 
00084 smallPoint112 = greatPoint223
00085 smallPoint212 = greatPoint323
00086 smallPoint122 = MakeVertex(10, 20, 20)
00087 smallPoint222 = MakeVertex(20, 20, 20)
00088 
00089 # Edges
00090 # -----
00091 
00092 smallEdgeX11 = MakeEdge(smallPoint111, smallPoint211)
00093 smallEdgeX21 = MakeEdge(smallPoint121, smallPoint221)
00094 smallEdgeX12 = MakeEdge(smallPoint112, smallPoint212)
00095 smallEdgeX22 = MakeEdge(smallPoint122, smallPoint222)
00096 
00097 smallEdgeY11 = MakeEdge(smallPoint111, smallPoint121)
00098 smallEdgeY21 = MakeEdge(smallPoint211, smallPoint221)
00099 smallEdgeY12 = MakeEdge(smallPoint112, smallPoint122)
00100 smallEdgeY22 = MakeEdge(smallPoint212, smallPoint222)
00101 
00102 smallEdgeZ11 = MakeEdge(smallPoint111, smallPoint112)
00103 smallEdgeZ21 = MakeEdge(smallPoint211, smallPoint212)
00104 smallEdgeZ12 = MakeEdge(smallPoint121, smallPoint122)
00105 smallEdgeZ22 = MakeEdge(smallPoint221, smallPoint222)
00106 
00107 
00108 greatEdgeX111 = MakeEdge(greatPoint111, greatPoint211)
00109 greatEdgeX211 = MakeEdge(greatPoint211, greatPoint311)
00110 greatEdgeX311 = MakeEdge(greatPoint311, greatPoint411)
00111 greatEdgeX121 = MakeEdge(greatPoint121, greatPoint221)
00112 greatEdgeX221 = MakeEdge(greatPoint221, greatPoint321)
00113 greatEdgeX321 = MakeEdge(greatPoint321, greatPoint421)
00114 
00115 greatEdgeX112 = MakeEdge(greatPoint112, greatPoint212)
00116 greatEdgeX212 = MakeEdge(greatPoint212, greatPoint312)
00117 greatEdgeX312 = MakeEdge(greatPoint312, greatPoint412)
00118 greatEdgeX122 = MakeEdge(greatPoint122, greatPoint222)
00119 greatEdgeX222 = smallEdgeX11
00120 greatEdgeX322 = MakeEdge(greatPoint322, greatPoint422)
00121 
00122 greatEdgeX113 = MakeEdge(greatPoint113, greatPoint213)
00123 greatEdgeX213 = MakeEdge(greatPoint213, greatPoint313)
00124 greatEdgeX313 = MakeEdge(greatPoint313, greatPoint413)
00125 greatEdgeX123 = MakeEdge(greatPoint123, greatPoint223)
00126 greatEdgeX223 = smallEdgeX12
00127 greatEdgeX323 = MakeEdge(greatPoint323, greatPoint423)
00128 
00129 greatEdgeX114 = MakeEdge(greatPoint114, greatPoint214)
00130 greatEdgeX214 = MakeEdge(greatPoint214, greatPoint314)
00131 greatEdgeX314 = MakeEdge(greatPoint314, greatPoint414)
00132 greatEdgeX124 = MakeEdge(greatPoint124, greatPoint224)
00133 greatEdgeX224 = MakeEdge(greatPoint224, greatPoint324)
00134 greatEdgeX324 = MakeEdge(greatPoint324, greatPoint424)
00135 
00136 greatEdgeY11 = MakeEdge(greatPoint111, greatPoint121)
00137 greatEdgeY21 = MakeEdge(greatPoint211, greatPoint221)
00138 greatEdgeY31 = MakeEdge(greatPoint311, greatPoint321)
00139 greatEdgeY41 = MakeEdge(greatPoint411, greatPoint421)
00140 
00141 greatEdgeY12 = MakeEdge(greatPoint112, greatPoint122)
00142 greatEdgeY22 = MakeEdge(greatPoint212, greatPoint222)
00143 greatEdgeY32 = MakeEdge(greatPoint312, greatPoint322)
00144 greatEdgeY42 = MakeEdge(greatPoint412, greatPoint422)
00145 
00146 greatEdgeY13 = MakeEdge(greatPoint113, greatPoint123)
00147 greatEdgeY23 = MakeEdge(greatPoint213, greatPoint223)
00148 greatEdgeY33 = MakeEdge(greatPoint313, greatPoint323)
00149 greatEdgeY43 = MakeEdge(greatPoint413, greatPoint423)
00150 
00151 greatEdgeY14 = MakeEdge(greatPoint114, greatPoint124)
00152 greatEdgeY24 = MakeEdge(greatPoint214, greatPoint224)
00153 greatEdgeY34 = MakeEdge(greatPoint314, greatPoint324)
00154 greatEdgeY44 = MakeEdge(greatPoint414, greatPoint424)
00155 
00156 greatEdgeZ111 = MakeEdge(greatPoint111, greatPoint112)
00157 greatEdgeZ211 = MakeEdge(greatPoint211, greatPoint212)
00158 greatEdgeZ311 = MakeEdge(greatPoint311, greatPoint312)
00159 greatEdgeZ411 = MakeEdge(greatPoint411, greatPoint412)
00160 
00161 greatEdgeZ121 = MakeEdge(greatPoint121, greatPoint122)
00162 greatEdgeZ221 = MakeEdge(greatPoint221, greatPoint222)
00163 greatEdgeZ321 = MakeEdge(greatPoint321, greatPoint322)
00164 greatEdgeZ421 = MakeEdge(greatPoint421, greatPoint422)
00165 
00166 greatEdgeZ112 = MakeEdge(greatPoint112, greatPoint113)
00167 greatEdgeZ212 = MakeEdge(greatPoint212, greatPoint213)
00168 greatEdgeZ312 = MakeEdge(greatPoint312, greatPoint313)
00169 greatEdgeZ412 = MakeEdge(greatPoint412, greatPoint413)
00170 
00171 greatEdgeZ122 = MakeEdge(greatPoint122, greatPoint123)
00172 greatEdgeZ222 = smallEdgeZ11
00173 greatEdgeZ322 = smallEdgeZ21
00174 greatEdgeZ422 = MakeEdge(greatPoint422, greatPoint423)
00175 
00176 greatEdgeZ113 = MakeEdge(greatPoint113, greatPoint114)
00177 greatEdgeZ213 = MakeEdge(greatPoint213, greatPoint214)
00178 greatEdgeZ313 = MakeEdge(greatPoint313, greatPoint314)
00179 greatEdgeZ413 = MakeEdge(greatPoint413, greatPoint414)
00180 
00181 greatEdgeZ123 = MakeEdge(greatPoint123, greatPoint124)
00182 greatEdgeZ223 = MakeEdge(greatPoint223, greatPoint224)
00183 greatEdgeZ323 = MakeEdge(greatPoint323, greatPoint324)
00184 greatEdgeZ423 = MakeEdge(greatPoint423, greatPoint424)
00185 
00186 # Faces
00187 # -----
00188 
00189 smallFaceX1 = MakeQuad(smallEdgeY11, smallEdgeZ11, smallEdgeY12, smallEdgeZ12)
00190 smallFaceX2 = MakeQuad(smallEdgeY21, smallEdgeZ21, smallEdgeY22, smallEdgeZ22)
00191 smallFaceY1 = MakeQuad(smallEdgeX11, smallEdgeZ11, smallEdgeX12, smallEdgeZ21)
00192 smallFaceY2 = MakeQuad(smallEdgeX21, smallEdgeZ12, smallEdgeX22, smallEdgeZ22)
00193 smallFaceZ1 = MakeQuad(smallEdgeX11, smallEdgeY11, smallEdgeX21, smallEdgeY21)
00194 smallFaceZ2 = MakeQuad(smallEdgeX12, smallEdgeY12, smallEdgeX22, smallEdgeY22)
00195 
00196 
00197 greatFaceX11 = MakeQuad(greatEdgeY11, greatEdgeZ111, greatEdgeY12, greatEdgeZ121)
00198 greatFaceX21 = MakeQuad(greatEdgeY21, greatEdgeZ211, greatEdgeY22, greatEdgeZ221)
00199 greatFaceX31 = MakeQuad(greatEdgeY31, greatEdgeZ311, greatEdgeY32, greatEdgeZ321)
00200 greatFaceX41 = MakeQuad(greatEdgeY41, greatEdgeZ411, greatEdgeY42, greatEdgeZ421)
00201 
00202 greatFaceX12 = MakeQuad(greatEdgeY12, greatEdgeZ112, greatEdgeY13, greatEdgeZ122)
00203 greatFaceX22 = MakeQuad(greatEdgeY22, greatEdgeZ212, greatEdgeY23, greatEdgeZ222)
00204 greatFaceX32 = MakeQuad(greatEdgeY32, greatEdgeZ312, greatEdgeY33, greatEdgeZ322)
00205 greatFaceX42 = MakeQuad(greatEdgeY42, greatEdgeZ412, greatEdgeY43, greatEdgeZ422)
00206 
00207 greatFaceX13 = MakeQuad(greatEdgeY13, greatEdgeZ113, greatEdgeY14, greatEdgeZ123)
00208 greatFaceX23 = MakeQuad(greatEdgeY23, greatEdgeZ213, greatEdgeY24, greatEdgeZ223)
00209 greatFaceX33 = MakeQuad(greatEdgeY33, greatEdgeZ313, greatEdgeY34, greatEdgeZ323)
00210 greatFaceX43 = MakeQuad(greatEdgeY43, greatEdgeZ413, greatEdgeY44, greatEdgeZ423)
00211 
00212 greatFaceY111 = MakeQuad(greatEdgeX111, greatEdgeZ111, greatEdgeX112, greatEdgeZ211)
00213 greatFaceY211 = MakeQuad(greatEdgeX211, greatEdgeZ211, greatEdgeX212, greatEdgeZ311)
00214 greatFaceY311 = MakeQuad(greatEdgeX311, greatEdgeZ311, greatEdgeX312, greatEdgeZ411)
00215 greatFaceY121 = MakeQuad(greatEdgeX121, greatEdgeZ121, greatEdgeX122, greatEdgeZ221)
00216 greatFaceY221 = MakeQuad(greatEdgeX221, greatEdgeZ221, greatEdgeX222, greatEdgeZ321)
00217 greatFaceY321 = MakeQuad(greatEdgeX321, greatEdgeZ321, greatEdgeX322, greatEdgeZ421)
00218 
00219 greatFaceY112 = MakeQuad(greatEdgeX112, greatEdgeZ112, greatEdgeX113, greatEdgeZ212)
00220 greatFaceY212 = MakeQuad(greatEdgeX212, greatEdgeZ212, greatEdgeX213, greatEdgeZ312)
00221 greatFaceY312 = MakeQuad(greatEdgeX312, greatEdgeZ312, greatEdgeX313, greatEdgeZ412)
00222 greatFaceY122 = MakeQuad(greatEdgeX122, greatEdgeZ122, greatEdgeX123, greatEdgeZ222)
00223 greatFaceY222 = smallFaceY1
00224 greatFaceY322 = MakeQuad(greatEdgeX322, greatEdgeZ322, greatEdgeX323, greatEdgeZ422)
00225 
00226 greatFaceY113 = MakeQuad(greatEdgeX113, greatEdgeZ113, greatEdgeX114, greatEdgeZ213)
00227 greatFaceY213 = MakeQuad(greatEdgeX213, greatEdgeZ213, greatEdgeX214, greatEdgeZ313)
00228 greatFaceY313 = MakeQuad(greatEdgeX313, greatEdgeZ313, greatEdgeX314, greatEdgeZ413)
00229 greatFaceY123 = MakeQuad(greatEdgeX123, greatEdgeZ123, greatEdgeX124, greatEdgeZ223)
00230 greatFaceY223 = MakeQuad(greatEdgeX223, greatEdgeZ223, greatEdgeX224, greatEdgeZ323)
00231 greatFaceY323 = MakeQuad(greatEdgeX323, greatEdgeZ323, greatEdgeX324, greatEdgeZ423)
00232 
00233 greatFaceZ11 = MakeQuad(greatEdgeX111, greatEdgeY11, greatEdgeX121, greatEdgeY21)
00234 greatFaceZ21 = MakeQuad(greatEdgeX211, greatEdgeY21, greatEdgeX221, greatEdgeY31)
00235 greatFaceZ31 = MakeQuad(greatEdgeX311, greatEdgeY31, greatEdgeX321, greatEdgeY41)
00236 
00237 greatFaceZ12 = MakeQuad(greatEdgeX112, greatEdgeY12, greatEdgeX122, greatEdgeY22)
00238 greatFaceZ22 = MakeQuad(greatEdgeX212, greatEdgeY22, greatEdgeX222, greatEdgeY32)
00239 greatFaceZ32 = MakeQuad(greatEdgeX312, greatEdgeY32, greatEdgeX322, greatEdgeY42)
00240 
00241 greatFaceZ13 = MakeQuad(greatEdgeX113, greatEdgeY13, greatEdgeX123, greatEdgeY23)
00242 greatFaceZ23 = MakeQuad(greatEdgeX213, greatEdgeY23, greatEdgeX223, greatEdgeY33)
00243 greatFaceZ33 = MakeQuad(greatEdgeX313, greatEdgeY33, greatEdgeX323, greatEdgeY43)
00244 
00245 greatFaceZ14 = MakeQuad(greatEdgeX114, greatEdgeY14, greatEdgeX124, greatEdgeY24)
00246 greatFaceZ24 = MakeQuad(greatEdgeX214, greatEdgeY24, greatEdgeX224, greatEdgeY34)
00247 greatFaceZ34 = MakeQuad(greatEdgeX314, greatEdgeY34, greatEdgeX324, greatEdgeY44)
00248 
00249 # Solids
00250 # ------
00251 
00252 smallBlock   = MakeHexa(smallFaceX1, smallFaceX2, smallFaceY1, smallFaceY2, smallFaceZ1, smallFaceZ2)
00253 
00254 greatBlock11 = MakeHexa(greatFaceX11, greatFaceX21, greatFaceY111, greatFaceY121, greatFaceZ11, greatFaceZ12)
00255 greatBlock21 = MakeHexa(greatFaceX21, greatFaceX31, greatFaceY211, greatFaceY221, greatFaceZ21, greatFaceZ22)
00256 greatBlock31 = MakeHexa(greatFaceX31, greatFaceX41, greatFaceY311, greatFaceY321, greatFaceZ31, greatFaceZ32)
00257 
00258 greatBlock12 = MakeHexa(greatFaceX12, greatFaceX22, greatFaceY112, greatFaceY122, greatFaceZ12, greatFaceZ13)
00259 greatBlock22 = MakeHexa(greatFaceX22, greatFaceX32, greatFaceY212, greatFaceY222, greatFaceZ22, greatFaceZ23)
00260 greatBlock32 = MakeHexa(greatFaceX32, greatFaceX42, greatFaceY312, greatFaceY322, greatFaceZ32, greatFaceZ33)
00261 
00262 greatBlock13 = MakeHexa(greatFaceX13, greatFaceX23, greatFaceY113, greatFaceY123, greatFaceZ13, greatFaceZ14)
00263 greatBlock23 = MakeHexa(greatFaceX23, greatFaceX33, greatFaceY213, greatFaceY223, greatFaceZ23, greatFaceZ24)
00264 greatBlock33 = MakeHexa(greatFaceX33, greatFaceX43, greatFaceY313, greatFaceY323, greatFaceZ33, greatFaceZ34)
00265 
00266 # Compound
00267 # --------
00268 
00269 c_l = []
00270 c_l.append(smallBlock)
00271 c_l.append(greatBlock11)
00272 c_l.append(greatBlock21)
00273 c_l.append(greatBlock31)
00274 c_l.append(greatBlock12)
00275 c_l.append(greatBlock22)
00276 c_l.append(greatBlock32)
00277 c_l.append(greatBlock13)
00278 c_l.append(greatBlock23)
00279 c_l.append(greatBlock33)
00280 
00281 piece = MakeCompound(c_l)
00282 
00283 # Add in study
00284 # ------------
00285 
00286 piece_id = addToStudy(piece, "ex01_cube2build")
00287 
00288 # Meshing
00289 # =======
00290 
00291 smesh.SetCurrentStudy(salome.myStudy)
00292 
00293 # Create hexahedrical mesh on piece
00294 # ---------------------------------
00295 
00296 hexa = smesh.Mesh(piece, "ex01_cube2build:hexa")
00297 
00298 algo = hexa.Segment()
00299 algo.NumberOfSegments(4)
00300 
00301 hexa.Quadrangle()
00302 
00303 hexa.Hexahedron()
00304 
00305 # Create local hypothesis
00306 # -----------------------
00307 
00308 algo = hexa.Segment(greatEdgeX111)
00309 
00310 algo.Arithmetic1D(1, 4)
00311 
00312 algo.Propagation()
00313 
00314 # Compute the mesh
00315 # ----------------
00316 
00317 hexa.Compute()