]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Correction of bug detected by Nizhny MEDfieldnValue by MEDfieldnValueWithProfile.
authorageay <ageay>
Tue, 5 Apr 2011 14:07:43 +0000 (14:07 +0000)
committerageay <ageay>
Tue, 5 Apr 2011 14:07:43 +0000 (14:07 +0000)
src/MEDLoader/MEDLoader.cxx
src/MEDLoader/Swig/MEDLoaderTest.py
src/MEDLoader/Test/MEDLoaderTest.cxx

index 14ea0cbb9177288ed0f2a402f74e7a4a43878905..3c049964edb129022bab85a3b264bb609da7e4cc 100644 (file)
@@ -500,8 +500,8 @@ std::vector<ParaMEDMEM::TypeOfField> 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<ParaMEDMEM::TypeOfField> MEDLoader::GetTypesOfField(const char *file
         {
           if(curFieldName==fieldName)
             {
+              int profilesize,nbi;
               if(nbPdt>0)
                 {
                   bool found=false;
                   for(int i=0;i<nbPdt && !found;i++)
                     {
                       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(nbOfVal>0)
                         {
                           ret.push_back(ON_NODES);
@@ -540,7 +542,8 @@ std::vector<ParaMEDMEM::TypeOfField> 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<std::string> 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<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
@@ -654,6 +657,7 @@ std::vector<std::string> 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<std::string> 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<std::string> MEDLoader::GetNodeFieldNamesOnMesh(const char *fileName
   std::vector<std::string> 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<std::string> 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<int,int>, 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<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
@@ -743,12 +754,14 @@ std::vector< std::pair< std::pair<int,int>, double> > MEDLoader::GetAllFieldIter
       if(curFieldName==fieldName)
         {
           bool found=false;
+          int profilesize,nbi;
           for(int j=0;j<MED_N_CELL_FIXED_GEO && !found;j++)
             {
               for(int k=0;k<nbPdt;k++)
                 {
                   MEDfieldComputingStepInfo(fid,nomcha,k+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);
                   std::string maa_ass_cpp(maa_ass);
                   if(meshNameCpp==maa_ass_cpp && nbOfVal>0)
                     {
@@ -760,7 +773,8 @@ std::vector< std::pair< std::pair<int,int>, double> > MEDLoader::GetAllFieldIter
           for(int k=0;k<nbPdt;k++)
             {
               MEDfieldComputingStepInfo(fid,nomcha,k+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);
               std::string maa_ass_cpp(maa_ass);
               if(meshNameCpp==maa_ass_cpp && nbOfVal>0)
                 {
@@ -851,6 +865,8 @@ std::vector< std::pair<int,int> > 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<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
@@ -871,8 +887,10 @@ std::vector< std::pair<int,int> > MEDLoader::GetCellFieldIterations(const char *
             {
               for(int k=0;k<nbPdt;k++)
                 {
+                  int profilesize,nbi;
                   MEDfieldComputingStepInfo(fid,nomcha,k+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);
                   std::string maa_ass_cpp(maa_ass);
                   if(meshNameCpp==maa_ass_cpp && nbOfVal>0)
                     {
@@ -898,6 +916,8 @@ std::vector< std::pair<int,int> > 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<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
@@ -915,8 +935,10 @@ std::vector< std::pair<int,int> > MEDLoader::GetNodeFieldIterations(const char *
         {
           for(int k=0;k<nbPdt;k++)
             {
+              int profilesize,nbi;
               MEDfieldComputingStepInfo(fid,nomcha,k+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);
                std::string maa_ass_cpp(maa_ass);
                if(meshNameCpp==maa_ass_cpp && nbOfVal>0)
                  {
@@ -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);
index 4ea3a780814723ec44e40f48c5b9370c27b86330..e8159b2c2ed3b9f11007e36f60f598604c86632f 100644 (file)
@@ -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));
         #
index e0613e08346f2833fdf955f2060fa68f2427b14b..835c14f7fee5bc06198535681fbb4d0e812de299 100644 (file)
@@ -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<ParaMEDMEM::TypeOfField> 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));
   //