00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 import salome
00029 import geompy
00030 import smesh
00031 from math import sqrt
00032
00033
00034
00035
00036 barier_height = 7.0
00037 barier_radius = 5.6 / 2
00038 colis_radius = 1.0 / 2
00039 colis_step = 2.0
00040 cc_width = 0.11
00041
00042
00043
00044 cc_radius = colis_radius + cc_width
00045 colis_center = sqrt(2.0)*colis_step/2
00046
00047
00048
00049 boolean_common = 1
00050 boolean_cut = 2
00051 boolean_fuse = 3
00052 boolean_section = 4
00053
00054
00055
00056 p0 = geompy.MakeVertex(0.,0.,0.)
00057 vz = geompy.MakeVectorDXDYDZ(0.,0.,1.)
00058
00059
00060
00061 barier = geompy.MakeCylinder(p0, vz, barier_radius, barier_height)
00062
00063
00064
00065 colis = geompy.MakeCylinder(p0, vz, colis_radius, barier_height)
00066 cc = geompy.MakeCylinder(p0, vz, cc_radius, barier_height)
00067
00068 colis_cc = geompy.MakeCompound([colis, cc])
00069 colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0)
00070
00071 colis_cc_multi = geompy.MultiRotate1D(colis_cc, vz, 4)
00072
00073
00074
00075 Compound1 = geompy.MakeCompound([colis_cc_multi, barier])
00076 SubShape_theShape = geompy.SubShapeAll(Compound1,geompy.ShapeType["SOLID"])
00077 alveole = geompy.MakePartition(SubShape_theShape)
00078
00079 print "Analysis of the geometry to mesh (right after the Partition) :"
00080
00081 subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"])
00082 subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"])
00083 subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"])
00084
00085 print "number of Shells in alveole : ", len(subShellList)
00086 print "number of Faces in alveole : ", len(subFaceList)
00087 print "number of Edges in alveole : ", len(subEdgeList)
00088
00089 subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"])
00090
00091
00092
00093 comp1 = geompy.MakeCompound( [ subshapes[0], subshapes[1] ] )
00094 comp2 = geompy.MakeCompound( [ subshapes[2], subshapes[3] ] )
00095 comp3 = geompy.MakeCompound( [ subshapes[4], subshapes[5] ] )
00096 comp4 = geompy.MakeCompound( [ subshapes[6], subshapes[7] ] )
00097
00098 compGOs = []
00099 compGOs.append( comp1 )
00100 compGOs.append( comp2 )
00101 compGOs.append( comp3 )
00102 compGOs.append( comp4 )
00103 comp = geompy.MakeCompound( compGOs )
00104
00105 alveole = geompy.MakeCompound( [ comp, subshapes[8] ])
00106
00107 idalveole = geompy.addToStudy(alveole, "alveole")
00108
00109 print "Analysis of the geometry to mesh (right after the MakeCompound) :"
00110
00111 subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"])
00112 subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"])
00113 subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"])
00114
00115 print "number of Shells in alveole : ", len(subShellList)
00116 print "number of Faces in alveole : ", len(subFaceList)
00117 print "number of Edges in alveole : ", len(subEdgeList)
00118
00119 status = geompy.CheckShape(alveole)
00120 print " check status ", status
00121
00122
00123 smesh.SetCurrentStudy(salome.myStudy)
00124
00125
00126 shape_mesh = salome.IDToObject( idalveole )
00127
00128 mesh = smesh.Mesh(shape_mesh, "MeshAlveole")
00129
00130 print "-------------------------- create Hypothesis (In this case global hypothesis are used)"
00131
00132 print "-------------------------- NumberOfSegments"
00133
00134 numberOfSegments = 10
00135
00136 regular1D = mesh.Segment()
00137 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
00138 print hypNbSeg.GetName()
00139 print hypNbSeg.GetId()
00140 print hypNbSeg.GetNumberOfSegments()
00141 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
00142
00143 print "-------------------------- MaxElementArea"
00144
00145 maxElementArea = 0.1
00146
00147 mefisto2D = mesh.Triangle()
00148 hypArea = mefisto2D.MaxElementArea(maxElementArea)
00149 print hypArea.GetName()
00150 print hypArea.GetId()
00151 print hypArea.GetMaxElementArea()
00152 smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
00153
00154 print "-------------------------- MaxElementVolume"
00155
00156 maxElementVolume = 0.5
00157
00158 netgen3D = mesh.Tetrahedron(smesh.NETGEN)
00159 hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
00160 print hypVolume.GetName()
00161 print hypVolume.GetId()
00162 print hypVolume.GetMaxElementVolume()
00163 smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
00164
00165 print "-------------------------- compute the mesh of alveole "
00166 ret = mesh.Compute()
00167
00168 if ret != 0:
00169 log=mesh.GetLog(0)
00170 for linelog in log:
00171 print linelog
00172 print "Information about the Mesh_mechanic:"
00173 print "Number of nodes : ", mesh.NbNodes()
00174 print "Number of edges : ", mesh.NbEdges()
00175 print "Number of faces : ", mesh.NbFaces()
00176 print "Number of triangles : ", mesh.NbTriangles()
00177 print "Number of volumes : ", mesh.NbVolumes()
00178 print "Number of tetrahedrons: ", mesh.NbTetras()
00179 else:
00180 print "problem when computing the mesh"
00181
00182 salome.sg.updateObjBrowser(1)