16#include "arcane/mesh/ItemConnectivityMng.h"
17#include "arcane/mesh/ItemConnectivitySynchronizer.h"
30 std::map<IItemConnectivity*, IItemConnectivitySynchronizer*>::iterator ite = m_synchronizers.find(connectivity);
32 if (ite == m_synchronizers.end()){
34 m_synchronizers[connectivity] = synchronizer;
40 m_synchronizers.erase(ite);
41 m_synchronizers[connectivity] = synchronizer;
49void ItemConnectivityMng::
50_register(
const String& connectivity_name,
const String& source_family_name,
const String& target_family_name)
52 std::pair<FamilyStateMap::iterator,bool> source_family_state_insertor = m_family_states.insert(std::make_pair(source_family_name,
FamilyState()));
53 std::pair<FamilyStateMap::iterator,bool> target_family_state_insertor = m_family_states.insert(std::make_pair(target_family_name,
FamilyState()));
54 std::pair<ConnectivityStateMap::iterator,bool> connectivity_state_insertor = m_connectivity_states.insert(std::make_pair(connectivity_name,
ConnectivityState()));
55 FamilyState& source_family_state = source_family_state_insertor.first->second;
56 FamilyState& target_family_state = target_family_state_insertor.first->second;
57 ConnectivityState& connectivity_state = connectivity_state_insertor.first->second;
59 if (connectivity_state_insertor.second){
60 connectivity_state.m_state_with_source_family.m_last_family_state = source_family_state.
m_state;
61 connectivity_state.m_state_with_source_family.m_last_added_item_index = source_family_state.
m_added_items.
size()-1;
62 connectivity_state.m_state_with_source_family.m_last_removed_item_index = source_family_state.
m_removed_items.
size()-1;
63 connectivity_state.m_state_with_target_family.m_last_family_state = target_family_state.
m_state;
64 connectivity_state.m_state_with_target_family.m_last_added_item_index = target_family_state.
m_added_items.
size()-1;
65 connectivity_state.m_state_with_target_family.m_last_removed_item_index = target_family_state.
m_removed_items.
size()-1;
68 m_trace_mng->warning() <<
"Connectivity " << connectivity_name <<
" already registered.";
74void ItemConnectivityMng::
90void ItemConnectivityMng::
95 _getModifiedItems(connectivity_state.m_state_with_source_family,family_state,added_items,removed_items);
101void ItemConnectivityMng::
106 _getModifiedItems(connectivity_state.m_state_with_target_family,family_state,added_items,removed_items);
109void ItemConnectivityMng::
110getSourceFamilyModifiedItems(IIncrementalItemConnectivity* connectivity, Int32ArrayView& added_items, Int32ArrayView& removed_items)
112 ConnectivityState& connectivity_state = _findConnectivity(connectivity->name());
113 FamilyState& family_state = _findFamily(connectivity->sourceFamily()->fullName());
114 _getModifiedItems(connectivity_state.m_state_with_source_family,family_state,added_items,removed_items);
120void ItemConnectivityMng::
121getTargetFamilyModifiedItems(IIncrementalItemConnectivity* connectivity, Int32ArrayView& added_items, Int32ArrayView& removed_items)
123 ConnectivityState& connectivity_state = _findConnectivity(connectivity->name());
124 FamilyState& family_state = _findFamily(connectivity->targetFamily()->fullName());
125 _getModifiedItems(connectivity_state.m_state_with_target_family,family_state,added_items,removed_items);
130void ItemConnectivityMng::
131_getModifiedItems(ConnectivityStateData& connectivity_state, FamilyState& family_state,
132 Int32ArrayView& added_items, Int32ArrayView& removed_items)
134 if (connectivity_state.m_last_family_state == family_state.m_state)
137 Integer first_added_item_index = connectivity_state.m_last_added_item_index +1;
138 Integer nb_added_items = family_state.m_added_items.size()-first_added_item_index;
139 auto unfiltered_added_items = family_state.m_added_items.subView(first_added_item_index,nb_added_items);
141 family_state.m_current_added_items.clear();
142 family_state.m_current_added_items.resize(nb_added_items);
144 std::copy_if(unfiltered_added_items.begin(),unfiltered_added_items.end(),
145 family_state.m_current_added_items.begin(),
146 [&true_size](Int32
const& item_lid){
147 auto do_copy = (item_lid != NULL_ITEM_LOCAL_ID);
148 if (do_copy) ++true_size;
151 family_state.m_current_added_items.resize(true_size);
152 added_items = family_state.m_current_added_items.view();
154 Integer first_removed_item_index = connectivity_state.m_last_removed_item_index +1;
155 Integer nb_removed_items = family_state.m_removed_items.size()-first_removed_item_index;
156 removed_items = family_state.m_removed_items.subView(first_removed_item_index,nb_removed_items);
162void ItemConnectivityMng::
168 _setUpToDate(connectivity_state.m_state_with_source_family,source_family_state);
169 _setUpToDate(connectivity_state.m_state_with_target_family,target_family_state);
172void ItemConnectivityMng::
178 _setUpToDate(connectivity_state.m_state_with_source_family,source_family_state);
179 _setUpToDate(connectivity_state.m_state_with_target_family,target_family_state);
185void ItemConnectivityMng::
188 connectivity_state.m_last_family_state = family_state.
m_state;
189 connectivity_state.m_last_added_item_index = family_state.
m_added_items.
size()-1;
195Integer ItemConnectivityMng::
196_lastUpdateSourceFamilyState(
const String& connectivity_name)
198 return _findConnectivity(connectivity_name).m_state_with_source_family.m_last_family_state;
205_lastUpdateTargetFamilyState(
const String& connectivity_name)
207 return _findConnectivity(connectivity_name).m_state_with_target_family.m_last_family_state;
214_familyState(
const String& family_full_name)
216 return _findFamily(family_full_name).m_state;
222ConnectivityState& ItemConnectivityMng::
223_findConnectivity(
const String& connectivity_name)
225 ConnectivityStateMap::iterator connectivity_state_iterator = m_connectivity_states.find(connectivity_name);
226 if (connectivity_state_iterator == m_connectivity_states.end())
227 throw FatalErrorException(String::format(
228 "Cannot find connectivity {0}. Use registerConnectivity(connectivity) first",connectivity_name));
229 return connectivity_state_iterator->second;
235FamilyState& ItemConnectivityMng::
236_findFamily(
const String& family_full_name)
238 FamilyStateMap::iterator family_state_iterator = m_family_states.find(family_full_name);
239 if (family_state_iterator == m_family_states.end())
240 throw FatalErrorException(String::format(
241 "Cannot find family {0}. Use registerConnectivity(connectivity) first",family_full_name));
242 return family_state_iterator->second;
248void ItemConnectivityMng::
260 if (new_id < nb_item) family_state.
m_added_items[i] = new_id;
Integer size() const
Nombre d'éléments du vecteur.
void clear()
Supprime les éléments du tableau.
void addRange(ConstReferenceType val, Int64 n)
Ajoute n élément de valeur val à la fin du tableau.
Int32SharedArray m_removed_items
idem
Int32SharedArray m_added_items
Concatenation of all the family changes during the simulation.
Interface pour gérer une connectivité incrémentale.
virtual String name() const =0
Nom de la connectivité
virtual IItemFamily * targetFamily() const =0
Famille cible.
virtual IItemFamily * sourceFamily() const =0
Famille source.
Interface pour gérer une connectivité.
virtual IItemFamily * targetFamily() const =0
Famille cible.
virtual IItemFamily * sourceFamily() const =0
Famille source.
virtual const String & name() const =0
Nom de la connectivité
Interface d'une famille d'entités.
virtual String fullName() const =0
Nom complet de la famille (avec celui du maillage)
Chaîne de caractères unicode.
Int32 Integer
Type représentant un entier.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
ArrayView< Int32 > Int32ArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.