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