Back to index

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

List of all members.

Public Member Functions

def testMesh1DRW
def testMesh2DCurveRW
def testMesh2DRW
def testMesh3DSurfRW
def testMesh3DRW
def testFieldRW1
def testFieldRW2
def testFieldRW3
def testMultiMeshRW1
def testFieldProfilRW1
def testFieldGaussRW1
def testFieldGaussNERW1
def testMesh3DSurfShuffleRW
def testMultiFieldShuffleRW1
def testWriteUMeshesRW1
def testFieldNodeProfilRW1
def testFieldNodeProfilRW2
def testMixCellAndNodesFieldRW1
def testGetAllFieldNamesRW1

Detailed Description

Definition at line 26 of file MEDLoaderTest.py.


Member Function Documentation

Definition at line 313 of file MEDLoaderTest.py.

00313 
00314     def testFieldGaussNERW1(self):
00315         fileName="Pyfile14.med";
00316         f1=MEDLoaderDataForTest.buildVecFieldOnGaussNE_1();
00317         MEDLoader.MEDLoader.WriteField(fileName,f1,True);
00318         f2=MEDLoader.MEDLoader.ReadField(MEDLoader.ON_GAUSS_NE,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
00319         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
00320         pass

Definition at line 305 of file MEDLoaderTest.py.

00305 
00306     def testFieldGaussRW1(self):
00307         fileName="Pyfile13.med";
00308         f1=MEDLoaderDataForTest.buildVecFieldOnGauss_1();
00309         MEDLoader.MEDLoader.WriteField(fileName,f1,True);
00310         f2=MEDLoader.MEDLoader.ReadField(MEDLoader.ON_GAUSS_PT,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
00311         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
00312         pass

Definition at line 402 of file MEDLoaderTest.py.

00402 
00403     def testFieldNodeProfilRW1(self):
00404         fileName="Pyfile19.med";
00405         fileName2="Pyfile20.med";
00406         m=MEDLoaderDataForTest.build2DMesh_1();
00407         nbOfNodes=m.getNumberOfNodes();
00408         MEDLoader.MEDLoader.WriteUMesh(fileName,m,True);
00409         f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
00410         f1.setName("VFieldOnNodes");
00411         f1.setMesh(m);
00412         array=MEDLoader.DataArrayDouble.New();
00413         arr1=[1.,101.,2.,102.,3.,103.,4.,104.,5.,105.,6.,106.,7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.]
00414         array.setValues(arr1,nbOfNodes,2);
00415         f1.setArray(array);
00416         array.setInfoOnComponent(0,"tyty [mm]");
00417         array.setInfoOnComponent(1,"uiop [MW]");
00418         f1.setTime(3.14,2,7);
00419         f1.checkCoherency();
00420         arr2=[1,4]
00421         f2=f1.buildSubPart(arr2);
00422         f2.getMesh().setName(f1.getMesh().getName());
00423         MEDLoader.MEDLoader.WriteField(fileName,f2,False);#<- False important for the test
00424         #
00425         f3=MEDLoader.MEDLoader.ReadFieldNode(fileName,f2.getMesh().getName(),0,f2.getName(),2,7);
00426         f3.checkCoherency();
00427         self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
00428         #
00429         arr3=[1,3,0,5,2,4]
00430         f2.renumberNodes(arr3);
00431         MEDLoader.MEDLoader.WriteUMesh(fileName2,m,True);
00432         MEDLoader.MEDLoader.WriteField(fileName2,f2,False);#<- False important for the test
00433         f3=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f2.getMesh().getName(),0,f2.getName(),2,7);
00434         f3.checkCoherency();
00435         self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
00436         #
00437         pass

Definition at line 438 of file MEDLoaderTest.py.

00438 
00439     def testFieldNodeProfilRW2(self):
00440         fileName="Pyfile23.med";
00441         mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
00442         MEDLoader.MEDLoader.WriteUMesh(fileName,mesh,True);
00443         #
00444         f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
00445         f1.setName("FieldMix");
00446         f1.setMesh(mesh);
00447         arr2=[1071.,1171.,1010.,1110.,1020.,1120.,1030.,1130.,1040.,1140.,1050.,1150.,
00448               1060.,1160.,1070.,1170.,1080.,1180.,1090.,1190.,1091.,1191.,1092.,1192.];
00449         array=MEDLoader.DataArrayDouble.New();
00450         array.setValues(arr2,12,2);
00451         f1.setArray(array);
00452         array.setInfoOnComponent(0,"plkj [mm]");
00453         array.setInfoOnComponent(1,"pqqqss [mm]");
00454         tmp=array.getPointer();
00455         f1.setTime(3.17,2,7);
00456         #
00457         renumArr=[3,7,2,1,5,11,10,0,9,6,8,4]
00458         f1.renumberNodes(renumArr);
00459         f1.checkCoherency();
00460         MEDLoader.MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
00461         f2=MEDLoader.MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
00462         self.assertTrue(f2.isEqual(f1,1e-12,1e-12));
00463         #
00464         pass

Definition at line 273 of file MEDLoaderTest.py.

00273 
00274     def testFieldProfilRW1(self):
00275         fileName="Pyfile12.med";
00276         mesh1=MEDLoaderDataForTest.build3DMesh_1();
00277         da,b,newNbOfNodes=mesh1.mergeNodes(1e-12);
00278         MEDLoader.MEDLoader.WriteUMesh(fileName,mesh1,True);
00279         part1=[1,2,4,13,15]
00280         mesh2=mesh1.buildPartOfMySelf(part1,True);
00281         mesh2.setName(mesh1.getName());#<- important for the test
00282         #
00283         nbOfCells=mesh2.getNumberOfCells();
00284         self.assertEqual(5,nbOfCells);
00285         f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
00286         f1.setName("VectorFieldOnCells");
00287         f1.setMesh(mesh2);
00288         array=MEDLoader.DataArrayDouble.New();
00289         array.alloc(nbOfCells,2);
00290         f1.setArray(array);
00291         arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.]
00292         array.setValues(arr1,nbOfCells,2);
00293         f1.setTime(3.14,2,7);
00294         f1.checkCoherency();
00295         #
00296         MEDLoader.MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
00297         #
00298         f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
00299         tt=MEDLoader.MEDLoader.GetTypesOfField(fileName,f1.getMesh().getName(),f1.getName());
00300         self.assertEqual(tt,[MEDLoader.ON_CELLS]);
00301         f2.checkCoherency();
00302         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
00303         #
00304         pass

