Salome HOME
Comment out the example.
[modules/smesh.git] / src / SMESH_SWIG / SMESH_box3_tetra.py
1 #
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
5 #
6
7 import salome
8 import geompy
9
10 import StdMeshers
11 import NETGENPlugin
12
13 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
14
15 smeshgui = salome.ImportComponentGUI("SMESH")
16 smeshgui.Init(salome.myStudyId);
17
18 # ---- define 3 boxes box1, box2 and box3
19
20 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
21
22 idbox1 = geompy.addToStudy(box1, "box1")
23
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"])
28
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)
32
33 box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.)
34
35 idbox2 = geompy.addToStudy(box2, "box2")
36
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"])
41
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)
45
46 box3 = geompy.MakeBox(0., 0., 300., 200., 200., 500.)
47
48 idbox3 = geompy.addToStudy(box3, "box3")
49
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"])
54
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)
58
59 shell = geompy.MakePartition([box1, box2, box3])
60 idshell = geompy.addToStudy(shell,"shell")
61
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"])
66
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)
70
71
72 ### ---------------------------- SMESH --------------------------------------
73
74 # ---- create Hypothesis
75
76 print "-------------------------- create Hypothesis"
77
78 print "-------------------------- NumberOfSegments"
79
80 numberOfSegments = 10
81
82 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
83 hypNbSeg.SetNumberOfSegments(numberOfSegments)
84
85 print hypNbSeg.GetName()
86 print hypNbSeg.GetId()
87 print hypNbSeg.GetNumberOfSegments()
88
89 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
90
91 print "-------------------------- MaxElementArea"
92
93 maxElementArea = 500
94
95 hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
96 hypArea.SetMaxElementArea(maxElementArea)
97
98 print hypArea.GetName()
99 print hypArea.GetId()
100 print hypArea.GetMaxElementArea()
101
102 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
103
104 print "-------------------------- MaxElementVolume"
105
106 maxElementVolume = 500
107
108 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
109 hypVolume.SetMaxElementVolume(maxElementVolume)
110
111 print hypVolume.GetName()
112 print hypVolume.GetId()
113 print hypVolume.GetMaxElementVolume()
114
115 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
116
117 # ---- create Algorithms
118
119 print "-------------------------- create Algorithms"
120
121 print "-------------------------- Regular_1D"
122
123 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
124 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
125
126 print "-------------------------- MEFISTO_2D"
127
128 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
129 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
130
131 print "-------------------------- NETGEN_3D"
132
133 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
134 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
135
136 # ---- init a Mesh with the shell
137
138 mesh = smesh.CreateMesh(shell)
139 smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox3")
140
141 # ---- add hypothesis to shell
142
143 print "-------------------------- add hypothesis to shell"
144
145 mesh.AddHypothesis(shell,regular1D)
146 mesh.AddHypothesis(shell,hypNbSeg)
147
148 mesh.AddHypothesis(shell,mefisto2D)
149 mesh.AddHypothesis(shell,hypArea)
150
151 mesh.AddHypothesis(shell,netgen3D)
152 mesh.AddHypothesis(shell,hypVolume)
153
154 salome.sg.updateObjBrowser(1)
155
156 print "-------------------------- compute shell"
157 ret = smesh.Compute(mesh,shell)
158 print ret
159 if ret != 0:
160     log = mesh.GetLog(0) # no erase trace
161     for linelog in log:
162         print linelog
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()
170 else:
171     print "probleme when computing the mesh"