Back to index

salome-med  6.5.0
Public Member Functions
MEDLoaderTest3.MEDLoaderTest Class Reference

List of all members.

Public Member Functions

def testMEDMesh1
def testMEDMesh2
def testMEDMesh3
def testMEDMesh4
def testMEDMesh5
def testMEDMesh6
def testMEDMesh7
def testMEDField1
def testMEDField2
def testMEDField3
def testMEDField4
def testMEDField5
def testMEDField6
def testMEDField7
def testMEDField8
def testMEDFileData1
def testMEDField9
def testMEDField10
def testMEDField11
def testMEDField12
def testMEDField13
def testMEDField14
def testMEDField15
def testMEDField16
def testMEDField17
def testMEDField18
def testMEDFieldBug1
def testMEDMesh8
def testMEDLoaderMEDLoaderNSReadFieldDoubleDataInMedFile
def testMEDLoaderMultiLevelCellField1
def testFieldOnPflRetrieveOnMdimRelMax1

Detailed Description

Definition at line 26 of file MEDLoaderTest3.py.


Member Function Documentation

Definition at line 1069 of file MEDLoaderTest3.py.

01069 
01070     def testFieldOnPflRetrieveOnMdimRelMax1(self):
01071         fname="Pyfile43.med"
01072         m2,m1,m0,f2,f1,f0,p,n2,n1,n0,fns,fids,grpns,famIdsPerGrp=MEDLoaderDataForTest.buildMultiLevelMesh_1()
01073         m=MEDFileUMesh.New()
01074         m.setMeshAtLevel(0,m2)
01075         m.setMeshAtLevel(-1,m1)
01076         m.setMeshAtLevel(-2,m0)
01077         f=MEDFileField1TS.New()
01078         ff=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME)
01079         ff.setName("NodeFieldPfl")
01080         arr=DataArrayDouble.New() ; arr.setValues([1.,10.,100.,2.,20.,200.],2,3)
01081         ff.setArray(arr)
01082         pfl=DataArrayInt.New() ; pfl.setValues([2,3],2,1) ; pfl.setName("PflNode")
01083         f.setFieldProfile(ff,m,-2,pfl)
01084         tes0=f.getFieldOnMeshAtLevel(ON_NODES,-1,m)
01085         self.assertEqual(ON_NODES,tes0.getTypeOfField())
01086         self.assertEqual(1,tes0.getMesh().getMeshDimension())
01087         self.assertEqual(1,tes0.getMesh().getNumberOfCells())
01088         self.assertEqual(2,tes0.getMesh().getNumberOfNodes())
01089         self.assertEqual([1,0,1],tes0.getMesh().getNodalConnectivity().getValues())
01090         self.assertEqual([0,3],tes0.getMesh().getNodalConnectivityIndex().getValues())
01091         self.assertEqual(2,tes0.getArray().getNumberOfTuples())
01092         self.assertEqual(3,tes0.getArray().getNumberOfComponents())
01093         expected1=[1.,10.,100.,2.,20.,200.]
01094         nodeCoordsWithValue1=[10.,2.5,0.]
01095         nodeCoordsWithValue2=[10.,3.75,0.]
01096         for i in xrange(3):
01097             self.assertAlmostEqual(nodeCoordsWithValue1[i],tes0.getMesh().getCoordinatesOfNode(0)[i],13);
01098             self.assertAlmostEqual(nodeCoordsWithValue2[i],tes0.getMesh().getCoordinatesOfNode(1)[i],13);
01099             pass
01100         for i in xrange(6):
01101             self.assertAlmostEqual(expected1[i],tes0.getArray().getIJ(0,i),13);
01102             pass
01103         del tes0
01104         #
01105         tes1=f.getFieldOnMeshAtLevel(ON_NODES,1,m)
01106         self.assertEqual(ON_CELLS,tes1.getTypeOfField())# it is not a bug even if ON_NODES has been sepecified
01107         self.assertEqual(0,tes1.getMesh().getMeshDimension())
01108         self.assertEqual(2,tes1.getMesh().getNumberOfCells())
01109         self.assertEqual(135,tes1.getMesh().getNumberOfNodes())
01110         self.assertEqual([0,2,0,3],tes1.getMesh().getNodalConnectivity().getValues())
01111         self.assertEqual([0,2,4],tes1.getMesh().getNodalConnectivityIndex().getValues())
01112         self.assertEqual(2,tes1.getArray().getNumberOfTuples())
01113         self.assertEqual(3,tes1.getArray().getNumberOfComponents())
01114         for i in xrange(6):
01115             self.assertAlmostEqual(expected1[i],tes1.getArray().getIJ(0,i),13);
01116             pass
01117         m.write(fname,2)
01118         f.write(fname,0)
01119         #
01120         pfl=DataArrayInt.New() ; pfl.setValues([3,2],2,1) ; pfl.setName("PflNode")
01121         f=MEDFileField1TS.New()
01122         f.setFieldProfile(ff,m,-2,pfl)
01123         tes2=f.getFieldOnMeshAtLevel(ON_NODES,-1,m)
01124         self.assertEqual(ON_NODES,tes2.getTypeOfField())
01125         self.assertEqual(1,tes2.getMesh().getMeshDimension())
01126         self.assertEqual(1,tes2.getMesh().getNumberOfCells())
01127         self.assertEqual(2,tes2.getMesh().getNumberOfNodes())
01128         self.assertEqual([1,0,1],tes2.getMesh().getNodalConnectivity().getValues())
01129         self.assertEqual([0,3],tes2.getMesh().getNodalConnectivityIndex().getValues())
01130         self.assertEqual(2,tes2.getArray().getNumberOfTuples())
01131         self.assertEqual(3,tes2.getArray().getNumberOfComponents())
01132         expected2=[2.,20.,200.,1.,10.,100.]
01133         for i in xrange(3):
01134             self.assertAlmostEqual(nodeCoordsWithValue1[i],tes2.getMesh().getCoordinatesOfNode(0)[i],13);
01135             self.assertAlmostEqual(nodeCoordsWithValue2[i],tes2.getMesh().getCoordinatesOfNode(1)[i],13);
01136             pass
01137         for i in xrange(6):
01138             self.assertAlmostEqual(expected2[i],tes2.getArray().getIJ(0,i),13);#compare tes2 and tes3
01139             pass
01140         #
01141         tes3=f.getFieldOnMeshAtLevel(ON_NODES,1,m)
01142         self.assertEqual(ON_CELLS,tes3.getTypeOfField())# it is not a bug even if ON_NODES has been sepecified
01143         self.assertEqual(0,tes3.getMesh().getMeshDimension())
01144         self.assertEqual(2,tes3.getMesh().getNumberOfCells())
01145         self.assertEqual(135,tes3.getMesh().getNumberOfNodes())
01146         self.assertEqual([0,3,0,2],tes3.getMesh().getNodalConnectivity().getValues())
01147         self.assertEqual([0,2,4],tes3.getMesh().getNodalConnectivityIndex().getValues())
01148         self.assertEqual(2,tes3.getArray().getNumberOfTuples())
01149         self.assertEqual(3,tes3.getArray().getNumberOfComponents())
01150         for i in xrange(6):
01151             self.assertAlmostEqual(expected1[i],tes3.getArray().getIJ(0,i),13);
01152             pass
        pass

Definition at line 377 of file MEDLoaderTest3.py.

00377 
00378     def testMEDField1(self):
00379         mm=MEDFileMesh.New("Pyfile17.med")
00380         mm.write("Pyfile17_bis.med",2)
00381         ff=MEDFileFieldMultiTS.New("Pyfile17.med","MeasureOfMesh_Extruded")
00382         ff.write("Pyfile17_bis.med",0)
00383         pass

Definition at line 636 of file MEDLoaderTest3.py.

