From: Anthony Geay Date: Thu, 5 Mar 2020 04:55:17 +0000 (+0100) Subject: WIP X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=250557984a53f2f4426af5931016a91122ecbb1e;p=tools%2Fmedcoupling.git WIP --- diff --git a/src/ParaMEDMEM/ParaUMesh.cxx b/src/ParaMEDMEM/ParaUMesh.cxx index f29a61399..e1d873d8f 100644 --- a/src/ParaMEDMEM/ParaUMesh.cxx +++ b/src/ParaMEDMEM/ParaUMesh.cxx @@ -26,7 +26,11 @@ #include "BlockTopology.hxx" #include "MEDCouplingMemArray.hxx" +#include "mpi.h" + #include +#include +#include #include using namespace std; @@ -48,5 +52,29 @@ MCAuto 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 nbOfElems(new long[size]); + long nbOfNodeIdsLoc(FromIdType(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 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 globalNodeIdsOfCurProc(DataArrayIdType::New()); + globalNodeIdsOfCurProc->useArray(allGlobalNodeIds.get()+offset,false,DeallocType::CPP_DEALLOC,nbOfElems[curRk],1); + offset += nbOfElems[curRk]; + MCAuto globalNodeIdsCaptured(_node_global->buildIntersection(globalNodeIdsOfCurProc)); + MCAuto localNodeIdsToLocate(_node_global->findIdForEach(globalNodeIdsCaptured->begin(),globalNodeIdsCaptured->end())); + MCAuto localCellCaptured(_mesh->getCellIdsLyingOnNodes(localNodeIdsToLocate->begin(),localNodeIdsToLocate->end(),false)); + MCAuto localCellCapturedGlob(_cell_global->selectByTupleIdSafe(localCellCaptured->begin(),localCellCaptured->end())); + + } + // MCAuto local; }