Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ExtraGhostItemsManager.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ExtraGhostItemsManager.cc (C) 2000-2021 */
9/* */
10/* Construction of extra ghost items. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/mesh/ExtraGhostItemsManager.h"
15
17#include "arcane/utils/String.h"
18#include "arcane/utils/ScopedPtr.h"
19#include "arcane/core/IParallelMng.h"
20#include "arcane/core/IParallelExchanger.h"
21#include "arcane/core/ISerializeMessage.h"
22#include "arcane/core/ParallelMngUtils.h"
23
24#include <set>
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29void Arcane::mesh::ExtraGhostItemsManager::
30computeExtraGhostItems()
31{
32 const Integer nb_builder = m_builders.size();
33
34 if (nb_builder == 0)
35 return;
36
37 m_trace_mng->info() << "Compute extra ghost cells";
38
39 for (Integer i = 0; i < nb_builder; ++i) {
40 // Calculation of extraordinary cells to send
41 m_builders[i]->computeExtraItemsToSend();
42 }
43
44 IParallelMng* pm = m_extra_ghost_items_adder->subDomain()->parallelMng();
45
46 auto exchanger{ ParallelMngUtils::createExchangerRef(pm) };
47
48 const Integer nsd = m_extra_ghost_items_adder->subDomain()->nbSubDomain();
49
50 // Construction of items to send // See how to make it compatible with the ExtraGhostBuilder
51 UniqueArray<Arcane::SharedArray<Int32>> item_to_send(nsd);
52
53 // Initialization of the data exchanger
54 for (Integer isd = 0; isd < nsd; ++isd) {
55 for (Integer i = 0; i < nb_builder; ++i) {
56 item_to_send[isd].addRange(m_builders[i]->extraItemsToSend(isd));
57 }
58 if (!item_to_send[isd].empty())
59 exchanger->addSender(isd);
60 }
61
62 exchanger->initializeCommunicationsMessages();
63
64 // Sending items
65 for (Integer i = 0, ns = exchanger->nbSender(); i < ns; ++i) {
66 ISerializeMessage* sm = exchanger->messageToSend(i);
67 const Int32 rank = sm->destination().value();
68 ISerializer* s = sm->serializer();
69 const Arcane::Int32Array& items_to_send_to_rank = item_to_send[rank];
70 m_extra_ghost_items_adder->serializeGhostItems(s, items_to_send_to_rank);
71 }
72 exchanger->processExchange();
73
74 // Receiving cells
75 for (Integer i = 0, ns = exchanger->nbReceiver(); i < ns; ++i) {
76 ISerializeMessage* sm = exchanger->messageToReceive(i);
77 ISerializer* s = sm->serializer();
78 m_extra_ghost_items_adder->addExtraGhostItems(s);
79 }
80 m_extra_ghost_items_adder->updateSynchronizationInfo(); // Collective Operation
81}
82
83/*---------------------------------------------------------------------------*/
84/*---------------------------------------------------------------------------*/
Declarations of types used in Arcane.
Ref< IParallelExchanger > createExchangerRef(IParallelMng *pm)
Returns an interface to transfer messages between ranks.
Int32 Integer
Type representing an integer.
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
Definition UtilsTypes.h:127
std::int32_t Int32
Signed integer type of 32 bits.