00636 
00637     def testMEDField10(self):
00638         fname="Pyfile31.med"
00639         m1=MEDLoaderDataForTest.build2DMesh_1()
00640         m1.renumberCells([0,1,4,2,3,5],False)
00641         mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.setName(m1.getName())
00642         mm1.write(fname,2)
00643         ff1=MEDFileFieldMultiTS.New()
00644         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f1.setName("F2")
00645         d=DataArrayDouble.New() ; d.alloc(2*4,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
00646         f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
00647         da=DataArrayInt.New(); da.setValues([0,1,2,4],4,1) ; da.setName("sup2")
00648         #
00649         ff1.appendFieldProfile(f1,mm1,0,da)
00650         f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
00651         ff1.appendFieldProfile(f1,mm1,0,da)
00652         ff1.write(fname,0)
00653         #
00654         vals,pfl=ff1.getFieldWithProfile(ON_CELLS,1,2,0,mm1) ; vals.setName("")
00655         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00656         self.assertTrue(vals.isEqual(e,1e-14))
00657         vals,pfl=ff1.getFieldWithProfile(ON_CELLS,-1,-1,0,mm1) ; vals.setName("")
00658         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00659         self.assertTrue(vals.isEqual(d,1e-14))
00660         #
00661         ff2=MEDFileFieldMultiTS.New(fname,f1.getName())
00662         self.assertEqual([(-1, -1, 0.0), (1, 2, 1.2)],ff2.getTimeSteps())
00663         vals,pfl=ff2.getFieldWithProfile(ON_CELLS,1,2,0,mm1) ; vals.setName("")
00664         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00665         self.assertTrue(vals.isEqual(e,1e-14))
00666         vals,pfl=ff2.getFieldWithProfile(ON_CELLS,-1,-1,0,mm1) ; vals.setName("")
00667         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00668         self.assertTrue(vals.isEqual(d,1e-14))
00669         pass
    

Definition at line 671 of file MEDLoaderTest3.py.

00671 
00672     def testMEDField11(self):
00673         fname="Pyfile32.med"
00674         m1=MEDLoaderDataForTest.build2DMesh_1()
00675         m1.renumberCells([0,1,4,2,3,5],False)
00676         mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
00677         mm1.write(fname,2)
00678         ff1=MEDFileField1TS.New()
00679         f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME) ; f1.setName("F1Node")
00680         d=DataArrayDouble.New() ; d.alloc(2*6,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
00681         f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
00682         da=DataArrayInt.New(); da.setValues([1,2,4,5,7,8],6,1) ; da.setName("sup1Node")
00683         #
00684         ff1.setFieldProfile(f1,mm1,0,da)
00685         self.assertEqual(ff1.getNonEmptyLevels(),(-1, []))
00686         ff1.write(fname,0)
00687         #
00688         vals,pfl=ff1.getFieldWithProfile(ON_NODES,0,mm1) ; vals.setName("")
00689         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00690         self.assertTrue(vals.isEqual(d,1e-14))
00691         ## #
00692         ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
00693         vals,pfl=ff2.getFieldWithProfile(ON_NODES,0,mm1) ; vals.setName("")
00694         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00695         self.assertTrue(vals.isEqual(d,1e-14))
00696         pass

Definition at line 697 of file MEDLoaderTest3.py.

00697 
00698     def testMEDField12(self):
00699         fname="Pyfile33.med"
00700         m1=MEDLoaderDataForTest.build2DMesh_1()
00701         m1.renumberCells([0,1,4,2,3,5],False)
00702         mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
00703         mm1.write(fname,2)
00704         ff1=MEDFileFieldMultiTS.New()
00705         f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME) ; f1.setName("F1Node")
00706         d=DataArrayDouble.New() ; d.alloc(2*6,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
00707         f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
00708         da=DataArrayInt.New(); da.setValues([1,2,4,5,7,8],6,1) ; da.setName("sup1Node")
00709         #
00710         ff1.appendFieldProfile(f1,mm1,0,da)
00711         f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
00712         ff1.appendFieldProfile(f1,mm1,0,da)
00713         ff1.write(fname,0)
00714         #
00715         vals,pfl=ff1.getFieldWithProfile(ON_NODES,1,2,0,mm1) ; vals.setName("")
00716         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00717         self.assertTrue(vals.isEqual(e,1e-14))
00718         vals,pfl=ff1.getFieldWithProfile(ON_NODES,-1,-1,0,mm1) ; vals.setName("")
00719         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00720         self.assertTrue(vals.isEqual(d,1e-14))
00721         #
00722         ff2=MEDFileFieldMultiTS.New(fname,f1.getName())
00723         vals,pfl=ff2.getFieldWithProfile(ON_NODES,1,2,0,mm1) ; vals.setName("")
00724         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00725         self.assertTrue(vals.isEqual(e,1e-14))
00726         vals,pfl=ff2.getFieldWithProfile(ON_NODES,-1,-1,0,mm1) ; vals.setName("")
00727         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00728         self.assertTrue(vals.isEqual(d,1e-14))
00729         pass

Definition at line 730 of file MEDLoaderTest3.py.

00730 
00731     def testMEDField13(self):
00732         fname="Pyfile34.med"
00733         m1=MEDLoaderDataForTest.build2DMesh_1()
00734         m1.renumberCells([0,1,4,2,3,5],False)
00735         tmp=m1.getName();
00736         m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
00737         mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
00738         mm1.write(fname,2)
00739         ff1=MEDFileField1TS.New()
00740         f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) ; f1.setName("F3Node")
00741         d=DataArrayDouble.New() ; d.alloc(2*11,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
00742         f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
00743         da=DataArrayInt.New(); da.setValues([0,2,3],3,1) ; da.setName("sup1NodeElt")
00744         #
00745         ff1.setFieldProfile(f1,mm1,0,da)
00746         ff1.write(fname,0)
00747         #
00748         vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,0,mm1) ; vals.setName("")
00749         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00750         self.assertTrue(vals.isEqual(d,1e-14))
00751         #
00752         ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
00753         vals,pfl=ff2.getFieldWithProfile(ON_GAUSS_NE,0,mm1) ; vals.setName("")
00754         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00755         self.assertTrue(vals.isEqual(d,1e-14))
00756         pass

Definition at line 757 of file MEDLoaderTest3.py.

00757 
00758     def testMEDField14(self):
00759         fname="Pyfile35.med"
00760         m1=MEDLoaderDataForTest.build2DMesh_1()
00761         m1.renumberCells([0,1,4,2,3,5],False)
00762         tmp=m1.getName();
00763         m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
00764         mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
00765         mm1.write(fname,2)
00766         ff1=MEDFileFieldMultiTS.New()
00767         f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) ; f1.setName("F4Node")
00768         d=DataArrayDouble.New() ; d.alloc(2*11,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
00769         f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
00770         da=DataArrayInt.New(); da.setValues([0,2,3],3,1) ; da.setName("sup1NodeElt")
00771         #
00772         ff1.appendFieldProfile(f1,mm1,0,da)
00773         f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
00774         ff1.appendFieldProfile(f1,mm1,0,da)
00775         ff1.write(fname,0)
00776         #
00777         vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,-1,-1,0,mm1) ; vals.setName("")
00778         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00779         self.assertTrue(vals.isEqual(d,1e-14))
00780         vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,1,2,0,mm1) ; vals.setName("")
00781         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00782         self.assertTrue(vals.isEqual(e,1e-14))
00783         self.assertEqual([[3],[3]],ff1.getTypesOfFieldAvailable())
00784         #
00785         ff2=MEDFileFieldMultiTS.New(fname,f1.getName())
00786         vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,-1,-1,0,mm1) ; vals.setName("")
00787         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00788         self.assertTrue(vals.isEqual(d,1e-14))
00789         vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,1,2,0,mm1) ; vals.setName("")
00790         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00791         self.assertTrue(vals.isEqual(e,1e-14))
        pass

Definition at line 795 of file MEDLoaderTest3.py.

00795 
00796     def testMEDField15(self):
00797         fname="Pyfile36.med"
00798         m0=MEDLoaderDataForTest.build2DMesh_1()
00799         m0.renumberCells([0,1,4,2,3,5],False)
00800         tmp=m0.getName();
00801         m1=m0.buildPartOfMySelf([0,1,1,2,3,3,4,4],True) ; m1.setName(tmp) # suppression of last cell that is a polygon and creation of one more cell per type
00802         mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
00803         ff1=MEDFileField1TS.New()
00804         f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) ; f1.setName("F4Node")
00805         d=DataArrayDouble.New() ; d.alloc(2*20,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
00806         f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
00807         da=DataArrayInt.New(); da.setValues([0,1,3,4,6],5,1) ; da.setName("sup1NodeElt")
00808         #
00809         ff1.setFieldProfile(f1,mm1,0,da)
00810         m1=m0.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) ; mm1.setMeshAtLevel(0,m1) ;
00811         mm1.write(fname,2)
00812         ff1.write(fname,0)
00813         f1=ff1.getFieldOnMeshAtLevel(ON_GAUSS_NE,m1,0)
00814         f2,p1=ff1.getFieldWithProfile(ON_GAUSS_NE,0,mm1) ; f2.setName("")
00815         self.assertTrue(p1.isIdentity())
00816         self.assertEqual(5,p1.getNumberOfTuples())
00817         self.assertTrue(f1.getArray().isEqual(f2,1e-12))
        pass

Definition at line 819 of file MEDLoaderTest3.py.

