Back to index

salome-smesh  6.5.0
ex09_grid4build.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 import math
00031 
00032 # Geometry
00033 # ========
00034 
00035 # Element of a grid compound by a square with a cylinder on each vertex build by points, edges, faces and solids
00036 
00037 # Values
00038 # ------
00039 
00040 ox = 0
00041 oy = 0
00042 oz = 0
00043 
00044 arete   =  50
00045 hauteur = 100
00046 
00047 rayon = 10
00048 
00049 demi = rayon/2
00050 r3   = demi*math.sqrt(3)
00051 
00052 # Points
00053 # ------
00054 
00055 piecePoint111 = MakeVertex(ox+rayon      , oy, oz)
00056 piecePoint211 = MakeVertex(ox+arete-rayon, oy, oz)
00057 piecePoint112 = MakeVertex(ox            , oy, oz+rayon)
00058 piecePoint212 = MakeVertex(ox+arete      , oy, oz+rayon)
00059 piecePoint113 = MakeVertex(ox            , oy, oz+arete-rayon)
00060 piecePoint213 = MakeVertex(ox+arete      , oy, oz+arete-rayon)
00061 piecePoint114 = MakeVertex(ox+rayon      , oy, oz+arete)
00062 piecePoint214 = MakeVertex(ox+arete-rayon, oy, oz+arete)
00063 
00064 pieceCenter1  = MakeVertex(ox            , oy, oz)
00065 pieceCenter2  = MakeVertex(ox+arete      , oy, oz)
00066 pieceCenter3  = MakeVertex(ox            , oy, oz+arete)
00067 pieceCenter4  = MakeVertex(ox+arete      , oy, oz+arete)
00068 
00069 piecePass1    = MakeVertex(ox+demi       , oy, oz+r3)
00070 piecePass2    = MakeVertex(ox+arete-demi , oy, oz+r3)
00071 piecePass3    = MakeVertex(ox+arete-demi , oy, oz+arete-r3)
00072 piecePass4    = MakeVertex(ox+demi       , oy, oz+arete-r3)
00073 
00074 # Edges
00075 # -----
00076 
00077 pieceEdgeSquare1   = MakeEdge(piecePoint111, piecePoint211)
00078 pieceEdgeSquare2   = MakeEdge(piecePoint114, piecePoint214)
00079 pieceEdgeSquare3   = MakeEdge(piecePoint112, piecePoint113)
00080 pieceEdgeSquare4   = MakeEdge(piecePoint212, piecePoint213)
00081 
00082 pieceEdgeDiagonal1 = MakeEdge(piecePoint111, piecePoint213)
00083 pieceEdgeDiagonal2 = MakeEdge(piecePoint112, piecePoint214)
00084 
00085 pieceEdgeArc1 = MakeArc(piecePoint111, piecePass1, piecePoint112)
00086 pieceEdgeArc2 = MakeArc(piecePoint211, piecePass2, piecePoint212)
00087 pieceEdgeArc3 = MakeArc(piecePoint213, piecePass3, piecePoint214)
00088 pieceEdgeArc4 = MakeArc(piecePoint113, piecePass4, piecePoint114)
00089 
00090 # Faces
00091 # -----
00092 
00093 pieceFace1 = MakeQuad(pieceEdgeSquare1, pieceEdgeArc2, pieceEdgeSquare4, pieceEdgeDiagonal1)
00094 pieceFace2 = MakeQuad(pieceEdgeSquare2, pieceEdgeArc4, pieceEdgeSquare3, pieceEdgeDiagonal2)
00095 
00096 pieceFace3 = MakeQuad(pieceEdgeArc1, pieceEdgeDiagonal1, pieceEdgeArc3, pieceEdgeDiagonal2)
00097 
00098 # Solids
00099 # ------
00100 
00101 pieceVector = MakeVectorDXDYDZ(0, 1, 0)
00102 
00103 pieceSolid1 = MakePrismVecH(pieceFace1, pieceVector, hauteur)
00104 pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur)
00105 pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur)
00106 
00107 # Compound and glue
00108 # -----------------
00109 
00110 c_cpd = MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3])
00111 
00112 piece = MakeGlueFaces(c_cpd, 1.e-5)
00113 
00114 # Add in study
00115 # ------------
00116 
00117 piece_id = addToStudy(piece, "ex09_grid4build")
00118 
00119 # Meshing
00120 # =======
00121 
00122 smesh.SetCurrentStudy(salome.myStudy)
00123 
00124 # Create a hexahedral mesh
00125 # ------------------------
00126 
00127 hexa = smesh.Mesh(piece, "ex09_grid4build:hexa")
00128 
00129 algo = hexa.Segment()
00130 algo.NumberOfSegments(6)
00131 
00132 hexa.Quadrangle()
00133 
00134 hexa.Hexahedron()
00135 
00136 # Mesh calculus
00137 # -------------
00138 
00139 hexa.Compute()