Back to index

salome-smesh  6.5.0
ex18_dome2.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 # Geometrie
00033 # =========
00034 
00035 # Creer un cylindre ayant a chaque bout un morceau de sphere et le tout troue par un petit cylindrique excentre.
00036 # Decouper en hexahedre et mailler.
00037 
00038 # Donnees
00039 # -------
00040 
00041 # unite: millimetre
00042 
00043 g_ox = 0
00044 g_oy = 0
00045 g_oz = 0
00046 
00047 g_cyl_rayon       = 1000
00048 g_cyl_demiHauteur = 3000
00049 
00050 g_trou_rayon       =   5
00051 g_trou_centre      = 300
00052 
00053 g_sphere_rayon = 3500
00054 
00055 g_trim = 15000
00056 
00057 # Cylindre
00058 # --------
00059 
00060 c_point    = MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
00061 c_dir      = MakeVectorDXDYDZ(0, 0, 1)
00062 c_hauteur  = 2*g_cyl_demiHauteur
00063 
00064 c_cylindre = MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
00065 
00066 # Sphere
00067 # ------
00068 
00069 s_hauteur = math.sqrt(g_sphere_rayon*g_sphere_rayon - g_cyl_rayon*g_cyl_rayon) - g_cyl_demiHauteur
00070 
00071 s_sphere  = MakeSphere(g_ox, g_oy, g_oz-s_hauteur, g_sphere_rayon)
00072 
00073 # Calottes
00074 # --------
00075 
00076 c_outils = []
00077 c_outils.append(MakePlane(MakeVertex(g_ox, g_oy, g_oz+g_cyl_demiHauteur), MakeVectorDXDYDZ(0, 0, 1), g_trim))
00078 
00079 c_cpd = MakePartition([s_sphere], c_outils, [], [], ShapeType["SOLID"])
00080 c_calotte_haut, c_reste = SubShapeAllSorted(c_cpd, ShapeType["SOLID"])
00081 
00082 c_plan = MakePlane(MakeVertex(g_ox, g_oy, g_oz), MakeVectorDXDYDZ(0, 0, 1), g_trim)
00083 c_calotte_bas = MakeMirrorByPlane(c_calotte_haut, c_plan)
00084 
00085 # Fusionner
00086 # ---------
00087 
00088 f_piece1 = MakeFuse(c_cylindre, c_calotte_haut)
00089 f_piece  = MakeFuse(f_piece1, c_calotte_bas)
00090 
00091 # Trouer
00092 # ------
00093 
00094 t_hauteur = g_sphere_rayon
00095 t_point   = MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
00096 t_trou    = MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
00097 
00098 t_piece   = MakeCut(f_piece, t_trou)
00099 
00100 # Decouper
00101 # --------
00102 
00103 h_outils = []
00104 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(1, 0, 0), g_trim))
00105 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(0, 1, 0), g_trim))
00106 
00107 h_piece = MakePartition([t_piece], h_outils, [], [], ShapeType["SOLID"])
00108 
00109 # Reparer
00110 # -------
00111 
00112 piece = RemoveExtraEdges(h_piece)
00113 
00114 # Ajouter la piece dans l'etude
00115 # -----------------------------
00116 
00117 piece_id = addToStudy(piece, "ex18_dome2")
00118 
00119 # Maillage
00120 # ========
00121 
00122 smesh.SetCurrentStudy(salome.myStudy)
00123 
00124 # Maillage hexahedrique
00125 # ---------------------
00126 
00127 hexa = smesh.Mesh(piece, "ex18_dome2:hexa")
00128 
00129 algo = hexa.Segment()
00130 algo.NumberOfSegments(2)
00131 
00132 hexa.Quadrangle()
00133 
00134 hexa.Hexahedron()
00135 
00136 # Calcul du maillage
00137 # ------------------
00138 
00139 hexa.Compute()