00819 
00820     def testMEDField16(self):
00821         fname="Pyfile37.med"
00822         f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
00823         m1=f1.getMesh()
00824         mm1=MEDFileUMesh.New()
00825         mm1.setCoords(m1.getCoords())
00826         mm1.setMeshAtLevel(0,m1)
00827         mm1.setName(m1.getName())
00828         ff1=MEDFileField1TS.New()
00829         ff1.setFieldNoProfileSBT(f1)
00830         m2=m1.buildDescendingConnectivity()[0]
00831         m2.sortCellsInMEDFileFrmt()
00832         m2.setName(m1.getName())
00833         mm1.setMeshAtLevel(-1,m2)
00834         mm1.write(fname,2)
00835         f2=m2.getMeasureField(True)
00836         dd=DataArrayDouble.New()
00837         dd.alloc(f2.getArray().getNumberOfTuples(),3)
00838         dd[:,0]=f2.getArray()
00839         dd[:,1]=2*f2.getArray()
00840         dd[:,2]=3*f2.getArray()
00841         f2=f2.buildNewTimeReprFromThis(ONE_TIME,False)
00842         f2.setArray(dd)
00843         f2.copyTinyStringsFrom(f1)
00844         f2.copyTinyAttrFrom(f1)
00845         ff1.setFieldNoProfileSBT(f2)
00846         ff1.write(fname,0)
00847         # Reading Pyfile37.med
00848         ff2=MEDFileField1TS.New(fname,f2.getName(),0,1)
00849         f1bis=ff2.getFieldAtLevel(ON_CELLS,0)
00850         self.assertTrue(f1.isEqual(f1bis,1e-12,1e-12))
00851         f1bis=ff2.getFieldAtLevel(ON_CELLS,-1)
00852         self.assertTrue(f2.isEqual(f1bis,1e-12,1e-12))
00853         f1bis=ff2.getFieldAtTopLevel(ON_CELLS)
00854         self.assertTrue(f1.isEqual(f1bis,1e-12,1e-12))
00855         # More complex
00856         fname="Pyfile38.med"
00857         mm1.write(fname,2)
00858         ff1=MEDFileField1TS.New()
00859         ff1.setFieldNoProfileSBT(f2)
00860         ff1.write(fname,0)
00861         ff2=MEDFileField1TS.New(fname,f2.getName(),0,1)
00862         f1bis=ff2.getFieldAtTopLevel(ON_CELLS)
00863         self.assertTrue(f2.isEqual(f1bis,1e-12,1e-12))
00864         pass

Definition at line 866 of file MEDLoaderTest3.py.

