14#include "arcane/utils/FatalErrorException.h"
15#include "arcane/utils/TraceInfo.h"
16#include "arcane/utils/PlatformUtils.h"
17#include "arcane/utils/ValueConvert.h"
19#include "arcane/IParallelMng.h"
20#include "arcane/Timer.h"
21#include "arcane/IItemFamilyPolicyMng.h"
22#include "arcane/IItemFamilyExchanger.h"
23#include "arcane/IParticleFamily.h"
25#include "arcane/mesh/MeshExchanger.h"
26#include "arcane/mesh/DynamicMesh.h"
27#include "arcane/mesh/MeshExchange.h"
28#include "arcane/mesh/DynamicMeshIncrementalBuilder.h"
40MeshExchanger(DynamicMesh* mesh,ITimeStats* stats)
41: TraceAccessor(mesh->traceMng())
44, m_phase(ePhase::Init)
48 String max_pending_str = platform::getEnvironmentVariable(
"ARCANE_MESH_EXCHANGE_MAX_PENDING_MESSAGE");
49 if (!max_pending_str.null()){
50 Int32 max_pending = 0;
51 if (!builtInGetValue(max_pending,max_pending_str))
52 m_exchanger_option.setMaxPendingMessage(max_pending);
55 String use_collective_str = platform::getEnvironmentVariable(
"ARCANE_MESH_EXCHANGE_USE_COLLECTIVE");
56 if (use_collective_str==
"1" || use_collective_str==
"TRUE")
57 m_exchanger_option.setExchangeMode(ParallelExchangerOptions::EM_Collective);
59 m_exchanger_option.setVerbosityLevel(1);
68 for( IItemFamilyExchanger* exchanger : m_family_exchangers )
81 if ( !m_mesh->itemFamilyNetwork() || !IItemFamilyNetwork::plug_serializer )
87 UniqueArray<IItemFamily*> sorted_families;
89 sorted_families.reserve(families.count());
90 sorted_families.add(m_mesh->cellFamily());
91 sorted_families.add(m_mesh->faceFamily());
92 sorted_families.add(m_mesh->edgeFamily());
93 sorted_families.add(m_mesh->nodeFamily());
94 for( IItemFamily* family : families )
96 IParticleFamily* particle_family = family->toParticleFamily();
98 sorted_families.add(family);
106 std::map<IItemFamily*,IItemFamilyExchanger*> family_exchanger_map;
107 for( IItemFamily* family : sorted_families ){
108 _addItemFamilyExchanger(family);
113 if(m_mesh->useMeshItemFamilyDependencies())
115 _buildWithItemFamilyNetwork();
119 std::set<String> family_set ;
120 UniqueArray<IItemFamily*> sorted_families;
122 sorted_families.reserve(families.count());
123 sorted_families.add(m_mesh->cellFamily());
124 family_set.insert(m_mesh->cellFamily()->name()) ;
125 sorted_families.add(m_mesh->faceFamily());
126 family_set.insert(m_mesh->faceFamily()->name()) ;
127 sorted_families.add(m_mesh->edgeFamily());
128 family_set.insert(m_mesh->edgeFamily()->name()) ;
129 sorted_families.add(m_mesh->nodeFamily());
130 family_set.insert(m_mesh->nodeFamily()->name()) ;
131 for( IItemFamily* family : families )
133 IParticleFamily* particle_family = family->toParticleFamily();
136 sorted_families.add(family);
137 family_set.insert(family->name()) ;
141 for(
auto family : m_mesh->itemFamilyNetwork()->getFamilies(IItemFamilyNetwork::InverseTopologicalOrder) )
143 auto value = family_set.insert(family->name()) ;
146 sorted_families.add(family) ;
155 std::map<IItemFamily*,IItemFamilyExchanger*> family_exchanger_map;
156 for( IItemFamily* family : sorted_families ){
157 _addItemFamilyExchanger(family);
161 m_phase = ePhase::ComputeInfos;
168_buildWithItemFamilyNetwork()
170 m_mesh->itemFamilyNetwork()->schedule([&](IItemFamily* family) {
171 _addItemFamilyExchanger(family);
172 }, IItemFamilyNetwork::InverseTopologicalOrder);
174 for( IItemFamily* family : m_mesh->itemFamilies() ){
175 IParticleFamily* particle_family = family->toParticleFamily();
177 _addItemFamilyExchanger(family);
185_addItemFamilyExchanger(IItemFamily* family)
187 IItemFamilyExchanger* exchanger = family->policyMng()->createExchanger();
188 m_family_exchangers.add(exchanger);
189 m_family_exchanger_map.insert(std::make_pair(family,exchanger));
190 exchanger->setParallelExchangerOption(m_exchanger_option);
197_checkPhase(ePhase wanted_phase)
199 if (m_phase!=wanted_phase)
200 ARCANE_FATAL(
"Invalid exchange phase wanted={0} current={1}",
201 (
int)wanted_phase,(
int)m_phase);
208computeExchangeInfos()
210 _checkPhase(ePhase::ComputeInfos);
215 info() <<
"MeshExchange begin date=" << platform::getCurrentDateTime();
230 pwarning() <<
"No load balance is performed";
240 info() <<
"ComputeExchange family=" << family->
name()
241 <<
" date=" << platform::getCurrentDateTime();
250 exchanger->computeExchangeItems();
252 exchanger->setExchangeItems(
mesh_exchange.getItemsToSend(family));
253 exchanger->computeExchangeInfos();
266 Int32 rank = m_mesh->meshPartInfo().partRank();
278 m_phase = ePhase::ProcessExchange;
289 _checkPhase(ePhase::ProcessExchange);
291 info() <<
"ExchangeItems date=" << platform::getCurrentDateTime()
292 <<
" MemUsed=" << platform::getMemoryUsed();
299 e->processExchange();
302 m_phase = ePhase::RemoveItems;
311 _checkPhase(ePhase::RemoveItems);
323 info() <<
"RemoveItems date=" << platform::getCurrentDateTime();
329 exchanger->removeSentItems();
333 m_mesh->incrementalBuilder()->removeNeedRemoveMarkedItems();
335 m_phase = ePhase::AllocateItems;
342allocateReceivedItems()
344 _checkPhase(ePhase::AllocateItems);
346 info() <<
"AllocItems date=" << platform::getCurrentDateTime();
352 e->readAndAllocItems();
356 if (m_mesh->itemFamilyNetwork() && m_mesh->itemFamilyNetwork()->isActivated())
358 auto family_set = m_mesh->itemFamilyNetwork()->getFamilies();
360 m_family_exchanger_map[family]->readAndAllocItemRelations();
366 e->readAndAllocSubMeshItems();
374 e->itemFamily()->notifyItemsOwnerChanged();
377 m_phase = ePhase::UpdateItemGroups;
386 _checkPhase(ePhase::UpdateItemGroups);
388 info() <<
"ReadGroups date=" << platform::getCurrentDateTime();
393 m_phase = ePhase::UpdateVariables;
402 _checkPhase(ePhase::UpdateVariables);
404 info() <<
"ReadVariables date=" << platform::getCurrentDateTime();
411 m_phase = ePhase::Finalize;
420 _checkPhase(ePhase::Finalize);
430 e->finalizeExchange();
432 m_phase = ePhase::Ended;
441 auto x = m_family_exchanger_map.find(family);
442 if (x==m_family_exchanger_map.end())
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Échange des entités et leurs caractéristiques pour une famille donnée.
Interface d'une famille d'entités.
virtual IParticleFamily * toParticleFamily()=0
Retourne l'interface de la famille de particule de cette famille.
virtual ItemGroup allItems() const =0
Groupe de toutes les entités.
virtual String name() const =0
Nom de la famille.
virtual void notifyItemsOwnerChanged()=0
Notifie que les entités propres au sous-domaine de la famille ont été modifiées.
virtual VariableItemInt32 & itemsNewOwner()=0
Variable contenant le numéro du nouveau sous-domaine propriétaire de l'entité.
Interface d'une famille de particules.
Classe de base d'un élément de maillage.
impl::MutableItemBase mutableItemBase() const
Partie interne modifiable de l'entité.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
void setOwner(Integer suid, Int32 current_sub_domain)
Positionne le numéro du sous-domaine propriétaire de l'entité.
Postionne le nom de l'action en cours d'exécution.
Echange des entités de maillages entre entre sous-domaines.
Collection< IItemFamily * > IItemFamilyCollection
Collection de familles d'entités.