From 01fdac21a9ac3eab5f8e6e1b8acc846b6785a3f2 Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 7 Nov 2012 16:53:05 +0000 Subject: [PATCH] Correction of bug seen by EDF. --- .../GaussPoints/InterpKernelGaussCoords.cxx | 4 +- .../MEDCouplingFieldDiscretization.cxx | 82 +++++++------------ .../MEDCouplingFieldDiscretization.hxx | 2 +- 3 files changed, 31 insertions(+), 57 deletions(-) diff --git a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx index 57e9c936a..0fa9d7b5a 100644 --- a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx +++ b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx @@ -359,7 +359,7 @@ void GaussInfo::initLocalInfo() throw (INTERP_KERNEL::Exception) if(!aSatify) { - hexa8aInit(); + hexa8bInit(); aSatify = isSatisfy(); CHECK_MACRO; } @@ -373,7 +373,7 @@ void GaussInfo::initLocalInfo() throw (INTERP_KERNEL::Exception) if(!aSatify) { - hexa20aInit(); + hexa20bInit(); aSatify = isSatisfy(); CHECK_MACRO; } diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index 2739ca421..474fcc4b0 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -999,7 +999,7 @@ DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValue DataArrayDouble *ret=DataArrayDouble::New(); int spaceDim=mesh->getSpaceDimension(); ret->alloc(nbOfTuples,spaceDim); - std::vector< std::vector > locIds; + std::vector< int > locIds; std::vector parts=splitIntoSingleGaussDicrPerCellType(locIds); std::vector< MEDCouplingAutoRefCountObjectPtr > parts2(parts.size()); std::copy(parts.begin(),parts.end(),parts2.begin()); @@ -1013,21 +1013,17 @@ DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValue for(std::size_t i=0;i::const_iterator it=locIds[i].begin();it!=locIds[i].end();it++) - { - const MEDCouplingGaussLocalization& cli=_loc[*it];//curLocInfo - INTERP_KERNEL::NormalizedCellType typ=cli.getType(); - const std::vector& wg=cli.getWeights(); - calculator.addGaussInfo(typ,INTERP_KERNEL::CellModel::GetCellModel(typ).getDimension(), + // + const MEDCouplingGaussLocalization& cli=_loc[locIds[i]];//curLocInfo + INTERP_KERNEL::NormalizedCellType typ=cli.getType(); + const std::vector& wg=cli.getWeights(); + calculator.addGaussInfo(typ,INTERP_KERNEL::CellModel::GetCellModel(typ).getDimension(), &cli.getGaussCoords()[0],(int)wg.size(),&cli.getRefCoords()[0], INTERP_KERNEL::CellModel::GetCellModel(typ).getNumberOfNodes()); - } + // int nbt=parts2[i]->getNumberOfTuples(); for(const int *w=parts2[i]->getConstPointer();w!=parts2[i]->getConstPointer()+nbt;w++) - { - const MEDCouplingGaussLocalization& cli=_loc[*w]; - calculator.calculateCoords(cli.getType(),coords,spaceDim,conn+connI[*w]+1,valsToFill+spaceDim*(ptrOffsets[*w])); - } + calculator.calculateCoords(cli.getType(),coords,spaceDim,conn+connI[*w]+1,valsToFill+spaceDim*(ptrOffsets[*w])); } ret->copyStringInfoFrom(*umesh->getCoords()); return ret; @@ -1419,54 +1415,32 @@ void MEDCouplingFieldDiscretizationGauss::zipGaussLocalizations() * * If no descretization is set in 'this' and exception will be thrown. */ -std::vector MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType(std::vector< std::vector >& locIds) const throw(INTERP_KERNEL::Exception) +std::vector MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType(std::vector& locIds) const throw(INTERP_KERNEL::Exception) { if(!_discr_per_cell) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType : no descretization set !"); locIds.clear(); - std::vector ret; - const int *discrPerCell=_discr_per_cell->getConstPointer(); - MEDCouplingAutoRefCountObjectPtr ret2=_discr_per_cell->getIdsNotEqual(-1); - int nbOfTuplesSet=ret2->getNumberOfTuples(); - std::list idsRemaining(ret2->getConstPointer(),ret2->getConstPointer()+nbOfTuplesSet); - std::list::iterator it=idsRemaining.begin(); - while(it!=idsRemaining.end()) + std::set df=_discr_per_cell->getDifferentValues(); + df.erase(-1); + std::map m; + int nid=0; + std::vector > ret2(df.size()); locIds.resize(df.size()); + for(std::set::iterator it=df.begin();it!=df.end();it++,nid++) + { m[*it]=nid; locIds[nid]=*it; } + nid=0; + for(const int *discrPerCell=_discr_per_cell->begin();discrPerCell!=_discr_per_cell->end();discrPerCell++,nid++) + { + if(*discrPerCell!=-1) + ret2[m[*discrPerCell]].push_back(nid); + } + nid=0; + std::vector ret(df.size()); + for(std::set::iterator it=df.begin();it!=df.end();it++,nid++) { - std::vector ids; - std::set curLocIds; - std::set curCellTypes; - while(it!=idsRemaining.end()) - { - int curDiscrId=discrPerCell[*it]; - INTERP_KERNEL::NormalizedCellType typ=_loc[curDiscrId].getType(); - if(curCellTypes.find(typ)!=curCellTypes.end()) - { - if(curLocIds.find(curDiscrId)!=curLocIds.end()) - { - curLocIds.insert(curDiscrId); - curCellTypes.insert(typ); - ids.push_back(*it); - it=idsRemaining.erase(it); - } - else - it++; - } - else - { - curLocIds.insert(curDiscrId); - curCellTypes.insert(typ); - ids.push_back(*it); - it=idsRemaining.erase(it); - } - } - it=idsRemaining.begin(); - ret.resize(ret.size()+1); DataArrayInt *part=DataArrayInt::New(); - part->alloc((int)ids.size(),1); - std::copy(ids.begin(),ids.end(),part->getPointer()); - ret.back()=part; - locIds.resize(locIds.size()+1); - locIds.back().insert(locIds.back().end(),curLocIds.begin(),curLocIds.end()); + part->alloc(ret2[nid].size(),1); + std::copy(ret2[nid].begin(),ret2[nid].end(),part->getPointer()); + ret[nid]=part; } return ret; } diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx index df43d9527..d38217c61 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx @@ -246,7 +246,7 @@ namespace ParaMEDMEM int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception); void getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const throw(INTERP_KERNEL::Exception); const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception); - std::vector splitIntoSingleGaussDicrPerCellType(std::vector< std::vector >& locIds) const throw(INTERP_KERNEL::Exception); + std::vector splitIntoSingleGaussDicrPerCellType(std::vector< int >& locIds) const throw(INTERP_KERNEL::Exception); DataArrayInt *buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception); protected: MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other); -- 2.39.2