From: Anthony Geay Date: Fri, 24 Apr 2020 09:25:23 +0000 (+0200) Subject: WIP X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ff07df0067baceeedf2e8156eb21031fffdbbe8e;p=tools%2Fmedcoupling.git WIP --- diff --git a/src/MEDCoupling/MCAuto.hxx b/src/MEDCoupling/MCAuto.hxx index 5b29608b5..7e92f0653 100644 --- a/src/MEDCoupling/MCAuto.hxx +++ b/src/MEDCoupling/MCAuto.hxx @@ -81,6 +81,16 @@ namespace MEDCoupling return ret; } + template + std::vector> FromVecConstToVecAuto(const std::vector& inputVec) + { + std::size_t size(inputVec.size()); + std::vector> ret(size); + typename std::vector>::iterator itArrays(ret.begin()); + std::for_each(inputVec.begin(),inputVec.end(),[&itArrays](const T *elt) { (*itArrays).takeRef(const_cast(elt)); itArrays++; }); + return ret; + } + template typename MEDCoupling::MCAuto DynamicCast(typename MEDCoupling::MCAuto& autoSubPtr) throw() { diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 778411e29..972a04eb4 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -18,8 +18,7 @@ // // Author : Anthony Geay (CEA/DEN) -#ifndef __PARAMEDMEM_MEDCOUPLINGUMESH_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGUMESH_HXX__ +#pragma once #include "MEDCoupling.hxx" #include "MEDCouplingPointSet.hxx" @@ -442,6 +441,31 @@ namespace MEDCoupling mcIdType _conn_lgth; static const int NOTICABLE_FIRST_VAL=-7; }; + + template + class UMeshGenIterator : public std::iterator< std::input_iterator_tag, const TOUT *, mcIdType, const TOUT **, const TOUT *> + { + std::size_t _num = 0; + std::vector *_data = nullptr; + using my_reference = typename std::iterator< std::input_iterator_tag, const TOUT *, mcIdType, const TOUT **, const TOUT *>::reference; + public: + explicit UMeshGenIterator(std::size_t num , std::vector *data) : _num(num),_data(data) {} + UMeshGenIterator& operator++() { ++_num; return *this; } + bool operator==(const UMeshGenIterator& other) const { return _num == other._num; } + bool operator!=(const UMeshGenIterator& other) const { return !(*this == other); } + my_reference operator*() const { T tt; return tt((*_data)[_num]); } + }; + + struct UMeshIndexConnectivityFunctor { const DataArrayIdType *operator()(const MEDCouplingUMesh *um) { return um->getNodalConnectivity(); } }; + + using UMeshConnectivityIndexIterator = UMeshGenIterator; + + struct UMeshConnectivityFunctor { const DataArrayIdType *operator()(const MEDCouplingUMesh *um) { return um->getNodalConnectivity(); } }; + + using UMeshConnectivityIterator = UMeshGenIterator; + + struct UMeshCoordsFunctor { const DataArrayDouble *operator()(const MEDCouplingUMesh *um) { return um->getCoords(); } }; + + using UMeshCoordsIterator = UMeshGenIterator; } -#endif diff --git a/src/ParaMEDMEM/ParaUMesh.cxx b/src/ParaMEDMEM/ParaUMesh.cxx index 812a7e4d8..2cb940dab 100644 --- a/src/ParaMEDMEM/ParaUMesh.cxx +++ b/src/ParaMEDMEM/ParaUMesh.cxx @@ -152,5 +152,27 @@ MCAuto ParaUMesh::redistributeCells(const DataArrayIdType *globalCell globalCellIdsToBeSent[curRk] = globalCellIdsCaptured; globalNodeIdsToBeSent[curRk] = globalNodeIdsPart; } - // Receive + // Receive + std::vector< MCAuto > globalCellIdsReceived,globalNodeIdsReceived; + ci.allToAllArrays(comm,globalCellIdsToBeSent,globalCellIdsReceived); + ci.allToAllArrays(comm,globalNodeIdsToBeSent,globalNodeIdsReceived); + //now exchange the 3 arrays for the umesh : connectivity, connectivityindex and coordinates + std::vector meshPartsToBeSent2(FromVecAutoToVecOfConst(meshPartsToBeSent)); + //connectivityindex + std::vector< MCAuto > connectivityIndexReceived,connectivityReceived; + { + std::vector connectivityIndexToBeSent(UMeshConnectivityIndexIterator(0,&meshPartsToBeSent2),UMeshConnectivityIndexIterator(meshPartsToBeSent2.size(),&meshPartsToBeSent2)); + ci.allToAllArrays(comm,FromVecConstToVecAuto(connectivityIndexToBeSent),connectivityIndexReceived); + } + //connectivity + { + std::vector connectivityToBeSent(UMeshConnectivityIterator(0,&meshPartsToBeSent2),UMeshConnectivityIterator(meshPartsToBeSent2.size(),&meshPartsToBeSent2)); + ci.allToAllArrays(comm,FromVecConstToVecAuto(connectivityToBeSent),connectivityReceived); + } + //coordinates + std::vector< MCAuto > coordsReceived; + { + std::vector coordsToBeSent(UMeshCoordsIterator(0,&meshPartsToBeSent2),UMeshCoordsIterator(meshPartsToBeSent2.size(),&meshPartsToBeSent2)); + FromVecConstToVecAuto(coordsToBeSent); + } }