Salome HOME
removing the call to the tetrahedron generator NETGEN, because I did not yet
[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 SMESH_fixation
8 import SMESH
9 import smeshpy
10
11 compshell = SMESH_fixation.compshell
12 idcomp = SMESH_fixation.idcomp
13 geompy = SMESH_fixation.geompy
14 salome = SMESH_fixation.salome
15 sg = SMESH_fixation.sg
16
17 ShapeTypeShell     = 3
18 ShapeTypeFace      = 4
19 ShapeTypeEdge      = 6
20
21 print "Analysis of the geometry to be meshed :"
22 subShellList=geompy.SubShapeAll(compshell,ShapeTypeShell)
23 subFaceList=geompy.SubShapeAll(compshell,ShapeTypeFace)
24 subEdgeList=geompy.SubShapeAll(compshell,ShapeTypeEdge)
25
26 print "number of Shells in compshell : ",len(subShellList)
27 print "number of Faces in compshell : ",len(subFaceList)
28 print "number of Edges in compshell : ",len(subEdgeList)
29
30 status=geompy.CheckShape(compshell)
31 print " check status ", status
32
33 ### ---- launch SMESH
34
35 smeshgui = salome.ImportComponentGUI("SMESH")
36 smeshgui.Init(salome.myStudyId)
37
38 gen=smeshpy.smeshpy()
39
40 ### ---- create Hypothesis
41
42 print "-------------------------- create Hypothesis"
43
44 print "-------------------------- NumberOfSegments"
45
46 numberOfSegments = 5
47
48 hypothesis=gen.CreateHypothesis("NumberOfSegments")
49 hypNbSeg=hypothesis._narrow(SMESH.SMESH_NumberOfSegments)
50 hypNbSeg.SetNumberOfSegments(numberOfSegments)
51 hypNbSegID = hypNbSeg.GetId()
52 print hypNbSeg.GetName()
53 print hypNbSegID
54 print hypNbSeg.GetNumberOfSegments()
55
56 idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
57 smeshgui.SetName(idseg, "NumberOfSegments")
58
59 print "-------------------------- MaxElementArea"
60
61 maxElementArea = 80
62
63 hypothesis=gen.CreateHypothesis("MaxElementArea")
64 hypArea=hypothesis._narrow(SMESH.SMESH_MaxElementArea)
65 hypArea.SetMaxElementArea(maxElementArea)
66 print hypArea.GetName()
67 print hypArea.GetId()
68 print hypArea.GetMaxElementArea()
69
70 idarea = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea) )
71 smeshgui.SetName(idarea, "MaxElementArea")
72
73 print "-------------------------- MaxElementVolume"
74
75 maxElementVolume = 150
76
77 hypothesis=gen.CreateHypothesis("MaxElementVolume")
78 hypVolume=hypothesis._narrow(SMESH.SMESH_MaxElementVolume)
79 hypVolume.SetMaxElementVolume(maxElementVolume)
80 print hypVolume.GetName()
81 print hypVolume.GetId()
82 print hypVolume.GetMaxElementVolume()
83
84 idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
85 smeshgui.SetName(idvolume, "MaxElementVolume")
86
87 # ---- create Algorithms
88
89 print "-------------------------- create Algorithms"
90
91 print "-------------------------- Regular_1D"
92
93 hypothesis=gen.CreateHypothesis("Regular_1D")
94 regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
95 regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
96 smeshgui.SetName(regularID, "Wire Discretisation")
97
98 print "-------------------------- MEFISTO_2D"
99
100 hypothesis=gen.CreateHypothesis("MEFISTO_2D")
101 mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
102 mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
103 smeshgui.SetName(mefistoID, "MEFISTO_2D")
104
105 print "-------------------------- NETGEN_3D"
106
107 hypothesis=gen.CreateHypothesis("NETGEN_3D")
108 netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
109 netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
110 smeshgui.SetName(netgenID, "NETGEN_3D")
111
112 # ---- init a Mesh with the compshell
113
114 mesh=gen.Init(idcomp)
115 idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
116 smeshgui.SetName(idmesh, "MeshcompShell")
117 smeshgui.SetShape(idcomp, idmesh)
118
119 # ---- add hypothesis to compshell
120
121 print "-------------------------- add hypothesis to compshell"
122
123 ret=mesh.AddHypothesis(compshell,regular1D)
124 print ret
125 ret=mesh.AddHypothesis(compshell,hypNbSeg)
126 print ret
127 ret=mesh.AddHypothesis(compshell,mefisto2D)
128 print ret
129 ret=mesh.AddHypothesis(compshell,hypArea)
130 print ret
131 ret=mesh.AddHypothesis(compshell,netgen3D)
132 print ret
133 ret=mesh.AddHypothesis(compshell,hypVolume)
134 print ret
135
136 smeshgui.SetAlgorithms( idmesh, regularID)
137 smeshgui.SetHypothesis( idmesh, idseg )
138 smeshgui.SetAlgorithms( idmesh, mefistoID )
139 smeshgui.SetHypothesis( idmesh, idarea )
140 smeshgui.SetAlgorithms( idmesh, netgenID )
141 smeshgui.SetHypothesis( idmesh, idvolume )
142
143 sg.updateObjBrowser(1)
144
145 print "-------------------------- compute compshell"
146 ret=gen.Compute(mesh,idcomp)
147 print ret
148 if ret != 0:
149     log=mesh.GetLog(0) # no erase trace
150     for linelog in log:
151         print linelog
152 else:
153     print "problem when computing the mesh"
154
155 sg.updateObjBrowser(1)