14#include "arcane/Timer.h"
16#include "arcane/ItemFamilyCompactInfos.h"
17#include "arcane/IItemFamily.h"
18#include "arcane/IItemFamilyPolicyMng.h"
19#include "arcane/IItemFamilyCompactPolicy.h"
21#include "arcane/mesh/MeshCompacter.h"
22#include "arcane/mesh/DynamicMesh.h"
33MeshCompacter(IMesh* mesh,ITimeStats* stats)
34: TraceAccessor(mesh->traceMng())
37, m_phase(ePhase::Init)
39, m_is_compact_variables_and_groups(true)
41 for( IItemFamily* family : m_mesh->itemFamilies() ){
50MeshCompacter(IItemFamily* family,ITimeStats* stats)
51: TraceAccessor(family->traceMng())
52, m_mesh(family->mesh())
54, m_phase(ePhase::Init)
56, m_is_compact_variables_and_groups(true)
67 for(
const auto& i : m_family_compact_infos_map )
78_addFamily(IItemFamily* family)
81 IItemFamilyCompactPolicy* c = family->policyMng()->compactPolicy();
83 m_item_families.add(family);
92 m_phase = ePhase::BeginCompact;
99_checkPhase(ePhase wanted_phase)
101 if (m_phase!=wanted_phase)
102 ARCANE_FATAL(
"Invalid exchange phase wanted={0} current={1}",
103 (
int)wanted_phase,(
int)m_phase);
112 _checkPhase(ePhase::BeginCompact);
117 Timer::Action ts_action(m_time_stats,
"CompactItemsBegin");
118 for( IItemFamily* family : m_item_families ){
119 auto compact_infos =
new ItemFamilyCompactInfos(
this,family);
120 m_family_compact_infos_map.insert(std::make_pair(family,compact_infos));
122 for( IItemFamily* family : m_item_families ){
123 IItemFamilyCompactPolicy* c = family->policyMng()->compactPolicy();
124 auto iter = m_family_compact_infos_map.find(family);
125 if (iter==m_family_compact_infos_map.end())
126 ARCANE_FATAL(
"Can not find family '{0}'",family->name());
127 c->beginCompact(*iter->second);
131 m_phase = ePhase::CompactVariableAndGroups;
138compactVariablesAndGroups()
140 _checkPhase(ePhase::CompactVariableAndGroups);
144 if (m_is_compact_variables_and_groups){
145 Timer::Action ts_action(m_time_stats,
"CompactVariables");
146 for(
const auto& iter : m_family_compact_infos_map ){
147 const ItemFamilyCompactInfos* compact_infos = iter.second;
148 IItemFamilyCompactPolicy* c = compact_infos->family()->policyMng()->compactPolicy();
149 c->compactVariablesAndGroups(*compact_infos);
153 m_phase = ePhase::UpdateInternalReferences;
160updateInternalReferences()
162 _checkPhase(ePhase::UpdateInternalReferences);
166 Timer::Action ts_action(m_time_stats,
"CompactUpdateInternalReferences");
167 for( IItemFamily* family : m_mesh->itemFamilies() ){
168 IItemFamilyCompactPolicy* c = family->policyMng()->compactPolicy();
170 c->updateInternalReferences(
this);
174 m_phase = ePhase::EndCompact;
183 _checkPhase(ePhase::EndCompact);
187 Timer::Action ts_action(m_time_stats,
"CompactItemFinish");
189 for(
const auto& iter : m_family_compact_infos_map ){
190 ItemFamilyCompactInfos* compact_infos = iter.second;
191 IItemFamilyCompactPolicy* c = compact_infos->family()->policyMng()->compactPolicy();
192 c->endCompact(*compact_infos);
196 m_phase = ePhase::Finalize;
205 _checkPhase(ePhase::Finalize);
209 Timer::Action ts_action(m_time_stats,
"CompactItemFinish");
211 for( IItemFamily* family : m_mesh->itemFamilies() ){
212 IItemFamilyCompactPolicy* c = family->policyMng()->compactPolicy();
214 c->finalizeCompact(
this);
218 m_phase = ePhase::Ended;
227 auto x = m_family_compact_infos_map.find(family);
228 if (x==m_family_compact_infos_map.end())
249 compactVariablesAndGroups();
250 updateInternalReferences();
261 _checkPhase(ePhase::BeginCompact);
269_setCompactVariablesAndGroups(
bool v)
271 _checkPhase(ePhase::BeginCompact);
272 m_is_compact_variables_and_groups = v;
281 return m_item_families;
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Interface d'une famille d'entités.
Informations pour gérer le compactage des entités d'une famille.