1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/
21 # Tetrahedrization of the geometry generated by the Python script
23 # Hypothesis and algorithms for the mesh generation are global
30 compshell = SMESH_fixation.compshell
31 idcomp = SMESH_fixation.idcomp
32 geompy = SMESH_fixation.geompy
33 salome = SMESH_fixation.salome
35 print "Analysis of the geometry to be meshed :"
36 subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"])
37 subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"])
38 subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"])
40 print "number of Shells in compshell : ", len(subShellList)
41 print "number of Faces in compshell : ", len(subFaceList)
42 print "number of Edges in compshell : ", len(subEdgeList)
44 status = geompy.CheckShape(compshell)
45 print " check status ", status
47 ### ---------------------------- SMESH --------------------------------------
48 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
50 smeshgui = salome.ImportComponentGUI("SMESH")
51 smeshgui.Init(salome.myStudyId)
53 print "-------------------------- create Hypothesis"
55 print "-------------------------- NumberOfSegments"
59 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
60 hypNbSeg.SetNumberOfSegments(numberOfSegments)
62 print hypNbSeg.GetName()
63 print hypNbSeg.GetId()
64 print hypNbSeg.GetNumberOfSegments()
66 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_5")
68 print "-------------------------- MaxElementArea"
70 ## maxElementArea = 80
72 ## hypArea=smesh.CreateHypothesis("MaxElementArea")
73 ## hypArea.SetMaxElementArea(maxElementArea)
74 ## print hypArea.GetName()
75 ## print hypArea.GetId()
76 ## print hypArea.GetMaxElementArea()
77 ## smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_160")
79 hypLengthFromEdges = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
80 smeshgui.SetName(salome.ObjectToID(hypLengthFromEdges), "LengthFromEdges")
83 print "-------------------------- MaxElementVolume"
85 maxElementVolume = 1000
87 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
88 hypVolume.SetMaxElementVolume(maxElementVolume)
90 print hypVolume.GetName()
91 print hypVolume.GetId()
92 print hypVolume.GetMaxElementVolume()
94 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_1000")
96 print "-------------------------- create Algorithms"
98 print "-------------------------- Regular_1D"
100 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
102 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
104 print "-------------------------- MEFISTO_2D"
106 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
108 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
110 print "-------------------------- NETGEN_3D"
112 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
114 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
116 # ---- init a Mesh with the compshell
118 mesh = smesh.CreateMesh(compshell)
119 smeshgui.SetName(salome.ObjectToID(mesh), "MeshcompShel")
121 print "-------------------------- add hypothesis to compshell"
123 mesh.AddHypothesis(compshell,regular1D)
124 mesh.AddHypothesis(compshell,hypNbSeg)
126 mesh.AddHypothesis(compshell,mefisto2D)
127 mesh.AddHypothesis(compshell,hypLengthFromEdges)
129 mesh.AddHypothesis(compshell,netgen3D)
130 mesh.AddHypothesis(compshell,hypVolume)
132 salome.sg.updateObjBrowser(1)
134 print "-------------------------- compute compshell"
135 ret = smesh.Compute(mesh,compshell)
138 log = mesh.GetLog(0) # no erase trace
141 print "Information about the MeshcompShel:"
142 print "Number of nodes : ", mesh.NbNodes()
143 print "Number of edges : ", mesh.NbEdges()
144 print "Number of faces : ", mesh.NbFaces()
145 print "Number of triangles : ", mesh.NbTriangles()
146 print "Number of volumes : ", mesh.NbVolumes()
147 print "Number of tetrahedrons : ", mesh.NbTetras()
150 print "problem when computing the mesh"