00866 
00867     def testMEDField17(self):
00868         fname="Pyfile39.med"
00869         m1=MEDLoaderDataForTest.build2DMesh_1()
00870         m1.renumberCells([0,1,4,2,3,5],False)
00871         mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.setName(m1.getName())
00872         mm1.write(fname,2)
00873         ffs=MEDFileFields.New()
00874         ff1=MEDFileFieldMultiTS.New()
00875         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f1.setName("F2")
00876         d=DataArrayDouble.New() ; d.alloc(2*4,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
00877         f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
00878         da=DataArrayInt.New(); da.setValues([0,1,2,4],4,1) ; da.setName("sup2")
00879         #
00880         ff1.appendFieldProfile(f1,mm1,0,da)
00881         f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
00882         ff1.appendFieldProfile(f1,mm1,0,da)
00883         ffs.resize(1)
00884         ffs.setFieldAtPos(0,ff1)
00885         ffs.write(fname,0)
00886         #
00887         ffsr=MEDFileFields.New(fname)
00888         ff3=ffsr.getFieldAtPos(0)
00889         f4=ff3.getFieldAtTopLevel(ON_CELLS,1,2)
00890         self.assertTrue(f4.getArray().isEqual(f1.getArray(),1e-12))
00891         pass

Definition at line 893 of file MEDLoaderTest3.py.

00893 
00894     def testMEDField18(self):
00895         fname="Pyfile40.med"
00896         m1=MEDLoaderDataForTest.build2DMesh_1()
00897         m1.renumberCells([0,1,4,2,3,5],False)
00898         mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.setName(m1.getName())
00899         mm1.write(fname,2)
00900         ffs=MEDFileFields.New()
00901         ff1=MEDFileFieldMultiTS.New()
00902         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f1.setName("F2")
00903         d=DataArrayDouble.New() ; d.alloc(2*4,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
00904         f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
00905         da=DataArrayInt.New(); da.setValues([0,1,2,4],4,1) ; da.setName("sup2")
00906         #
00907         ff1.appendFieldProfile(f1,mm1,0,da)
00908         f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
00909         ff1.appendFieldProfile(f1,mm1,0,da)
00910         ffs.pushField(ff1)
00911         ffs.write(fname,0)
00912         #
00913         ffsr=MEDFileFields.New(fname)
00914         ff3=ffsr.getFieldAtPos(0)
00915         f4=ff3.getFieldAtTopLevel(ON_CELLS,1,2)
00916         self.assertTrue(f4.getArray().isEqual(f1.getArray(),1e-12))
00917         pass

Definition at line 385 of file MEDLoaderTest3.py.

00385 
00386     def testMEDField2(self):
00387         mm=MEDFileMesh.New("Pyfile19.med")
00388         mm.write("Pyfile19_bis.med",2)
00389         ff=MEDFileFieldMultiTS.New("Pyfile19.med","VFieldOnNodes")
00390         ff.write("Pyfile19_bis.med",0)
00391         self.assertEqual([('tyty','mm'),('uiop','MW')],MEDLoader.GetComponentsNamesOfField("Pyfile19_bis.med","VFieldOnNodes"))
00392         pass

Definition at line 394 of file MEDLoaderTest3.py.

00394 
00395     def testMEDField3(self):
00396         mm=MEDFileMesh.New("Pyfile13.med")
00397         mm.write("Pyfile13_bis.med",2)
00398         ff=MEDFileFieldMultiTS.New("Pyfile13.med","MyFirstFieldOnGaussPoint")
00399         ff.write("Pyfile13_bis.med",0)
00400         ff=MEDFileField1TS.New("Pyfile13.med","MyFirstFieldOnGaussPoint",1,5)
00401         f=ff.getFieldAtLevel(ON_GAUSS_PT,0)
00402         f2=MEDLoader.ReadFieldGauss("Pyfile13.med",'2DMesh_2',0,'MyFirstFieldOnGaussPoint',1,5)
00403         self.assertTrue(f.isEqual(f2,1e-12,1e-12))
00404         pass

Definition at line 406 of file MEDLoaderTest3.py.

00406 
00407     def testMEDField4(self):
00408         mm=MEDFileMesh.New("Pyfile14.med")
00409         mm.write("Pyfile14_bis.med",2)
00410         ff=MEDFileFieldMultiTS.New("Pyfile14.med","MyFieldOnGaussNE")
00411         ff.write("Pyfile14_bis.med",0)
00412         ff=MEDFileField1TS.New("Pyfile14.med","MyFieldOnGaussNE",1,5)
00413         f=ff.getFieldAtLevel(ON_GAUSS_NE,0)
00414         f2=MEDLoader.ReadFieldGaussNE("Pyfile14.med",'2DMesh_2',0,"MyFieldOnGaussNE",1,5)
00415         self.assertTrue(f.isEqual(f2,1e-12,1e-12))
00416         pass

Definition at line 418 of file MEDLoaderTest3.py.

00418 
00419     def testMEDField5(self):
00420         ff=MEDFileField1TS.New("Pyfile17.med","MeasureOfMesh_Extruded",1,2)
00421         f=ff.getFieldAtLevel(ON_CELLS,0)
00422         f2=MEDLoader.ReadFieldCell("Pyfile17.med","Extruded",0,"MeasureOfMesh_Extruded",1,2)
00423         self.assertTrue(f.getMesh().getCoords().isEqual(f2.getMesh().getCoords(),1e-12))
00424         f.getMesh().tryToShareSameCoords(f2.getMesh(),1e-12)
00425         f.changeUnderlyingMesh(f2.getMesh(),22,1e-12)
00426         self.assertTrue(f.isEqual(f2,1e-12,1e-12))
00427         # no with renumbering
00428         f=ff.getFieldAtLevel(ON_CELLS,0,1)
00429         f2=MEDLoader.ReadFieldCell("Pyfile17.med","Extruded",0,"MeasureOfMesh_Extruded",1,2)
00430         self.assertTrue(f.isEqual(f2,1e-12,1e-12))
00431         f=ff.getFieldAtLevel(ON_CELLS,0,3)
00432         self.assertTrue(f.isEqual(f2,1e-12,1e-12))
00433         f=ff.getFieldAtLevel(ON_CELLS,0,2)
00434         self.assertTrue(not f.isEqual(f2,1e-12,1e-12))
00435         f.changeUnderlyingMesh(f2.getMesh(),12,1e-12)
00436         self.assertTrue(f.isEqual(f2,1e-12,1e-12))
00437         pass

Definition at line 439 of file MEDLoaderTest3.py.

00439 
00440     def testMEDField6(self):
00441         ff=MEDFileFieldMultiTS.New("Pyfile7.med","VectorFieldOnNodes")
00442         its=ff.getIterations()
00443         self.assertRaises(InterpKernelException,ff.getFieldAtLevel,ON_CELLS,its[0][0],its[0][1],0)# request on cell and it is not on cells
00444         f=ff.getFieldAtLevel(ON_NODES,its[0][0],its[0][1],0)
00445         f2=MEDLoader.ReadFieldNode("Pyfile7.med",'3DSurfMesh_1',0,"VectorFieldOnNodes",its[0][0],its[0][1])
00446         self.assertTrue(f.isEqual(f2,1e-12,1e-12))
00447         ff=MEDFileFieldMultiTS.New("Pyfile19.med","VFieldOnNodes")
00448         its=ff.getIterations()
00449         f=ff.getFieldAtLevel(ON_NODES,its[0][0],its[0][1],0)
00450         f2=MEDLoader.ReadFieldNode("Pyfile19.med",'2DMesh_1',0,"VFieldOnNodes",its[0][0],its[0][1])
00451         self.assertTrue(f.isEqual(f2,1e-12,1e-12))
00452         self.assertRaises(InterpKernelException,ff.getFieldAtLevel,ON_CELLS,its[0][0],its[0][1],0)# request on cell and it is not on cells
00453         self.assertRaises(InterpKernelException,ff.getFieldAtLevel,ON_NODES,its[0][0],its[0][1],0,1)#request renumber following mesh : it is on profile !
00454         pass

Definition at line 456 of file MEDLoaderTest3.py.

00456 
00457     def testMEDField7(self):
00458         ff=MEDFileFieldMultiTS.New("Pyfile12.med","VectorFieldOnCells")
00459         its=ff.getIterations()
00460         f=ff.getFieldAtLevel(ON_CELLS,its[0][0],its[0][1],0)
00461         f2=MEDLoader.ReadFieldCell("Pyfile12.med",'3DMesh_1',0,"VectorFieldOnCells",its[0][0],its[0][1])
00462         self.assertTrue(f.isEqual(f2,1e-12,1e-12))
00463         pass

Definition at line 465 of file MEDLoaderTest3.py.

00465 
00466     def testMEDField8(self):
00467         fname="Pyfile25.med"
00468         f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
00469         m1=f1.getMesh()
00470         mm1=MEDFileUMesh.New()
00471         mm1.setCoords(m1.getCoords())
00472         mm1.setMeshAtLevel(0,m1)
00473         mm1.setName(m1.getName())
00474         mm1.write(fname,2)
00475         ff1=MEDFileField1TS.New()
00476         ff1.setFieldNoProfileSBT(f1)
00477         ff1.write(fname,0)
00478         f2=MEDLoader.ReadFieldCell(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2]);
00479         ti,itt,orr=ff1.getTime()
00480         self.assertEqual(0,itt); self.assertEqual(1,orr); self.assertAlmostEqual(2.,ti,14);
00481         self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
00482         ff1.setTime(2.3,3,4)
00483         ti,itt,orr=ff1.getTime()
00484         self.assertEqual(3,itt); self.assertEqual(4,orr); self.assertAlmostEqual(2.3,ti,14);
00485         da,infos=ff1.getUndergroundDataArrayExt()
00486         f2.getArray().setName(da.getName())#da has the same name than f2
00487         self.assertTrue(da.isEqual(f2.getArray(),1e-12))
00488         self.assertEqual([((3, 0), (0, 2)), ((4, 0), (2, 4)), ((6, 0), (4, 5)), ((5, 0), (5, 6))],infos)
00489         #
00490         fname="Pyfile26.med"
00491         f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
00492         m1=f1.getMesh()
00493         mm1=MEDFileUMesh.New()
00494         mm1.setCoords(m1.getCoords())
00495         mm1.setMeshAtLevel(0,m1)
00496         mm1.setName(m1.getName())
00497         mm1.write(fname,2)
00498         ff1=MEDFileField1TS.New()
00499         ff1.setFieldNoProfileSBT(f1)
00500         nv=1456.
00501         da=ff1.getUndergroundDataArray().setIJ(0,0,nv)
00502         ff1.write(fname,0)
00503         f2=MEDLoader.ReadFieldNode(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2])
00504         self.assertTrue(not f1.isEqual(f2,1e-12,1e-12))
00505         f1.getArray().setIJ(0,0,nv)
00506         self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
00507         #
00508         fname="Pyfile27.med"
00509         f1=MEDLoaderDataForTest.buildVecFieldOnGaussNE_1();
00510         m1=f1.getMesh()
00511         mm1=MEDFileUMesh.New()
00512         mm1.setCoords(m1.getCoords())
00513         mm1.setMeshAtLevel(0,m1)
00514         mm1.setName(m1.getName())
00515         mm1.write(fname,2)
00516         ff1=MEDFileField1TS.New()
00517         ff1.setFieldNoProfileSBT(f1)
00518         ff1.write(fname,0)
00519         f2=MEDLoader.ReadFieldGaussNE(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2])
00520         self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
00521         da,infos=ff1.getUndergroundDataArrayExt()
00522         f2.getArray().setName(da.getName())#da has the same name than f2
00523         self.assertTrue(da.isEqual(f2.getArray(),1e-12))
00524         self.assertEqual([((3, 0), (0, 6)), ((4, 0), (6, 14)), ((6, 0), (14, 20))],infos)
00525         #
00526         fname="Pyfile28.med"
00527         f1=MEDLoaderDataForTest.buildVecFieldOnGauss_2_Simpler();
00528         m1=f1.getMesh()
00529         mm1=MEDFileUMesh.New()
00530         mm1.setCoords(m1.getCoords())
00531         mm1.setMeshAtLevel(0,m1)
00532         mm1.setName(m1.getName())
00533         mm1.write(fname,2)
00534         ff1=MEDFileField1TS.New()
00535         ff1.setFieldNoProfileSBT(f1)
00536         ff1.write(fname,0)
00537         ff2=MEDFileField1TS.New(fname,f1.getName(),f1.getTime()[1],f1.getTime()[2])
00538         f2=ff2.getFieldAtLevel(ON_GAUSS_PT,0)
00539         self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
00540         sbt=ff2.getFieldSplitedByType2()
00541         loc1=ff2.getLocalization("Loc_MyFirstFieldOnGaussPoint_NORM_TRI6_5")
00542         self.assertEqual("Loc_MyFirstFieldOnGaussPoint_NORM_TRI6_5",loc1.getName())
00543         self.assertEqual((-1, 1,-1,-1,1,-1,-1,0,0,-1,0,0),loc1.getRefCoords())
00544         self.assertEqual(6,loc1.getNumberOfPointsInCells())
00545         self.assertEqual(3,loc1.getNumberOfGaussPoints())
00546         self.assertEqual(2,loc1.getDimension())
00547         da,infos=ff2.getUndergroundDataArrayExt()
00548         f2.getArray().setName(da.getName())#da has the same name than f2
00549         self.assertTrue(da.isEqual(f2.getArray(),1e-12))
00550         self.assertEqual(53,da.getNumberOfTuples())
00551         self.assertEqual([((3, 0), (0, 18)), ((3, 1), (18, 30)), ((3, 2), (30, 36)), ((4, 0), (36, 42)), ((4, 1), (42, 44)), ((6, 0), (44, 53))],infos)
00552         #
00553         pass
    

Definition at line 600 of file MEDLoaderTest3.py.

00600 
00601     def testMEDField9(self):
00602         # first test field profile WR. Full type but with some type missing
00603         fname="Pyfile30.med"
00604         m1=MEDLoaderDataForTest.build2DMesh_3()
00605         mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
00606         mm1.write(fname,2)
00607         ff1=MEDFileField1TS.New()
00608         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f1.setName("F1")
00609         d=DataArrayDouble.New() ; d.alloc(2*9,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
00610         f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
00611         da=DataArrayInt.New(); da.alloc(9,1) ; da.iota(0) ; da.setName("sup1")
00612         #
00613         ff1.setFieldProfile(f1,mm1,0,da)
00614         ff1.changePflsNames([(["sup1_NORM_QUAD4"],"ForV650")])
00615         ff1.write(fname,0)
00616         #
00617         vals,pfl=ff1.getFieldWithProfile(ON_CELLS,0,mm1) ; vals.setName("")
00618         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))# profiles names cannot be contracted in pfl array name
00619         self.assertTrue(vals.isEqual(d,1e-14))
00620         #
00621         ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
00622         sbt=ff2.getFieldSplitedByType2()
00623         self.assertEqual(3,sbt[0][0])#TRI3
00624         self.assertEqual(0,sbt[0][1][0][0])#CELL For TRI3
00625         self.assertEqual("",sbt[0][1][0][2])#no profile For TRI3
00626         self.assertEqual([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],sbt[0][1][0][1].getValues())# values for TRI3
00627         self.assertEqual(4,sbt[1][0])#QUAD4
00628         self.assertEqual(0,sbt[1][1][0][0])#CELL For QUAD4
00629         self.assertEqual("ForV650",sbt[1][1][0][2])# profile For QUAD4
00630         self.assertEqual([19, 20, 21, 22, 23, 24],sbt[1][1][0][1].getValues())# values for QUAD4
00631         self.assertEqual([0],ff2.getTypesOfFieldAvailable())
00632         vals,pfl=ff2.getFieldWithProfile(ON_CELLS,0,mm1) ; vals.setName("")
00633         self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
00634         self.assertTrue(vals.isEqual(d,1e-14))
00635         pass
    

