Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/smesh.git] / src / SMESH_SWIG / SMESH_box_tetra.py
1 #
2 # Tetrahedrization of a simple box. Hypothesis and algorithms for
3 # the mesh generation are global
4 #
5
6 import salome
7 import geompy
8
9 import StdMeshers
10 import NETGENPlugin
11
12 geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
13 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
14
15 smeshgui = salome.ImportComponentGUI("SMESH")
16 smeshgui.Init(salome.myStudyId);
17
18 # -----------------------------------------------------------------------------
19 ShapeTypeShell     = 3
20 ShapeTypeFace      = 4
21 ShapeTypeEdge      = 6
22
23 # ---- define a boxe
24
25 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
26
27 idbox = geompy.addToStudy(box,"box")
28
29 print "Analysis of the geometry box :"
30 subShellList=geompy.SubShapeAll(box,ShapeTypeShell)
31 subFaceList=geompy.SubShapeAll(box,ShapeTypeFace)
32 subEdgeList=geompy.SubShapeAll(box,ShapeTypeEdge)
33
34 print "number of Shells in box : ",len(subShellList)
35 print "number of Faces in box : ",len(subFaceList)
36 print "number of Edges in box : ",len(subEdgeList)
37
38
39 ### ---------------------------- SMESH --------------------------------------
40
41 # ---- create Hypothesis
42
43 print "-------------------------- create Hypothesis"
44
45 print "-------------------------- NumberOfSegments"
46
47 numberOfSegments = 10
48
49 hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
50 hypNbSeg.SetNumberOfSegments(numberOfSegments)
51
52 print hypNbSeg.GetName()
53 print hypNbSeg.GetId()
54 print hypNbSeg.GetNumberOfSegments()
55
56 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
57
58 print "-------------------------- MaxElementArea"
59
60 maxElementArea = 500
61
62 hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
63 hypArea.SetMaxElementArea(maxElementArea)
64
65 print hypArea.GetName()
66 print hypArea.GetId()
67 print hypArea.GetMaxElementArea()
68
69 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
70
71 print "-------------------------- MaxElementVolume"
72
73 maxElementVolume = 500
74
75 hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
76 hypVolume.SetMaxElementVolume(maxElementVolume)
77
78 print hypVolume.GetName()
79 print hypVolume.GetId()
80 print hypVolume.GetMaxElementVolume()
81
82 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
83
84 # ---- create Algorithms
85
86 print "-------------------------- create Algorithms"
87
88 print "-------------------------- Regular_1D"
89
90 regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
91 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
92
93 print "-------------------------- MEFISTO_2D"
94
95 mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
96 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
97
98 print "-------------------------- NETGEN_3D"
99
100 netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
101 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
102
103 # ---- init a Mesh with the boxe
104
105 mesh = smesh.CreateMesh(box)
106 smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox")
107
108 # ---- add hypothesis to the boxe
109
110 print "-------------------------- add hypothesis to the box"
111
112 mesh.AddHypothesis(box,regular1D)
113 mesh.AddHypothesis(box,hypNbSeg)
114
115 mesh.AddHypothesis(box,mefisto2D)
116 mesh.AddHypothesis(box,hypArea)
117
118 mesh.AddHypothesis(box,netgen3D)
119 mesh.AddHypothesis(box,hypVolume)
120
121 salome.sg.updateObjBrowser(1)
122
123 print "-------------------------- compute the mesh of the boxe"
124 ret=smesh.Compute(mesh,box)
125 print ret
126 if ret != 0:
127     log=mesh.GetLog(0) # no erase trace
128     for linelog in log:
129         print linelog
130     print "Information about the MeshBox:"
131     print "Number of nodes       : ", mesh.NbNodes()
132     print "Number of edges       : ", mesh.NbEdges()
133     print "Number of faces       : ", mesh.NbFaces()
134     print "Number of triangles   : ", mesh.NbTriangles()
135     print "Number of volumes     : ", mesh.NbVolumes()
136     print "Number of tetrahedrons: ", mesh.NbTetras()
137 else:
138     print "probleme when computing the mesh"