]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
duplication of nodes along meshdim-1 group.
authorageay <ageay>
Thu, 14 Jun 2012 14:05:46 +0000 (14:05 +0000)
committerageay <ageay>
Thu, 14 Jun 2012 14:05:46 +0000 (14:05 +0000)
src/MEDCoupling_Swig/MEDCoupling.i
src/MEDLoader/MEDFileMesh.cxx
src/MEDLoader/MEDFileMesh.hxx
src/MEDLoader/MEDFileMeshLL.cxx
src/MEDLoader/MEDFileMeshLL.hxx
src/MEDLoader/Swig/MEDLoader.i
src/ParaMEDMEM/ElementLocator.cxx

index 3a007ff18c625d298b5fee798537dc396163bcdd..4728fb379d67817030f94c355dcb3a1812f811c8 100644 (file)
@@ -237,6 +237,7 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingMesh::buildUnstructured;
 %newobject ParaMEDMEM::MEDCouplingMesh::MergeMeshes;
 %newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer;
+%newobject ParaMEDMEM::MEDCouplingPointSet::findBoundaryNodes;
 %newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh;
 %newobject ParaMEDMEM::MEDCouplingPointSet::MergeNodesArray;
 %newobject ParaMEDMEM::MEDCouplingPointSet::BuildInstanceFromMeshType;
@@ -253,6 +254,7 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMesh;
 %newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes;
 %newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshesOnSameCoords;
+%newobject ParaMEDMEM::MEDCouplingUMesh::ComputeSpreadZoneGradually;
 %newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt;
 %newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes;
 %newobject ParaMEDMEM::MEDCouplingUMesh::sortCellsInMEDFileFrmt;
@@ -709,6 +711,7 @@ namespace ParaMEDMEM
                            const std::vector<std::string>& littleStrings) throw(INTERP_KERNEL::Exception);
       virtual void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) throw(INTERP_KERNEL::Exception) = 0;
       virtual DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception) = 0;
+      virtual DataArrayInt *findBoundaryNodes() const = 0;
       %extend 
          {
            std::string __str__() const
@@ -808,15 +811,7 @@ namespace ParaMEDMEM
                  return convertMesh(ret, SWIG_POINTER_OWN | 0 );
                }
            }
-           PyObject *findBoundaryNodes() const throw(INTERP_KERNEL::Exception)
-           {
-             std::vector<int> nodes;
-             self->findBoundaryNodes(nodes);
-             DataArrayInt *ret=DataArrayInt::New();
-             ret->alloc((int)nodes.size(),1);
-             std::copy(nodes.begin(),nodes.end(),ret->getPointer());
-             return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
-           }
+
            void renumberNodes(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception)
            {
              void *da=0;
@@ -929,6 +924,27 @@ namespace ParaMEDMEM
              return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
            }
 