Definition at line 67 of file MEDLoaderTest.py.

00067 
00068     def testFieldRW1(self):
00069         f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
00070         MEDLoader.MEDLoader.WriteField("Pyfile6.med",f1,True);
00071         f2=MEDLoader.MEDLoader.ReadFieldCell("Pyfile6.med",f1.getMesh().getName(),0,f1.getName(),0,1);
00072         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
00073         #
00074         f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
00075         MEDLoader.MEDLoader.WriteField("Pyfile7.med",f1,True);
00076         f2=MEDLoader.MEDLoader.ReadFieldNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
00077         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
00078         self.assertRaises(Exception,MEDLoader.MEDLoader.ReadFieldCell,"Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
00079         pass

Definition at line 80 of file MEDLoaderTest.py.

00080 
00081     def testFieldRW2(self):
00082         fileName="Pyfile8.med";
00083         VAL1=12345.67890314;
00084         VAL2=-1111111111111.;
00085         f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
00086         MEDLoader.MEDLoader.WriteField(fileName,f1,True);
00087         f1.setTime(10.,8,9);
00088         f1.getArray().setIJ(0,0,VAL1);
00089         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00090         f1.setTime(10.14,18,19);
00091         f1.getArray().setIJ(0,0,VAL2);
00092         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00093         #retrieving time steps...
00094         f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),8,9);
00095         f1.setTime(10.,8,9);
00096         f1.getArray().setIJ(0,0,VAL1);
00097         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
00098         f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),0,1);
00099         f3=MEDLoaderDataForTest.buildVecFieldOnCells_1();
00100         self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
00101         f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),18,19);
00102         f1.setTime(10.14,18,19);
00103         f1.getArray().setIJ(0,0,VAL2);
00104         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
00105         #test of throw on invalid (dt,it)
00106         self.assertRaises(Exception,MEDLoader.MEDLoader.ReadFieldCell,fileName,f1.getMesh().getName(),0,f1.getName(),28,19);
00107         #ON NODES
00108         f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
00109         fileName2="Pyfile9.med";
00110         MEDLoader.MEDLoader.WriteField(fileName2,f1,True);
00111         f1.setTime(110.,108,109);
00112         tmp=f1.getArray().getPointer();
00113         f1.getArray().setIJ(0,3,VAL1);
00114         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
00115         f1.setTime(210.,208,209);
00116         f1.getArray().setIJ(0,3,VAL2);
00117         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
00118         f2=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),108,109);
00119         f1.setTime(110.,108,109);
00120         f1.getArray().setIJ(0,3,VAL1);
00121         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
00122         f2=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),2,3);
00123         f3=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
00124         self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
00125         f2=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),208,209);
00126         f1.setTime(210.,208,209);
00127         f1.getArray().setIJ(0,3,VAL2);
00128         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
00129         pass