Definition at line 918 of file MEDLoaderTest3.py.

00918 
00919     def testMEDFieldBug1(self):
00920         fname="Pyfile13.med"
00921         d=MEDFileData.New(fname)
00922         self.assertEqual(('GP_MyFirstFieldOnGaussPoint0', 'GP_MyFirstFieldOnGaussPoint1', 'GP_MyFirstFieldOnGaussPoint2'),d.getFields().getFieldAtPos(0).getLocs())
00923         pass

Definition at line 554 of file MEDLoaderTest3.py.

00554 
00555     def testMEDFileData1(self):
00556         fname="Pyfile29.med"
00557         d=MEDFileData.New()
00558         #
00559         m1=MEDLoaderDataForTest.build1DMesh_1()
00560         mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.setName(m1.getName())
00561         mmm1=MEDFileMeshMultiTS.New() ;
00562         mmm1.setOneTimeStep(mm1)
00563         m2=MEDLoaderDataForTest.build2DCurveMesh_1()
00564         mm2=MEDFileUMesh.New() ; mm2.setCoords(m2.getCoords()) ; mm2.setMeshAtLevel(0,m2) ; mm2.setName(m2.getName())
00565         mmm2=MEDFileMeshMultiTS.New() ; mmm2.setOneTimeStep(mm2)
00566         ms=MEDFileMeshes.New(); ms.setMeshAtPos(0,mm1) ; ms.setMeshAtPos(1,mm2)
00567         d.setMeshes(ms)
00568         self.assertEqual(('1DMesh_1', '2DCurveMesh_1'),d.getMeshes().getMeshesNames())
00569         #
00570         ff1=MEDFileFieldMultiTS.New()
00571         ff21=MEDFileFieldMultiTS.New()
00572         ff22=MEDFileFieldMultiTS.New()
00573         f1=m1.getMeasureField(True) ; f1.setName("f1") ; f1=f1.buildNewTimeReprFromThis(ONE_TIME,False)
00574         f1.getArray().setInfoOnComponent(0,"power [kW]")
00575         ff1.appendFieldNoProfileSBT(f1)
00576         f21=m2.getMeasureField(True) ; f21.setName("f21") ; f21=f21.buildNewTimeReprFromThis(ONE_TIME,False)
00577         f21.getArray().setInfoOnComponent(0,"sta [mm]") ;
00578         ff21.appendFieldNoProfileSBT(f21)
00579         f22=f21.deepCpy() ; f22.setName("f22") ; f22=f22.buildNewTimeReprFromThis(ONE_TIME,False) ;
00580         f22.applyFunc(2,"3*x*IVec+2*x*JVec")
00581         f22.getArray().setInfoOnComponent(0,"distance [km]") ; f22.getArray().setInfoOnComponent(1,"displacement [cm]")
00582         ff22.appendFieldNoProfileSBT(f22)
00583         fs=MEDFileFields.New()
00584         fs.pushField(ff1) ; fs.pushField(ff21) ; fs.pushField(ff22)
00585         d.setFields(fs)
00586         #
00587         fname2="Pyfile29_2.med"
00588         d.write(fname2,2)
00589         #
00590         d2=MEDFileData.New(fname2)
00591         self.assertEqual(2,d2.getNumberOfMeshes())
00592         self.assertEqual(3,d2.getNumberOfFields())
00593         self.assertTrue(isinstance(d2.getMeshes().getMeshAtPos(0),MEDFileUMesh))
00594         m1bis=d2.getMeshes().getMeshAtPos(0).getMeshAtLevel(0)
00595         self.assertTrue(m1.isEqual(m1bis,1e-12))
00596         self.assertEqual(('f1', 'f21', 'f22'),d2.getFields().getFieldsNames())
00597         self.assertEqual([(-1, -1, 0.0)],d2.getFields().getFieldAtPos(2).getTimeSteps())
00598         self.assertEqual([(-1, -1, 0.0)],d2.getFields().getFieldWithName("f21").getTimeSteps())
00599         pass
    

Definition at line 967 of file MEDLoaderTest3.py.

00967 
00968     def testMEDLoaderMEDLoaderNSReadFieldDoubleDataInMedFile(self):
00969         fname="Pyfile41.med"
00970         f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
00971         m1=f1.getMesh()
00972         mm1=MEDFileUMesh.New()
00973         mm1.setCoords(m1.getCoords())
00974         mm1.setMeshAtLevel(0,m1)
00975         mm1.write(fname,2)
00976         ff1=MEDFileField1TS.New()
00977         ff1.setFieldNoProfileSBT(f1)
00978         ff1.write(fname,0)
00979         # writing mesh1 and field1, now creation of mesh2 and field2
00980         f2=f1.deepCpy()
00981         m2=f2.getMesh()
00982         m2.translate([0.5,0.6,0.7])
00983         m2.setName("3DSurfMesh_2")
00984         f2.getArray()[:]*=2.
00985         f2.setName("VectorFieldOnCells2")
00986         mm2=MEDFileUMesh.New()
00987         mm2.setCoords(m2.getCoords())
00988         mm2.setMeshAtLevel(0,m2)
00989         mm2.write(fname,0)
00990         ff2=MEDFileField1TS.New()
00991         ff2.setFieldNoProfileSBT(f2)
00992         ff2.write(fname,0)
00993         #
00994         f3=MEDLoader.ReadFieldCell(fname,"3DSurfMesh_1",0,"VectorFieldOnCells",0,1)
00995         self.assertTrue(f3.isEqual(f1,1e-12,1e-12))
00996         f4=MEDLoader.ReadFieldCell(fname,"3DSurfMesh_2",0,"VectorFieldOnCells2",0,1)
00997         self.assertTrue(f4.isEqual(f2,1e-12,1e-12))
00998         pass

Definition at line 999 of file MEDLoaderTest3.py.

