Back to index

salome-smesh  6.5.0
ex16_cyl2complementary.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 # Create the hexahedrical block geometry of a holed parallelepipede.
00034 # The hole has a T form composed by 2 cylinders with different radius, and their axis are normal.
00035 # This piece is meshed in hexahedrical.
00036 
00037 # Values
00038 # ------
00039 
00040 gx = 0
00041 gy = 0
00042 gz = 0
00043 
00044 g_dx = 250
00045 g_dy = 200
00046 g_dz = 150
00047 
00048 g_rayonGrand = 70
00049 g_rayonPetit = 50
00050 
00051 g_trim = 1000
00052 
00053 # The parallelepipede
00054 # -------------------
00055 
00056 p_boite = MakeBox(gx-g_dx, gy-g_dy, gz-g_dz,  gx+g_dx, gy+g_dy, gz+g_dz)
00057 
00058 # The great cylinder
00059 # ------------------
00060 
00061 g_base = MakeVertex(gx-g_dx, gy, gz)
00062 g_dir  = MakeVectorDXDYDZ(1, 0, 0)
00063 g_cyl  = MakeCylinder(g_base, g_dir, g_rayonGrand, g_dx*2)
00064 
00065 # The first hole
00066 # --------------
00067 
00068 b_boite = MakeCut(p_boite , g_cyl)
00069 
00070 # Partitioning
00071 # ------------
00072 
00073 p_base = MakeVertex(gx, gy, gz)
00074 
00075 p_tools = []
00076 
00077 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0,  1   , 0   ), g_trim))
00078 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0,  g_dz, g_dy), g_trim))
00079 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0, -g_dz, g_dy), g_trim))
00080 
00081 p_tools.append(MakePlane(MakeVertex(gx-g_rayonPetit, gy, gz), g_dir, g_trim))
00082 p_tools.append(MakePlane(MakeVertex(gx+g_rayonPetit, gy, gz), g_dir, g_trim))
00083 
00084 p_piece = MakePartition([b_boite], p_tools, [], [], ShapeType["SOLID"])
00085 
00086 # The small cylinder
00087 # ------------------
00088 
00089 c_cyl = MakeCylinder(p_base, MakeVectorDXDYDZ(0, 0, 1), g_rayonPetit, g_dz)
00090 
00091 # The second hole
00092 # ---------------
00093 
00094 d_element = SubShapeAllSorted(p_piece, ShapeType["SOLID"])
00095 
00096 d_element[ 8] = MakeCut(d_element[ 8], c_cyl)
00097 d_element[10] = MakeCut(d_element[10], c_cyl)
00098 
00099 # Compound
00100 # --------
00101 
00102 piece = RemoveExtraEdges(MakeCompound(d_element))
00103 piece = MakeGlueFaces(piece, 1e-07)
00104 
00105 # Add piece in study
00106 # ------------------
00107 
00108 piece_id = addToStudy(piece, "ex16_cyl2complementary")
00109 
00110 # Meshing
00111 # =======
00112 
00113 smesh.SetCurrentStudy(salome.myStudy)
00114 
00115 # Create a hexahedral mesh
00116 # ------------------------
00117 
00118 hexa = smesh.Mesh(piece, "ex16_cyl2complementary:hexa")
00119 
00120 algo = hexa.Segment()
00121 algo.NumberOfSegments(12)
00122 
00123 hexa.Quadrangle()
00124 
00125 hexa.Hexahedron()
00126 
00127 # Define local hypothesis
00128 # -----------------------
00129 
00130 def local(x, y, z, d):
00131     edge = GetEdgeNearPoint(piece, MakeVertex(x, y, z))
00132     algo = hexa.Segment(edge)
00133     algo.NumberOfSegments(d)
00134     algo.Propagation()
00135 
00136 local(gx     , gy+g_dy, gz+g_dz, 7)
00137 local(gx+g_dx, gy+g_dy, gz     , 21)
00138 local(gx+g_dx, gy-g_dy, gz     , 21)
00139 
00140 # Mesh calculus
00141 # -------------
00142 
00143 hexa.Compute()