Back to index

salome-smesh  6.5.0
SMESH_fixation_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 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 
00053 mesh = smesh.Mesh(compshell, "MeshcompShell")
00054 
00055 
00056 # ---- set Hypothesis and Algorithm
00057 
00058 print "-------------------------- NumberOfSegments"
00059 
00060 numberOfSegments = 5
00061 
00062 regular1D = mesh.Segment()
00063 regular1D.SetName("Wire Discretisation")
00064 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
00065 print hypNbSeg.GetName()
00066 print hypNbSeg.GetId()
00067 print hypNbSeg.GetNumberOfSegments()
00068 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
00069 
00070 ## print "-------------------------- MaxElementArea"
00071 
00072 ## maxElementArea = 80
00073 
00074 ## mefisto2D = mesh.Triangle()
00075 ## mefisto2D.SetName("MEFISTO_2D")
00076 ## hypArea = mefisto2D.MaxElementArea(maxElementArea)
00077 ## print hypArea.GetName()
00078 ## print hypArea.GetId()
00079 ## print hypArea.GetMaxElementArea()
00080 ## smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
00081 
00082 print "-------------------------- LengthFromEdges"
00083 
00084 mefisto2D = mesh.Triangle()
00085 mefisto2D.SetName("MEFISTO_2D")
00086 hypLengthFromEdges = mefisto2D.LengthFromEdges()
00087 print hypLengthFromEdges.GetName()
00088 print hypLengthFromEdges.GetId()
00089 smesh.SetName(hypLengthFromEdges, "LengthFromEdges")
00090 
00091 
00092 print "-------------------------- MaxElementVolume"
00093 
00094 maxElementVolume = 1000
00095 
00096 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
00097 netgen3D.SetName("NETGEN_3D")
00098 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
00099 print hypVolume.GetName()
00100 print hypVolume.GetId()
00101 print hypVolume.GetMaxElementVolume()
00102 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
00103 
00104 
00105 salome.sg.updateObjBrowser(1)
00106 
00107 print "-------------------------- compute compshell"
00108 ret = mesh.Compute(mesh)
00109 print ret
00110 if ret != 0:
00111     log = mesh.GetLog(0) # no erase trace
00112     for linelog in log:
00113         print linelog
00114     print "Information about the MeshcompShel:"
00115     print "Number of nodes        : ", mesh.NbNodes()
00116     print "Number of edges        : ", mesh.NbEdges()
00117     print "Number of faces        : ", mesh.NbFaces()
00118     print "Number of triangles    : ", mesh.NbTriangles()
00119     print "Number of volumes      : ", mesh.NbVolumes()
00120     print "Number of tetrahedrons : ", mesh.NbTetras()
00121     
00122 else:
00123     print "problem when computing the mesh"