Definition at line 133 of file MEDLoaderTest.py.

00133 
00134     def testFieldRW3(self):
00135         fileName="Pyfile11.med";
00136         VAL1=12345.67890314;
00137         VAL2=-1111111111111.;
00138         name1="AField";
00139         name3="AMesh1";
00140         f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
00141         f1.getMesh().setName(name3);
00142         f1.setName(name1);
00143         f1.setTime(10.,8,9);
00144         tmp=f1.getArray().getPointer();
00145         f1.getArray().setIJ(0,0,VAL1);
00146         MEDLoader.MEDLoader.WriteField(fileName,f1,True);
00147         f1.setTime(10.14,18,19);
00148         f1.getArray().setIJ(0,0,VAL2);
00149         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00150         f1.getMesh().setName(name3);
00151         f1.setTime(10.55,28,29);
00152         f1.getArray().setIJ(0,0,3*VAL1);
00153         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00154         vec=MEDLoader.MEDLoader.GetMeshNamesOnField(fileName,name1);
00155         f1.setTime(10.66,38,39);
00156         f1.getArray().setIJ(0,0,3*VAL2);
00157         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00158         f1.setTime(10.77,48,49);
00159         f1.getArray().setIJ(0,0,4*VAL2);
00160         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00161         #ON NODES
00162         f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
00163         f1.setName(name1);
00164         f1.getMesh().setName(name3);
00165         f1.setTime(110.,8,9);
00166         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00167         f1.setTime(110.,108,109);
00168         tmp=f1.getArray().getPointer();
00169         f1.getArray().setIJ(0,3,VAL1);
00170         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00171         f1.setTime(210.,208,209);
00172         f1.getArray().setIJ(0,3,VAL2);
00173         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00174         #
00175         it1=MEDLoader.MEDLoader.GetCellFieldIterations(fileName,name3,name1);
00176         self.assertEqual(5,len(it1));
00177         self.assertEqual(8,it1[0][0]); self.assertEqual(9,it1[0][1]);
00178         self.assertEqual(18,it1[1][0]); self.assertEqual(19,it1[1][1]);
00179         self.assertEqual(28,it1[2][0]); self.assertEqual(29,it1[2][1]);
00180         self.assertEqual(38,it1[3][0]); self.assertEqual(39,it1[3][1]);
00181         self.assertEqual(48,it1[4][0]); self.assertEqual(49,it1[4][1]);
00182         it3=MEDLoader.MEDLoader.GetNodeFieldIterations(fileName,name3,name1);
00183         self.assertEqual(3,len(it3));
00184         self.assertEqual(8,it3[0][0]); self.assertEqual(9,it3[0][1]);
00185         self.assertEqual(108,it3[1][0]); self.assertEqual(109,it3[1][1]);
00186         self.assertEqual(208,it3[2][0]); self.assertEqual(209,it3[2][1]);
00187         #
00188         #
00189         f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name3,0,name1,8,9);
00190         self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,0),13);
00191         f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name3,0,name1,18,19);
00192         self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,0),13);
00193         f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name3,0,name1,28,29);
00194         self.assertAlmostEqual(3*VAL1,f1.getArray().getIJ(0,0),13);
00195         f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name3,0,name1,38,39);
00196         self.assertAlmostEqual(3*VAL2,f1.getArray().getIJ(0,0),13);
00197         f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name3,0,name1,48,49);
00198         self.assertAlmostEqual(4*VAL2,f1.getArray().getIJ(0,0),13);
00199         #
00200         f1=MEDLoader.MEDLoader.ReadFieldNode(fileName,name3,0,name1,8,9);
00201         self.assertAlmostEqual(71.,f1.getArray().getIJ(0,3),13);
00202         f1=MEDLoader.MEDLoader.ReadFieldNode(fileName,name3,0,name1,108,109);
00203         self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,3),13);
00204         f1=MEDLoader.MEDLoader.ReadFieldNode(fileName,name3,0,name1,208,209);
00205         self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,3),13);
00206         pass

