Back to index

salome-smesh  6.5.0
SMESH_fixation_hexa.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 # Hexahedrization of the geometry generated by the Python script
00025 # SMESH_fixation.py
00026 # Hypothesis and algorithms for the mesh generation are global
00027 #
00028 import SMESH_fixation
00029 import smesh
00030 
00031 compshell = SMESH_fixation.compshell
00032 idcomp = SMESH_fixation.idcomp
00033 geompy = SMESH_fixation.geompy
00034 salome = SMESH_fixation.salome
00035 
00036 print "Analysis of the geometry to be meshed :"
00037 subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"])
00038 subFaceList  = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
00039 subEdgeList  = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
00040 
00041 print "number of Shells in compshell : ", len(subShellList)
00042 print "number of Faces  in compshell : ", len(subFaceList)
00043 print "number of Edges  in compshell : ", len(subEdgeList)
00044 
00045 status = geompy.CheckShape(compshell)
00046 print " check status ", status
00047 
00048 ### ---------------------------- SMESH --------------------------------------
00049 smesh.SetCurrentStudy(salome.myStudy)
00050 
00051 # ---- init a Mesh with the compshell
00052 shape_mesh = salome.IDToObject( idcomp  )
00053 
00054 mesh = smesh.Mesh(shape_mesh, "MeshCompShell")
00055 
00056 
00057 # ---- set Hypothesis and Algorithm
00058 
00059 print "-------------------------- NumberOfSegments"
00060 
00061 numberOfSegments = 5
00062 
00063 regular1D = mesh.Segment()
00064 regular1D.SetName("Wire Discretisation")
00065 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
00066 print hypNbSeg.GetName()
00067 print hypNbSeg.GetId()
00068 print hypNbSeg.GetNumberOfSegments()
00069 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
00070 
00071 print "-------------------------- Quadrangle_2D"
00072 
00073 quad2D = mesh.Quadrangle()
00074 quad2D.SetName("Quadrangle_2D")
00075 
00076 print "-------------------------- Hexa_3D"
00077 
00078 hexa3D = mesh.Hexahedron()
00079 hexa3D.SetName("Hexa_3D")
00080 
00081 
00082 salome.sg.updateObjBrowser(1)
00083 
00084 print "-------------------------- compute compshell"
00085 ret = mesh.Compute()
00086 print ret
00087 if ret != 0:
00088     log = mesh.GetLog(0) # no erase trace
00089     for linelog in log:
00090         print linelog
00091     print "Information about the MeshcompShel:"
00092     print "Number of nodes       : ", mesh.NbNodes()
00093     print "Number of edges       : ", mesh.NbEdges()
00094     print "Number of faces       : ", mesh.NbFaces()
00095     print "Number of quadrangles : ", mesh.NbQuadrangles()
00096     print "Number of volumes     : ", mesh.NbVolumes()
00097     print "Number of hexahedrons : ", mesh.NbHexas()
00098 else:
00099     print "problem when Computing the mesh"