From d469de1f8c709042cea31ceac5c49be37a5129ed Mon Sep 17 00:00:00 2001 From: ageay Date: Thu, 11 Jul 2013 06:25:47 +0000 Subject: [PATCH] Rollback modif in tests dans SauvLoader. --- .../MEDCouplingFieldDiscretization.cxx | 13 +++++++++++-- src/MEDLoader/MEDFileField.cxx | 16 ++++++++++++---- src/MEDLoader/SauvMedConvertor.cxx | 9 +-------- src/MEDLoader/Swig/SauvLoaderTest.py | 4 +--- src/MEDLoader/Test/SauvLoaderTest.cxx | 3 +-- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index ec5661169..a927a731c 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -1323,7 +1323,7 @@ const char *MEDCouplingFieldDiscretizationGauss::getRepr() const */ int MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& 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 && *wsplitProfilePerType(profile,code,idsInPflPerType,idsPerType); std::vector< MEDCouplingAutoRefCountObjectPtr > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin()); std::vector< MEDCouplingAutoRefCountObjectPtr > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); - std::vector idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin()); - //int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3); - /*if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples()) + std::vector idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin()); + // start of check + MEDCouplingAutoRefCountObjectPtr field2=field->clone(false); + if(type==ON_GAUSS_NE) + { + MEDCouplingAutoRefCountObjectPtr 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(); // diff --git a/src/MEDLoader/SauvMedConvertor.cxx b/src/MEDLoader/SauvMedConvertor.cxx index b0ce566b2..c4b17862c 100644 --- a/src/MEDLoader/SauvMedConvertor.cxx +++ b/src/MEDLoader/SauvMedConvertor.cxx @@ -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 diff --git a/src/MEDLoader/Swig/SauvLoaderTest.py b/src/MEDLoader/Swig/SauvLoaderTest.py index 18c4c5855..70fed0dc2 100644 --- a/src/MEDLoader/Swig/SauvLoaderTest.py +++ b/src/MEDLoader/Swig/SauvLoaderTest.py @@ -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 ) diff --git a/src/MEDLoader/Test/SauvLoaderTest.cxx b/src/MEDLoader/Test/SauvLoaderTest.cxx index 1f90c7bea..113633c73 100644 --- a/src/MEDLoader/Test/SauvLoaderTest.cxx +++ b/src/MEDLoader/Test/SauvLoaderTest.cxx @@ -192,6 +192,7 @@ void SauvLoaderTest::testMed2Sauv() // add a field on 2 faces to pointeMed MEDCouplingAutoRefCountObjectPtr ff1=MEDFileFieldMultiTS::New(); MEDCouplingAutoRefCountObjectPtr f1=MEDCouplingFieldDouble::New(ON_GAUSS_NE,ONE_TIME); + f1->setMesh( pointeM1D ); f1->setName("Field on 2 faces"); MEDCouplingAutoRefCountObjectPtr d=DataArrayDouble::New(); d->alloc(3+4,2); @@ -208,8 +209,6 @@ void SauvLoaderTest::testMed2Sauv() { 0,2 }; - MEDCouplingAutoRefCountObjectPtr 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"); -- 2.39.2