From: ageay Date: Tue, 5 Apr 2011 14:07:43 +0000 (+0000) Subject: Correction of bug detected by Nizhny MEDfieldnValue by MEDfieldnValueWithProfile. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=17082547fedbb38fbf832481049fea1d2ca1a40d;p=tools%2Fmedcoupling.git Correction of bug detected by Nizhny MEDfieldnValue by MEDfieldnValueWithProfile. --- diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index 14ea0cbb9..3c049964e 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -500,8 +500,8 @@ std::vector MEDLoader::GetTypesOfField(const char *file //med_int nbpdtnor=0,pflsize,*pflval,lnsize; med_int numdt=0,numo=0; med_float dt=0.0; - //char pflname[MED_NAME_SIZE+1]=""; - //char locname[MED_NAME_SIZE+1]=""; + char pflname[MED_NAME_SIZE+1]=""; + char locname[MED_NAME_SIZE+1]=""; char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); char *nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); med_bool localmesh; @@ -520,13 +520,15 @@ std::vector MEDLoader::GetTypesOfField(const char *file { if(curFieldName==fieldName) { + int profilesize,nbi; if(nbPdt>0) { bool found=false; for(int i=0;i0) { ret.push_back(ON_NODES); @@ -540,7 +542,8 @@ std::vector MEDLoader::GetTypesOfField(const char *file if(nbPdt>0) { MEDfieldComputingStepInfo(fid,nomcha,1,&numdt,&numo,&dt); - med_int nbOfVal=MEDfieldnValue(fid,nomcha,numdt,numo,MED_CELL,typmai[j]); + med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE, + pflname,&profilesize,locname,&nbi); if(nbOfVal>0) { found=true; @@ -638,8 +641,8 @@ std::vector MEDLoader::GetCellFieldNamesOnMesh(const char *fileName //med_int nbpdtnor=0,pflsize,*pflval,lnsize; med_int numdt=0,numo=0; med_float dt=0.0; - //char pflname[MED_NAME_SIZE+1]=""; - //char locname[MED_NAME_SIZE+1]=""; + char pflname[MED_NAME_SIZE+1]=""; + char locname[MED_NAME_SIZE+1]=""; INTERP_KERNEL::AutoPtr maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); INTERP_KERNEL::AutoPtr nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); @@ -654,6 +657,7 @@ std::vector MEDLoader::GetCellFieldNamesOnMesh(const char *fileName MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); + int profilesize,nbi; if(curMeshName==meshName) { bool found=false; @@ -662,7 +666,8 @@ std::vector MEDLoader::GetCellFieldNamesOnMesh(const char *fileName if(nbPdt>0) { MEDfieldComputingStepInfo(fid,nomcha,1,&numdt,&numo,&dt); - med_int nbOfVal=MEDfieldnValue(fid,nomcha,numdt,numo,MED_CELL,typmai[j]); + med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE, + pflname,&profilesize,locname,&nbi); if(nbOfVal>0) { found=true; @@ -682,6 +687,8 @@ std::vector MEDLoader::GetNodeFieldNamesOnMesh(const char *fileName std::vector ret; med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); + char pflname[MED_NAME_SIZE+1]=""; + char locname[MED_NAME_SIZE+1]=""; // med_field_type typcha; med_int numdt=0,numo=0; @@ -703,8 +710,10 @@ std::vector MEDLoader::GetNodeFieldNamesOnMesh(const char *fileName bool found=false; if(nbPdt>0) { + int profilesize,nbi; MEDfieldComputingStepInfo(fid,nomcha,1,&numdt,&numo,&dt); - med_int nbOfVal=MEDfieldnValue(fid,nomcha,numdt,numo,MED_NODE,MED_NONE); + med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_NODE,MED_NONE,1,MED_COMPACT_PFLMODE, + pflname,&profilesize,locname,&nbi); if(curMeshName==meshName && nbOfVal>0) { found=true; @@ -727,6 +736,8 @@ std::vector< std::pair< std::pair, double> > MEDLoader::GetAllFieldIter med_field_type typcha; med_int numdt=0,numo=0; med_float dt=0.0; + char pflname[MED_NAME_SIZE+1]=""; + char locname[MED_NAME_SIZE+1]=""; INTERP_KERNEL::AutoPtr maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); INTERP_KERNEL::AutoPtr nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); @@ -743,12 +754,14 @@ std::vector< std::pair< std::pair, double> > MEDLoader::GetAllFieldIter if(curFieldName==fieldName) { bool found=false; + int profilesize,nbi; for(int j=0;j0) { @@ -760,7 +773,8 @@ std::vector< std::pair< std::pair, double> > MEDLoader::GetAllFieldIter for(int k=0;k0) { @@ -851,6 +865,8 @@ std::vector< std::pair > MEDLoader::GetCellFieldIterations(const char * med_field_type typcha; med_int numdt=0,numo=0; med_float dt=0.0; + char pflname[MED_NAME_SIZE+1]=""; + char locname[MED_NAME_SIZE+1]=""; INTERP_KERNEL::AutoPtr maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); INTERP_KERNEL::AutoPtr nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); @@ -871,8 +887,10 @@ std::vector< std::pair > MEDLoader::GetCellFieldIterations(const char * { for(int k=0;k0) { @@ -898,6 +916,8 @@ std::vector< std::pair > MEDLoader::GetNodeFieldIterations(const char * med_field_type typcha; med_int numdt=0,numo=0; med_float dt=0.0; + char pflname[MED_NAME_SIZE+1]=""; + char locname[MED_NAME_SIZE+1]=""; INTERP_KERNEL::AutoPtr maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); INTERP_KERNEL::AutoPtr nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); @@ -915,8 +935,10 @@ std::vector< std::pair > MEDLoader::GetNodeFieldIterations(const char * { for(int k=0;k0) { @@ -1880,9 +1902,9 @@ ParaMEDMEM::MEDCouplingFieldDouble *MEDLoaderNS::readFieldDoubleLev1(const char std::ostringstream oss; oss << "Error on reading file \"" << fileName << "\" meshName=\"" << meshName << "\" meshDimRelToMax=" << meshDimRelToMax; oss << std::endl << "FieldName=\"" << fieldName << "\" (iteration=" << iteration << ",order=" << order << ")" << std::endl; if(typeOfOutField==ON_CELLS || typeOfOutField==ON_GAUSS_PT || typeOfOutField==ON_GAUSS_NE) - oss << "Request for cell field, maybe it is a node field instead ?"; + oss << "Request for cell field, maybe it is a node instead or by changing meshDimRelToMax ?"; else - oss << "Request for a node field, maybe it is a cell field instead ?"; + oss << "Request for a node field, maybe it is a cell field instead ?"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } ParaMEDMEM::MEDCouplingUMesh *mesh=readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim,cellRenum); diff --git a/src/MEDLoader/Swig/MEDLoaderTest.py b/src/MEDLoader/Swig/MEDLoaderTest.py index 4ea3a7808..e8159b2c2 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest.py +++ b/src/MEDLoader/Swig/MEDLoaderTest.py @@ -74,7 +74,7 @@ class MEDLoaderTest(unittest.TestCase): MEDLoader.MEDLoader.WriteField("Pyfile7.med",f1,True); f2=MEDLoader.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.MEDLoader.ReadFieldCell,"file7.med",f1.getMesh().getName(),0,f1.getName(),2,3); + self.assertRaises(Exception,MEDLoader.MEDLoader.ReadFieldCell,"Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3); pass def testFieldRW2(self): @@ -295,6 +295,8 @@ class MEDLoaderTest(unittest.TestCase): MEDLoader.MEDLoader.WriteField(fileName,f1,False);#<- False important for the test # f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7); + tt=MEDLoader.MEDLoader.GetTypesOfField(fileName,f1.getName(),f1.getMesh().getName()); + self.assertEqual(tt,[MEDLoader.ON_CELLS]); f2.checkCoherency(); self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); # diff --git a/src/MEDLoader/Test/MEDLoaderTest.cxx b/src/MEDLoader/Test/MEDLoaderTest.cxx index e0613e083..835c14f7f 100644 --- a/src/MEDLoader/Test/MEDLoaderTest.cxx +++ b/src/MEDLoader/Test/MEDLoaderTest.cxx @@ -372,6 +372,9 @@ void MEDLoaderTest::testFieldProfilRW1() MEDLoader::WriteField(fileName,f1,false);//<- false important for the test // MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),2,7); + std::vector types=MEDLoader::GetTypesOfField(fileName,f1->getName(),f1->getMesh()->getName()); + CPPUNIT_ASSERT_EQUAL(1,(int)types.size()); + CPPUNIT_ASSERT(types[0]==ON_CELLS); f2->checkCoherency(); CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); //