Back to index

salome-smesh  6.5.0
SMESH_box_tetra.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 # Tetrahedrization of a simple box. Hypothesis and algorithms for
00025 # the mesh generation are global
00026 #
00027 import salome
00028 import geompy
00029 import smesh
00030 
00031 
00032 # ---- define a boxe
00033 
00034 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
00035 
00036 idbox = geompy.addToStudy(box, "box")
00037 
00038 print "Analysis of the geometry box :"
00039 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
00040 subFaceList  = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
00041 subEdgeList  = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
00042 
00043 print "number of Shells in box : ", len(subShellList)
00044 print "number of Faces  in box : ", len(subFaceList)
00045 print "number of Edges  in box : ", len(subEdgeList)
00046 
00047 
00048 ### ---------------------------- SMESH --------------------------------------
00049 smesh.SetCurrentStudy(salome.myStudy)
00050 
00051 # ---- init a Mesh with the boxe
00052 
00053 mesh = smesh.Mesh(box, "MeshBox")
00054 
00055 # ---- set Hypothesis and Algorithm
00056 
00057 print "-------------------------- NumberOfSegments"
00058 numberOfSegments = 10
00059 
00060 regular1D = mesh.Segment()
00061 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
00062 print hypNbSeg.GetName()
00063 print hypNbSeg.GetId()
00064 print hypNbSeg.GetNumberOfSegments()
00065 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
00066 
00067 print "-------------------------- MaxElementArea"
00068 
00069 maxElementArea = 500
00070 
00071 mefisto2D = mesh.Triangle()
00072 hypArea = mefisto2D.MaxElementArea(maxElementArea)
00073 print hypArea.GetName()
00074 print hypArea.GetId()
00075 print hypArea.GetMaxElementArea()
00076 smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
00077 
00078 print "-------------------------- MaxElementVolume"
00079 
00080 maxElementVolume = 500
00081 
00082 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
00083 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
00084 print hypVolume.GetName()
00085 print hypVolume.GetId()
00086 print hypVolume.GetMaxElementVolume()
00087 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
00088 
00089 salome.sg.updateObjBrowser(1)
00090 
00091 print "-------------------------- compute the mesh of the boxe"
00092 ret = mesh.Compute()
00093 print ret
00094 if ret != 0:
00095     log = mesh.GetLog(0) # no erase trace
00096     for linelog in log:
00097         print linelog
00098     print "Information about the MeshBox:"
00099     print "Number of nodes       : ", mesh.NbNodes()
00100     print "Number of edges       : ", mesh.NbEdges()
00101     print "Number of faces       : ", mesh.NbFaces()
00102     print "Number of triangles   : ", mesh.NbTriangles()
00103     print "Number of volumes     : ", mesh.NbVolumes()
00104     print "Number of tetrahedrons: ", mesh.NbTetras()
00105 else:
00106     print "probleme when computing the mesh"