Back to index

salome-smesh  6.5.0
ex14_cyl1holed.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 # Geometrie
00031 # =========
00032 
00033 # Creer un cylindre avec un trou cylindrique excentre, decoupage en hexahedre et mailler.
00034 
00035 # Donnees
00036 # -------
00037 
00038 # unite: millimetre
00039 
00040 g_ox = 0
00041 g_oy = 0
00042 g_oz = 0
00043 
00044 g_cyl_rayon       = 1000
00045 g_cyl_demiHauteur = 3000
00046 
00047 g_trou_rayon       =   5
00048 g_trou_centre      = 300
00049 
00050 g_trim = 15000
00051 
00052 # Construire le cylindre
00053 # ----------------------
00054 
00055 c_point    = MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
00056 c_dir      = MakeVectorDXDYDZ(0, 0, 1)
00057 c_hauteur  = 2*g_cyl_demiHauteur
00058 c_cylindre = MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
00059 
00060 # Trouer le cylindre par un minuscule cylindre excentre
00061 # -----------------------------------------------------
00062 
00063 t_hauteur = g_cyl_demiHauteur
00064 t_point   = MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
00065 t_trou    = MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
00066 
00067 t_piece   = MakeCut(c_cylindre, t_trou)
00068 
00069 # Geometrie hexahedrique
00070 # ======================
00071 
00072 # Decouper
00073 # --------
00074 
00075 h_outils = []
00076 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(1, 0, 0), g_trim))
00077 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(0, 1, 0), g_trim))
00078 
00079 h_piece = MakePartition([t_piece], h_outils, [], [], ShapeType["SOLID"])
00080 
00081 # Decouper pour les conditions locales
00082 # ------------------------------------
00083 
00084 l_outils = []
00085 l_i = 1
00086 l_n = 12
00087 l_hauteur = c_hauteur/l_n
00088 
00089 while l_i<l_n:
00090     l_outils.append(MakePlane(MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur+l_i*l_hauteur), c_dir, g_trim))
00091     l_i = l_i+1
00092 
00093 piece = MakePartition([h_piece], l_outils, [], [], ShapeType["SOLID"])
00094 
00095 # Ajouter la piece dans l'etude
00096 # -----------------------------
00097 
00098 piece_id = addToStudy(piece, "ex14_cyl1holed")
00099 
00100 # Maillage
00101 # ========
00102 
00103 smesh.SetCurrentStudy(salome.myStudy)
00104 
00105 # Creer un maillage hexahedrique
00106 # ------------------------------
00107 
00108 hexa = smesh.Mesh(piece, "ex14_cyl1holed:hexa")
00109 
00110 algo = hexa.Segment()
00111 algo.NumberOfSegments(4)
00112 
00113 hexa.Quadrangle()
00114 
00115 hexa.Hexahedron()
00116 
00117 # Poser les hypotheses locales
00118 # ----------------------------
00119 
00120 m_i = 0
00121 m_n = 12
00122 m_h = c_hauteur/m_n
00123 m_d = [4, 6, 8, 10, 10, 9, 8, 7, 6, 5, 4, 3]
00124 
00125 m_x = g_ox+g_cyl_rayon
00126 m_y = g_oy
00127 m_z = g_oz-g_cyl_demiHauteur+m_h/2
00128 
00129 while m_i<m_n:
00130     m_p = MakeVertex(m_x, m_y, m_z + m_i*m_h)
00131     m_e = GetEdgeNearPoint(piece, m_p)
00132     m_a = hexa.Segment(m_e)
00133     m_a.NumberOfSegments(m_d[m_i])
00134     m_a.Propagation()
00135     m_i = m_i + 1
00136 
00137 # Calculer le maillage
00138 # --------------------
00139 
00140 hexa.Compute()