Definition at line 517 of file MEDLoaderTest.py.

00517 
00518     def testGetAllFieldNamesRW1(self):
00519         fileName="Pyfile22.med";
00520         mesh=MEDLoaderDataForTest.build2DMesh_2();
00521         f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
00522         f1.setName("Field1");
00523         f1.setTime(3.44,5,6);
00524         f1.setMesh(mesh);
00525         f1.fillFromAnalytic(2,"x+y");
00526         MEDLoader.MEDLoader.WriteField(fileName,f1,True);
00527         f1.setTime(1002.3,7,8);
00528         f1.fillFromAnalytic(2,"x+77.*y");
00529         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00530         f1.setName("Field2");
00531         MEDLoader.MEDLoader.WriteField(fileName,f1,False);
00532         f1.setName("Field3");
00533         mesh.setName("2DMesh_2Bis");
00534         MEDLoader.MEDLoader.WriteField(fileName,f1,False);
00535         f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
00536         f1.setName("Field8");
00537         f1.setTime(8.99,7,9);
00538         f1.setMesh(mesh);
00539         f1.fillFromAnalytic(3,"3*x+y");
00540         MEDLoader.MEDLoader.WriteField(fileName,f1,False);
00541         fs=MEDLoader.MEDLoader.GetAllFieldNames(fileName);
00542         self.assertEqual(4,len(fs));
00543         self.assertTrue(fs[0]=="Field1");
00544         self.assertTrue(fs[1]=="Field2");
00545         self.assertTrue(fs[2]=="Field3");
00546         self.assertTrue(fs[3]=="Field8");
        pass

Definition at line 27 of file MEDLoaderTest.py.

00027 
00028     def testMesh1DRW(self):
00029         mesh=MEDLoaderDataForTest.build1DMesh_1();
00030         mesh.checkCoherency();
00031         MEDLoader.MEDLoader.WriteUMesh("Pyfile1.med",mesh,True);
00032         mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile1.med",mesh.getName(),0);
00033         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
00034         pass

Definition at line 35 of file MEDLoaderTest.py.

00035 
00036     def testMesh2DCurveRW(self):
00037         mesh=MEDLoaderDataForTest.build2DCurveMesh_1();
00038         mesh.checkCoherency();
00039         MEDLoader.MEDLoader.WriteUMesh("Pyfile2.med",mesh,True);
00040         mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile2.med",mesh.getName(),0);
00041         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
00042         pass

Definition at line 43 of file MEDLoaderTest.py.

