From 54392587ef36dd9f414f21c3c8619e7e39b32779 Mon Sep 17 00:00:00 2001 From: ageay Date: Thu, 18 Jul 2013 12:13:27 +0000 Subject: [PATCH] On the road of last imps for MEDReader --- src/MEDLoader/MEDFileField.cxx | 4 +- src/MEDLoader/MEDFileFieldOverView.cxx | 120 ++++++++++++------------- src/MEDLoader/MEDFileFieldOverView.hxx | 20 ++--- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 35426735e..3e28557a1 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -8326,7 +8326,7 @@ std::vector< std::vector > MEDFileAnyTypeFieldMult while(it!=lstFMTS.end()) { MEDFileAnyTypeFieldMultiTS *curIt(*it); - if(cmp->isEqual(ref)) + if(cmp->isEqual(curIt)) { elt.push_back(curIt); it=lstFMTS.erase(it); } else it++; @@ -9784,7 +9784,6 @@ MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldNam MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception) { MEDCouplingAutoRefCountObjectPtr ret=MEDFileFields::New(); - ret->shallowCpyOnlyUsedGlobs(*this); for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fields.begin();it!=_fields.end();it++) { const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it); @@ -9797,6 +9796,7 @@ MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *mes ret->_fields.push_back(cur2); } } + ret->shallowCpyOnlyUsedGlobs(*this); return ret.retn(); } diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index d77b36f13..153a05927 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -107,20 +107,20 @@ MEDFileField1TSStructItem2::MEDFileField1TSStructItem2(INTERP_KERNEL::Normalized _pfl->setName(c.c_str()); } -void MEDFileField1TSStructItem2::checkWithMeshStructForCells(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception) +void MEDFileField1TSStructItem2::checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception) { int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type); checkInRange(nbOfEnt,1,globs); } -void MEDFileField1TSStructItem2::checkWithMeshStructForGaussNE(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception) +void MEDFileField1TSStructItem2::checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception) { int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type); checkInRange(nbOfEnt,(int)cm.getNumberOfNodes(),globs); } -void MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception) +void MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception) { if(!globs) throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no globals specified !"); @@ -156,13 +156,14 @@ void MEDFileField1TSStructItem2::checkInRange(int nbOfEntity, int nip, const MED const DataArrayInt *pfl=globs->getProfile(_pfl->getName().c_str()); if(!pfl) throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no such profile found in file !"); - if(!pfl->checkAllIdsInRange(0,nbOfEntity)) - throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : The profile specified is invalid !"); + pfl->checkAllIdsInRange(0,nbOfEntity); } } bool MEDFileField1TSStructItem2::operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception) { + //_nb_of_entity is not taken into account here. It is not a bug, because no mesh consideration needed here to perform fast compare. + //idem for _loc. It is not an effective attribute for support comparison. return _geo_type==other._geo_type && _start_end==other._start_end && _pfl->getName()==other._pfl->getName(); } @@ -202,30 +203,30 @@ MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const if(obj->_pfl->getName().empty()) throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! Several same geo type chunk must all lie on profiles !"); arrs[i]=globs->getProfile(obj->_pfl->getName().c_str()); - MEDCouplingAutoRefCountObjectPtr arr(DataArrayInt::Aggregate(arrs)); - arr->sort(); - int oldNbTuples(arr->getNumberOfTuples()); - arr=arr->buildUnique(); - if(oldNbTuples!=arr->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : some entities are present several times !"); - if(arr->isIdentity() && oldNbTuples==nbEntityRef) - { - std::pair p(0,nbEntityRef); - std::string a,b; - MEDFileField1TSStructItem2 ret(gt,p,a,b); - ret._nb_of_entity=nbEntityRef; - return ret; - } - else - { - arr->setName("???"); - std::pair p(0,oldNbTuples); - std::string a,b; - MEDFileField1TSStructItem2 ret(gt,p,a,b); - ret._nb_of_entity=nbEntityRef; - ret._pfl=arr; - return ret; - } + } + MEDCouplingAutoRefCountObjectPtr arr(DataArrayInt::Aggregate(arrs)); + arr->sort(); + int oldNbTuples(arr->getNumberOfTuples()); + arr=arr->buildUnique(); + if(oldNbTuples!=arr->getNumberOfTuples()) + throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : some entities are present several times !"); + if(arr->isIdentity() && oldNbTuples==nbEntityRef) + { + std::pair p(0,nbEntityRef); + std::string a,b; + MEDFileField1TSStructItem2 ret(gt,p,a,b); + ret._nb_of_entity=nbEntityRef; + return ret; + } + else + { + arr->setName("???"); + std::pair p(0,oldNbTuples); + std::string a,b; + MEDFileField1TSStructItem2 ret(gt,p,a,b); + ret._nb_of_entity=nbEntityRef; + ret._pfl=arr; + return ret; } } @@ -235,7 +236,7 @@ MEDFileField1TSStructItem::MEDFileField1TSStructItem(TypeOfField a, const std::v { } -void MEDFileField1TSStructItem::checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception) +void MEDFileField1TSStructItem::checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception) { switch(_type) { @@ -338,7 +339,7 @@ MEDFileField1TSStructItem MEDFileField1TSStructItem::simplifyMeOnCellEntity(cons const std::vector& ids=m[i].second; std::vectorobjs(ids.size()); for(std::size_t j=0;jgetNumberOfLevs()); if(nbOfLevs==0) - throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnExactlyOneLev : no levels in input mesh structure !"); + throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : no levels in input mesh structure !"); + std::vector levs(nbOfLevs); theFirstLevFull=1; int nbOfGT=0; - bool firstShot(true); std::set gts; for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++) { @@ -401,18 +402,15 @@ bool MEDFileField1TSStructItem::isFullyOnExactlyOneLev(const MEDFileMeshStruct * return false; INTERP_KERNEL::NormalizedCellType gt((*it).getGeo()); if(gts.find(gt)!=gts.end()) - throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnExactlyOneLev : internal error !"); + throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : internal error !"); gts.insert(gt); int pos(meshSt->getLevelOfGeoType((*it).getGeo())); - if(firstShot) - theFirstLevFull=pos; - else - if(theFirstLevFull!=pos) - return false; - firstShot=false; - nbOfGT++; + levs[-pos]++; } - return nbOfGT==meshSt->getNumberOfGeoTypesInLev(theFirstLevFull); + for(int i=0;igetNumberOfGeoTypesInLev(-i)==levs[i]) + { theFirstLevFull=-i; return true; } + return false; } const MEDFileField1TSStructItem2& MEDFileField1TSStructItem::operator[](std::size_t i) const throw(INTERP_KERNEL::Exception) @@ -424,14 +422,14 @@ const MEDFileField1TSStructItem2& MEDFileField1TSStructItem::operator[](std::siz //= -MEDFileField1TSStruct *MEDFileField1TSStruct::New(const MEDFileAnyTypeField1TS *ref) throw(INTERP_KERNEL::Exception) +MEDFileField1TSStruct *MEDFileField1TSStruct::New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst) throw(INTERP_KERNEL::Exception) { - return new MEDFileField1TSStruct(ref); + return new MEDFileField1TSStruct(ref,mst); } -MEDFileField1TSStruct::MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref) +MEDFileField1TSStruct::MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst) { - _already_checked.push_back(BuildItemFrom(ref)); + _already_checked.push_back(BuildItemFrom(ref,mst)); } void MEDFileField1TSStruct::checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception) @@ -441,9 +439,9 @@ void MEDFileField1TSStruct::checkWithMeshStruct(MEDFileMeshStruct *mst, const ME _already_checked.back().checkWithMeshStruct(mst,globs); } -bool MEDFileField1TSStruct::isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other) const throw(INTERP_KERNEL::Exception) +bool MEDFileField1TSStruct::isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const throw(INTERP_KERNEL::Exception) { - MEDFileField1TSStructItem b(BuildItemFrom(other)); + MEDFileField1TSStructItem b(BuildItemFrom(other,mst)); for(std::vector::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++) { if((*it)==b) @@ -455,11 +453,11 @@ bool MEDFileField1TSStruct::isEqualConsideringThePast(const MEDFileAnyTypeField1 /*! * Not const because \a other structure will be added to the \c _already_checked attribute in case of success. */ -bool MEDFileField1TSStruct::isSupportSameAs(const MEDFileAnyTypeField1TS *other) throw(INTERP_KERNEL::Exception) +bool MEDFileField1TSStruct::isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception) { if(_already_checked.empty()) throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : no ref !"); - MEDFileField1TSStructItem b(BuildItemFrom(other)); + MEDFileField1TSStructItem b(BuildItemFrom(other,meshSt)); if(!_already_checked[0].isEntityCell() || !b.isEntityCell()) throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : only available on cell entities !"); MEDFileField1TSStructItem other1(b.simplifyMeOnCellEntity(other->contentNotNull())); @@ -488,7 +486,7 @@ bool MEDFileField1TSStruct::isCompatibleWithNodesDiscr(const MEDFileAnyTypeField throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isCompatibleWithNodesDiscr : no ref !"); if(!_already_checked[0].isEntityCell()) throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isCompatibleWithNodesDiscr : only available on cell entities !"); - MEDFileField1TSStructItem other1(BuildItemFrom(other)); + MEDFileField1TSStructItem other1(BuildItemFrom(other,meshSt)); // int found=-1,i=0; for(std::vector::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++) @@ -514,7 +512,7 @@ std::size_t MEDFileField1TSStruct::getHeapMemorySize() const return 0; } -MEDFileField1TSStructItem MEDFileField1TSStruct::BuildItemFrom(const MEDFileAnyTypeField1TS *ref) +MEDFileField1TSStructItem MEDFileField1TSStruct::BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt) { TypeOfField atype; std::vector< MEDFileField1TSStructItem2 > anItems; @@ -545,7 +543,9 @@ MEDFileField1TSStructItem MEDFileField1TSStruct::BuildItemFrom(const MEDFileAnyT throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : can be applied only on single spatial discretization fields ! Call SplitPerDiscretization method !"); } } - return MEDFileField1TSStructItem(atype,anItems); + MEDFileField1TSStructItem ret(atype,anItems); + ret.checkWithMeshStruct(meshSt,ref->contentNotNull()); + return ret; } //= @@ -563,7 +563,7 @@ MEDFileFastCellSupportComparator::MEDFileFastCellSupportComparator(const MEDFile for(int i=0;i elt=ref->getTimeStepAtPos(i); - _f1ts_cmps[i]=MEDFileField1TSStruct::New(elt); + _f1ts_cmps[i]=MEDFileField1TSStruct::New(elt,_mesh_comp); _f1ts_cmps[i]->checkWithMeshStruct(_mesh_comp,elt->contentNotNull()); } } @@ -591,8 +591,8 @@ bool MEDFileFastCellSupportComparator::isEqual(const MEDFileAnyTypeFieldMultiTS for(int i=0;i elt=other->getTimeStepAtPos(i); - if(!_f1ts_cmps[i]->isEqualConsideringThePast(elt)) - if(!_f1ts_cmps[i]->isSupportSameAs(elt)) + if(!_f1ts_cmps[i]->isEqualConsideringThePast(elt,_mesh_comp)) + if(!_f1ts_cmps[i]->isSupportSameAs(elt,_mesh_comp)) return false; } return true; diff --git a/src/MEDLoader/MEDFileFieldOverView.hxx b/src/MEDLoader/MEDFileFieldOverView.hxx index 161b092c6..7951df90c 100644 --- a/src/MEDLoader/MEDFileFieldOverView.hxx +++ b/src/MEDLoader/MEDFileFieldOverView.hxx @@ -62,9 +62,9 @@ namespace ParaMEDMEM public: MEDFileField1TSStructItem2(); MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair& b, const std::string& pfl, const std::string& loc); - void checkWithMeshStructForCells(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); - void checkWithMeshStructForGaussNE(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); - void checkWithMeshStructForGaussPT(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); + void checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); + void checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); + void checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); // INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; } std::string getPflName() const; @@ -85,7 +85,7 @@ namespace ParaMEDMEM { public: MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b); - void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); + void checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); bool operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception); bool isEntityCell() const; bool isComputed() const { return _computed; } @@ -95,7 +95,7 @@ namespace ParaMEDMEM bool isCellSupportEqual(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception); MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobs *globs) const throw(INTERP_KERNEL::Exception); bool isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobs *globs) const throw(INTERP_KERNEL::Exception); - bool isFullyOnExactlyOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const throw(INTERP_KERNEL::Exception); + bool isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const throw(INTERP_KERNEL::Exception); private: bool _computed; TypeOfField _type; @@ -105,15 +105,15 @@ namespace ParaMEDMEM class MEDFileField1TSStruct : public RefCountObject { public: - static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref) throw(INTERP_KERNEL::Exception); + static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst) throw(INTERP_KERNEL::Exception); void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); std::size_t getHeapMemorySize() const; - bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other) const throw(INTERP_KERNEL::Exception); - bool isSupportSameAs(const MEDFileAnyTypeField1TS *other) throw(INTERP_KERNEL::Exception); + bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const throw(INTERP_KERNEL::Exception); + bool isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception); bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception); private: - MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref); - static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref); + MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst); + static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt); private: std::vector _already_checked; }; -- 2.30.2