2 # Tetrahedrization of the geometry union of 2 boxes having a face in common
3 # Hypothesis and algorithms for the mesh generation are global
12 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
14 smeshgui = salome.ImportComponentGUI("SMESH")
15 smeshgui.Init(salome.myStudyId);
17 # ---- define 2 boxes box1 and box2
19 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
21 idbox1 = geompy.addToStudy(box1, "box1")
23 print "Analysis of the geometry box1 :"
24 subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"])
25 subFaceList = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
26 subEdgeList = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"])
28 print "number of Shells in box1 : ", len(subShellList)
29 print "number of Faces in box1 : ", len(subFaceList)
30 print "number of Edges in box1 : ", len(subEdgeList)
32 box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.)
34 idbox2 = geompy.addToStudy(box2, "box2")
36 print "Analysis of the geometry box2 :"
37 subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"])
38 subFaceList = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
39 subEdgeList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
41 print "number of Shells in box2 : ", len(subShellList)
42 print "number of Faces in box2 : ", len(subFaceList)
43 print "number of Edges in box2 : ", len(subEdgeList)
45 # append the tow boxes to make ine shel, referrencing only once
46 # the internal interface
48 shell = geompy.MakePartition([box1, box2])
49 idshell = geompy.addToStudy(shell, "shell")
51 print "Analysis of the geometry shell (union of box1 and box2) :"
52 subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"])
53 subFaceList = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"])
54 subEdgeList = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"])
56 print "number of Shells in shell : ", len(subShellList)
57 print "number of Faces in shell : ", len(subFaceList)
58 print "number of Edges in shell : ", len(subEdgeList)
61 ### ---------------------------- SMESH --------------------------------------
63 # ---- create Hypothesis
65 print "-------------------------- create Hypothesis"
67 print "-------------------------- NumberOfSegments"
71 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
72 hypNbSeg.SetNumberOfSegments(numberOfSegments)
74 print hypNbSeg.GetName()
75 print hypNbSeg.GetId()
76 print hypNbSeg.GetNumberOfSegments()
78 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
80 print "-------------------------- MaxElementArea"
84 hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
85 hypArea.SetMaxElementArea(maxElementArea)
87 print hypArea.GetName()
89 print hypArea.GetMaxElementArea()
91 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
93 print "-------------------------- MaxElementVolume"
95 maxElementVolume = 500
97 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
98 hypVolume.SetMaxElementVolume(maxElementVolume)
100 print hypVolume.GetName()
101 print hypVolume.GetId()
102 print hypVolume.GetMaxElementVolume()
104 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
106 # ---- create Algorithms
108 print "-------------------------- create Algorithms"
110 print "-------------------------- Regular_1D"
112 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
113 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
115 print "-------------------------- MEFISTO_2D"
117 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
118 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
120 print "-------------------------- NETGEN_3D"
122 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
123 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
125 # ---- init a Mesh with the shell
127 mesh = smesh.CreateMesh(shell)
128 smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox2")
130 # ---- add hypothesis to shell
132 print "-------------------------- add hypothesis to shell"
134 mesh.AddHypothesis(shell,regular1D)
135 mesh.AddHypothesis(shell,hypNbSeg)
137 mesh.AddHypothesis(shell,mefisto2D)
138 mesh.AddHypothesis(shell,hypArea)
140 mesh.AddHypothesis(shell,netgen3D)
141 mesh.AddHypothesis(shell,hypVolume)
143 salome.sg.updateObjBrowser(1)
145 print "-------------------------- compute shell"
146 ret = smesh.Compute(mesh,shell)
149 log = mesh.GetLog(0) # no erase trace
152 print "Information about the MeshBox2:"
153 print "Number of nodes : ", mesh.NbNodes()
154 print "Number of edges : ", mesh.NbEdges()
155 print "Number of faces : ", mesh.NbFaces()
156 print "Number of triangles : ", mesh.NbTriangles()
157 print "Number of volumes : ", mesh.NbVolumes()
158 print "Number of tetrahedrons: ", mesh.NbTetras()
160 print "probleme when computing the mesh"