14#include "arcane/utils/ScopedPtr.h"
15#include "arcane/utils/CheckedConvert.h"
17#include "arcane/IExtraGhostCellsBuilder.h"
18#include "arcane/IParallelExchanger.h"
19#include "arcane/IParallelMng.h"
20#include "arcane/ISerializeMessage.h"
21#include "arcane/ParallelMngUtils.h"
23#include "arcane/mesh/ExtraGhostCellsBuilder.h"
24#include "arcane/mesh/DynamicMesh.h"
35ExtraGhostCellsBuilder::
36ExtraGhostCellsBuilder(DynamicMesh* mesh)
37: TraceAccessor(mesh->traceMng())
45void ExtraGhostCellsBuilder::
46addExtraGhostCellsBuilder(IExtraGhostCellsBuilder* builder)
48 if (m_builders.contains(builder))
49 ARCANE_FATAL(
"Instance {0} is already registered",builder);
50 m_builders.add(builder);
56void ExtraGhostCellsBuilder::
57removeExtraGhostCellsBuilder(IExtraGhostCellsBuilder* builder)
59 auto iter_begin = m_builders.begin();
60 auto iter_end = m_builders.end();
61 auto x = std::find(iter_begin,iter_end,builder);
64 m_builders.remove(x - iter_begin);
70bool ExtraGhostCellsBuilder::
73 return !m_builders.empty();
79void ExtraGhostCellsBuilder::
80computeExtraGhostCells()
82 if (m_builders.empty())
85 info() <<
"Compute extra ghost cells";
87 for( IExtraGhostCellsBuilder* v : m_builders ){
89 v->computeExtraCellsToSend();
92 IParallelMng* pm = m_mesh->parallelMng();
94 auto exchanger { ParallelMngUtils::createExchangerRef(pm) };
99 UniqueArray<std::set<Integer> > to_sends(nsd);
102 for(Integer isd=0;isd<nsd;++isd) {
103 std::set<Integer>& cell_set = to_sends[isd];
104 for( IExtraGhostCellsBuilder* builder : m_builders ){
107 for(Integer j=0, size=extra_cells.size(); j<size; ++j)
108 cell_set.insert(extra_cells[j]);
110 if (!cell_set.empty())
111 exchanger->addSender(isd);
113 exchanger->initializeCommunicationsMessages();
116 for (Integer i=0, ns=exchanger->nbSender(); i<ns; ++i) {
117 ISerializeMessage* sm = exchanger->messageToSend(i);
118 const Int32 rank = sm->destination().value();
119 ISerializer* s = sm->serializer();
120 const std::set<Integer>& cell_set = to_sends[rank];
122 std::copy(std::begin(cell_set),std::end(cell_set),std::begin(items_to_send));
123 m_mesh->serializeCells(s, items_to_send);
125 exchanger->processExchange();
128 for( Integer i=0, ns=exchanger->nbReceiver(); i<ns; ++i ) {
129 ISerializeMessage* sm = exchanger->messageToReceive(i);
130 ISerializer* s = sm->serializer();
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
virtual Int32 commSize() const =0
Nombre d'instance dans le communicateur.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.