2 # Tetrahedrization of the geometry generated by the Python script GEOM_Partition1.py
3 # Hypothesis and algorithms for the mesh generation are global
5 #%Make geometry (like CEA script (A1)) using Partition algorithm% from OCC
6 # -- Rayon de la bariere
14 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
15 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
17 geom.GetCurrentStudy(salome.myStudy._get_StudyId())
18 smesh.SetCurrentStudy(salome.myStudy)
20 smeshgui = salome.ImportComponentGUI("SMESH")
21 smeshgui.Init(salome.myStudyId);
23 #---------------------------------------------------------------
26 barier_radius = 5.6 / 2 # Rayon de la bariere
27 colis_radius = 1.0 / 2 # Rayon du colis
28 colis_step = 2.0 # Distance s
\89parant deux colis
29 cc_width = 0.11 # Epaisseur du complement de colisage
33 cc_radius = colis_radius + cc_width
35 colis_center = sqrt(2.0)*colis_step/2
46 barier = geompy.MakeCylinder(
47 geom.MakePointStruct(0.,0.,0.),
48 geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
54 colis = geompy.MakeCylinder(
55 geom.MakePointStruct(0.,0.,0.),
56 geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
60 cc = geompy.MakeCylinder(
61 geom.MakePointStruct(0.,0.,0.),
62 geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
66 colis_cc = geompy.MakeCompound(
67 [colis._get_Name(), cc._get_Name()])
69 colis_cc = geompy.MakeTranslation(
70 colis_cc, colis_center, 0.0, 0.0)
72 colis_cc_multi = geompy.MakeMultiRotation1D(
74 geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
75 geom.MakePointStruct(0.,0.,0.),
80 alveole = geompy.Partition(
81 [colis_cc_multi._get_Name(), barier._get_Name()])
87 print "Analysis of the geometry to mesh (right after the Partition) :"
89 subShellList=geompy.SubShapeAll(alveole,ShapeTypeShell)
90 subFaceList=geompy.SubShapeAll(alveole,ShapeTypeFace)
91 subEdgeList=geompy.SubShapeAll(alveole,ShapeTypeEdge)
93 print "number of Shells in alveole : ",len(subShellList)
94 print "number of Faces in alveole : ",len(subFaceList)
95 print "number of Edges in alveole : ",len(subEdgeList)
97 subshapes = geompy.SubShapeAll( alveole, geompy.ShapeType["SHAPE"] )
99 ## there are 9 subshapes
101 comp1 = geompy.MakeCompound( [ subshapes[0]._get_Name(), subshapes[1]._get_Name() ] );
102 comp2 = geompy.MakeCompound( [ subshapes[2]._get_Name(), subshapes[3]._get_Name() ] );
103 comp3 = geompy.MakeCompound( [ subshapes[4]._get_Name(), subshapes[5]._get_Name() ] );
104 comp4 = geompy.MakeCompound( [ subshapes[6]._get_Name(), subshapes[7]._get_Name() ] );
107 compIORs.append( comp1._get_Name() );
108 compIORs.append( comp2._get_Name() );
109 compIORs.append( comp3._get_Name() );
110 compIORs.append( comp4._get_Name() );
111 comp = geompy.MakeCompound( compIORs );
113 alveole = geompy.MakeCompound( [ comp._get_Name(), subshapes[8]._get_Name() ]);
115 idalveole= geompy.addToStudy(alveole, "alveole")
117 print "Analysis of the geometry to mesh (right after the MakeCompound) :"
119 subShellList=geompy.SubShapeAll(alveole,ShapeTypeShell)
120 subFaceList=geompy.SubShapeAll(alveole,ShapeTypeFace)
121 subEdgeList=geompy.SubShapeAll(alveole,ShapeTypeEdge)
123 print "number of Shells in alveole : ",len(subShellList)
124 print "number of Faces in alveole : ",len(subFaceList)
125 print "number of Edges in alveole : ",len(subEdgeList)
127 status=geompy.CheckShape(alveole)
128 print " check status ", status
132 # ---- create Hypothesis
134 print "-------------------------- create Hypothesis (In this case global hypothesis are used)"
136 print "-------------------------- NumberOfSegments"
138 numberOfSegments = 10
140 hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
141 hypNbSeg.SetNumberOfSegments(numberOfSegments)
142 print hypNbSeg.GetName()
143 print hypNbSeg.GetId()
144 print hypNbSeg.GetNumberOfSegments()
146 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
148 print "-------------------------- MaxElementArea"
152 hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
153 hypArea.SetMaxElementArea(maxElementArea)
154 print hypArea.GetName()
155 print hypArea.GetId()
156 print hypArea.GetMaxElementArea()
158 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_0.1")
160 print "-------------------------- MaxElementVolume"
162 maxElementVolume = 0.5
164 hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
165 hypVolume.SetMaxElementVolume(maxElementVolume)
166 print hypVolume.GetName()
167 print hypVolume.GetId()
168 print hypVolume.GetMaxElementVolume()
170 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_0.5")
172 # ---- create Algorithms
174 print "-------------------------- create Algorithms"
176 print "-------------------------- Regular_1D"
178 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
179 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
181 print "-------------------------- MEFISTO_2D"
183 mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
184 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
186 print "-------------------------- NETGEN_3D"
188 netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
189 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
191 # ---- init a Mesh with the alveole
192 shape_mesh = salome.IDToObject( idalveole )
194 mesh=smesh.CreateMesh(shape_mesh)
195 smeshgui.SetName(salome.ObjectToID(mesh), "MeshAlveole")
197 # ---- add hypothesis to alveole
199 print "-------------------------- add hypothesis to alveole"
201 mesh.AddHypothesis(shape_mesh,regular1D)
202 mesh.AddHypothesis(shape_mesh,hypNbSeg)
204 mesh.AddHypothesis(shape_mesh,mefisto2D)
205 mesh.AddHypothesis(shape_mesh,hypArea)
207 mesh.AddHypothesis(shape_mesh,netgen3D)
208 mesh.AddHypothesis(shape_mesh,hypVolume)
210 print "-------------------------- compute the mesh of alveole "
211 ret=smesh.Compute(mesh,shape_mesh)
214 log=mesh.GetLog(0) # no erase trace
217 print "Information about the Mesh_mechanic:"
218 print "Number of nodes : ", mesh.NbNodes()
219 print "Number of edges : ", mesh.NbEdges()
220 print "Number of faces : ", mesh.NbFaces()
221 print "Number of triangles : ", mesh.NbTriangles()
222 print "Number of volumes: ", mesh.NbVolumes()
223 print "Number of tetrahedrons: ", mesh.NbTetras()
225 print "problem when computing the mesh"
227 salome.sg.updateObjBrowser(1)