]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Correction of bug seen by EDF.
authorageay <ageay>
Wed, 7 Nov 2012 16:53:05 +0000 (16:53 +0000)
committerageay <ageay>
Wed, 7 Nov 2012 16:53:05 +0000 (16:53 +0000)
src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx
src/MEDCoupling/MEDCouplingFieldDiscretization.cxx
src/MEDCoupling/MEDCouplingFieldDiscretization.hxx

index 57e9c936aea16eeba53c0f24320cb1297f2a6371..0fa9d7b5acde60717db21bbc867748548e7bf597 100644 (file)
@@ -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;
         }
index 2739ca421baee04a9a10e8fda3d0d6a09ed36dd7..474fcc4b09fb9baa0c7c6327d871e4ca4f18315b 100644 (file)
@@ -999,7 +999,7 @@ DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValue
   DataArrayDouble *ret=DataArrayDouble::New();
   int spaceDim=mesh->getSpaceDimension();
   ret->alloc(nbOfTuples,spaceDim);
-  std::vector< std::vector<int> > locIds;
+  std::vector< int > locIds;
   std::vector<DataArrayInt *> parts=splitIntoSingleGaussDicrPerCellType(locIds);
   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > 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<parts2.size();i++)
     {
       INTERP_KERNEL::GaussCoords calculator;
-      for(std::vector<int>::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<double>& 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<double>& 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<DataArrayInt *> MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType(std::vector< std::vector<int> >& locIds) const throw(INTERP_KERNEL::Exception)
+std::vector<DataArrayInt *> MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType(std::vector<int>& locIds) const throw(INTERP_KERNEL::Exception)
 {
   if(!_discr_per_cell)
     throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType : no descretization set !");
   locIds.clear();
-  std::vector<DataArrayInt *> ret;
-  const int *discrPerCell=_discr_per_cell->getConstPointer();
-  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret2=_discr_per_cell->getIdsNotEqual(-1);
-  int nbOfTuplesSet=ret2->getNumberOfTuples();
-  std::list<int> idsRemaining(ret2->getConstPointer(),ret2->getConstPointer()+nbOfTuplesSet);
-  std::list<int>::iterator it=idsRemaining.begin();
-  while(it!=idsRemaining.end())
+  std::set<int> df=_discr_per_cell->getDifferentValues();
+  df.erase(-1);
+  std::map<int,int> m;
+  int nid=0;
+  std::vector<std::vector<int> > ret2(df.size()); locIds.resize(df.size());
+  for(std::set<int>::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<DataArrayInt *> ret(df.size());
+  for(std::set<int>::iterator it=df.begin();it!=df.end();it++,nid++)
     {
-      std::vector<int> ids;
-      std::set<int> curLocIds;
-      std::set<INTERP_KERNEL::NormalizedCellType> 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;
 }
index df43d95277b35b88f76c16117cd50c163994f8c5..d38217c615538aaf671b05fbe949b3afc505fdd1 100644 (file)
@@ -246,7 +246,7 @@ namespace ParaMEDMEM
     int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
     void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
     const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
-    std::vector<DataArrayInt *> splitIntoSingleGaussDicrPerCellType(std::vector< std::vector<int> >& locIds) const throw(INTERP_KERNEL::Exception);
+    std::vector<DataArrayInt *> splitIntoSingleGaussDicrPerCellType(std::vector< int >& locIds) const throw(INTERP_KERNEL::Exception);
     DataArrayInt *buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception);
   protected:
     MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other);