00043 
00044     def testMesh2DRW(self):
00045         mesh=MEDLoaderDataForTest.build2DMesh_1();
00046         mesh.checkCoherency();
00047         MEDLoader.MEDLoader.WriteUMesh("Pyfile3.med",mesh,True);
00048         mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile3.med",mesh.getName(),0);
00049         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
00050         pass

Definition at line 59 of file MEDLoaderTest.py.

00059 
00060     def testMesh3DRW(self):
00061         mesh=MEDLoaderDataForTest.build3DMesh_1();
00062         mesh.checkCoherency();
00063         MEDLoader.MEDLoader.WriteUMesh("Pyfile5.med",mesh,True);
00064         mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile5.med",mesh.getName(),0);
00065         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
00066         pass

Definition at line 51 of file MEDLoaderTest.py.

00051 
00052     def testMesh3DSurfRW(self):
00053         mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
00054         mesh.checkCoherency();
00055         MEDLoader.MEDLoader.WriteUMesh("Pyfile4.med",mesh,True);
00056         mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile4.med",mesh.getName(),0);
00057         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
00058         pass

Definition at line 321 of file MEDLoaderTest.py.

00321 
00322     def testMesh3DSurfShuffleRW(self):
00323         fileName="Pyfile15.med";
00324         mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
00325         renumber1=[2,5,1,0,3,4]
00326         mesh.renumberCells(renumber1,False);
00327         mesh.checkCoherency();
00328         MEDLoader.MEDLoader.WriteUMesh(fileName,mesh,True);
00329         mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,mesh.getName(),0);
00330         self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
00331         pass

Definition at line 465 of file MEDLoaderTest.py.

00465 
00466     def testMixCellAndNodesFieldRW1(self):
00467         fileName="Pyfile21.med";
00468         mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
00469         f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
00470         f1.setName("FieldMix");
00471         f1.setMesh(mesh);
00472         array=MEDLoader.DataArrayDouble.New();
00473         f1.setArray(array);
00474         arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.]
00475         array.setValues(arr1,6,2);
00476         array.setInfoOnComponent(0,"plkj [mm]");
00477         array.setInfoOnComponent(1,"pqqqss [mm]");
00478         f1.setTime(3.14,2,7);
00479         f1.checkCoherency();
00480         #
00481         f2=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
00482         f2.setName("FieldMix");
00483         f2.setMesh(mesh);
00484         array=MEDLoader.DataArrayDouble.New();
00485         f2.setArray(array);
00486         arr2=[1071.,1171.,1010.,1110.,1020.,1120.,1030.,1130.,1040.,1140.,1050.,1150.,
00487               1060.,1160.,1070.,1170.,1080.,1180.,1090.,1190.,1091.,1191.,1092.,1192.]
00488         array.setValues(arr2,12,2)
00489         array.setInfoOnComponent(0,"plkj [mm]");
00490         array.setInfoOnComponent(1,"pqqqss [mm]");
00491         f2.setTime(3.14,2,7);
00492         f2.checkCoherency();
00493         #
00494         MEDLoader.MEDLoader.WriteField(fileName,f1,True);
00495         ts=MEDLoader.MEDLoader.GetTypesOfField(fileName,f1.getMesh().getName(),f1.getName());
00496         self.assertEqual(1,len(ts));
00497         self.assertEqual(MEDLoader.ON_CELLS,ts[0]);
00498         fs=MEDLoader.MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName());
00499         self.assertEqual(1,len(fs));
00500         self.assertTrue(fs[0]=="FieldMix");
00501         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f2);
00502         fs=MEDLoader.MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName());
00503         self.assertEqual(1,len(fs));
00504         self.assertTrue(fs[0]=="FieldMix");
00505         #
00506         ts=MEDLoader.MEDLoader.GetTypesOfField(fileName,f1.getMesh().getName(),f1.getName());
00507         self.assertEqual(2,len(ts));
00508         self.assertEqual(MEDLoader.ON_NODES,ts[0]);
00509         self.assertEqual(MEDLoader.ON_CELLS,ts[1]);
00510         #
00511         f3=MEDLoader.MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
00512         self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
00513         f3=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
00514         self.assertTrue(f3.isEqual(f1,1e-12,1e-12));
00515         #
00516         pass