00999 
01000     def testMEDLoaderMultiLevelCellField1(self):
01001         fname="Pyfile42.med"
01002         m2,m1,m0,f2,f1,f0,p,n2,n1,n0,fns,fids,grpns,famIdsPerGrp=MEDLoaderDataForTest.buildMultiLevelMesh_1()
01003         m=MEDFileUMesh.New()
01004         m.setCoords(m2.getCoords())
01005         m.setMeshAtLevel(0,m2)
01006         m.setMeshAtLevel(-1,m1)
01007         m.setMeshAtLevel(-2,m0)
01008         m.write(fname,2)
01009         #
01010         FieldName1="Field1"
01011         compNames1=["comp1","comp2","comp3"]
01012         ff1=MEDFileField1TS.New()
01013         da2=DataArrayDouble.New()
01014         da2.alloc(m2.getNumberOfCells()*len(compNames1),1)
01015         da2.iota(7.)
01016         da2.rearrange(len(compNames1))
01017         da2.setInfoOnComponents(compNames1)
01018         f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f2.setName(FieldName1) ; f2.setArray(da2) ; f2.setMesh(m2) ; f2.checkCoherency()
01019         ff1.setFieldNoProfileSBT(f2)
01020         self.assertEqual(ff1.getNonEmptyLevels(),(2, [0]))
01021         da0=DataArrayDouble.New()
01022         da0.alloc(m0.getNumberOfCells()*len(compNames1),1)
01023         da0.iota(190.)
01024         da0.rearrange(len(compNames1))
01025         da0.setInfoOnComponents(compNames1)
01026         f0=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f0.setName(FieldName1) ; f0.setArray(da0) ; f0.setMesh(m0) ; f0.checkCoherency()
01027         ff1.setFieldNoProfileSBT(f0)
01028         self.assertEqual(ff1.getNonEmptyLevels(),(2, [0,-2]))
01029         da1=DataArrayDouble.New()
01030         da1.alloc(m1.getNumberOfCells()*len(compNames1),1)
01031         da1.iota(90.)
01032         da1.rearrange(len(compNames1))
01033         da1.setInfoOnComponents(compNames1)
01034         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f1.setName(FieldName1) ; f1.setArray(da1) ; f1.setMesh(m1) ; f1.checkCoherency()
01035         ff1.setFieldNoProfileSBT(f1)
01036         self.assertEqual(ff1.getNonEmptyLevels(),(2, [0,-1,-2]))
01037         #
01038         ff1.write(fname,0)
01039         #
01040         FieldName2="Field2"
01041         compNames2=["comp11","comp22"]
01042         ff2=MEDFileField1TS.New()
01043         da0=DataArrayDouble.New()
01044         da0.alloc(m0.getNumberOfCells()*2,1)
01045         da0.iota(-190.)
01046         da0.rearrange(2)
01047         da0.setInfoOnComponents(compNames2)
01048         f0=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f0.setName(FieldName2) ; f0.setArray(da0) ; f0.setMesh(m0) ; f0.checkCoherency()
01049         ff2.setFieldNoProfileSBT(f0)
01050         self.assertEqual(ff2.getNonEmptyLevels(),(0, [0]))
01051         da1=DataArrayDouble.New()
01052         da1.alloc(m1.getNumberOfCells()*len(compNames2),1)
01053         da1.iota(-90.)
01054         da1.rearrange(len(compNames2))
01055         da1.setInfoOnComponents(compNames2)
01056         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f1.setName(FieldName2) ; f1.setArray(da1) ; f1.setMesh(m1) ; f1.checkCoherency()
01057         ff2.setFieldNoProfileSBT(f1)
01058         self.assertEqual(ff2.getNonEmptyLevels(),(1, [0,-1]))
01059         #
01060         ff2.write(fname,0)
01061         #
01062         ff1=MEDFileField1TS.New(fname,FieldName1,-1,-1)
01063         self.assertEqual(ff1.getNonEmptyLevels(),(2, [0,-1,-2]))
01064         self.assertEqual(ff1.getFieldSplitedByType(),[(0, [(0, (0, 4), '', '')]), (1, [(0, (4, 84), '', '')]), (3, [(0, (84, 148), '', '')]), (4, [(0, (148, 212), '', '')])])
01065         ff2=MEDFileField1TS.New(fname,FieldName2,-1,-1)
01066         self.assertEqual(ff2.getNonEmptyLevels(),(1, [0,-1]))
01067         self.assertEqual(ff2.getFieldSplitedByType(),[(0, [(0, (0, 4), '', '')]), (1, [(0, (4, 84), '', '')])])
01068         pass

Definition at line 27 of file MEDLoaderTest3.py.

00027 
00028     def testMEDMesh1(self):
00029         fileName="Pyfile18.med"
00030         mname="ExampleOfMultiDimW"
00031         medmesh=MEDFileMesh.New(fileName,mname)
00032         self.assertEqual((0,-1),medmesh.getNonEmptyLevels())
00033         m1_0=medmesh.getLevel0Mesh(True)
00034         m1_1=MEDLoader.ReadUMeshFromFile(fileName,mname,0)
00035         self.assertTrue(m1_0.isEqual(m1_1,1e-12));
00036         m2_0=medmesh.getLevelM1Mesh(True)
00037         m2_1=MEDLoader.ReadUMeshFromFile(fileName,mname,-1)
00038         self.assertTrue(m2_0.isEqual(m2_1,1e-12));
        pass

Definition at line 39 of file MEDLoaderTest3.py.

00039 
00040     def testMEDMesh2(self):
00041         fileName="Pyfile10.med"
00042         mname="3DToto"
00043         outFileName="MEDFileMesh1.med"
00044         medmesh=MEDFileUMesh.New(fileName,mname)
00045         self.assertEqual((0,),medmesh.getNonEmptyLevels())
00046         m1_0=medmesh.getLevel0Mesh(True)
00047         m1_1=MEDLoader.ReadUMeshFromFile(fileName,mname,0)
00048         self.assertTrue(m1_0.isEqual(m1_1,1e-12));
00049         g1_0=medmesh.getGroup(0,"mesh2",True)
00050         g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh2"]);
00051         self.assertTrue(g1_0.isEqual(g1_1,1e-12));
00052         g1_0=medmesh.getGroup(0,"mesh3",True)
00053         g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh3"]);
00054         self.assertTrue(g1_0.isEqual(g1_1,1e-12));
00055         g1_0=medmesh.getGroups(0,["mesh3","mesh2"])
00056         g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh3","mesh2"]);
00057         g1_1.setName(g1_0.getName())
00058         self.assertTrue(g1_0.isEqual(g1_1,1e-12));
00059         g1_0=medmesh.getFamily(0,"Family_2",True)
00060         g1_1=MEDLoader.ReadUMeshFromFamilies(fileName,mname,0,["Family_2"]);
00061         self.assertTrue(g1_0.isEqual(g1_1,1e-12));
00062         g1_0=medmesh.getFamilies(0,["Family_2","Family_4"],True)
00063         g1_1=MEDLoader.ReadUMeshFromFamilies(fileName,mname,0,["Family_2","Family_4"]);
00064         g1_1.setName(g1_0.getName())
00065         self.assertTrue(g1_0.isEqual(g1_1,1e-12));
00066         self.assertTrue(g1_0.isEqual(g1_1,1e-12));
00067         medmesh.write(outFileName,2);
00068         self.assertEqual([2,3,5,14,16],medmesh.getGroupArr(0,"mesh2",True).getValues());
00069         self.assertEqual([2,3,16],medmesh.getFamilyArr(0,"Family_2",True).getValues());
00070         self.assertEqual([2,3,5,14,16],medmesh.getFamiliesArr(0,["Family_4","Family_2"],True).getValues());
00071         self.assertEqual([19,2,3,4,5,14,15,16],medmesh.getGroupsArr(0,["mesh2","mesh4","mesh3"],True).getValues());
00072         famn=medmesh.getFamilyNameGivenId(0)
00073         self.assertRaises(InterpKernelException,medmesh.getNodeFamilyArr,famn,True);
00074         #without renum
00075         self.assertEqual([2,3,5,14,16],medmesh.getGroupArr(0,"mesh2",False).getValues());
00076         self.assertEqual([2,3,16],medmesh.getFamilyArr(0,"Family_2",False).getValues());
00077         self.assertEqual([2,3,5,14,16],medmesh.getFamiliesArr(0,["Family_4","Family_2"],False).getValues());
00078         self.assertEqual([0,2,3,4,5,14,15,16],medmesh.getGroupsArr(0,["mesh2","mesh3","mesh4"],False).getValues());
00079         self.assertRaises(InterpKernelException,medmesh.getNodeFamilyArr,famn,False);
00080         pass

Definition at line 82 of file MEDLoaderTest3.py.

