]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
WIP
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 5 Mar 2020 04:55:17 +0000 (05:55 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 5 Mar 2020 04:55:17 +0000 (05:55 +0100)
src/ParaMEDMEM/ParaUMesh.cxx

index f29a61399c34c575bac6b7874cf64fb244008db9..e1d873d8f8046a92fc3e86120dc14c406b44c596 100644 (file)
 #include "BlockTopology.hxx"
 #include "MEDCouplingMemArray.hxx"
 
+#include "mpi.h"
+
 #include <fstream>
+#include <numeric>
+#include <memory>
 #include <vector>
 
 using namespace std;
@@ -48,5 +52,29 @@ MCAuto<DataArrayIdType> ParaUMesh::getCellIdsLyingOnNodes(DataArrayIdType *globa
   DACheckNbOfTuplesAndComp(globalNodeIds,_mesh->getNumberOfNodes(),1,"ParaUMesh::getCellIdsLyingOnNodes");
   if(fullyIn)
     throw INTERP_KERNEL::Exception("ParaUMesh::getCellIdsLyingOnNodes : not implemented yet for fullyIn == True !");
+  MPI_Comm comm(MPI_COMM_WORLD);
+  int rk,size;
+  MPI_Comm_rank(comm,&rk);
+  MPI_Comm_size(comm,&size);
+  std::unique_ptr<long[]> nbOfElems(new long[size]);
+  long nbOfNodeIdsLoc(FromIdType<long>(globalNodeIds->getNumberOfTuples()));
+  MPI_Allgather(&nbOfNodeIdsLoc,1,MPI_LONG,nbOfElems.get(),size,MPI_LONG,comm);
+  long nbOfNodeIdsSum(std::accumulate(nbOfElems.get(),nbOfElems.get()+size,0L));
+  std::unique_ptr<int []> allGlobalNodeIds(new int[nbOfNodeIdsSum]);
+  MPI_Allgather(globalNodeIds->begin(),1,MPI_INT,allGlobalNodeIds.get(),size,MPI_INT,comm);
+  // compute for each proc the cell contribution among _mesh cells
+  mcIdType offset(0);
+  for(int curRk = 0 ; curRk < size ; ++curRk)
+  {
+      MCAuto<DataArrayIdType> globalNodeIdsOfCurProc(DataArrayIdType::New());
+      globalNodeIdsOfCurProc->useArray(allGlobalNodeIds.get()+offset,false,DeallocType::CPP_DEALLOC,nbOfElems[curRk],1);
+      offset += nbOfElems[curRk];
+      MCAuto<DataArrayIdType> globalNodeIdsCaptured(_node_global->buildIntersection(globalNodeIdsOfCurProc));
+      MCAuto<DataArrayIdType> localNodeIdsToLocate(_node_global->findIdForEach(globalNodeIdsCaptured->begin(),globalNodeIdsCaptured->end()));
+      MCAuto<DataArrayIdType> localCellCaptured(_mesh->getCellIdsLyingOnNodes(localNodeIdsToLocate->begin(),localNodeIdsToLocate->end(),false));
+      MCAuto<DataArrayIdType> localCellCapturedGlob(_cell_global->selectByTupleIdSafe(localCellCaptured->begin(),localCellCaptured->end()));
+      
+  }
+  //
   MCAuto<DataArrayIdType> local;
 }