Back to index

salome-smesh  6.5.0
ex10_grid4geometry.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 # Element of a grid compound by a square with a cylinder on each vertex build by using partition
00034 
00035 # Values
00036 # ------
00037 
00038 ox = 0
00039 oy = 0
00040 oz = 0
00041 
00042 arete   =  50
00043 hauteur = 100
00044 rayon   =  10
00045 
00046 g_trim = 1000
00047 
00048 # Box
00049 # ---
00050 
00051 piecePoint = MakeVertex(ox, oy, oz)
00052 
00053 pieceBox = MakeBoxTwoPnt(piecePoint, MakeVertex(ox+arete, oy+hauteur, oz+arete))
00054 
00055 # Cut by cylinders
00056 # ----------------
00057 
00058 dirUp = MakeVectorDXDYDZ(0, 1, 0)
00059 
00060 pieceCut1 = MakeCut(pieceBox , MakeCylinder(piecePoint                        , dirUp, rayon, hauteur))
00061 pieceCut2 = MakeCut(pieceCut1, MakeCylinder(MakeVertex(ox+arete, oy, oz      ), dirUp, rayon, hauteur))
00062 pieceCut3 = MakeCut(pieceCut2, MakeCylinder(MakeVertex(ox      , oy, oz+arete), dirUp, rayon, hauteur))
00063 pieceCut4 = MakeCut(pieceCut3, MakeCylinder(MakeVertex(ox+arete, oy, oz+arete), dirUp, rayon, hauteur))
00064 
00065 # Compound by make a partition of a solid
00066 # ---------------------------------------
00067 
00068 dir = MakeVectorDXDYDZ(-1, 0, 1)
00069 
00070 tools = []
00071 tools.append(MakePlane(MakeVertex(ox+rayon, oy, oz      ), dir, g_trim))
00072 tools.append(MakePlane(MakeVertex(ox      , oy, oz+rayon), dir, g_trim))
00073 
00074 piece = MakePartition([pieceCut4], tools, [], [], ShapeType["SOLID"])
00075 
00076 # Add in study
00077 # ------------
00078 
00079 piece_id = addToStudy(piece, "ex10_grid4geometry")
00080 
00081 # Meshing
00082 # =======
00083 
00084 smesh.SetCurrentStudy(salome.myStudy)
00085 
00086 # Create a hexahedral mesh
00087 # ------------------------
00088 
00089 hexa = smesh.Mesh(piece, "ex10_grid4geometry:hexa")
00090 
00091 algo = hexa.Segment()
00092 algo.NumberOfSegments(10)
00093 
00094 hexa.Quadrangle()
00095 
00096 hexa.Hexahedron()
00097 
00098 # Mesh calculus
00099 # -------------
00100 
00101 hexa.Compute()