1 from MEDLoader import *
6 coords=DataArrayDouble([0,0, 1,0, 2,0, 3,0, 4,0, 5,0, 0,1, 1,1, 2,1, 0,2, 1,2, 3,1, 4,1],13,2)
7 m0=MEDCouplingUMesh(meshName,2)
10 m0.insertNextCell(NORM_TRI3,[2,3,8])
11 m0.insertNextCell(NORM_TRI3,[3,4,11])
12 m0.insertNextCell(NORM_TRI3,[4,5,12])
13 m0.insertNextCell(NORM_TRI3,[6,7,9])
14 m0.insertNextCell(NORM_TRI3,[7,8,10])
15 m0.insertNextCell(NORM_QUAD4,[0,1,7,6])
16 m0.insertNextCell(NORM_QUAD4,[1,2,8,7])
18 m1=MEDCouplingUMesh(meshName,1)
21 m1.insertNextCell(NORM_SEG2,[0,1])
22 m1.insertNextCell(NORM_SEG2,[1,2])
23 m1.insertNextCell(NORM_SEG2,[2,3])
24 m1.insertNextCell(NORM_SEG2,[3,4])
25 m1.insertNextCell(NORM_SEG2,[4,5])
27 mm.setFamilyFieldArr(0,DataArrayInt([-1,-1,-2,-3,-3,-1,-3]))
28 mm.setFamilyFieldArr(-1,DataArrayInt([-1,-4,-4,-4,-1]))
29 for i in [-1,-2,-3,-4]:
30 mm.setFamilyId("Fam_%d"%i,i)
31 mm.setFamiliesOnGroup("G%d"%(abs(i)),["Fam_%d"%i])
35 f0=MEDCouplingFieldDouble(ON_GAUSS_PT)
37 f0.setName("MyFieldPG") ; f0.setMesh(m0)
38 f0.setGaussLocalizationOnType(NORM_TRI3,[0,0, 1,0, 0,1],[0.1,0.1, 0.8,0.1, 0.1,0.8],[0.3,0.3,0.4])
39 f0.setGaussLocalizationOnType(NORM_QUAD4,[-1,-1, 1,-1, 1,1, -1,1],[-0.57735,-0.57735,0.57735,-0.57735,0.57735,0.57735,-0.57735,0.57735],[0.25,0.25,0.25,0.25])
40 arr=DataArrayDouble(f0.getNumberOfTuplesExpected()) ; arr.iota()
41 arr=DataArrayDouble.Meld(arr,arr)
42 arr.setInfoOnComponents(["comp0","comp1"])
44 WriteFieldUsingAlreadyWrittenMesh(fname,f0)
46 f1=MEDCouplingFieldDouble(ON_CELLS)
48 f1.setName("MyFieldCell") ; f1.setMesh(m0)
49 arr=DataArrayDouble(f1.getNumberOfTuplesExpected()) ; arr.iota()
50 arr=DataArrayDouble.Meld(arr,arr)
51 arr.setInfoOnComponents(["comp2","comp3"])
53 WriteFieldUsingAlreadyWrittenMesh(fname,f1)