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