Back to index

salome-smesh  6.5.0
ex11_grid3partition.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 # grid compound of 3 x 3 elements
00034 # an element is compound of 3 cylinders concentriques
00035 # an element is centered in a square of the grid
00036 # the smaller cylinder is a hole
00037 
00038 # prism the grid, and mesh it in hexahedral way
00039 
00040 # Values
00041 # ------
00042 
00043 g_x = 0
00044 g_y = 0
00045 g_z = 0
00046 
00047 g_arete   = 50
00048 g_hauteur = 30
00049 
00050 g_rayon1 = 20
00051 g_rayon2 = 30
00052 g_rayon3 = 40
00053 
00054 g_grid = 3
00055 
00056 g_trim = 1000
00057 
00058 # Element
00059 # -------
00060 
00061 e_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete,  g_x+g_arete, g_y+g_hauteur, g_z+g_arete)
00062 
00063 e_hauteur = 2*g_hauteur
00064 e_centre  = MakeVertex(g_x, g_y-g_hauteur, g_z)
00065 e_dir     = MakeVectorDXDYDZ(0, 1, 0)
00066 
00067 e_cyl1 = MakeCylinder(e_centre, e_dir, g_rayon3, e_hauteur)
00068 
00069 e_blo1 = MakeCut(e_boite, e_cyl1)
00070 
00071 e_cyl2 = MakeCylinder(e_centre, e_dir, g_rayon2, e_hauteur)
00072 
00073 e_blo2 = MakeCut(e_cyl1, e_cyl2)
00074 
00075 e_cyl3 = MakeCylinder(e_centre, e_dir, g_rayon1, e_hauteur)
00076 
00077 e_blo3 = MakeCut(e_cyl2, e_cyl3)
00078 
00079 # Partition and repair
00080 # --------------------
00081 
00082 p_tools = []
00083 p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim))
00084 p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim))
00085 
00086 p_part = MakePartition([e_blo1, e_blo2, e_blo3], p_tools, [], [], ShapeType["SOLID"])
00087 
00088 p_element = RemoveExtraEdges(p_part, doUnionFaces=True)
00089 
00090 # Grid and glue
00091 # -------------
00092 
00093 grid = MakeMultiTranslation2D(p_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
00094 
00095 piece = MakeGlueFaces(grid, 1e-5)
00096 
00097 # Add in study
00098 # ------------
00099 
00100 piece_id = addToStudy(piece, "ex11_grid3partition")
00101 
00102 # Meshing
00103 # =======
00104 
00105 smesh.SetCurrentStudy(salome.myStudy)
00106 
00107 # Create a hexahedral mesh
00108 # ------------------------
00109 
00110 hexa = smesh.Mesh(piece, "ex11_grid3partition:hexa")
00111 
00112 algo = hexa.Segment()
00113 algo.NumberOfSegments(3)
00114 
00115 hexa.Quadrangle()
00116 
00117 hexa.Hexahedron()
00118 
00119 # Mesh calculus
00120 # -------------
00121 
00122 hexa.Compute()