Definition at line 332 of file MEDLoaderTest.py.

00332 
00333     def testMultiFieldShuffleRW1(self):
00334         fileName="Pyfile17.med";
00335         m=MEDLoaderDataForTest.build3DMesh_2();
00336         self.assertEqual(20,m.getNumberOfCells());
00337         self.assertEqual(45,m.getNumberOfNodes());
00338         polys=[1,4,6]
00339         m.convertToPolyTypes(polys);
00340         renum=[1,3,2,8,9,12,13,16,19,0,4,7,5,15,14,17,10,18,6,11]
00341         m.renumberCells(renum,False);
00342         m.orientCorrectlyPolyhedrons();
00343         # Writing
00344         MEDLoader.MEDLoader.WriteUMesh(fileName,m,True);
00345         f1Tmp=m.getMeasureField(False);
00346         f1=f1Tmp.buildNewTimeReprFromThis(MEDLoader.ONE_TIME,False);
00347         f1.setTime(0.,1,2);
00348         f_1=f1.cloneWithMesh(True);
00349         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00350         f1.applyFunc("2*x");
00351         f1.setTime(0.01,3,4);
00352         f_2=f1.cloneWithMesh(True);
00353         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00354         f1.applyFunc("2*x/3");
00355         f1.setTime(0.02,5,6);
00356         f_3=f1.cloneWithMesh(True);
00357         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00358         # Reading
00359         its=[(1,2),(3,4),(5,6)];
00360         fs=MEDLoader.MEDLoader.ReadFieldsOnSameMesh(MEDLoader.ON_CELLS,fileName,f_1.getMesh().getName(),0,f_1.getName(),its);
00361         self.assertEqual(3,len(fs));
00362         self.assertTrue(fs[0].isEqual(f_1,1e-12,1e-12));
00363         self.assertTrue(fs[1].isEqual(f_2,1e-12,1e-12));
00364         self.assertTrue(fs[2].isEqual(f_3,1e-12,1e-12));
00365         pass

Definition at line 207 of file MEDLoaderTest.py.

