2 # Tetrahedrization of a simple box. Hypothesis and algorithms for
3 # the mesh generation are global
12 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
14 smeshgui = salome.ImportComponentGUI("SMESH")
15 smeshgui.Init(salome.myStudyId);
19 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
21 idbox = geompy.addToStudy(box, "box")
23 print "Analysis of the geometry box :"
24 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
25 subFaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
26 subEdgeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
28 print "number of Shells in box : ", len(subShellList)
29 print "number of Faces in box : ", len(subFaceList)
30 print "number of Edges in box : ", len(subEdgeList)
33 ### ---------------------------- SMESH --------------------------------------
35 # ---- create Hypothesis
37 print "-------------------------- create Hypothesis"
39 print "-------------------------- NumberOfSegments"
43 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
44 hypNbSeg.SetNumberOfSegments(numberOfSegments)
46 print hypNbSeg.GetName()
47 print hypNbSeg.GetId()
48 print hypNbSeg.GetNumberOfSegments()
50 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
52 print "-------------------------- MaxElementArea"
56 hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
57 hypArea.SetMaxElementArea(maxElementArea)
59 print hypArea.GetName()
61 print hypArea.GetMaxElementArea()
63 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
65 print "-------------------------- MaxElementVolume"
67 maxElementVolume = 500
69 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
70 hypVolume.SetMaxElementVolume(maxElementVolume)
72 print hypVolume.GetName()
73 print hypVolume.GetId()
74 print hypVolume.GetMaxElementVolume()
76 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
78 # ---- create Algorithms
80 print "-------------------------- create Algorithms"
82 print "-------------------------- Regular_1D"
84 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
85 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
87 print "-------------------------- MEFISTO_2D"
89 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
90 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
92 print "-------------------------- NETGEN_3D"
94 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
95 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
97 # ---- init a Mesh with the boxe
99 mesh = smesh.CreateMesh(box)
100 smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox")
102 # ---- add hypothesis to the boxe
104 print "-------------------------- add hypothesis to the box"
106 mesh.AddHypothesis(box,regular1D)
107 mesh.AddHypothesis(box,hypNbSeg)
109 mesh.AddHypothesis(box,mefisto2D)
110 mesh.AddHypothesis(box,hypArea)
112 mesh.AddHypothesis(box,netgen3D)
113 mesh.AddHypothesis(box,hypVolume)
115 salome.sg.updateObjBrowser(1)
117 print "-------------------------- compute the mesh of the boxe"
118 ret = smesh.Compute(mesh,box)
121 log = mesh.GetLog(0) # no erase trace
124 print "Information about the MeshBox:"
125 print "Number of nodes : ", mesh.NbNodes()
126 print "Number of edges : ", mesh.NbEdges()
127 print "Number of faces : ", mesh.NbFaces()
128 print "Number of triangles : ", mesh.NbTriangles()
129 print "Number of volumes : ", mesh.NbVolumes()
130 print "Number of tetrahedrons: ", mesh.NbTetras()
132 print "probleme when computing the mesh"