Back to index

salome-smesh  6.5.0
ex04_cube5tetraHexa.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 # 5 box with a hexahedral mesh and with 2 box in tetrahedral mesh
00034 
00035 # Values
00036 # ------
00037 
00038 arete = 100
00039 
00040 arete0 = 0
00041 arete1 = arete
00042 arete2 = arete*2
00043 arete3 = arete*3
00044 
00045 # Solids
00046 # ------
00047 
00048 box_tetra1 = MakeBox(arete0, arete0, 0,  arete1, arete1, arete)
00049 
00050 box_ijk1   = MakeBox(arete1, arete0, 0,  arete2, arete1, arete)
00051 
00052 box_hexa   = MakeBox(arete1, arete1, 0,  arete2, arete2, arete)
00053 
00054 box_ijk2   = MakeBox(arete2, arete1, 0,  arete3, arete2, arete)
00055 
00056 box_tetra2 = MakeBox(arete2, arete2, 0,  arete3 ,arete3, arete)
00057 
00058 # Piece
00059 # -----
00060 
00061 piece_cpd = MakeCompound([box_tetra1, box_ijk1, box_hexa, box_ijk2, box_tetra2])
00062 
00063 piece = MakeGlueFaces(piece_cpd, 1e-4)
00064 
00065 piece_id = addToStudy(piece, "ex04_cube5tetraHexa")
00066 
00067 # Meshing
00068 # =======
00069 
00070 smesh.SetCurrentStudy(salome.myStudy)
00071 
00072 # Create a hexahedral mesh
00073 # ------------------------
00074 
00075 mixed = smesh.Mesh(piece, "ex04_cube5tetraHexa:mixed")
00076 
00077 algo = mixed.Segment()
00078 
00079 algo.StartEndLength(3, 25)
00080 
00081 mixed.Quadrangle()
00082 
00083 mixed.Hexahedron()
00084 
00085 # Tetrahedral local mesh
00086 # ----------------------
00087 
00088 def localMesh(b, hyp):
00089     box   = GetInPlace(piece, b)
00090     faces = SubShapeAll(box, ShapeType["FACE"])
00091 
00092     i = 0
00093     n = len(faces)
00094     while i<n:
00095         algo = mixed.Triangle(faces[i])
00096         if hyp:
00097             algo.MaxElementArea(80)
00098         else:
00099             algo.LengthFromEdges()
00100         i = i + 1
00101 
00102     algo = mixed.Tetrahedron(smesh.NETGEN, box)
00103     algo.MaxElementVolume(400)
00104 
00105 localMesh(box_tetra1, 1)
00106 localMesh(box_tetra2, 0)
00107 
00108 # Mesh calculus
00109 # -------------
00110 
00111 mixed.Compute()