2 # Tetrahedrization of the geometry union of 3 boxes aligned where the middle
3 # one has a race in common with the two others.
4 # Hypothesis and algorithms for the mesh generation are global
13 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
15 smeshgui = salome.ImportComponentGUI("SMESH")
16 smeshgui.Init(salome.myStudyId);
18 # ---- define 3 boxes box1, box2 and box3
20 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
22 idbox1 = geompy.addToStudy(box1, "box1")
24 print "Analysis of the geometry box1 :"
25 subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"])
26 subFaceList = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
27 subEdgeList = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"])
29 print "number of Shells in box1 : ", len(subShellList)
30 print "number of Faces in box1 : ", len(subFaceList)
31 print "number of Edges in box1 : ", len(subEdgeList)
33 box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.)
35 idbox2 = geompy.addToStudy(box2, "box2")
37 print "Analysis of the geometry box2 :"
38 subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"])
39 subFaceList = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
40 subEdgeList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
42 print "number of Shells in box2 : ", len(subShellList)
43 print "number of Faces in box2 : ", len(subFaceList)
44 print "number of Edges in box2 : ", len(subEdgeList)
46 box3 = geompy.MakeBox(0., 0., 300., 200., 200., 500.)
48 idbox3 = geompy.addToStudy(box3, "box3")
50 print "Analysis of the geometry box3 :"
51 subShellList = geompy.SubShapeAll(box3, geompy.ShapeType["SHELL"])
52 subFaceList = geompy.SubShapeAll(box3, geompy.ShapeType["FACE"])
53 subEdgeList = geompy.SubShapeAll(box3, geompy.ShapeType["EDGE"])
55 print "number of Shells in box3 : ", len(subShellList)
56 print "number of Faces in box3 : ", len(subFaceList)
57 print "number of Edges in box3 : ", len(subEdgeList)
59 shell = geompy.MakePartition([box1, box2, box3])
60 idshell = geompy.addToStudy(shell,"shell")
62 print "Analysis of the geometry shell (union of box1, box2 and box3) :"
63 subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"])
64 subFaceList = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"])
65 subEdgeList = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"])
67 print "number of Shells in shell : ", len(subShellList)
68 print "number of Faces in shell : ", len(subFaceList)
69 print "number of Edges in shell : ", len(subEdgeList)
72 ### ---------------------------- SMESH --------------------------------------
74 # ---- create Hypothesis
76 print "-------------------------- create Hypothesis"
78 print "-------------------------- NumberOfSegments"
82 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
83 hypNbSeg.SetNumberOfSegments(numberOfSegments)
85 print hypNbSeg.GetName()
86 print hypNbSeg.GetId()
87 print hypNbSeg.GetNumberOfSegments()
89 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
91 print "-------------------------- MaxElementArea"
95 hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
96 hypArea.SetMaxElementArea(maxElementArea)
98 print hypArea.GetName()
100 print hypArea.GetMaxElementArea()
102 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
104 print "-------------------------- MaxElementVolume"
106 maxElementVolume = 500
108 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
109 hypVolume.SetMaxElementVolume(maxElementVolume)
111 print hypVolume.GetName()
112 print hypVolume.GetId()
113 print hypVolume.GetMaxElementVolume()
115 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
117 # ---- create Algorithms
119 print "-------------------------- create Algorithms"
121 print "-------------------------- Regular_1D"
123 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
124 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
126 print "-------------------------- MEFISTO_2D"
128 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
129 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
131 print "-------------------------- NETGEN_3D"
133 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
134 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
136 # ---- init a Mesh with the shell
138 mesh = smesh.CreateMesh(shell)
139 smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox3")
141 # ---- add hypothesis to shell
143 print "-------------------------- add hypothesis to shell"
145 mesh.AddHypothesis(shell,regular1D)
146 mesh.AddHypothesis(shell,hypNbSeg)
148 mesh.AddHypothesis(shell,mefisto2D)
149 mesh.AddHypothesis(shell,hypArea)
151 mesh.AddHypothesis(shell,netgen3D)
152 mesh.AddHypothesis(shell,hypVolume)
154 salome.sg.updateObjBrowser(1)
156 print "-------------------------- compute shell"
157 ret = smesh.Compute(mesh,shell)
160 log = mesh.GetLog(0) # no erase trace
163 print "Information about the MeshBox3:"
164 print "Number of nodes : ", mesh.NbNodes()
165 print "Number of edges : ", mesh.NbEdges()
166 print "Number of faces : ", mesh.NbFaces()
167 print "Number of triangles : ", mesh.NbTriangles()
168 print "Number of volumes : ", mesh.NbVolumes()
169 print "Number of tetrahedrons: ", mesh.NbTetras()
171 print "probleme when computing the mesh"