]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Rollback modif in tests dans SauvLoader.
authorageay <ageay>
Thu, 11 Jul 2013 06:25:47 +0000 (06:25 +0000)
committerageay <ageay>
Thu, 11 Jul 2013 06:25:47 +0000 (06:25 +0000)
src/MEDCoupling/MEDCouplingFieldDiscretization.cxx
src/MEDLoader/MEDFileField.cxx
src/MEDLoader/SauvMedConvertor.cxx
src/MEDLoader/Swig/SauvLoaderTest.py
src/MEDLoader/Test/SauvLoaderTest.cxx

index ec5661169ea9571644563621f1fa1515c00b9c0c..a927a731c068e65c8c6dafb02d2c7831e300dc77 100644 (file)
@@ -1323,7 +1323,7 @@ const char *MEDCouplingFieldDiscretizationGauss::getRepr() const
  */
 int MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
 {
-  if(!_discr_per_cell || _discr_per_cell->isAllocated() || _discr_per_cell->getNumberOfComponents()!=1)
+  if(!_discr_per_cell || !_discr_per_cell->isAllocated() || _discr_per_cell->getNumberOfComponents()!=1)
     throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode");
   if(code.size()%3!=0)
     throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode : invalid input code !");
@@ -1366,8 +1366,17 @@ int MEDCouplingFieldDiscretizationGauss::getNumberOfTuples(const MEDCouplingMesh
     throw INTERP_KERNEL::Exception("Discretization is not initialized!");
   const int *dcPtr=_discr_per_cell->getConstPointer();
   int nbOfTuples=_discr_per_cell->getNumberOfTuples();
+  int maxSz=(int)_loc.size();
   for(const int *w=dcPtr;w!=dcPtr+nbOfTuples;w++)
-    ret+=_loc[*w].getNumberOfGaussPt();
+    {
+      if(*w>=0 && *w<maxSz)
+        ret+=_loc[*w].getNumberOfGaussPt();
+      else
+        {
+          std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGauss::getNumberOfTuples : At cell #" << std::distance(dcPtr,w) << " localization id is " << *w << " should be in [0," << maxSz << ") !";
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+    }
   return ret;
 }
 
index f70338e50ca92ad7600e383c81ed0cbebec1cc6f..4bc92ed38dfbdb0dc8bed461ac2d43486c5f1854 100644 (file)
@@ -4266,13 +4266,21 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDou
       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
       std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
       std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
-      std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin()); 
-      //int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
-      /*if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
+      std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
+      // start of check
+      MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
+      if(type==ON_GAUSS_NE)
+        {
+          MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mPart=m->buildPart(profile->begin(),profile->end());
+          field2->setMesh(mPart);
+        }
+      int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
+      if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
         {
           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
           throw INTERP_KERNEL::Exception(oss.str().c_str());
-          }*/
+        }
+      // end of check
       int start=copyTinyInfoFrom(field,arrOfVals);
       code2=m->getDistributionOfTypes();
       //
index b0ce566b2699e8a4954bc09ac5890a501ca057b9..c4b17862c1d5a79a622e0345f6544abec6fe159f 100644 (file)
@@ -2163,14 +2163,7 @@ void IntermediateMED::setTS( SauvUtilities::DoubleField*  fld,
   if ( onAll )
     fld->_curMedField->appendFieldNoProfileSBT( timeStamp );
   else
-    {
-      if(fld->getMedType()==ON_GAUSS_NE)
-        {
-          MEDCouplingAutoRefCountObjectPtr< MEDCouplingPointSet > dimMesh2 = dimMesh->buildPartOfMySelf(support->_medGroup->begin(),support->_medGroup->end(),true);
-          timeStamp->setMesh( dimMesh2 );
-        }
-      fld->_curMedField->appendFieldProfile( timeStamp, mesh, dimRel, support->_medGroup );
-    }
+    fld->_curMedField->appendFieldProfile( timeStamp, mesh, dimRel, support->_medGroup );
   timeStamp->decrRef();
 
   if ( isNewMedField ) // timeStamp must be added before this
index 18c4c585553f4e5b72c638ba9abf30f7dc16fe9d..70fed0dc21a7fa22eeefa51080236142ab6dd2d6 100644 (file)
@@ -72,7 +72,7 @@ class SauvLoaderTest(unittest.TestCase):
         # add a field on 2 faces to pointeMed
         ff1=MEDFileFieldMultiTS.New()
         f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME)
-        #
+        #f1.setMesh( pointeM1D )
         f1.setName("Field on 2 faces")
         d=DataArrayDouble.New()
         d.alloc(3+4,2)
@@ -83,8 +83,6 @@ class SauvLoaderTest(unittest.TestCase):
         da=DataArrayInt.New()
         da.setValues([0,2],2,1)
         da.setName("sup2")
-        pointeM1D_2=pointeM1D[da]
-        f1.setMesh( pointeM1D_2 )
         ff1.appendFieldProfile(f1,pointeMedMesh,-1,da)
         pointeMed.getFields().pushField( ff1 )
 
index 1f90c7beacd573a42dabe63cdf40059adbfb6a2b..113633c734c9066b19a09792eea67f82e9b13703 100644 (file)
@@ -192,6 +192,7 @@ void SauvLoaderTest::testMed2Sauv()
   // add a field on 2 faces to pointeMed
   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ff1=MEDFileFieldMultiTS::New();
   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=MEDCouplingFieldDouble::New(ON_GAUSS_NE,ONE_TIME);
+  f1->setMesh( pointeM1D );
   f1->setName("Field on 2 faces");
   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> d=DataArrayDouble::New();
   d->alloc(3+4,2);
@@ -208,8 +209,6 @@ void SauvLoaderTest::testMed2Sauv()
     {
       0,2
     };
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> pointeM1D_part=pointeM1D->buildPartOfMySelf(ids,ids+2,true);
-  f1->setMesh( pointeM1D_part );
   da->alloc(2,1);
   std::copy(ids,ids+da->getNbOfElems(),da->getPointer());
   da->setName("sup2");