2 # Tetrahedrization of the geometry generated by the Python script
4 # Hypothesis and algorithms for the mesh generation are global
11 compshell = SMESH_fixation.compshell
12 idcomp = SMESH_fixation.idcomp
13 geompy = SMESH_fixation.geompy
14 salome = SMESH_fixation.salome
15 sg = SMESH_fixation.sg
21 print "Analysis of the geometry to be meshed :"
22 subShellList=geompy.SubShapeAll(compshell,ShapeTypeShell)
23 subFaceList=geompy.SubShapeAll(compshell,ShapeTypeFace)
24 subEdgeList=geompy.SubShapeAll(compshell,ShapeTypeEdge)
26 print "number of Shells in compshell : ",len(subShellList)
27 print "number of Faces in compshell : ",len(subFaceList)
28 print "number of Edges in compshell : ",len(subEdgeList)
30 status=geompy.CheckShape(compshell)
31 print " check status ", status
35 smeshgui = salome.ImportComponentGUI("SMESH")
36 smeshgui.Init(salome.myStudyId)
40 ### ---- create Hypothesis
42 print "-------------------------- create Hypothesis"
44 print "-------------------------- NumberOfSegments"
48 hypothesis=gen.CreateHypothesis("NumberOfSegments")
49 hypNbSeg=hypothesis._narrow(SMESH.SMESH_NumberOfSegments)
50 hypNbSeg.SetNumberOfSegments(numberOfSegments)
51 hypNbSegID = hypNbSeg.GetId()
52 print hypNbSeg.GetName()
54 print hypNbSeg.GetNumberOfSegments()
56 idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
57 smeshgui.SetName(idseg, "NumberOfSegments")
59 print "-------------------------- MaxElementArea"
63 hypothesis=gen.CreateHypothesis("MaxElementArea")
64 hypArea=hypothesis._narrow(SMESH.SMESH_MaxElementArea)
65 hypArea.SetMaxElementArea(maxElementArea)
66 print hypArea.GetName()
68 print hypArea.GetMaxElementArea()
70 idarea = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea) )
71 smeshgui.SetName(idarea, "MaxElementArea")
73 print "-------------------------- MaxElementVolume"
75 maxElementVolume = 150
77 hypothesis=gen.CreateHypothesis("MaxElementVolume")
78 hypVolume=hypothesis._narrow(SMESH.SMESH_MaxElementVolume)
79 hypVolume.SetMaxElementVolume(maxElementVolume)
80 print hypVolume.GetName()
81 print hypVolume.GetId()
82 print hypVolume.GetMaxElementVolume()
84 idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
85 smeshgui.SetName(idvolume, "MaxElementVolume")
87 # ---- create Algorithms
89 print "-------------------------- create Algorithms"
91 print "-------------------------- Regular_1D"
93 hypothesis=gen.CreateHypothesis("Regular_1D")
94 regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
95 regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
96 smeshgui.SetName(regularID, "Wire Discretisation")
98 print "-------------------------- MEFISTO_2D"
100 hypothesis=gen.CreateHypothesis("MEFISTO_2D")
101 mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
102 mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
103 smeshgui.SetName(mefistoID, "MEFISTO_2D")
105 print "-------------------------- NETGEN_3D"
107 hypothesis=gen.CreateHypothesis("NETGEN_3D")
108 netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
109 netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
110 smeshgui.SetName(netgenID, "NETGEN_3D")
112 # ---- init a Mesh with the compshell
114 mesh=gen.Init(idcomp)
115 idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
116 smeshgui.SetName(idmesh, "MeshcompShell")
117 smeshgui.SetShape(idcomp, idmesh)
119 # ---- add hypothesis to compshell
121 print "-------------------------- add hypothesis to compshell"
123 ret=mesh.AddHypothesis(compshell,regular1D)
125 ret=mesh.AddHypothesis(compshell,hypNbSeg)
127 ret=mesh.AddHypothesis(compshell,mefisto2D)
129 ret=mesh.AddHypothesis(compshell,hypArea)
131 ret=mesh.AddHypothesis(compshell,netgen3D)
133 ret=mesh.AddHypothesis(compshell,hypVolume)
136 smeshgui.SetAlgorithms( idmesh, regularID)
137 smeshgui.SetHypothesis( idmesh, idseg )
138 smeshgui.SetAlgorithms( idmesh, mefistoID )
139 smeshgui.SetHypothesis( idmesh, idarea )
140 smeshgui.SetAlgorithms( idmesh, netgenID )
141 smeshgui.SetHypothesis( idmesh, idvolume )
143 sg.updateObjBrowser(1)
145 print "-------------------------- compute compshell"
146 ret=gen.Compute(mesh,idcomp)
149 log=mesh.GetLog(0) # no erase trace
153 print "problem when computing the mesh"
155 sg.updateObjBrowser(1)