176#if BITPIT_ENABLE_MPI==1
178 size_t exchangeDataSize =
sizeof(consecutiveId);
179 std::unique_ptr<DataCommunicator> dataCommunicator;
187 const int rank = entry.first;
188 const auto &list = entry.second;
190 dataCommunicator->setRecv(rank, list.size() * exchangeDataSize);
191 dataCommunicator->startRecv(rank);
196#if BITPIT_ENABLE_MPI==1
201 MPI_Allgather(&nLocalInternalCells, 1, MPI_LONG, m_nGlobalInternalCells.data(), 1, MPI_LONG, m_patch->
getCommunicator());
203 m_nGlobalInternalCells.resize(1);
209 m_cellLocalToConsecutiveMap.reserve(m_patch->
getCellCount());
216 std::size_t index = 0;
219 long id = itr.getId();
222 nativeIds[index++] = std::make_pair(nativeId,
id);
225 auto nativeIdsBegin = nativeIds.begin();
226 auto nativeIdsEnd = nativeIds.end();
231 [](
const std::pair<long, long> &x,
const std::pair<long, long> &y) ->
bool
233 return x.first < y.first;
237#if BITPIT_ENABLE_MPI==1
240 m_cellConsecutiveOffset = 0;
243 consecutiveId = m_cellConsecutiveOffset;
244 for (
auto itr = nativeIdsBegin; itr != nativeIdsEnd; ++itr) {
245 m_cellLocalToConsecutiveMap.insert({itr->second, consecutiveId++});
249#if BITPIT_ENABLE_MPI==1
254 const int rank = entry.first;
255 auto &list = entry.second;
257 dataCommunicator->setSend(rank, list.size() * exchangeDataSize);
258 SendBuffer &buffer = dataCommunicator->getSendBuffer(rank);
259 for (
long id : list) {
260 buffer << m_cellLocalToConsecutiveMap.at(
id);
262 dataCommunicator->startSend(rank);
266 int nCompletedRecvs = 0;
267 while (nCompletedRecvs < dataCommunicator->getRecvCount()) {
268 int rank = dataCommunicator->waitAnyRecv();
271 RecvBuffer &buffer = dataCommunicator->getRecvBuffer(rank);
272 for (
long id : list) {
273 buffer >> consecutiveId;
274 m_cellLocalToConsecutiveMap.insert({id, consecutiveId});
281 dataCommunicator->waitAllSends();