From c3944f0418a61dc9145998e92bdc388c3bfe2a91 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Sun, 8 Mar 2020 23:41:24 +0100 Subject: [PATCH] It works for int32 config --- src/ParaMEDMEM/ParaUMesh.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ParaMEDMEM/ParaUMesh.cxx b/src/ParaMEDMEM/ParaUMesh.cxx index 1b1ac5c2f..c03a6cd23 100644 --- a/src/ParaMEDMEM/ParaUMesh.cxx +++ b/src/ParaMEDMEM/ParaUMesh.cxx @@ -30,6 +30,7 @@ #include "mpi.h" #include +#include #include #include #include @@ -46,6 +47,10 @@ ParaUMesh::ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, Dat _cell_global.checkNotNull(); _node_global.checkNotNull(); _mesh->checkConsistencyLight(); + if(_mesh->getNumberOfNodes() != _node_global->getNumberOfTuples()) + throw INTERP_KERNEL::Exception("ParaUMesh constructor : mismatch between # nodes and len of global # nodes."); + if(_mesh->getNumberOfCells() != _cell_global->getNumberOfTuples()) + throw INTERP_KERNEL::Exception("ParaUMesh constructor : mismatch between # cells and len of global # cells."); } MCAuto ParaUMesh::getCellIdsLyingOnNodes(DataArrayIdType *globalNodeIds, bool fullyIn) const @@ -53,8 +58,7 @@ MCAuto ParaUMesh::getCellIdsLyingOnNodes(DataArrayIdType *globa 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); + int size; MPI_Comm_size(comm,&size); std::unique_ptr nbOfElems(new long[size]),nbOfElems2(new long[size]); long nbOfNodeIdsLoc(FromIdType(globalNodeIds->getNumberOfTuples())); @@ -63,8 +67,9 @@ MCAuto ParaUMesh::getCellIdsLyingOnNodes(DataArrayIdType *globa std::vector< MCAuto > tabs(size); { std::unique_ptr allGlobalNodeIds(new int[nbOfNodeIdsSum]); - MPI_Allgather(globalNodeIds->begin(),1,MPI_INT,allGlobalNodeIds.get(),1,MPI_INT,comm); - // compute for each proc the cell contribution among _mesh cells + std::unique_ptr nbOfElemsInt( CommInterface::ToIntArray(nbOfElems,size) ); + std::unique_ptr offsetsIn( CommInterface::ComputeOffset(nbOfElemsInt,size) ); + MPI_Allgatherv(globalNodeIds->begin(),globalNodeIds->getNumberOfTuples(),MPI_INT,allGlobalNodeIds.get(),nbOfElemsInt.get(),offsetsIn.get(),MPI_INT,comm); long offset(0); for(int curRk = 0 ; curRk < size ; ++curRk) { -- 2.39.2