00207 
00208     def testMultiMeshRW1(self):
00209         fileName="Pyfile10.med";
00210         mesh1=MEDLoaderDataForTest.build3DMesh_1();
00211         part1=[1,2,4,13,15]
00212         mesh2=mesh1.buildPartOfMySelf(part1,True);
00213         mesh2.setName("mesh2");
00214         part2=[3,4,13,14]
00215         mesh3=mesh1.buildPartOfMySelf(part2,True);
00216         mesh3.setName("mesh3");
00217         mesh4=MEDLoader.MEDCouplingUMesh.New();
00218         mesh4.setName("mesh4");
00219         mesh4.setMeshDimension(3);
00220         mesh4.allocateCells(1);
00221         conn=[0,11,1,3]
00222         mesh4.insertNextCell(MEDLoader.NORM_TETRA4,4,conn[0:4])
00223         mesh4.finishInsertingCells();
00224         mesh4.setCoords(mesh1.getCoords());
00225         meshes=[mesh1,mesh2,mesh3,mesh4]
00226         mnane="3DToto";
00227         MEDLoader.MEDLoader.WriteUMeshesPartition(fileName,mnane,meshes,True);
00228         #
00229         mesh5=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,mnane);
00230         mesh1.setName(mnane);
00231         part3=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]
00232         mesh6=mesh5.buildPartOfMySelf(part3,True);
00233         mesh6.setName(mnane);
00234         self.assertTrue(mesh6.isEqual(mesh1,1e-12));
00235         grps=MEDLoader.MEDLoader.GetMeshGroupsNames(fileName,mnane);
00236         self.assertEqual(4,len(grps));
00237         grps.index("mesh2");
00238         grps.index("mesh3");
00239         grps.index("mesh4");
00240         grps.index("3DMesh_1");
00241         #
00242         vec=("mesh2",);
00243         mesh2_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
00244         self.assertTrue(mesh2_2.isEqual(mesh2,1e-12));
00245         vec=["mesh3"];
00246         mesh3_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
00247         self.assertTrue(mesh3_2.isEqual(mesh3,1e-12));
00248         vec=["mesh4"];
00249         mesh4_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
00250         self.assertTrue(mesh4_2.isEqual(mesh4,1e-12));
00251         vec="3DMesh_1";
00252         mesh1_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
00253         mesh1.setName("3DMesh_1");
00254         self.assertTrue(mesh1_2.isEqual(mesh1,1e-12));
00255         #
00256         vec=["Family_4","Family_2"];
00257         mesh2_2=MEDLoader.MEDLoader.ReadUMeshFromFamilies(fileName,mnane,0,vec);
00258         mesh2_2.setName("mesh2");
00259         self.assertTrue(mesh2_2.isEqual(mesh2,1e-12));
00260         #
00261         ret=MEDLoader.MEDLoader.GetMeshFamiliesNamesOnGroup(fileName,"3DToto","3DMesh_1");
00262         self.assertEqual(4,len(ret));
00263         self.assertEqual(ret[0],"Family_1");
00264         self.assertEqual(ret[1],"Family_2");
00265         self.assertEqual(ret[2],"Family_3");
00266         self.assertEqual(ret[3],"Family_4");
00267         #
00268         ret1=MEDLoader.MEDLoader.GetMeshGroupsNamesOnFamily(fileName,"3DToto","Family_2");
00269         self.assertEqual(2,len(ret1));
00270         self.assertEqual(ret1[0],"3DMesh_1");
00271         self.assertEqual(ret1[1],"mesh2");
00272         pass

Definition at line 366 of file MEDLoaderTest.py.

00366 
00367     def testWriteUMeshesRW1(self):
00368         fileName="Pyfile18.med";
00369         m3d=MEDLoaderDataForTest.build3DMesh_2();
00370         pt=[0.,0.,-0.3]
00371         vec=[0.,0.,1.]
00372         nodes=m3d.findNodesOnPlane(pt,vec,1e-12);
00373         m2d=m3d.buildFacePartOfMySelfNode(nodes,True);
00374         renumber=[1,2,0,4,3]
00375         m2d.renumberCells(renumber,False);
00376         m2d.setName("ExampleOfMultiDimW");
00377         meshes=[m2d,m3d]
00378         MEDLoader.MEDLoader.WriteUMeshes(fileName,meshes,True);
00379         m3d_bis=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),0);
00380         self.assertTrue(not m3d_bis.isEqual(m3d,1e-12));
00381         m3d_bis.setName(m3d.getName());
00382         self.assertTrue(m3d_bis.isEqual(m3d,1e-12));
00383         m2d_bis=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),-1);#-1 for faces
00384         self.assertTrue(m2d_bis.isEqual(m2d,1e-12));
00385         # Creation of a field on faces.
00386         f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
00387         f1.setName("FieldOnFacesShuffle");
00388         f1.setMesh(m2d);
00389         array=MEDLoader.DataArrayDouble.New();
00390         arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.]
00391         array.setValues(arr1,m2d.getNumberOfCells(),2);
00392         array.setInfoOnComponent(0,"plkj [mm]");
00393         array.setInfoOnComponent(1,"pqqqss [mm]");
00394         f1.setArray(array);
00395         tmp=array.setValues(arr1,m2d.getNumberOfCells(),2);
00396         f1.setTime(3.14,2,7);
00397         f1.checkCoherency();
00398         MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
00399         f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7);
00400         self.assertTrue(f2.isEqual(f1,1e-12,1e-12));
00401         pass


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