1 from libMEDMEM_Swig import *
4 #MedFile = "carre_quad4_3.med"
5 #MedFile = "polyedres.med"
6 #MedFile = "polygones.med"
8 #meshName = "CARRE_EN_QUAD4"
9 #meshName = "Erreur orientation"
12 myMesh = MESH(MED_DRIVER,MedFile,meshName)
15 nameMesh = myMesh.getName()
17 print "Mesh name : ",nameMesh
19 numberOfTypes = myMesh.getNumberOfTypes(MED_CELL)
20 print "Show Connectivity (Nodal) : "
22 # This example use access with a specified medGeometryElement through
25 for i in range(numberOfTypes):
26 cellType = myMesh.getCellType(MED_CELL,i)
27 nameType = cellType.getName()
28 type = cellType.getType()
29 numberOfElements = myMesh.getNumberOfElements(MED_CELL,type)
30 numberOfNodesPerCell = cellType.getNumberOfNodes()
31 connectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,
32 MED_NODAL,MED_CELL,type)
33 print "For Type ",nameType," : "
34 for j in range(numberOfElements):
35 print "Element ",(j+1)," : ",connectivity[j*numberOfNodesPerCell:
36 (j+1)*numberOfNodesPerCell]
38 print "Show Reverse Nodal Connectivity :"
40 # This example use global access with index array
42 numberOfNodes = myMesh.getNumberOfNodes()
44 reverseNodalConnectivity = myMesh.getReverseConnectivity(MED_NODAL)
45 reverseNodalConnectivityIndex = myMesh.getReverseConnectivityIndex(MED_NODAL)
47 for i in range(numberOfNodes):
48 indexBegin = reverseNodalConnectivityIndex[i]
49 indexEnd = reverseNodalConnectivityIndex[i+1]
51 # Index value begin at 1 so (index-1) is in fact used here
53 print "Node ",(i+1)," : ",reverseNodalConnectivity[(indexBegin-1):
56 print "Show Connectivity (Descending) :"
58 # This example use global access with index array
60 numberOfElements = myMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
61 descendingConnectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,
62 MED_DESCENDING,MED_CELL,
64 descendingConnectivityIndex = myMesh.getConnectivityIndex(MED_DESCENDING,
67 for i in range(numberOfElements):
68 indexBegin = descendingConnectivityIndex[i]
69 indexEnd = descendingConnectivityIndex[i+1]
71 # Index value begin at 1 so (index-1) is in fact used here
73 print "Element ",(i+1)," : ",descendingConnectivity[(indexBegin-1):
76 print "Show Reverse Descending Connectivity :"
78 # This example use global access with index array
80 meshDimension = myMesh.getMeshDimension()
82 if (meshDimension == 1):
83 print "ERROR : Mesh Dimension = 1"
84 print "Then the Reverse Descending Connectivity could not be seen"
86 if (meshDimension == 2):
88 constituentEntity = MED_EDGE
90 if (meshDimension == 3):
92 constituentEntity = MED_FACE
94 numberOfConstituents = myMesh.getNumberOfElements(constituentEntity,
96 reverseDescendingConnectivity = myMesh.getReverseConnectivity(
98 reverseDescendingConnectivityIndex = myMesh.getReverseConnectivityIndex(
101 for i in range(numberOfConstituents):
102 indexBegin = reverseDescendingConnectivityIndex[i]
103 indexEnd = reverseDescendingConnectivityIndex[i+1]
105 # Index value begin at 1 so (index-1) is in fact used here
107 print constituent," : ",(i+1)," : ",reverseDescendingConnectivity[
108 (indexBegin-1):(indexEnd-1)]
110 print "Show ",constituent," Connectivity (Nodal) :"
112 constituentConnectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,
116 constituentConnectivityIndex = myMesh.getConnectivityIndex(MED_NODAL,
119 for i in range(numberOfConstituents):
120 indexBegin = constituentConnectivityIndex[i]
121 indexEnd = constituentConnectivityIndex[i+1]
123 # Index value begin at 1 so (index-1) is in fact used here
125 print constituent," : ",(i+1)," : ",constituentConnectivity[
126 (indexBegin-1):(indexEnd-1)]
130 nbPolygons = myMesh.getNumberOfPolygons()
133 print " Show Connectivity (Nodal) of POLYGONS:"
135 connectivity = myMesh.getPolygonsConnectivity(MED_NODAL,MED_CELL)
136 index = myMesh.getPolygonsConnectivityIndex(MED_NODAL,MED_CELL)
137 for j in range(nbPolygons):
138 print " Polygon",(j+1)," ",connectivity[ index[j]-1 : index[j+1]-1 ]
142 nbPolyhedrons = myMesh.getNumberOfPolyhedron()
143 if nbPolyhedrons > 0 :
145 print " Show Connectivity (Nodal) of POLYHEDRONS:"
147 connectivity = myMesh.getPolyhedronConnectivity(MED_NODAL)
148 fIndex = myMesh.getPolyhedronFacesIndex()
149 index = myMesh.getPolyhedronIndex(MED_NODAL)
150 for j in range(nbPolyhedrons):
151 print " Polyhedra",(j+1)
152 iF1, iF2 = index[ j ]-1, index[ j+1 ]-1
153 for f in range( iF2 - iF1 ):
154 iN1, iN2 = fIndex[ iF1+f ]-1, fIndex[ iF1+f+1 ]-1
155 print " Face",f+1," ",connectivity[ iN1 : iN2 ]