+           void duplicateNodesInCoords(PyObject *li) throw(INTERP_KERNEL::Exception)
+           {
+             int sw;
+             int singleVal;
+             std::vector<int> multiVal;
+             std::pair<int, std::pair<int,int> > slic;
+             ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+             convertObjToPossibleCpp2(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp);
+             switch(sw)
+               {
+               case 1:
+                 return self->duplicateNodesInCoords(&singleVal,&singleVal+1);
+               case 2:
+                 return self->duplicateNodesInCoords(&multiVal[0],&multiVal[0]+multiVal.size());
+               case 4:
+                 return self->duplicateNodesInCoords(daIntTyypp->begin(),daIntTyypp->end());
+               default:
+                 throw INTERP_KERNEL::Exception("MEDCouplingPointSet::duplicateNodesInCoords : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+               }
+           }
+
            static void Rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception)
            {
              int sz;
@@ -1088,6 +1104,7 @@ namespace ParaMEDMEM
     static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception);
     static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
     static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+    static DataArrayInt *ComputeSpreadZoneGradually(const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception);
     %extend {
       std::string __str__() const
       {
@@ -1156,6 +1173,70 @@ namespace ParaMEDMEM
           }
       }
 
+      void __setitem__(PyObject *li, const MEDCouplingUMesh& otherOnSameCoordsThanThis) throw(INTERP_KERNEL::Exception)
+      {
+        int sw;
+        int singleVal;
+        std::vector<int> multiVal;
+        std::pair<int, std::pair<int,int> > slic;
+        ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+        int nbc=self->getNumberOfCells();
+        convertObjToPossibleCpp2(li,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+        switch(sw)
+          {
+          case 1:
+            {
+              if(singleVal>=nbc)
+                {
+                  std::ostringstream oss;
+                  oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
+                  throw INTERP_KERNEL::Exception(oss.str().c_str());
+                }
+              if(singleVal>=0)
+                {
+                  self->setPartOfMySelf(&singleVal,&singleVal+1,otherOnSameCoordsThanThis);
+                  break;
+                }
+              else
+                {
+                  if(nbc+singleVal>0)
+                    {
+                      int tmp=nbc+singleVal;
+                      self->setPartOfMySelf(&tmp,&tmp+1,otherOnSameCoordsThanThis);
+                      break;
+                    }
+                  else
+                    {
+                      std::ostringstream oss;
+                      oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
+                      throw INTERP_KERNEL::Exception(oss.str().c_str());
+                    }
+                }
+            }
+          case 2:
+            {
+              self->setPartOfMySelf(&multiVal[0],&multiVal[0]+multiVal.size(),otherOnSameCoordsThanThis);
+              break;
+            }
+          case 3:
+            {
+              MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::Range(slic.first,slic.second.first,slic.second.second);
+              self->setPartOfMySelf(d0->begin(),d0->end(),otherOnSameCoordsThanThis);
+              break;
+            }
+          case 4:
+            {
+              if(!daIntTyypp)
+                throw INTERP_KERNEL::Exception("MEDCouplingUMesh::__setitem__ : null instance has been given in input !");
+              daIntTyypp->checkAllocated();
+              self->setPartOfMySelf(daIntTyypp->begin(),daIntTyypp->end(),otherOnSameCoordsThanThis);
+              break;
+            }
+          default:
+            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::__setitem__ : unrecognized type in input ! Possibilities are : int, list or tuple of int DataArrayInt instance !");
+          }
+      }
+
       void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li) throw(INTERP_KERNEL::Exception)
       {
         int sz;
@@ -1264,6 +1345,58 @@ namespace ParaMEDMEM
         return ret;
       }
 
+      PyObject *findNodesToDuplicate(MEDCouplingUMesh& otherDimM1OnSameCoords) const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayInt *tmp0=0,*tmp1=0;
+        self->findNodesToDuplicate(otherDimM1OnSameCoords,tmp0,tmp1);
+        PyObject *ret=PyTuple_New(2);
+        PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(tmp0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        return ret;
+      }
+
+      void duplicateNodes(PyObject *li) throw(INTERP_KERNEL::Exception)
+      {
+        int sw;
+        int singleVal;
+        std::vector<int> multiVal;
+        std::pair<int, std::pair<int,int> > slic;
+        ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+        convertObjToPossibleCpp2(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp);
+        switch(sw)
+          {
+          case 1:
+            return self->duplicateNodes(&singleVal,&singleVal+1);
+          case 2:
+            return self->duplicateNodes(&multiVal[0],&multiVal[0]+multiVal.size());
+          case 4:
+            return self->duplicateNodes(daIntTyypp->begin(),daIntTyypp->end());
+          default:
+            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::duplicateNodes : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+          }
+      }
+
+      void duplicateNodesInConn(PyObject *li, int offset) throw(INTERP_KERNEL::Exception)
+      {
+        int sw;
+        int singleVal;
+        std::vector<int> multiVal;
+        std::pair<int, std::pair<int,int> > slic;
+        ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+        convertObjToPossibleCpp2(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp);
+        switch(sw)
+          {
+          case 1:
+            return self->duplicateNodesInConn(&singleVal,&singleVal+1,offset);
+          case 2:
+            return self->duplicateNodesInConn(&multiVal[0],&multiVal[0]+multiVal.size(),offset);
+          case 4:
+            return self->duplicateNodesInConn(daIntTyypp->begin(),daIntTyypp->end(),offset);
+          default:
+            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::duplicateNodesInConn : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+          }
+      }
+
       void renumberNodesInConn(PyObject *li) throw(INTERP_KERNEL::Exception)
       {
         void *da=0;
@@ -1296,6 +1429,19 @@ namespace ParaMEDMEM
         return ret;
       }
 
+      static PyObject *AggregateSortedByTypeMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception)
+      {
+        std::vector<const ParaMEDMEM::MEDCouplingUMesh *> meshes;
+        convertPyObjToVecUMeshesCst(ms,meshes);
+        DataArrayInt *ret1=0,*ret2=0;
+        MEDCouplingUMesh *ret0=MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(meshes,ret1,ret2);
+        PyObject *ret=PyTuple_New(3);
+        PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        return ret;
+      }
+
       static PyObject *MergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception)
       {
         std::vector<const ParaMEDMEM::MEDCouplingUMesh *> meshes;
@@ -1335,6 +1481,138 @@ namespace ParaMEDMEM
         MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords(meshes,eps);
       }
 