00082 
00083     def testMEDMesh3(self):
00084         outFileName="MEDFileMesh3.med"
00085         c=DataArrayDouble.New()
00086         coords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ];
00087         targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
00088         c.setValues(coords,9,2)
00089         m=MEDCouplingUMesh.New();
00090         m.setMeshDimension(2);
00091         m.allocateCells(5);
00092         m.insertNextCell(NORM_TRI3,3,targetConn[4:7])
00093         m.insertNextCell(NORM_TRI3,3,targetConn[7:10])
00094         m.insertNextCell(NORM_QUAD4,4,targetConn[0:4])
00095         m.insertNextCell(NORM_POLYGON,4,targetConn[10:14])
00096         m.insertNextCell(NORM_POLYGON,4,targetConn[14:18])
00097         m.finishInsertingCells();
00098         m.setCoords(c)
00099         m.checkCoherency()
00100         m1=MEDCouplingUMesh.New();
00101         m1.setMeshDimension(1);
00102         m1.allocateCells(3);
00103         m1.insertNextCell(NORM_SEG2,2,[1,4])
00104         m1.insertNextCell(NORM_SEG2,2,[3,6])
00105         m1.insertNextCell(NORM_SEG3,3,[2,8,5])
00106         m1.finishInsertingCells();
00107         m1.setCoords(c)
00108         m1.checkCoherency()
00109         m2=MEDCouplingUMesh.New();
00110         m2.setMeshDimension(0);
00111         m2.allocateCells(4);
00112         m2.insertNextCell(NORM_POINT1,1,[1])
00113         m2.insertNextCell(NORM_POINT1,1,[3])
00114         m2.insertNextCell(NORM_POINT1,1,[2])
00115         m2.insertNextCell(NORM_POINT1,1,[6])
00116         m2.finishInsertingCells();
00117         m2.setCoords(c)
00118         m2.checkCoherency()
00119         #
00120         mm=MEDFileUMesh.New()
00121         mm.setName("MyFirstMEDCouplingMEDmesh")
00122         mm.setDescription("IHopeToConvinceLastMEDMEMUsers")
00123         mm.setCoords(c)
00124         mm.setMeshAtLevel(-1,m1);
00125         mm.setMeshAtLevel(0,m);
00126         mm.setMeshAtLevel(-2,m2);
00127         # playing with groups
00128         g1_2=DataArrayInt.New()
00129         g1_2.setValues([1,3],2,1)
00130         g1_2.setName("G1")
00131         g2_2=DataArrayInt.New()
00132         g2_2.setValues([1,2,3],3,1)
00133         g2_2.setName("G2")
00134         mm.setGroupsAtLevel(0,[g1_2,g2_2],False)
00135         g1_1=DataArrayInt.New()
00136         g1_1.setValues([0,1,2],3,1)
00137         g1_1.setName("G1")
00138         g2_1=DataArrayInt.New()
00139         g2_1.setValues([0,2],2,1)
00140         g2_1.setName("G2")
00141         mm.setGroupsAtLevel(-1,[g1_1,g2_1],False)
00142         g1_N=DataArrayInt.New()
00143         g1_N.setValues(range(8),8,1)
00144         g1_N.setName("G1")
00145         g2_N=DataArrayInt.New()
00146         g2_N.setValues(range(9),9,1)
00147         g2_N.setName("G2")
00148         mm.setGroupsAtLevel(1,[g1_N,g2_N],False)
00149         mm.createGroupOnAll(0,"GrpOnAllCell")
00150         # check content of mm
00151         t=mm.getGroupArr(0,"G1",False)
00152         self.assertTrue(g1_2.isEqual(t));
00153         t=mm.getGroupArr(0,"G2",False)
00154         self.assertTrue(g2_2.isEqual(t));
00155         t=mm.getGroupArr(-1,"G1",False)
00156         self.assertTrue(g1_1.isEqual(t));
00157         t=mm.getGroupArr(-1,"G2",False)
00158         self.assertTrue(g2_1.isEqual(t));
00159         t=mm.getGroupArr(1,"G1",False)
00160         self.assertTrue(g1_N.isEqual(t));
00161         t=mm.getGroupArr(1,"G2",False)
00162         self.assertTrue(g2_N.isEqual(t));
00163         self.assertTrue(mm.existsGroup("GrpOnAllCell"));
00164         t=mm.getGroupArr(0,"GrpOnAllCell")
00165         self.assertTrue(t.getValues()==range(5))
00166         #
00167         mm.write(outFileName,2);
00168         #
00169         mm=MEDFileMesh.New(outFileName)
00170         mbis=mm.getMeshAtLevel(0)
00171         m.setName(mm.getName()) ; m.setDescription(mm.getDescription())
00172         self.assertTrue(m.isEqual(mbis,1e-12));
00173         #
00174         self.assertEqual(([[(3, 2), (4, 1), (5, 8)], [(1, 2), (2, 1)], [(0, 4)]], 2, 2, 9),MEDLoader.GetUMeshGlobalInfo(outFileName,"MyFirstMEDCouplingMEDmesh"))
00175         pass

Definition at line 177 of file MEDLoaderTest3.py.

00177 
00178     def testMEDMesh4(self):
00179         outFileName="MEDFileMesh4.med"
00180         c=DataArrayDouble.New()
00181         coords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ];
00182         targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
00183         c.setValues(coords,9,2)
00184         c.setInfoOnComponent(0,"abcdef [km]")
00185         c.setInfoOnComponent(1,"ghij [MW]")
00186         m=MEDCouplingUMesh.New();
00187         m.setMeshDimension(2);
00188         m.allocateCells(5);
00189         m.insertNextCell(NORM_QUAD4,4,targetConn[0:4])
00190         m.insertNextCell(NORM_TRI3,3,targetConn[4:7])
00191         m.insertNextCell(NORM_TRI3,3,targetConn[7:10])
00192         m.insertNextCell(NORM_QUAD4,4,targetConn[10:14])
00193         m.insertNextCell(NORM_QUAD4,4,targetConn[14:18])
00194         m.finishInsertingCells();
00195         m.setCoords(c)
00196         m.checkCoherency()
00197         m1=MEDCouplingUMesh.New();
00198         m1.setMeshDimension(1);
00199         m1.allocateCells(3);
00200         m1.insertNextCell(NORM_SEG2,2,[1,4])
00201         m1.insertNextCell(NORM_SEG3,3,[2,8,5])
00202         m1.insertNextCell(NORM_SEG2,2,[3,6])
00203         m1.finishInsertingCells();
00204         m1.setCoords(c)
00205         m1.checkCoherency()
00206         m2=MEDCouplingUMesh.New();
00207         m2.setMeshDimension(0);
00208         m2.allocateCells(4);
00209         m2.insertNextCell(NORM_POINT1,1,[1])
00210         m2.insertNextCell(NORM_POINT1,1,[3])
00211         m2.insertNextCell(NORM_POINT1,1,[2])
00212         m2.insertNextCell(NORM_POINT1,1,[6])
00213         m2.finishInsertingCells();
00214         m2.setCoords(c)
00215         m2.checkCoherency()
00216         #
00217         mm=MEDFileUMesh.New()
00218         mm.setName("My2ndMEDCouplingMEDmesh")
00219         mm.setDescription("ThisIsImpossibleToDoWithMEDMEM")
00220         mm.setCoords(c)
00221         renumNode=DataArrayInt.New()
00222         renumNode.setValues([10,11,12,13,14,15,16,17,18],9,1)
00223         mm.setRenumFieldArr(1,renumNode)
00224         mm.setMeshAtLevel(-1,m1,True);
00225         mm.setMeshAtLevel(0,m,True);
00226         mm.setMeshAtLevel(-2,m2,True);
00227         mm.removeMeshAtLevel(-2)
00228         mm.setMeshAtLevel(-2,m2,True);
00229         # playing with groups
00230         g1_2=DataArrayInt.New()
00231         g1_2.setValues([2,3],2,1)
00232         g1_2.setName("G1")
00233         g2_2=DataArrayInt.New()
00234         g2_2.setValues([2,0,3],3,1)
00235         g2_2.setName("G2")
00236         mm.setGroupsAtLevel(0,[g1_2,g2_2],True)
00237         g1_1=DataArrayInt.New()
00238         g1_1.setValues([0,2,1],3,1)
00239         g1_1.setName("G1")
00240         g2_1=DataArrayInt.New()
00241         g2_1.setValues([0,2],2,1)
00242         g2_1.setName("G2")
00243         mm.setGroupsAtLevel(-1,[g1_1,g2_1],True)
00244         g1_N=DataArrayInt.New()
00245         g1_N.setValues([10,11,12,13,14,15,16,17],8,1)
00246         g1_N.setName("G1")
00247         g2_N=DataArrayInt.New()
00248         g2_N.setValues([10,11,12,13,14,15,16,17,18],9,1)
00249         g2_N.setName("G2")
00250         mm.setGroupsAtLevel(1,[g1_N,g2_N],True)
00251         # check content of mm
00252         t=mm.getGroupArr(0,"G1",True)
00253         self.assertTrue(g1_2.isEqual(t));
00254         t=mm.getGroupArr(0,"G2",True)
00255         self.assertTrue(g2_2.isEqual(t));
00256         t=mm.getGroupArr(-1,"G1",True)
00257         self.assertTrue(g1_1.isEqual(t));
00258         t=mm.getGroupArr(-1,"G2",True)
00259         self.assertTrue(g2_1.isEqual(t));
00260         self.assertTrue(not mm.existsGroup("GrpOnAllCell"));
00261         #
00262         mm.write(outFileName,2);
00263         mm2=MEDFileMesh.New(outFileName)
00264         res=mm.isEqual(mm2,1e-12)
00265         self.assertTrue(res[0])
00266         l=list(mm2.getFamiliesOnGroup("G2")) ; l.sort()
00267         self.assertEqual(['Family_10','Family_11','Family_3','Family_4','Family_7'],l)
00268         mm2.keepFamIdsOnlyOnLevs([3],[-1])
00269         for lev in mm.getGrpNonEmptyLevelsExt("G2"):
00270             self.assertEqual(mm.getGroupArr(lev,"G2").getValues(),mm2.getGroupArr(lev,"G2").getValues())
00271             pass
00272         l=list(mm2.getFamiliesOnGroup("G2")) ; l.sort()
00273         self.assertEqual(['Family_10','Family_11','Family_12','Family_3','Family_4','Family_7'],l)
00274         #
00275         self.assertEqual([7,7,6],mm2.getFamilyFieldAtLevel(-1).getValues())
00276         mm2.getFamilyFieldAtLevel(-1).setIJ(1,0,8)
00277         self.assertEqual([7,8,6],mm2.getFamilyFieldAtLevel(-1).getValues())
00278         self.assertTrue(not mm2.existsFamily("Family_8"))
00279         mm2.createGroupOnAll(-1,"GrpOnAllFace")
00280         self.assertTrue(mm2.existsFamily("Family_8"))
00281         self.assertEqual(range(3),mm2.getGroupArr(-1,"GrpOnAllFace").getValues())
00282         pass

