2 # Tetrahedrization of the geometry generated by the Python script GEOM_Partition1.py
\r
3 # Hypothesis and algorithms for the mesh generation are global
\r
5 #%Make geometry (like CEA script (A1)) using Partition algorithm% from OCC
\r
6 # -- Rayon de la bariere
\r
9 barier_radius = 5.6 / 2 # Rayon de la bariere
\r
10 colis_radius = 1.0 / 2 # Rayon du colis
\r
11 colis_step = 2.0 # Distance s
\89parant deux colis
\r
12 cc_width = 0.11 # Epaisseur du complement de colisage
\r
16 cc_radius = colis_radius + cc_width
\r
17 from math import sqrt
\r
18 colis_center = sqrt(2.0)*colis_step/2
\r
32 barier = geompy.MakeCylinder(
\r
33 geom.MakePointStruct(0.,0.,0.),
\r
34 geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
\r
40 colis = geompy.MakeCylinder(
\r
41 geom.MakePointStruct(0.,0.,0.),
\r
42 geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
\r
46 cc = geompy.MakeCylinder(
\r
47 geom.MakePointStruct(0.,0.,0.),
\r
48 geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
\r
52 colis_cc = geompy.MakeCompound(
\r
53 [colis._get_Name(), cc._get_Name()])
\r
55 colis_cc = geompy.MakeTranslation(
\r
56 colis_cc, colis_center, 0.0, 0.0)
\r
58 colis_cc_multi = geompy.MakeMultiRotation1D(
\r
60 geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
\r
61 geom.MakePointStruct(0.,0.,0.),
\r
66 alveole = geompy.Partition(
\r
67 [colis_cc_multi._get_Name(), barier._get_Name()])
\r
73 print "Analysis of the geometry to mesh (right after the Partition) :"
\r
75 subShellList=geompy.SubShapeAll(alveole,ShapeTypeShell)
\r
76 subFaceList=geompy.SubShapeAll(alveole,ShapeTypeFace)
\r
77 subEdgeList=geompy.SubShapeAll(alveole,ShapeTypeEdge)
\r
79 print "number of Shells in alveole : ",len(subShellList)
\r
80 print "number of Faces in alveole : ",len(subFaceList)
\r
81 print "number of Edges in alveole : ",len(subEdgeList)
\r
83 subshapes = geompy.SubShapeAll( alveole, geompy.ShapeType["SHAPE"] )
\r
85 ## there are 9 subshapes
\r
87 comp1 = geompy.MakeCompound( [ subshapes[0]._get_Name(), subshapes[1]._get_Name() ] );
\r
88 comp2 = geompy.MakeCompound( [ subshapes[2]._get_Name(), subshapes[3]._get_Name() ] );
\r
89 comp3 = geompy.MakeCompound( [ subshapes[4]._get_Name(), subshapes[5]._get_Name() ] );
\r
90 comp4 = geompy.MakeCompound( [ subshapes[6]._get_Name(), subshapes[7]._get_Name() ] );
\r
93 compIORs.append( comp1._get_Name() );
\r
94 compIORs.append( comp2._get_Name() );
\r
95 compIORs.append( comp3._get_Name() );
\r
96 compIORs.append( comp4._get_Name() );
\r
97 comp = geompy.MakeCompound( compIORs );
\r
99 alveole = geompy.MakeCompound( [ comp._get_Name(), subshapes[8]._get_Name() ]);
\r
101 idalveole= geompy.addToStudy(alveole, "alveole")
\r
103 print "Analysis of the geometry to mesh (right after the MakeCompound) :"
\r
105 subShellList=geompy.SubShapeAll(alveole,ShapeTypeShell)
\r
106 subFaceList=geompy.SubShapeAll(alveole,ShapeTypeFace)
\r
107 subEdgeList=geompy.SubShapeAll(alveole,ShapeTypeEdge)
\r
109 print "number of Shells in alveole : ",len(subShellList)
\r
110 print "number of Faces in alveole : ",len(subFaceList)
\r
111 print "number of Edges in alveole : ",len(subEdgeList)
\r
113 status=geompy.CheckShape(alveole)
\r
114 print " check status ", status
\r
116 # ---- launch SMESH
\r
119 from salome import sg
\r
124 smeshgui = salome.ImportComponentGUI("SMESH")
\r
125 smeshgui.Init(salome.myStudyId)
\r
127 gen=smeshpy.smeshpy()
\r
129 # ---- create Hypothesis
\r
131 print "-------------------------- create Hypothesis (In this case global hypothesis are used)"
\r
133 print "-------------------------- NumberOfSegments"
\r
135 numberOfSegments = 10
\r
137 hyp1=gen.CreateHypothesis("NumberOfSegments")
\r
138 hypNbSeg=hyp1._narrow(SMESH.SMESH_NumberOfSegments)
\r
139 hypNbSeg.SetNumberOfSegments(numberOfSegments)
\r
140 hypNbSegID = hypNbSeg.GetId()
\r
141 print hypNbSeg.GetName()
\r
143 print hypNbSeg.GetNumberOfSegments()
\r
145 idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
\r
146 smeshgui.SetName(idseg, "NumberOfSegments")
\r
148 print "-------------------------- MaxElementArea"
\r
150 maxElementArea = 0.1
\r
152 hyp2=gen.CreateHypothesis("MaxElementArea")
\r
153 hypArea=hyp2._narrow(SMESH.SMESH_MaxElementArea)
\r
154 hypArea.SetMaxElementArea(maxElementArea)
\r
155 print hypArea.GetName()
\r
156 print hypArea.GetId()
\r
157 print hypArea.GetMaxElementArea()
\r
159 idarea = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea) )
\r
160 smeshgui.SetName(idarea, "MaxElementArea")
\r
162 print "-------------------------- MaxElementVolume"
\r
164 maxElementVolume = 0.5
\r
166 hyp3=gen.CreateHypothesis("MaxElementVolume")
\r
167 hypVolume=hyp3._narrow(SMESH.SMESH_MaxElementVolume)
\r
168 hypVolume.SetMaxElementVolume(maxElementVolume)
\r
169 print hypVolume.GetName()
\r
170 print hypVolume.GetId()
\r
171 print hypVolume.GetMaxElementVolume()
\r
173 idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
\r
174 smeshgui.SetName(idvolume, "MaxElementVolume")
\r
176 # ---- create Algorithms
\r
178 print "-------------------------- create Algorithms"
\r
180 print "-------------------------- Regular_1D"
\r
182 hypothesis=gen.CreateHypothesis("Regular_1D")
\r
183 regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
\r
184 regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
\r
185 smeshgui.SetName(regularID, "Wire Discretisation")
\r
187 print "-------------------------- MEFISTO_2D"
\r
189 hypothesis=gen.CreateHypothesis("MEFISTO_2D")
\r
190 mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
\r
191 mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
\r
192 smeshgui.SetName(mefistoID, "MEFISTO_2D")
\r
194 print "-------------------------- NETGEN_3D"
\r
196 hypothesis=gen.CreateHypothesis("NETGEN_3D")
\r
197 netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
\r
198 netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
\r
199 smeshgui.SetName(netgenID, "NETGEN_3D")
\r
201 # ---- init a Mesh with the alveole
\r
203 mesh=gen.Init(idalveole)
\r
204 idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
\r
205 smeshgui.SetName(idmesh, "MeshAlveole")
\r
206 smeshgui.SetShape(idalveole, idmesh)
\r
208 # ---- add hypothesis to alveole
\r
210 print "-------------------------- add hypothesis to alveole"
\r
212 ret=mesh.AddHypothesis(alveole,regular1D)
\r
214 ret=mesh.AddHypothesis(alveole,hypNbSeg)
\r
216 ret=mesh.AddHypothesis(alveole,mefisto2D)
\r
218 ret=mesh.AddHypothesis(alveole,hypArea)
\r
220 ret=mesh.AddHypothesis(alveole,netgen3D)
\r
222 ret=mesh.AddHypothesis(alveole,hypVolume)
\r
225 smeshgui.SetAlgorithms( idmesh, regularID)
\r
226 smeshgui.SetHypothesis( idmesh, idseg )
\r
227 smeshgui.SetAlgorithms( idmesh, mefistoID )
\r
228 smeshgui.SetHypothesis( idmesh, idarea )
\r
229 smeshgui.SetAlgorithms( idmesh, netgenID )
\r
230 smeshgui.SetHypothesis( idmesh, idvolume )
\r
232 sg.updateObjBrowser(1)
\r
235 print "-------------------------- compute the mesh of alveole "
\r
236 ret=gen.Compute(mesh,idalveole)
\r
239 log=mesh.GetLog(0) # no erase trace
\r
240 for linelog in log:
\r
243 print "problem when computing the mesh"
\r
245 sg.updateObjBrowser(1)
\r