2 .. _python_testMEDCoupling2D_solution:
9 from MEDCoupling import *
10 from MEDLoader import *
17 print "1 ********************"
20 # Coordinates of central polygon
21 X = [1.,0.5,-0.5,-1.,-0.5,0.5]
22 Y = [0.,sqrt(3.)/2.,sqrt(3.)/2.,0.,-sqrt(3.)/2.,-sqrt(3.)/2.]
26 coordinates.append(0.)
27 coordinates.append(0.)
31 coordinates.append(X[i])
32 coordinates.append(Y[i])
34 # Coordinates of second couron
46 coordinates.append(xtmp+X[(i-1)%6])
47 coordinates.append(ytmp+Y[(i-1)%6])
48 coordinates.append(xtmp+X[i%6])
49 coordinates.append(ytmp+Y[i%6])
50 coordinates.append(xtmp+X[(i+1)%6])
51 coordinates.append(ytmp+Y[(i+1)%6])
53 print "2 ********************"
55 mesh=MEDCouplingUMesh.New()
56 mesh.setMeshDimension(2)
57 mesh.allocateCells(numberOfCells)
58 mesh.setName("MaFleur")
60 myCoords=DataArrayDouble.New()
61 myCoords.setValues(coordinates,numberOfNodes,2)
62 mesh.setCoords(myCoords)
64 print "3 ********************"
65 # Connectivity of triangular meshing
68 connectivity.append(0)
69 connectivity.append(i%6+1)
70 connectivity.append((i+1)%6+1)
72 mesh.insertNextCell(NORM_TRI3,3,connectivity[3*i:3*(i+1)])
75 print "4 ********************"
76 # Connectivity of hexagons
80 connectivity.append(start)
81 connectivity.append(start+2*(i+3))
82 connectivity.append(start+2*(i+3)+1)
83 connectivity.append(start+2*(i+3)+2)
85 connectivity.append(7)
87 connectivity.append(start+2*(i+3)+3)
88 connectivity.append((i+1)%6+1)
90 mesh.insertNextCell(NORM_POLYGON,6,connectivity[6*i:6*(i+1)])
93 print "5 ********************"
94 mesh.checkConsistencyLight()
96 medFileName = "MEDCoupling_Fleur.med"
97 MEDLoader.WriteUMesh(medFileName,mesh,True)