Definition at line 284 of file MEDLoaderTest3.py.

00284 
00285     def testMEDMesh5(self):
00286         fileName="Pyfile18.med"
00287         mname="ExampleOfMultiDimW"
00288         medmesh=MEDFileUMesh.New(fileName,mname)
00289         m1_0=medmesh.getLevel0Mesh(True)
00290         da1=medmesh.getFamilyFieldAtLevel(0)
00291         del medmesh
00292         self.assertEqual(20,m1_0.getNumberOfCells())
00293         self.assertEqual(20,da1.getNumberOfTuples())
00294         pass

Definition at line 295 of file MEDLoaderTest3.py.

00295 
00296     def testMEDMesh6(self):
00297         outFileName="MEDFileMesh5.med"
00298         m=MEDFileCMesh.New()
00299         m.setTime(2.3,-1,-1)
00300         m1=MEDCouplingCMesh.New();
00301         da=DataArrayDouble.New()
00302         da.setValues([0.,1.,2.],3,1)
00303         da.setInfoOnComponent(0,"XX [mm]")
00304         m1.setCoordsAt(0,da)
00305         da=DataArrayDouble.New()
00306         da.setValues([0.,1.2],2,1)
00307         da.setInfoOnComponent(0,"YY [km]")
00308         m1.setCoordsAt(1,da)
00309         da=DataArrayDouble.New()
00310         da.setValues([0.,1.3],2,1)
00311         da.setInfoOnComponent(0,"ZZ [um]")
00312         m1.setCoordsAt(2,da)
00313         m.setMesh(m1)
00314         m.setName("myFirstCartMesh")
00315         m.setDescription("mmmmpppppppp")
00316         m.setTimeValue(2.3)
00317         m.setTimeUnit("ms")
00318         da=DataArrayInt.New()
00319         da.setValues([0,0,1,0,1,2,4,3,0,1,2,2],12,1)
00320         m.setFamilyFieldArr(1,da)
00321         m.setFamilyId("family1",1)
00322         da=m.getFamilyArr(1,"family1")
00323         expected1=[2,4,9]
00324         self.assertEqual(expected1,da.getValues())
00325         m.write(outFileName,2);
00326         mm=MEDFileMesh.New(outFileName)
00327         self.assertTrue(m.isEqual(mm,1e-12)[0])
00328         self.assertEqual(expected1,mm.getFamilyArr(1,"family1").getValues())
00329         m2=mm.getMesh()
00330         tt=m.getTime()
00331         m1.setTime(tt[0],tt[1],tt[2])
00332         m1.setName(m.getName())
00333         m1.setTimeUnit(m.getTimeUnit())
00334         m1.setDescription(m.getDescription())
00335         self.assertTrue(m2.isEqual(m1,1e-12));
00336         pass

Definition at line 337 of file MEDLoaderTest3.py.

00337 
00338     def testMEDMesh7(self):
00339         fileName="Pyfile24.med"
00340         m2,m1,m0,f2,f1,f0,p,n2,n1,n0,fns,fids,grpns,famIdsPerGrp=MEDLoaderDataForTest.buildMultiLevelMesh_1()
00341         m=MEDFileUMesh.New()
00342         m.setCoords(m2.getCoords())
00343         m.setMeshAtLevel(0,m2)
00344         m.setMeshAtLevel(-1,m1)
00345         m.setMeshAtLevel(-2,m0)
00346         m.setFamilyFieldArr(0,f2)
00347         m.setFamilyFieldArr(-1,f1)
00348         m.setFamilyFieldArr(-2,f0)
00349         m.setFamilyFieldArr(1,p)
00350         m.setRenumFieldArr(0,n2)
00351         m.setRenumFieldArr(-1,n1)
00352         m.setRenumFieldArr(-2,n0)
00353         nbOfFams=len(fns)
00354         for i in xrange(nbOfFams):
00355             m.addFamily(fns[i],fids[i])
00356             pass
00357         nbOfGrps=len(grpns)
00358         for i in xrange(nbOfGrps):
00359             m.setFamiliesIdsOnGroup(grpns[i],famIdsPerGrp[i])
00360             pass
00361         m.setName(m2.getName())
00362         m.setDescription(m2.getDescription())
00363         #
00364         self.assertEqual((-1,),m.getGrpNonEmptyLevels("A2A4"))
00365         self.assertEqual((),m.getGrpNonEmptyLevels("A1"))
00366         self.assertEqual((-2,),m.getGrpNonEmptyLevels("AP2"))
00367         self.assertEqual((-1,-2),m.getGrpsNonEmptyLevels(["A2A4","AP2"]))
00368         self.assertEqual((-1,),m.getFamNonEmptyLevels('A4A3____________________________'))
00369         self.assertEqual((0,),m.getFamNonEmptyLevels('MESH____DALT3___DALLE___________'))
00370         self.assertEqual((0,-1,),m.getFamsNonEmptyLevels(['MESH____DALT3___DALLE___________','A4A3____________________________']))
00371         self.assertEqual(('A1A2','A2A4','A3A1','A3C5','A4A3','B1C1','B2B4','B3B1','B4C3','C1C4','C2B2','C3C2','C4B3','C5A4'),m.getGroupsOnSpecifiedLev(-1))
00372         self.assertEqual(('DALLE','DALQ1','DALQ2','DALT3','MESH'),m.getGroupsOnSpecifiedLev(0))
00373         #
00374         m.write(fileName,2)
00375         pass

Definition at line 924 of file MEDLoaderTest3.py.

00924 
00925     def testMEDMesh8(self):
00926         m=MEDLoaderDataForTest.build1DMesh_1()
00927         m.convertQuadraticCellsToLinear()
00928         mm=MEDFileUMesh.New()
00929         mm.setMeshAtLevel(0,m)
00930         g1=DataArrayInt.New() ; g1.setValues([0,2],2,1) ; g1.setName("g1")
00931         g2=DataArrayInt.New() ; g2.setValues([1,3],2,1) ; g2.setName("g2")
00932         g3=DataArrayInt.New() ; g3.setValues([1,2,3],3,1) ; g3.setName("g3")
00933         mm.setGroupsAtLevel(0,[g1,g2],False)
00934         self.assertEqual(('g1','g2'),mm.getGroupsNames())
00935         self.assertEqual(('Family_2','Family_3'),mm.getFamiliesNames())
00936         self.assertEqual(('Family_2',),mm.getFamiliesOnGroup('g1'))
00937         self.assertEqual(('Family_3',),mm.getFamiliesOnGroup('g2'))
00938         mm.assignFamilyNameWithGroupName()
00939         self.assertEqual(('g1','g2'),mm.getGroupsNames())
00940         self.assertEqual(('g1','g2'),mm.getFamiliesNames())
00941         self.assertEqual(('g1',),mm.getFamiliesOnGroup('g1'))
00942         self.assertEqual(('g2',),mm.getFamiliesOnGroup('g2'))
00943         #
00944         mm=MEDFileUMesh.New()
00945         mm.setMeshAtLevel(0,m)
00946         mm.setGroupsAtLevel(0,[g1,g2,g3],False)
00947         self.assertEqual(('g1','g2','g3'),mm.getGroupsNames())
00948         self.assertEqual(('Family_2', 'Family_4', 'Family_5'),mm.getFamiliesNames())
00949         self.assertEqual(('Family_2', 'Family_4'),mm.getFamiliesOnGroup('g1'))
00950         self.assertEqual(('Family_5',),mm.getFamiliesOnGroup('g2'))
00951         self.assertEqual(('Family_4','Family_5',),mm.getFamiliesOnGroup('g3'))
00952         mm.assignFamilyNameWithGroupName() # here it does nothing because no such group-family bijection found
00953         self.assertEqual(('g1','g2','g3'),mm.getGroupsNames())
00954         self.assertEqual(('Family_2', 'Family_4', 'Family_5'),mm.getFamiliesNames())
00955         self.assertEqual(('Family_2', 'Family_4'),mm.getFamiliesOnGroup('g1'))
00956         self.assertEqual(('Family_5',),mm.getFamiliesOnGroup('g2'))
00957         self.assertEqual(('Family_4','Family_5',),mm.getFamiliesOnGroup('g3'))
00958         mm.changeFamilyId(5,6)
00959         g=mm.getGroupArr(0,"g3")
00960         self.assertTrue(g.isEqual(g3));
00961         g=mm.getGroupArr(0,"g2")
00962         self.assertTrue(g.isEqual(g2));
00963         g=mm.getGroupArr(0,"g1")
00964         self.assertTrue(g.isEqual(g1));
00965         pass
    

The documentation for this class was generated from the following file: