if(found2)
time=dt;
}
+ if(!found2)
+ {
+ std::ostringstream oss; oss << "FieldDouble in file \""<< fileName<< "\" with name \"" << fieldName << "\" on mesh \"" << meshName;
+ oss << "\" does not have such time step : iteration=" << iteration << " order=" << order << std::endl;
+ delete [] valr;
+ delete [] comp;
+ delete [] unit;
+ delete [] dt_unit;
+ delete [] maa_ass;
+ MEDfermer(fid);
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
MEDchampLire(fid,(char *)meshName,(char *)fieldName,(unsigned char*)valr,MED_FULL_INTERLACE,MED_ALL,locname,
pflname,MED_COMPACT,tabEnt[typeOfOutField],tabType[typeOfOutField][j],iteration,order);
std::string tmp(locname);
return ret;
}
-ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldDouble(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
{
CheckFileForRead(fileName);
switch(type)
{
case ON_CELLS:
- return ReadFieldDoubleCell(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
+ return ReadFieldCell(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
case ON_NODES:
- return ReadFieldDoubleNode(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
+ return ReadFieldNode(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
case ON_GAUSS_PT:
- return ReadFieldDoubleGauss(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
+ return ReadFieldGauss(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
case ON_GAUSS_NE:
- return ReadFieldDoubleGaussNE(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
+ return ReadFieldGaussNE(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
default:
throw INTERP_KERNEL::Exception("Type of field specified not managed ! manages are ON_NODES, ON_CELLS, ON_GAUSS_PT or ON_GAUSS_NE !");
}
}
-std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsDoubleOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
- const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
+std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
{
CheckFileForRead(fileName);
std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ret(its.size());
return ret;
}
-std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsDoubleCellOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsCellOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
{
- return ReadFieldsDoubleOnSameMesh(ON_CELLS,fileName,meshName,meshDimRelToMax,fieldName,its);
+ return ReadFieldsOnSameMesh(ON_CELLS,fileName,meshName,meshDimRelToMax,fieldName,its);
}
-std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsDoubleNodeOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
- const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
+std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsNodeOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
{
- return ReadFieldsDoubleOnSameMesh(ON_NODES,fileName,meshName,meshDimRelToMax,fieldName,its);
+ return ReadFieldsOnSameMesh(ON_NODES,fileName,meshName,meshDimRelToMax,fieldName,its);
}
-std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsDoubleGaussOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
- const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
+std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsGaussOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
{
- return ReadFieldsDoubleOnSameMesh(ON_GAUSS_PT,fileName,meshName,meshDimRelToMax,fieldName,its);
+ return ReadFieldsOnSameMesh(ON_GAUSS_PT,fileName,meshName,meshDimRelToMax,fieldName,its);
}
-std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsDoubleGaussNEOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
- const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
+std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsGaussNEOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
{
- return ReadFieldsDoubleOnSameMesh(ON_GAUSS_NE,fileName,meshName,meshDimRelToMax,fieldName,its);
+ return ReadFieldsOnSameMesh(ON_GAUSS_NE,fileName,meshName,meshDimRelToMax,fieldName,its);
}
-ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldDoubleCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
{
return MEDLoaderNS::readFieldDoubleLev1(fileName,meshName,meshDimRelToMax,fieldName,iteration,order,ON_CELLS);
}
-ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldDoubleNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
{
return MEDLoaderNS::readFieldDoubleLev1(fileName,meshName,meshDimRelToMax,fieldName,iteration,order,ON_NODES);
}
-ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldDoubleGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
{
return MEDLoaderNS::readFieldDoubleLev1(fileName,meshName,meshDimRelToMax,fieldName,iteration,order,ON_GAUSS_PT);
}
-ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldDoubleGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
{
return MEDLoaderNS::readFieldDoubleLev1(fileName,meshName,meshDimRelToMax,fieldName,iteration,order,ON_GAUSS_NE);
}
static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
static int ReadUMeshDimFromFile(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDouble(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsDoubleOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
- static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsDoubleCellOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsCellOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
- static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsDoubleNodeOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsNodeOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
- static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsDoubleGaussOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsGaussOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
- static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsDoubleGaussNEOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsGaussNEOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
static void WriteUMeshesPartition(const char *fileName, const char *meshName, const std::vector<ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
def testFieldRW1(self):
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
MEDLoader.WriteField("Pyfile6.med",f1,True);
- f2=MEDLoader.ReadFieldDoubleCell("Pyfile6.med",f1.getMesh().getName(),0,f1.getName(),0,1);
+ 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.ReadFieldDoubleNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
+ f2=MEDLoader.ReadFieldNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
f1.getArray().setIJ(0,0,VAL2);
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
#retrieving time steps...
- f2=MEDLoader.ReadFieldDoubleCell(fileName,f1.getMesh().getName(),0,f1.getName(),8,9);
+ 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.ReadFieldDoubleCell(fileName,f1.getMesh().getName(),0,f1.getName(),0,1);
+ 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.ReadFieldDoubleCell(fileName,f1.getMesh().getName(),0,f1.getName(),18,19);
+ 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";
f1.setTime(210.,208,209);
f1.getArray().setIJ(0,3,VAL2);
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
- f2=MEDLoader.ReadFieldDoubleNode(fileName2,f1.getMesh().getName(),0,f1.getName(),108,109);
+ 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.ReadFieldDoubleNode(fileName2,f1.getMesh().getName(),0,f1.getName(),2,3);
+ 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.ReadFieldDoubleNode(fileName2,f1.getMesh().getName(),0,f1.getName(),208,209);
+ 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));
self.assertTrue(len(it4)==0);
#
#
- f1=MEDLoader.ReadFieldDoubleCell(fileName,name3,0,name1,8,9);
+ f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,8,9);
self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldDoubleCell(fileName,name3,0,name1,18,19);
+ f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,18,19);
self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldDoubleCell(fileName,name2,0,name1,28,29);
+ f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,28,29);
self.assertAlmostEqual(3*VAL1,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldDoubleCell(fileName,name2,0,name1,38,39);
+ f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,38,39);
self.assertAlmostEqual(3*VAL2,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldDoubleCell(fileName,name2,0,name1,48,49);
+ f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,48,49);
self.assertAlmostEqual(4*VAL2,f1.getArray().getIJ(0,0),13);
#
- f1=MEDLoader.ReadFieldDoubleNode(fileName,name2,0,name1,8,9);
+ f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,8,9);
self.assertAlmostEqual(71.,f1.getArray().getIJ(0,3),13);
- f1=MEDLoader.ReadFieldDoubleNode(fileName,name2,0,name1,108,109);
+ f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,108,109);
self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,3),13);
- f1=MEDLoader.ReadFieldDoubleNode(fileName,name2,0,name1,208,209);
+ f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,208,209);
self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,3),13);
pass
#
MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
#
- f2=MEDLoader.ReadFieldDoubleCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
+ f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
f2.checkCoherency();
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
#
fileName="Pyfile13.med";
f1=MEDLoaderDataForTest.buildVecFieldOnGauss_1();
MEDLoader.WriteField(fileName,f1,True);
- f2=MEDLoader.ReadFieldDouble(ON_GAUSS_PT,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
+ f2=MEDLoader.ReadField(ON_GAUSS_PT,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
fileName="Pyfile14.med";
f1=MEDLoaderDataForTest.buildVecFieldOnGaussNE_1();
MEDLoader.WriteField(fileName,f1,True);
- f2=MEDLoader.ReadFieldDouble(ON_GAUSS_NE,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
+ f2=MEDLoader.ReadField(ON_GAUSS_NE,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
# Reading
its=[(1,2),(3,4),(5,6)];
- fs=MEDLoader.ReadFieldsDoubleOnSameMesh(ON_CELLS,fileName,f_1.getMesh().getName(),0,f_1.getName(),its);
+ fs=MEDLoader.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));
f1.setTime(3.14,2,7);
f1.checkCoherency();
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
- f2=MEDLoader.ReadFieldDoubleCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7);
+ f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7);
self.assertTrue(f2.isEqual(f1,1e-12,1e-12));
pass
pass
def testFieldRW1(self):
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
MEDLoader.WriteFieldDep("Pyfile6.med",f1,False);
- f2=MEDLoader.ReadFieldDoubleCell("Pyfile6.med",f1.getMesh().getName(),0,f1.getName(),0,1);
+ 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.WriteFieldDep("Pyfile7.med",f1,False);
- f2=MEDLoader.ReadFieldDoubleNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
+ f2=MEDLoader.ReadFieldNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
f1.getArray().setIJ(0,0,VAL2);
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
#retrieving time steps...
- f2=MEDLoader.ReadFieldDoubleCell(fileName,f1.getMesh().getName(),0,f1.getName(),8,9);
+ 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.ReadFieldDoubleCell(fileName,f1.getMesh().getName(),0,f1.getName(),0,1);
+ 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.ReadFieldDoubleCell(fileName,f1.getMesh().getName(),0,f1.getName(),18,19);
+ 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));
f1.setTime(210.,208,209);
f1.getArray().setIJ(0,3,VAL2);
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
- f2=MEDLoader.ReadFieldDoubleNode(fileName2,f1.getMesh().getName(),0,f1.getName(),108,109);
+ 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.ReadFieldDoubleNode(fileName2,f1.getMesh().getName(),0,f1.getName(),2,3);
+ 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.ReadFieldDoubleNode(fileName2,f1.getMesh().getName(),0,f1.getName(),208,209);
+ 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));
self.assertTrue(len(it4)==0);
#
#
- f1=MEDLoader.ReadFieldDoubleCell(fileName,name3,0,name1,8,9);
+ f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,8,9);
self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldDoubleCell(fileName,name3,0,name1,18,19);
+ f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,18,19);
self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldDoubleCell(fileName,name2,0,name1,28,29);
+ f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,28,29);
self.assertAlmostEqual(3*VAL1,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldDoubleCell(fileName,name2,0,name1,38,39);
+ f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,38,39);
self.assertAlmostEqual(3*VAL2,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldDoubleCell(fileName,name2,0,name1,48,49);
+ f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,48,49);
self.assertAlmostEqual(4*VAL2,f1.getArray().getIJ(0,0),13);
#
- f1=MEDLoader.ReadFieldDoubleNode(fileName,name2,0,name1,8,9);
+ f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,8,9);
self.assertAlmostEqual(71.,f1.getArray().getIJ(0,3),13);
- f1=MEDLoader.ReadFieldDoubleNode(fileName,name2,0,name1,108,109);
+ f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,108,109);
self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,3),13);
- f1=MEDLoader.ReadFieldDoubleNode(fileName,name2,0,name1,208,209);
+ f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,208,209);
self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,3),13);
pass
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
# Reading
its=[(1,2),(3,4),(5,6)];
- fs=MEDLoader.ReadFieldsDoubleOnSameMesh(ON_CELLS,fileName,f_1.getMesh().getName(),0,f_1.getName(),its);
+ fs=MEDLoader.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));
f1.setTime(3.14,2,7);
f1.checkCoherency();
MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
- f2=MEDLoader.ReadFieldDoubleCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7);
+ f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7);
self.assertTrue(f2.isEqual(f1,1e-12,1e-12));
pass
pass
%newobject MEDLoader::ReadUMeshFromFamilies;
%newobject MEDLoader::ReadUMeshFromGroups;
%newobject MEDLoader::ReadUMeshFromFile;
-%newobject MEDLoader::ReadFieldDouble;
-%newobject MEDLoader::ReadFieldDoubleCell;
-%newobject MEDLoader::ReadFieldDoubleNode;
-%newobject MEDLoader::ReadFieldDoubleGauss;
-%newobject MEDLoader::ReadFieldDoubleGaussNE;
+%newobject MEDLoader::ReadField;
+%newobject MEDLoader::ReadFieldCell;
+%newobject MEDLoader::ReadFieldNode;
+%newobject MEDLoader::ReadFieldGauss;
+%newobject MEDLoader::ReadFieldGaussNE;
class MEDLoader
{
}
return ret;
}
- static PyObject *ReadFieldsDoubleOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax,
- const char *fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception)
+ static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax,
+ const char *fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception)
{
std::vector<std::pair<int,int> > its=convertTimePairIdsFromPy(liIts);
- std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> res=MEDLoader::ReadFieldsDoubleOnSameMesh(type,fileName,meshName,meshDimRelToMax,fieldName,its);
+ std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> res=MEDLoader::ReadFieldsOnSameMesh(type,fileName,meshName,meshDimRelToMax,fieldName,its);
return convertFieldDoubleVecToPy(res);
}
static void WriteUMeshesPartition(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception);
static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDouble(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
{
MEDCouplingFieldDouble *f1=buildVecFieldOnCells_1();
MEDLoader::WriteField("file6.med",f1,true);
- MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldDoubleCell("file6.med",f1->getMesh()->getName(),0,f1->getName(),0,1);
+ MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell("file6.med",f1->getMesh()->getName(),0,f1->getName(),0,1);
CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
f1->decrRef();
f2->decrRef();
//
f1=buildVecFieldOnNodes_1();
MEDLoader::WriteField("file7.med",f1,true);
- f2=MEDLoader::ReadFieldDoubleNode("file7.med",f1->getMesh()->getName(),0,f1->getName(),2,3);
+ f2=MEDLoader::ReadFieldNode("file7.med",f1->getMesh()->getName(),0,f1->getName(),2,3);
CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
f1->decrRef();
f2->decrRef();
tmp[0]=VAL2;
MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
//retrieving time steps...
- MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldDoubleCell(fileName,f1->getMesh()->getName(),0,f1->getName(),8,9);
+ MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),8,9);
f1->setTime(10.,8,9);
tmp[0]=VAL1;
CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
f2->decrRef();
- f2=MEDLoader::ReadFieldDoubleCell(fileName,f1->getMesh()->getName(),0,f1->getName(),0,1);
+ f2=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),0,1);
MEDCouplingFieldDouble *f3=buildVecFieldOnCells_1();
CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12));
f3->decrRef();
f2->decrRef();
- f2=MEDLoader::ReadFieldDoubleCell(fileName,f1->getMesh()->getName(),0,f1->getName(),18,19);
+ f2=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),18,19);
f1->setTime(10.14,18,19);
tmp[0]=VAL2;
CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
+ //test of throw on invalid (dt,it)
+ CPPUNIT_ASSERT_THROW(MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),28,19),INTERP_KERNEL::Exception);
f2->decrRef();
f1->decrRef();
//ON NODES
f1->setTime(210.,208,209);
tmp[3]=VAL2;
MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
- f2=MEDLoader::ReadFieldDoubleNode(fileName2,f1->getMesh()->getName(),0,f1->getName(),108,109);
+ f2=MEDLoader::ReadFieldNode(fileName2,f1->getMesh()->getName(),0,f1->getName(),108,109);
f1->setTime(110.,108,109);
tmp[3]=VAL1;
CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
f2->decrRef();
- f2=MEDLoader::ReadFieldDoubleNode(fileName2,f1->getMesh()->getName(),0,f1->getName(),2,3);
+ f2=MEDLoader::ReadFieldNode(fileName2,f1->getMesh()->getName(),0,f1->getName(),2,3);
f3=buildVecFieldOnNodes_1();
CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12));
f3->decrRef();
f2->decrRef();
- f2=MEDLoader::ReadFieldDoubleNode(fileName2,f1->getMesh()->getName(),0,f1->getName(),208,209);
+ f2=MEDLoader::ReadFieldNode(fileName2,f1->getMesh()->getName(),0,f1->getName(),208,209);
f1->setTime(210.,208,209);
tmp[3]=VAL2;
CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
//
f1->decrRef();
//
- f1=MEDLoader::ReadFieldDoubleCell(fileName,name3,0,name1,8,9);
+ f1=MEDLoader::ReadFieldCell(fileName,name3,0,name1,8,9);
CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL1,f1->getArray()->getConstPointer()[0],1e-13);
f1->decrRef();
- f1=MEDLoader::ReadFieldDoubleCell(fileName,name3,0,name1,18,19);
+ f1=MEDLoader::ReadFieldCell(fileName,name3,0,name1,18,19);
CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL2,f1->getArray()->getConstPointer()[0],1e-13);
f1->decrRef();
- f1=MEDLoader::ReadFieldDoubleCell(fileName,name2,0,name1,28,29);
+ f1=MEDLoader::ReadFieldCell(fileName,name2,0,name1,28,29);
CPPUNIT_ASSERT_DOUBLES_EQUAL(3*VAL1,f1->getArray()->getConstPointer()[0],1e-13);
f1->decrRef();
- f1=MEDLoader::ReadFieldDoubleCell(fileName,name2,0,name1,38,39);
+ f1=MEDLoader::ReadFieldCell(fileName,name2,0,name1,38,39);
CPPUNIT_ASSERT_DOUBLES_EQUAL(3*VAL2,f1->getArray()->getConstPointer()[0],1e-13);
f1->decrRef();
- f1=MEDLoader::ReadFieldDoubleCell(fileName,name2,0,name1,48,49);
+ f1=MEDLoader::ReadFieldCell(fileName,name2,0,name1,48,49);
CPPUNIT_ASSERT_DOUBLES_EQUAL(4*VAL2,f1->getArray()->getConstPointer()[0],1e-13);
f1->decrRef();
//
- f1=MEDLoader::ReadFieldDoubleNode(fileName,name2,0,name1,8,9);
+ f1=MEDLoader::ReadFieldNode(fileName,name2,0,name1,8,9);
CPPUNIT_ASSERT_DOUBLES_EQUAL(71.,f1->getArray()->getConstPointer()[3],1e-13);
f1->decrRef();
- f1=MEDLoader::ReadFieldDoubleNode(fileName,name2,0,name1,108,109);
+ f1=MEDLoader::ReadFieldNode(fileName,name2,0,name1,108,109);
CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL1,f1->getArray()->getConstPointer()[3],1e-13);
f1->decrRef();
- f1=MEDLoader::ReadFieldDoubleNode(fileName,name2,0,name1,208,209);
+ f1=MEDLoader::ReadFieldNode(fileName,name2,0,name1,208,209);
CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL2,f1->getArray()->getConstPointer()[3],1e-13);
f1->decrRef();
}
//
MEDLoader::WriteField(fileName,f1,false);//<- false important for the test
//
- MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldDoubleCell(fileName,f1->getMesh()->getName(),0,f1->getName(),2,7);
+ MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),2,7);
f2->checkCoherency();
CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
//
const char fileName[]="file13.med";
MEDCouplingFieldDouble *f1=buildVecFieldOnGauss_1();
MEDLoader::WriteField(fileName,f1,true);
- MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldDouble(ON_GAUSS_PT,fileName,f1->getMesh()->getName(),0,f1->getName(),1,5);
+ MEDCouplingFieldDouble *f2=MEDLoader::ReadField(ON_GAUSS_PT,fileName,f1->getMesh()->getName(),0,f1->getName(),1,5);
CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
f2->decrRef();
f1->decrRef();
const char fileName[]="file14.med";
MEDCouplingFieldDouble *f1=buildVecFieldOnGaussNE_1();
MEDLoader::WriteField(fileName,f1,true);
- MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldDouble(ON_GAUSS_NE,fileName,f1->getMesh()->getName(),0,f1->getName(),1,5);
+ MEDCouplingFieldDouble *f2=MEDLoader::ReadField(ON_GAUSS_NE,fileName,f1->getMesh()->getName(),0,f1->getName(),1,5);
CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
f2->decrRef();
f1->decrRef();
const int renumber1[6]={2,1,5,0,3,4};
f1->renumberCells(renumber1,false);
MEDLoader::WriteField(fileName,f1,true);
- MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldDoubleCell(fileName,mesh->getName(),0,f1->getName(),2,7);
+ MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(fileName,mesh->getName(),0,f1->getName(),2,7);
CPPUNIT_ASSERT(f2->isEqual(f1,1e-12,1e-12));
f2->decrRef();
//
its.push_back(std::pair<int,int>(1,2));
its.push_back(std::pair<int,int>(3,4));
its.push_back(std::pair<int,int>(5,6));
- std::vector<MEDCouplingFieldDouble *> fs=MEDLoader::ReadFieldsDoubleOnSameMesh(ON_CELLS,fileName,f_1->getMesh()->getName(),0,f_1->getName(),its);
+ std::vector<MEDCouplingFieldDouble *> fs=MEDLoader::ReadFieldsOnSameMesh(ON_CELLS,fileName,f_1->getMesh()->getName(),0,f_1->getName(),its);
CPPUNIT_ASSERT_EQUAL(3,(int)fs.size());
const MEDCouplingMesh *mm=fs[0]->getMesh();
CPPUNIT_ASSERT(fs[0]->isEqual(f_1,1e-12,1e-12));
f1->setTime(3.14,2,7);
f1->checkCoherency();
MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
- MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldDoubleCell(fileName,f1->getMesh()->getName(),-1,f1->getName(),2,7);
+ MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),-1,f1->getName(),2,7);
CPPUNIT_ASSERT(f2->isEqual(f1,1e-12,1e-12));
f1->decrRef();
f2->decrRef();