+      static bool RemoveIdsFromIndexedArrays(PyObject *li, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
+      {
+        int sw;
+        int singleVal;
+        std::vector<int> multiVal;
+        std::pair<int, std::pair<int,int> > slic;
+        ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+        if(!arrIndx)
+          throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
+        convertObjToPossibleCpp2(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+        switch(sw)
+          {
+          case 1:
+            return MEDCouplingUMesh::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
+          case 2:
+            return MEDCouplingUMesh::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
+          case 4:
+            return MEDCouplingUMesh::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
+          default:
+            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+          }
+      }
+      
+      static PyObject *ExtractFromIndexedArrays(PyObject *li, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayInt *arrOut=0,*arrIndexOut=0;
+        int sw;
+        int singleVal;
+        std::vector<int> multiVal;
+        std::pair<int, std::pair<int,int> > slic;
+        ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+        if(!arrIndxIn)
+          throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
+        convertObjToPossibleCpp2(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+        switch(sw)
+          {
+          case 1:
+            {
+              MEDCouplingUMesh::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
+              break;
+            }
+          case 2:
+            {
+              MEDCouplingUMesh::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
+              break;
+            }
+          case 4:
+            {
+              MEDCouplingUMesh::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
+              break;
+            }
+          default:
+            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+          }
+        PyObject *ret=PyTuple_New(2);
+        PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        return ret;
+      }
+
+      static PyObject *SetPartOfIndexedArrays(PyObject *li,
+                                              const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+                                              const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex) throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayInt *arrOut=0,*arrIndexOut=0;
+        int sw;
+        int singleVal;
+        std::vector<int> multiVal;
+        std::pair<int, std::pair<int,int> > slic;
+        ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+        if(!arrIndxIn)
+          throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArrays : null pointer as arrIndex !");
+        convertObjToPossibleCpp2(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+        switch(sw)
+          {
+          case 1:
+            {
+              MEDCouplingUMesh::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+              break;
+            }
+          case 2:
+            {
+              MEDCouplingUMesh::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+              break;
+            }
+          case 4:
+            {
+              MEDCouplingUMesh::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+              break;
+            }
+          default:
+            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+          }
+        PyObject *ret=PyTuple_New(2);
+        PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        return ret;
+      }
+
+      static void SetPartOfIndexedArraysSameIdx(PyObject *li, DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+                                                const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex) throw(INTERP_KERNEL::Exception)
+      {
+        int sw;
+        int singleVal;
+        std::vector<int> multiVal;
+        std::pair<int, std::pair<int,int> > slic;
+        ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+        if(!arrIndxIn)
+          throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
+        convertObjToPossibleCpp2(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+        switch(sw)
+          {
+          case 1:
+            {
+              MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
+              break;
+            }
+          case 2:
+            {
+              MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
+              break;
+            }
+          case 4:
+            {
+              MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
+              break;
+            }
+          default:
+            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+          }
+      }
+
       PyObject *are2DCellsNotCorrectlyOriented(PyObject *vec, bool polyOnly) const throw(INTERP_KERNEL::Exception)
       {
         std::vector<int> cells;
@@ -1466,6 +1744,16 @@ namespace ParaMEDMEM
         return ret;
       }
 
+      PyObject *computeNeighborsOfCellsAdv(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *revDesc, const DataArrayInt *revDescI) const throw(INTERP_KERNEL::Exception)
+      {
+        DataArrayInt *neighbors=0,*neighborsIdx=0;
+        self->computeNeighborsOfCellsAdv(desc,descI,revDesc,revDescI,neighbors,neighborsIdx);
+        PyObject *ret=PyTuple_New(2);
+        PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(neighbors),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(neighborsIdx),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+        return ret;
+      }        
+
       PyObject *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh)
       {
         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
@@ -2550,7 +2838,7 @@ namespace ParaMEDMEM
    DataArrayDouble *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
    {
      self->checkAllocated();
-     const char msg[]="Unexpected situation in __setitem__ !";
+     const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !";
      int nbOfTuples=self->getNumberOfTuples();
      int nbOfComponents=self->getNumberOfComponents();
      int sw1,sw2;
@@ -3802,6 +4090,48 @@ namespace ParaMEDMEM
        }
    }
 
+   DataArrayInt *getIdsEqualList(PyObject *obj) throw(INTERP_KERNEL::Exception)
+   {
+     int sw;
+     int singleVal;
+     std::vector<int> multiVal;
+     std::pair<int, std::pair<int,int> > slic;
+     ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+     convertObjToPossibleCpp2(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
+     switch(sw)
+       {
+       case 1:
+         return self->getIdsEqualList(&singleVal,&singleVal+1);
+       case 2:
+         return self->getIdsEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
+       case 4:
+         return self->getIdsEqualList(daIntTyypp->begin(),daIntTyypp->end());
+       default:
+         throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqualList : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+       }
+   }
+
+   DataArrayInt *getIdsNotEqualList(PyObject *obj) throw(INTERP_KERNEL::Exception)
+   {
+     int sw;
+     int singleVal;
+     std::vector<int> multiVal;
+     std::pair<int, std::pair<int,int> > slic;
+     ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+     convertObjToPossibleCpp2(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
+     switch(sw)
+       {
+       case 1:
+         return self->getIdsNotEqualList(&singleVal,&singleVal+1);
+       case 2:
+         return self->getIdsNotEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
+       case 4:
+         return self->getIdsNotEqualList(daIntTyypp->begin(),daIntTyypp->end());
+       default:
+         throw INTERP_KERNEL::Exception("DataArrayInt::getIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+       }
+   }
+
    PyObject *splitByValueRange(PyObject *li) const throw(INTERP_KERNEL::Exception)
    {
      DataArrayInt *ret0=0,*ret1=0,*ret2=0;
index 6fb0a0535ddd7ea6beabca6e9f44550c3958a6ec..f3475550301ddb3ae6e1063bf3e2d2040a286628 100644 (file)
@@ -1462,11 +1462,7 @@ int MEDFileUMesh::getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERN
 const DataArrayInt *MEDFileUMesh::getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
 {
   if(meshDimRelToMaxExt==1)
-    {
-      if(!((const DataArrayInt *)_fam_coords))
-        throw INTERP_KERNEL::Exception("MEDFileUMesh::getFamilyFieldAtLevel : no coordinates specified !");
-      return _fam_coords;
-    }
+    return _fam_coords;
   const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
   return l1->getFamilyField();
 }
@@ -1545,7 +1541,10 @@ MEDCouplingUMesh *MEDFileUMesh::getFamilies(int meshDimRelToMaxExt, const std::v
     }
   std::vector<int> famIds=getFamiliesIds(fams);
   const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
-  return l1->getFamilyPart(famIds,renum);
+  if(!famIds.empty())
+    return l1->getFamilyPart(&famIds[0],&famIds[0]+famIds.size(),renum);
+  else
+    return l1->getFamilyPart(0,0,renum);
 }
 
 DataArrayInt *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
@@ -1555,7 +1554,11 @@ DataArrayInt *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::ve
     {
       if((const DataArrayInt *)_fam_coords)
         {
-          MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam_coords->getIdsEqualList(famIds);
+          MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da;
+          if(!famIds.empty())
+            da=_fam_coords->getIdsEqualList(&famIds[0],&famIds[0]+famIds.size());
+          else
+            da=_fam_coords->getIdsEqualList(0,0);
           if(renum)
             return MEDFileUMeshSplitL1::Renumber(_num_coords,da);
           else
@@ -1568,7 +1571,10 @@ DataArrayInt *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::ve
         throw INTERP_KERNEL::Exception("MEDFileUMesh::getFamiliesArr : no family array specified on nodes !");
     }
   const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
-  return l1->getFamilyPartArr(famIds,renum);
+  if(!famIds.empty())
+    return l1->getFamilyPartArr(&famIds[0],&famIds[0]+famIds.size(),renum);
+  else
+    return l1->getFamilyPartArr(0,0,renum);
 }
 
 MEDCouplingUMesh *MEDFileUMesh::getMeshAtLevel(int meshDimRelToMaxExt, bool renum) const throw(INTERP_KERNEL::Exception)
@@ -1661,6 +1667,8 @@ void MEDFileUMesh::checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const
 
 void MEDFileUMesh::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
 {
+  if(!coords)
+    throw INTERP_KERNEL::Exception("MEDFileUMesh::setCoords : null pointer in input !");
   coords->checkAllocated();
   int nbOfTuples=coords->getNumberOfTuples();
   _coords=coords;
@@ -1721,6 +1729,84 @@ void MEDFileUMesh::optimizeFamilies() throw(INTERP_KERNEL::Exception)
     _groups.erase(*it);
 }
 
+void MEDFileUMesh::duplicateNodesOnM1Group(const char *grpNameM1, DataArrayInt *&nodesDuplicated, DataArrayInt *&cellsModified) throw(INTERP_KERNEL::Exception)
+{
+  std::vector<int> levs=getNonEmptyLevels();
+  if(std::find(levs.begin(),levs.end(),0)==levs.end() || std::find(levs.begin(),levs.end(),-1)==levs.end())
+    throw INTERP_KERNEL::Exception("MEDFileUMesh::duplicateNodesOnM1Group : This method works only for mesh definied on level 0 and -1 !");
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m0=getMeshAtLevel(0);
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m1=getMeshAtLevel(-1);
+  int nbNodes=m0->getNumberOfNodes();
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m11=getGroup(-1,grpNameM1);
+  DataArrayInt *tmp00=0,*tmp11=0;
+  m0->findNodesToDuplicate(*m11,tmp00,tmp11);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeIdsToDuplicate(tmp00);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellsToModifyConn0(tmp11);
+  m11=getGroup(-1,grpNameM1);
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp0=static_cast<MEDCouplingUMesh *>(m0->buildPartOfMySelf(cellsToModifyConn0->begin(),cellsToModifyConn0->end(),true));
+  tmp0->duplicateNodes(nodeIdsToDuplicate->begin(),nodeIdsToDuplicate->end());
+  m0->setCoords(tmp0->getCoords());
+  m0->setPartOfMySelf(cellsToModifyConn0->begin(),cellsToModifyConn0->end(),*tmp0);
+  m1->setCoords(m0->getCoords());
+  const DataArrayInt *fam=getFamilyFieldAtLevel(1);
+  fam->incrRef();
+  _coords=m0->getCoords(); _coords->incrRef();
+  DataArrayInt *famTmp=const_cast<DataArrayInt *>(getFamilyFieldAtLevel(1));
+  famTmp->setPartOfValues1(fam,0,fam->getNumberOfTuples(),1,0,1,1,true);
+  fam->decrRef();
+  //
+  m11->duplicateNodesInConn(nodeIdsToDuplicate->begin(),nodeIdsToDuplicate->end(),nbNodes); m11->setCoords(m0->getCoords());
+  std::vector<const MEDCouplingUMesh *> v(2); v[0]=m1; v[1]=m11;
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> newm1=MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(v,tmp00,tmp11);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> szOfCellGrpOfSameType(tmp00);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idInMsOfCellGrpOfSameType(tmp11);
+  //
+  newm1->setName(getName());
+  fam=getFamilyFieldAtLevel(-1);
+  if(!fam)
+    throw INTERP_KERNEL::Exception("MEDFileUMesh::duplicateNodesOnM1Group : internal problem !");
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newFam=DataArrayInt::New();
+  newFam->alloc(newm1->getNumberOfCells(),1);
+  int idd=getMaxFamilyId()+1;
+  int globStart=0,start=0,end,globEnd;
+  int nbOfChunks=szOfCellGrpOfSameType->getNumberOfTuples();
+  for(int i=0;i<nbOfChunks;i++)
+    {
+      globEnd=globStart+szOfCellGrpOfSameType->getIJ(i,0);
+      if(idInMsOfCellGrpOfSameType->getIJ(i,0)==0)
+        {
+          end=start+szOfCellGrpOfSameType->getIJ(i,0);
+          MEDCouplingAutoRefCountObjectPtr<DataArrayInt> part=fam->selectByTupleId2(start,end,1);
+          newFam->setPartOfValues1(part,globStart,globEnd,1,0,1,1,true);
+          start=end;
+        }
+      else
+        {
+          newFam->setPartOfValuesSimple1(idd,globStart,globEnd,1,0,1,1);
+        }
+      globStart=globEnd;
+    }
+  newm1->setCoords(getCoords());
+  setMeshAtLevel(-1,newm1);
+  setFamilyFieldArr(-1,newFam);
+  std::ostringstream famName; famName << "Family_" << idd;
+  std::string grpName2(grpNameM1); grpName2+="_dup";
+  addFamily(famName.str().c_str(),idd);
+  addFamilyOnGrp(grpName2.c_str(),famName.str().c_str());
+  //
+  fam=_fam_coords;
+  if(fam)
+    {
+      int newNbOfNodes=getCoords()->getNumberOfTuples();
+      newFam=DataArrayInt::New(); newFam->alloc(newNbOfNodes,1);
+      newFam->setPartOfValues1(fam,0,nbNodes,1,0,1,1,true);
+      newFam->setPartOfValuesSimple1(0,nbNodes,newNbOfNodes,1,0,1,1);
+      _fam_coords=newFam;
+    }
+  nodesDuplicated=nodeIdsToDuplicate; nodeIdsToDuplicate->incrRef();
+  cellsModified=cellsToModifyConn0; cellsToModifyConn0->incrRef();
+}
+
 void MEDFileUMesh::addNodeGroup(const std::string& name, const std::vector<int>& ids) throw(INTERP_KERNEL::Exception)
 {
   const DataArrayDouble *coords=_coords;
@@ -2305,7 +2391,11 @@ DataArrayInt *MEDFileCMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::ve
     {
       if((const DataArrayInt *)_fam_nodes)
         {
-          MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam_nodes->getIdsEqualList(famIds);
+          MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da;
+          if(!famIds.empty())
+            da=_fam_nodes->getIdsEqualList(&famIds[0],&famIds[0]+famIds.size());
+          else
+            da=_fam_nodes->getIdsEqualList(0,0);
           if(renum)
             return MEDFileUMeshSplitL1::Renumber(_num_nodes,da);
           else
@@ -2321,7 +2411,11 @@ DataArrayInt *MEDFileCMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::ve
     {
       if((const DataArrayInt *)_fam_cells)
         {
-          MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam_cells->getIdsEqualList(famIds);
+          MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da;
+          if(!famIds.empty())
+            da=_fam_cells->getIdsEqualList(&famIds[0],&famIds[0]+famIds.size());
+          else
+            da=_fam_cells->getIdsEqualList(0,0);
           if(renum)
             return MEDFileUMeshSplitL1::Renumber(_num_cells,da);
           else
index b10e3a671a7f22f5ebb8c9e026fa62f70c60e48f..49e7c3b91f06d214f7e9e8e8d1ef0f99af70a470 100644 (file)
@@ -192,6 +192,7 @@ namespace ParaMEDMEM
     void setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception);
     void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum) throw(INTERP_KERNEL::Exception);
     void optimizeFamilies() throw(INTERP_KERNEL::Exception);
+    void duplicateNodesOnM1Group(const char *grpNameM1, DataArrayInt *&nodesDuplicated, DataArrayInt *&cellsModified) throw(INTERP_KERNEL::Exception);
   private:
     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
     MEDFileUMesh();
index 028511608d65281776b588f9562249b4becb84e1..550894befc83089094aae1f182410eeaea26f2ec 100644 (file)
@@ -597,18 +597,18 @@ int MEDFileUMeshSplitL1::getSize() const throw(INTERP_KERNEL::Exception)
   return _m_by_types->getNumberOfCells();
 }
 
-MEDCouplingUMesh *MEDFileUMeshSplitL1::getFamilyPart(const std::vector<int>& ids, bool renum) const
+MEDCouplingUMesh *MEDFileUMeshSplitL1::getFamilyPart(const int *idsBg, const int *idsEnd, bool renum) const
 {
-  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsToKeep=_fam->getIdsEqualList(ids);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsToKeep=_fam->getIdsEqualList(idsBg,idsEnd);
   MEDCouplingUMesh *m=(MEDCouplingUMesh *)_m_by_types->buildPartOfMySelf(eltsToKeep->getConstPointer(),eltsToKeep->getConstPointer()+eltsToKeep->getNumberOfTuples(),true);
   if(renum)
     return renumIfNeeded(m,eltsToKeep->getConstPointer());
   return m;
 }
 
-DataArrayInt *MEDFileUMeshSplitL1::getFamilyPartArr(const std::vector<int>& ids, bool renum) const
+DataArrayInt *MEDFileUMeshSplitL1::getFamilyPartArr(const int *idsBg, const int *idsEnd, bool renum) const
 {
-  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam->getIdsEqualList(ids);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam->getIdsEqualList(idsBg,idsEnd);
   if(renum)
     return renumIfNeededArr(da);
   da->incrRef();
index 37ed23d4d65308f04c70f403cdc0af841257e22a..16f3a446ec8b5d0cd620ac4f65c6af66e4655370 100644 (file)
@@ -127,8 +127,8 @@ namespace ParaMEDMEM
     int getMeshDimension() const;
     void simpleRepr(std::ostream& oss) const;
     int getSize() const throw(INTERP_KERNEL::Exception);
-    MEDCouplingUMesh *getFamilyPart(const std::vector<int>& ids, bool renum) const;
-    DataArrayInt *getFamilyPartArr(const std::vector<int>& ids, bool renum) const;
+    MEDCouplingUMesh *getFamilyPart(const int *idsBg, const int *idsEnd, bool renum) const;
+    DataArrayInt *getFamilyPartArr(const int *idsBg, const int *idsEnd, bool renum) const;
     MEDCouplingUMesh *getWholeMesh(bool renum) const;
     const DataArrayInt *getFamilyField() const;
     const DataArrayInt *getNumberField() const;
index 0d9a0bdf5a7cc132e74e069add1990e6ee439fc4..642d6195846d6dc68b307175d8a8d273cd334e05 100644 (file)
@@ -534,6 +534,16 @@ namespace ParaMEDMEM
              ret->incrRef();
            return ret;
          }
+
+         PyObject *duplicateNodesOnM1Group(const char *grpNameM1) throw(INTERP_KERNEL::Exception)
+         {
+           DataArrayInt *ret0=0,*ret1=0;
+           self->duplicateNodesOnM1Group(grpNameM1,ret0,ret1);
+           PyObject *ret=PyTuple_New(2);
+           PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+           PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+           return ret;
+         }
        }
   };
 
index 8af351d7638b3e3ade27cbc2709d4e009073a1f0..8e15db02ddf46aa3c13fe9f0e54c15fcada8ce88 100644 (file)
@@ -27,6 +27,7 @@
 #include "ProcessorGroup.hxx"
 #include "MPIProcessorGroup.hxx"
 #include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
 #include "DirectedBoundingBox.hxx"
 
 #include <map>
@@ -693,11 +694,10 @@ namespace ParaMEDMEM
     CommInterface comm;
     DataArrayInt *globalIds=_local_para_field.returnGlobalNumbering();
     const int *globalIdsC=globalIds->getConstPointer();
-    std::vector<int> candidates;
-    _local_para_field.getSupport()->getCellMesh()->findBoundaryNodes(candidates);
-    for(std::vector<int>::iterator iter1=candidates.begin();iter1!=candidates.end();iter1++)
+    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> candidates=_local_para_field.getSupport()->getCellMesh()->findBoundaryNodes();
+    for(int *iter1=candidates->getPointer();iter1!=candidates->getPointer()+candidates->getNumberOfTuples();iter1++)
       (*iter1)=globalIdsC[*iter1];
-    std::set<int> candidatesS(candidates.begin(),candidates.end());
+    std::set<int> candidatesS(candidates->begin(),candidates->end());
     for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++)
       {
         const vector<int>& ids=_ids_per_working_proc[procId];