本文整理汇总了Python中MEDLoaderDataForTest.MEDLoaderDataForTest类的典型用法代码示例。如果您正苦于以下问题:Python MEDLoaderDataForTest类的具体用法?Python MEDLoaderDataForTest怎么用?Python MEDLoaderDataForTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MEDLoaderDataForTest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testFieldRW1
def testFieldRW1(self):
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
WriteFieldDep("Pyfile6.med",f1,False);
f2=ReadFieldCell("Pyfile6.med",f1.getMesh().getName(),0,f1.getName(),0,1);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
#
f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
WriteFieldDep("Pyfile7.med",f1,False);
f2=ReadFieldNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
示例2: testFieldRW1
def testFieldRW1(self):
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
MEDLoader.WriteField("Pyfile6.med",f1,True);
f2=MEDLoader.ReadFieldCell("Pyfile6.med",f1.getMesh().getName(),0,f1.getName(),0,1);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
#
f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
MEDLoader.WriteField("Pyfile7.med",f1,True);
f2=MEDLoader.ReadFieldNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
self.assertRaises(Exception,MEDLoader.ReadFieldCell,"Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
pass
示例3: testFieldRW2
def testFieldRW2(self):
fileName="Pyfile8.med";
VAL1=12345.67890314;
VAL2=-1111111111111.;
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
MEDLoader.WriteField(fileName,f1,True);
f1.setTime(10.,8,9);
f1.getArray().setIJ(0,0,VAL1);
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.setTime(10.14,18,19);
f1.getArray().setIJ(0,0,VAL2);
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
#retrieving time steps...
f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),8,9);
f1.setTime(10.,8,9);
f1.getArray().setIJ(0,0,VAL1);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),0,1);
f3=MEDLoaderDataForTest.buildVecFieldOnCells_1();
self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),18,19);
f1.setTime(10.14,18,19);
f1.getArray().setIJ(0,0,VAL2);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
#test of throw on invalid (dt,it)
self.assertRaises(Exception,MEDLoader.ReadFieldCell,fileName,f1.getMesh().getName(),0,f1.getName(),28,19);
#ON NODES
f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
fileName2="Pyfile9.med";
MEDLoader.WriteField(fileName2,f1,True);
f1.setTime(110.,108,109);
tmp=f1.getArray().getPointer();
f1.getArray().setIJ(0,3,VAL1);
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
f1.setTime(210.,208,209);
f1.getArray().setIJ(0,3,VAL2);
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),108,109);
f1.setTime(110.,108,109);
f1.getArray().setIJ(0,3,VAL1);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),2,3);
f3=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),208,209);
f1.setTime(210.,208,209);
f1.getArray().setIJ(0,3,VAL2);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
示例4: testFieldProfilRW1
def testFieldProfilRW1(self):
fileName="Pyfile12.med";
mesh1=MEDLoaderDataForTest.build3DMesh_1();
da,b,newNbOfNodes=mesh1.mergeNodes(1e-12);
MEDLoader.WriteUMesh(fileName,mesh1,True);
part1=[1,2,4,13,15]
mesh2=mesh1.buildPartOfMySelf(part1,True);
mesh2.setName(mesh1.getName());#<- important for the test
#
nbOfCells=mesh2.getNumberOfCells();
self.assertEqual(5,nbOfCells);
f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
f1.setName("VectorFieldOnCells");
f1.setMesh(mesh2);
array=MEDLoader.DataArrayDouble.New();
array.alloc(nbOfCells,2);
f1.setArray(array);
arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.]
array.setValues(arr1,nbOfCells,2);
f1.setTime(3.14,2,7);
f1.checkConsistencyLight();
#
MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
#
f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
tt=MEDLoader.GetTypesOfField(fileName,f1.getMesh().getName(),f1.getName());
self.assertEqual(tt,[MEDLoader.ON_CELLS]);
f2.checkConsistencyLight();
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
#
pass
示例5: testMesh3DRW
def testMesh3DRW(self):
mesh = MEDLoaderDataForTest.build3DMesh_1()
mesh.checkCoherency()
MEDLoader.WriteUMeshDep("Pyfile5.med", mesh, False)
mesh_rw = MEDLoader.ReadUMeshFromFile("Pyfile5.med", mesh.getName(), 0)
self.assertTrue(mesh.isEqual(mesh_rw, 1e-12))
pass
示例6: testMesh2DRW
def testMesh2DRW(self):
mesh=MEDLoaderDataForTest.build2DMesh_1();
mesh.checkCoherency();
MEDLoader.MEDLoader.WriteUMesh("Pyfile3.med",mesh,True);
mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile3.med",mesh.getName(),0);
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
示例7: testFieldGaussRW1
def testFieldGaussRW1(self):
fileName="Pyfile13.med";
f1=MEDLoaderDataForTest.buildVecFieldOnGauss_1();
MEDLoader.WriteField(fileName,f1,True);
f2=MEDLoader.ReadField(MEDLoader.ON_GAUSS_PT,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
示例8: testMesh3DSurfRW
def testMesh3DSurfRW(self):
mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
mesh.checkConsistencyLight();
MEDLoader.WriteUMesh("Pyfile4.med",mesh,True);
mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile4.med",mesh.getName(),0);
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
示例9: testGetAllFieldNamesRW1
def testGetAllFieldNamesRW1(self):
fileName="Pyfile22.med";
mesh=MEDLoaderDataForTest.build2DMesh_2();
f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
f1.setName("Field1");
f1.setTime(3.44,5,6);
f1.setMesh(mesh);
f1.fillFromAnalytic(2,"x+y");
MEDLoader.WriteField(fileName,f1,True);
f1.setTime(1002.3,7,8);
f1.fillFromAnalytic(2,"x+77.*y");
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.setName("Field2");
MEDLoader.WriteField(fileName,f1,False);
f1.setName("Field3");
mesh.setName("2DMesh_2Bis");
MEDLoader.WriteField(fileName,f1,False);
f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
f1.setName("Field8");
f1.setTime(8.99,7,9);
f1.setMesh(mesh);
f1.fillFromAnalytic(3,"3*x+y");
MEDLoader.WriteField(fileName,f1,False);
fs=MEDLoader.GetAllFieldNames(fileName);
self.assertEqual(4,len(fs));
self.assertTrue(fs[0]=="Field1");
self.assertTrue(fs[1]=="Field2");
self.assertTrue(fs[2]=="Field3");
self.assertTrue(fs[3]=="Field8");
pass
示例10: testFieldNodeProfilRW1
def testFieldNodeProfilRW1(self):
fileName="Pyfile19.med";
fileName2="Pyfile20.med";
m=MEDLoaderDataForTest.build2DMesh_1();
nbOfNodes=m.getNumberOfNodes();
MEDLoader.WriteUMesh(fileName,m,True);
f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
f1.setName("VFieldOnNodes");
f1.setMesh(m);
array=MEDLoader.DataArrayDouble.New();
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.]
array.setValues(arr1,nbOfNodes,2);
f1.setArray(array);
array.setInfoOnComponent(0,"tyty [mm]");
array.setInfoOnComponent(1,"uiop [MW]");
f1.setTime(3.14,2,7);
f1.checkConsistencyLight();
arr2=[1,4]
f2=f1.buildSubPart(arr2);
f2.getMesh().setName(f1.getMesh().getName());
MEDLoader.WriteField(fileName,f2,False);#<- False important for the test
#
f3=MEDLoader.ReadFieldNode(fileName,f2.getMesh().getName(),0,f2.getName(),2,7);
f3.checkConsistencyLight();
self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
#
arr3=[1,3,0,5,2,4]
f2.renumberNodes(arr3);
MEDLoader.WriteUMesh(fileName2,m,True);
MEDLoader.WriteField(fileName2,f2,False);#<- False important for the test
f3=MEDLoader.ReadFieldNode(fileName2,f2.getMesh().getName(),0,f2.getName(),2,7);
f3.checkConsistencyLight();
self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
#
pass
示例11: testWriteUMeshesRW1
def testWriteUMeshesRW1(self):
fileName="Pyfile18.med";
m3d=MEDLoaderDataForTest.build3DMesh_2();
pt=[0.,0.,-0.3]
vec=[0.,0.,1.]
nodes=m3d.findNodesOnPlane(pt,vec,1e-12);
m2d=m3d.buildFacePartOfMySelfNode(nodes,True);
renumber=[1,2,0,4,3]
m2d.renumberCells(renumber,False);
m2d.setName("ExampleOfMultiDimW");
meshes=[m2d,m3d]
WriteUMeshes(fileName,meshes,False);
m3d_bis=ReadUMeshFromFile(fileName,m2d.getName(),0);
self.assertTrue(not m3d_bis.isEqual(m3d,1e-12));
m3d_bis.setName(m3d.getName());
self.assertTrue(m3d_bis.isEqual(m3d,1e-12));
m2d_bis=ReadUMeshFromFile(fileName,m2d.getName(),-1);#-1 for faces
self.assertTrue(m2d_bis.isEqual(m2d,1e-12));
# Creation of a field on faces.
f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
f1.setName("FieldOnFacesShuffle");
f1.setMesh(m2d);
array=DataArrayDouble.New();
arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.]
array.setValues(arr1,m2d.getNumberOfCells(),2);
array.setInfoOnComponent(0,"plkj [mm]");
array.setInfoOnComponent(1,"pqqqss [mm]");
f1.setArray(array);
tmp=array.setValues(arr1,m2d.getNumberOfCells(),2);
f1.setTime(3.14,2,7);
f1.checkConsistencyLight();
WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f2=ReadFieldCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7);
self.assertTrue(f2.isEqual(f1,1e-12,1e-12));
pass
示例12: testMesh3DRW
def testMesh3DRW(self):
mesh=MEDLoaderDataForTest.build3DMesh_1();
mesh.checkConsistencyLight();
WriteUMeshDep("Pyfile5.med",mesh,False);
mesh_rw=ReadUMeshFromFile("Pyfile5.med",mesh.getName(),0);
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
示例13: testFieldNodeProfilRW2
def testFieldNodeProfilRW2(self):
fileName="Pyfile23.med";
mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
MEDLoader.WriteUMesh(fileName,mesh,True);
#
f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
f1.setName("FieldMix");
f1.setMesh(mesh);
arr2=[1071.,1171.,1010.,1110.,1020.,1120.,1030.,1130.,1040.,1140.,1050.,1150.,
1060.,1160.,1070.,1170.,1080.,1180.,1090.,1190.,1091.,1191.,1092.,1192.];
array=MEDLoader.DataArrayDouble.New();
array.setValues(arr2,12,2);
f1.setArray(array);
array.setInfoOnComponent(0,"plkj [mm]");
array.setInfoOnComponent(1,"pqqqss [mm]");
tmp=array.getPointer();
f1.setTime(3.17,2,7);
#
renumArr=[3,7,2,1,5,11,10,0,9,6,8,4]
f1.renumberNodes(renumArr);
f1.checkConsistencyLight();
MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
f2=MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
self.assertTrue(f2.isEqual(f1,1e-12,1e-12));
#
pass
示例14: testMultiFieldShuffleRW1
def testMultiFieldShuffleRW1(self):
fileName="Pyfile17.med";
m=MEDLoaderDataForTest.build3DMesh_2();
self.assertEqual(20,m.getNumberOfCells());
self.assertEqual(45,m.getNumberOfNodes());
polys=[1,4,6]
m.convertToPolyTypes(polys);
renum=[1,3,2,8,9,12,13,16,19,0,4,7,5,15,14,17,10,18,6,11]
m.renumberCells(renum,False);
m.orientCorrectlyPolyhedrons();
# Writing
WriteUMeshDep(fileName,m,False);
f1Tmp=m.getMeasureField(False);
f1=f1Tmp.buildNewTimeReprFromThis(ONE_TIME,False);
f1.setTime(0.,1,2);
f_1=f1.cloneWithMesh(True);
WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.applyFunc("2*x");
f1.setTime(0.01,3,4);
f_2=f1.cloneWithMesh(True);
WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.applyFunc("2*x/3");
f1.setTime(0.02,5,6);
f_3=f1.cloneWithMesh(True);
WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
# Reading
its=[(1,2),(3,4),(5,6)];
fs=ReadFieldsOnSameMesh(ON_CELLS,fileName,f_1.getMesh().getName(),0,f_1.getName(),its);
self.assertEqual(3,len(fs));
self.assertTrue(fs[0].isEqual(f_1,1e-12,1e-12));
self.assertTrue(fs[1].isEqual(f_2,1e-12,1e-12));
self.assertTrue(fs[2].isEqual(f_3,1e-12,1e-12));
pass
示例15: testFieldRW2
def testFieldRW2(self):
fileName = "Pyfile8.med"
VAL1 = 12345.67890314
VAL2 = -1111111111111.0
f1 = MEDLoaderDataForTest.buildVecFieldOnCells_1()
MEDLoader.WriteFieldDep(fileName, f1, False)
f1.setTime(10.0, 8, 9)
f1.getArray().setIJ(0, 0, VAL1)
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName, f1)
f1.setTime(10.14, 18, 19)
f1.getArray().setIJ(0, 0, VAL2)
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName, f1)
# retrieving time steps...
f2 = MEDLoader.ReadFieldCell(fileName, f1.getMesh().getName(), 0, f1.getName(), 8, 9)
f1.setTime(10.0, 8, 9)
f1.getArray().setIJ(0, 0, VAL1)
self.assertTrue(f1.isEqual(f2, 1e-12, 1e-12))
f2 = MEDLoader.ReadFieldCell(fileName, f1.getMesh().getName(), 0, f1.getName(), 0, 1)
f3 = MEDLoaderDataForTest.buildVecFieldOnCells_1()
self.assertTrue(f3.isEqual(f2, 1e-12, 1e-12))
f2 = MEDLoader.ReadFieldCell(fileName, f1.getMesh().getName(), 0, f1.getName(), 18, 19)
f1.setTime(10.14, 18, 19)
f1.getArray().setIJ(0, 0, VAL2)
self.assertTrue(f1.isEqual(f2, 1e-12, 1e-12))
# ON NODES
f1 = MEDLoaderDataForTest.buildVecFieldOnNodes_1()
fileName2 = "Pyfile9.med"
MEDLoader.WriteFieldDep(fileName2, f1, False)
f1.setTime(110.0, 108, 109)
tmp = f1.getArray().getPointer()
f1.getArray().setIJ(0, 3, VAL1)
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2, f1)
f1.setTime(210.0, 208, 209)
f1.getArray().setIJ(0, 3, VAL2)
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2, f1)
f2 = MEDLoader.ReadFieldNode(fileName2, f1.getMesh().getName(), 0, f1.getName(), 108, 109)
f1.setTime(110.0, 108, 109)
f1.getArray().setIJ(0, 3, VAL1)
self.assertTrue(f1.isEqual(f2, 1e-12, 1e-12))
f2 = MEDLoader.ReadFieldNode(fileName2, f1.getMesh().getName(), 0, f1.getName(), 2, 3)
f3 = MEDLoaderDataForTest.buildVecFieldOnNodes_1()
self.assertTrue(f3.isEqual(f2, 1e-12, 1e-12))
f2 = MEDLoader.ReadFieldNode(fileName2, f1.getMesh().getName(), 0, f1.getName(), 208, 209)
f1.setTime(210.0, 208, 209)
f1.getArray().setIJ(0, 3, VAL2)
self.assertTrue(f1.isEqual(f2, 1e-12, 1e-12))
pass