From: Anthony Geay Date: Sun, 8 Mar 2020 06:27:07 +0000 (+0100) Subject: First running case X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7c40d8443236de1c4d71781ebc4e1a673ce4f4f7;p=tools%2Fmedcoupling.git First running case --- diff --git a/src/ParaMEDMEM/CommInterface.hxx b/src/ParaMEDMEM/CommInterface.hxx index 76692c86e..861013366 100644 --- a/src/ParaMEDMEM/CommInterface.hxx +++ b/src/ParaMEDMEM/CommInterface.hxx @@ -95,6 +95,7 @@ namespace MEDCoupling { std::unique_ptr ret(new int[size]); std::copy(arr.get(),arr.get()+size,ret.get()); + return ret; } static std::unique_ptr ComputeOffset(const std::unique_ptr& counts, std::size_t sizeOfCounts) { diff --git a/src/ParaMEDMEM/ParaUMesh.cxx b/src/ParaMEDMEM/ParaUMesh.cxx index 1db9288dc..1b1ac5c2f 100644 --- a/src/ParaMEDMEM/ParaUMesh.cxx +++ b/src/ParaMEDMEM/ParaUMesh.cxx @@ -50,7 +50,6 @@ ParaUMesh::ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, Dat MCAuto ParaUMesh::getCellIdsLyingOnNodes(DataArrayIdType *globalNodeIds, bool fullyIn) const { - 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); @@ -59,7 +58,7 @@ MCAuto ParaUMesh::getCellIdsLyingOnNodes(DataArrayIdType *globa MPI_Comm_size(comm,&size); std::unique_ptr nbOfElems(new long[size]),nbOfElems2(new long[size]); long nbOfNodeIdsLoc(FromIdType(globalNodeIds->getNumberOfTuples())); - MPI_Allgather(&nbOfNodeIdsLoc,1,MPI_LONG,nbOfElems.get(),size,MPI_LONG,comm); + MPI_Allgather(&nbOfNodeIdsLoc,1,MPI_LONG,nbOfElems.get(),1,MPI_LONG,comm); long nbOfNodeIdsSum(std::accumulate(nbOfElems.get(),nbOfElems.get()+size,0L)); std::vector< MCAuto > tabs(size); { @@ -88,7 +87,7 @@ MCAuto ParaUMesh::getCellIdsLyingOnNodes(DataArrayIdType *globa cellIdsFromProcs->alloc(nbOfCellIdsSum,1); { std::unique_ptr nbOfElemsInt( CommInterface::ToIntArray(nbOfElems,size) ),nbOfElemsOutInt( CommInterface::ToIntArray(nbOfElems2,size) ); - std::unique_ptr offsetsIn( CommInterface::ComputeOffset(nbOfElemsInt,size) ), offsetsOut( CommInterface::ComputeOffset(CommInterface::ToIntArray(nbOfElems2,size),size) ); + std::unique_ptr offsetsIn( CommInterface::ComputeOffset(nbOfElemsInt,size) ), offsetsOut( CommInterface::ComputeOffset(nbOfElemsOutInt,size) ); MPI_Alltoallv(cells->begin(),nbOfElemsInt.get(),offsetsIn.get(),MPI_INT, cellIdsFromProcs->getPointer(),nbOfElemsOutInt.get(),offsetsOut.get(),MPI_INT,comm); } diff --git a/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i b/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i index a75ae3074..fd986e0b8 100644 --- a/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i +++ b/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i @@ -34,6 +34,7 @@ #include "ParaFIELD.hxx" #include "ICoCoMEDField.hxx" #include "ComponentTopology.hxx" +#include "ParaUMesh.hxx" using namespace INTERP_KERNEL; using namespace MEDCoupling; @@ -41,7 +42,6 @@ using namespace ICoCo; %} %include "InterpolationOptions.hxx" -%include "CommInterface.hxx" %include "ProcessorGroup.hxx" %include "DECOptions.hxx" %include "ParaMESH.hxx" @@ -57,8 +57,87 @@ using namespace ICoCo; %rename(ICoCoMEDField) ICoCo::MEDField; %include "ICoCoMEDField.hxx" +%newobject MEDCoupling::ParaUMesh::getCellIdsLyingOnNodes; + %nodefaultctor; +namespace MEDCoupling +{ + class CommInterface + { + public: + CommInterface(); + virtual ~CommInterface(); + int worldSize() const; + int commSize(MPI_Comm comm, int* size) const; + int commRank(MPI_Comm comm, int* rank) const; + int commGroup(MPI_Comm comm, MPI_Group* group) const; + int groupIncl(MPI_Group group, int size, int* ranks, MPI_Group* group_output) const; + int commCreate(MPI_Comm comm, MPI_Group group, MPI_Comm* comm_output) const; + int groupFree(MPI_Group* group) const; + int commFree(MPI_Comm* comm) const; + + int send(void* buffer, int count, MPI_Datatype datatype, int target, int tag, MPI_Comm comm) const; + int recv(void* buffer, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status* status) const; + int sendRecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, + int dest, int sendtag, void* recvbuf, int recvcount, + MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, + MPI_Status* status); + + int Isend(void* buffer, int count, MPI_Datatype datatype, int target, + int tag, MPI_Comm comm, MPI_Request *request) const; + int Irecv(void* buffer, int count, MPI_Datatype datatype, int source, + int tag, MPI_Comm comm, MPI_Request* request) const; + + int wait(MPI_Request *request, MPI_Status *status) const; + int test(MPI_Request *request, int *flag, MPI_Status *status) const; + int requestFree(MPI_Request *request) const; + int waitany(int count, MPI_Request *array_of_requests, int *index, MPI_Status *status) const; + int testany(int count, MPI_Request *array_of_requests, int *index, int *flag, MPI_Status *status) const; + int waitall(int count, MPI_Request *array_of_requests, MPI_Status *array_of_status) const { return MPI_Waitall(count, array_of_requests, array_of_status); } + int testall(int count, MPI_Request *array_of_requests, int *flag, MPI_Status *array_of_status) const; + int waitsome(int incount, MPI_Request *array_of_requests,int *outcount, int *array_of_indices, MPI_Status *array_of_status) const; + int testsome(int incount, MPI_Request *array_of_requests, int *outcount, + int *array_of_indices, MPI_Status *array_of_status) const; + int probe(int source, int tag, MPI_Comm comm, MPI_Status *status) const; + int Iprobe(int source, int tag, MPI_Comm comm, int *flag, MPI_Status *status) const; + int cancel(MPI_Request *request) const; + int testCancelled(MPI_Status *status, int *flag) const; + int barrier(MPI_Comm comm) const; + int errorString(int errorcode, char *string, int *resultlen) const; + int getCount(MPI_Status *status, MPI_Datatype datatype, int *count) const; + + int broadcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) const; + int allGather(void* sendbuf, int sendcount, MPI_Datatype sendtype, + void* recvbuf, int recvcount, MPI_Datatype recvtype, + MPI_Comm comm) const; + int allToAll(void* sendbuf, int sendcount, MPI_Datatype sendtype, + void* recvbuf, int recvcount, MPI_Datatype recvtype, + MPI_Comm comm) const; + int allToAllV(void* sendbuf, int* sendcounts, int* senddispls, + MPI_Datatype sendtype, void* recvbuf, int* recvcounts, + int* recvdispls, MPI_Datatype recvtype, + MPI_Comm comm) const; + + int reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) const; + int allReduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) const; + }; + + class ParaUMesh + { + public: + ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds); + %extend + { + DataArrayIdType *getCellIdsLyingOnNodes(DataArrayIdType *globalNodeIds, bool fullyIn) const + { + MCAuto ret(self->getCellIdsLyingOnNodes(globalNodeIds,fullyIn)); + return ret.retn(); + } + } + }; +} + /* This object can be used only if MED_ENABLE_FVM is defined*/ #ifdef MED_ENABLE_FVM class NonCoincidentDEC : public DEC