Arcane  v3.16.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ItemConnectivityMng.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* ItemConnectivityMng.h (C) 2000-2023 */
9/* */
10/* Gestionnaire des connectivités */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CONNECTIVITYMANAGER_H
13#define ARCANE_CONNECTIVITYMANAGER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18#include "arcane/utils/ITraceMng.h"
19#include "arcane/utils/Array.h"
20
21#include "arcane/IItemConnectivity.h"
22#include "arcane/IItemConnectivityMng.h"
23#include "arcane/IItemConnectivitySynchronizer.h"
24#include "arcane/IIncrementalItemConnectivity.h"
25#include "arcane/IItemFamily.h"
26
27#include <map>
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
42
43class FamilyState
44{
45 public:
46 FamilyState() : m_state(-1) {}
47 FamilyState(const FamilyState&) = default;
48 virtual ~FamilyState() = default;
49
50 public:
66};
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70
71class ConnectivityStateData
72{
73public:
74 ConnectivityStateData() : m_last_family_state(-1), m_last_added_item_index(-1), m_last_removed_item_index(-1) {}
75 ConnectivityStateData(const ConnectivityStateData&) = default;
76 virtual ~ConnectivityStateData() = default;
77
78public :
79 Integer m_last_family_state;
80 Integer m_last_added_item_index;
81 Integer m_last_removed_item_index;
82};
83
84class ConnectivityState
85{
86 public:
87 ConnectivityState(){}
88 ConnectivityState(const ConnectivityState&) = default;
89 virtual ~ConnectivityState() = default;
90
91 public :
92 ConnectivityStateData m_state_with_source_family;
93 ConnectivityStateData m_state_with_target_family;
94};
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
98
99class ARCANE_MESH_EXPORT ItemConnectivityMng
101{
102public:
103
105 ItemConnectivityMng(ITraceMng* trace_mng) : m_trace_mng(trace_mng) {}
106
109 {
110 for (const auto& map_element : m_synchronizers) {
111 if (map_element.second) delete map_element.second;
112 }
113 }
114
115 // Save Connectivity
116 void registerConnectivity(IItemConnectivity* connectivity) override
117 {
118 connectivity->sourceFamily()->addSourceConnectivity(connectivity);
119 connectivity->targetFamily()->addTargetConnectivity(connectivity);
120 // refactoring
121 connectivity->sourceFamily()->setConnectivityMng(this);
122 connectivity->targetFamily()->setConnectivityMng(this);
123 _register(connectivity->name(),connectivity->sourceFamily()->fullName(),connectivity->targetFamily()->fullName());
124 }
125
126 void unregisterConnectivity(IItemConnectivity* connectivity) override
127 {
128 connectivity->sourceFamily()->removeSourceConnectivity(connectivity);
129 connectivity->targetFamily()->removeTargetConnectivity(connectivity);
130 }
131
132 // Save Connectivity
133 void registerConnectivity(IIncrementalItemConnectivity* connectivity) override
134 {
135 //connectivity->sourceFamily()->addSourceConnectivity(connectivity);
136 //connectivity->targetFamily()->addTargetConnectivity(connectivity);
137 // refactoring
138 connectivity->sourceFamily()->setConnectivityMng(this);
139 connectivity->targetFamily()->setConnectivityMng(this);
140 _register(connectivity->name(),connectivity->sourceFamily()->fullName(),connectivity->targetFamily()->fullName());
141 }
142
143 void unregisterConnectivity([[maybe_unused]] IIncrementalItemConnectivity* connectivity) override
144 {
145 //connectivity->sourceFamily()->removeSourceConnectivity(connectivity);
146 //connectivity->targetFamily()->removeTargetConnectivity(connectivity);
147 }
148
149
155 IItemConnectivitySynchronizer* createSynchronizer(IItemConnectivity* connectivity,
156 IItemConnectivityGhostPolicy* connectivity_ghost_policy) override;
157 IItemConnectivitySynchronizer* getSynchronizer(IItemConnectivity* connectivity) override
158 {
159 // TODO handle failure
160 return m_synchronizers[connectivity];
161 }
162
164 void setModifiedItems(IItemFamily* family, Int32ConstArrayView added_items,Int32ConstArrayView removed_items) override;
165
167 void notifyLocalIdChanged(IItemFamily* family, Int32ConstArrayView old_to_new_ids,Integer nb_item) override;
168
170 bool isUpToDate(IItemConnectivity* connectivity) override
171 {
172 return (isUpToDateWithSourceFamily(connectivity) && isUpToDateWithTargetFamily(connectivity));
173 }
175 {
176 return (_lastUpdateSourceFamilyState(connectivity->name()) == _familyState(connectivity->sourceFamily()->fullName()));
177 }
179 {
180 return (_lastUpdateTargetFamilyState(connectivity->name()) == _familyState(connectivity->targetFamily()->fullName()));
181 }
182
184 void setUpToDate(IItemConnectivity* connectivity) override;
185
187 bool isUpToDate(IIncrementalItemConnectivity* connectivity) override
188 {
189 return (isUpToDateWithSourceFamily(connectivity) && isUpToDateWithTargetFamily(connectivity));
190 }
192 {
193 return (_lastUpdateSourceFamilyState(connectivity->name()) == _familyState(connectivity->sourceFamily()->fullName()));
194 }
196 {
197 return (_lastUpdateTargetFamilyState(connectivity->name()) == _familyState(connectivity->targetFamily()->fullName()));
198 }
199
201 void setUpToDate(IIncrementalItemConnectivity* connectivity) override;
202
204 void getSourceFamilyModifiedItems(IItemConnectivity* connectivity, Int32ArrayView& added_items,
205 Int32ArrayView& removed_items) override;
206 void getTargetFamilyModifiedItems(IItemConnectivity* connectivity, Int32ArrayView& added_items,
207 Int32ArrayView& removed_items) override;
208
209
210 void getSourceFamilyModifiedItems(IIncrementalItemConnectivity* connectivity, Int32ArrayView& added_items,
211 Int32ArrayView& removed_items) override;
212 void getTargetFamilyModifiedItems(IIncrementalItemConnectivity* connectivity, Int32ArrayView& added_items,
213 Int32ArrayView& removed_items) override;
214
215 private:
216
217 void _register(const String& connectivity_name,const String& from_family_name, const String& to_family_name);
218 Integer _lastUpdateSourceFamilyState(const String& connectivity_name);
219 Integer _lastUpdateTargetFamilyState(const String& connectivity_name);
220 Integer _familyState(const String& family_name);
221 ConnectivityState& _findConnectivity(const String& connectivity_name);
222 FamilyState& _findFamily(const String& family_full_name);
223 void _getModifiedItems(ConnectivityStateData& connectivity_state, FamilyState& family_state, Int32ArrayView& added_items, Int32ArrayView& removed_items);
224 void _setUpToDate(ConnectivityStateData& connectivity_state, FamilyState& family_state);
225
226 ITraceMng* m_trace_mng;
227 std::map<IItemConnectivity*,IItemConnectivitySynchronizer*> m_synchronizers;
228 typedef std::map<const String,FamilyState> FamilyStateMap;
229 FamilyStateMap m_family_states;
230 typedef std::map<const String,ConnectivityState> ConnectivityStateMap;
231 ConnectivityStateMap m_connectivity_states;
232};
233
234/*---------------------------------------------------------------------------*/
235/*---------------------------------------------------------------------------*/
236
237} // End namespace Arcane
238
239/*---------------------------------------------------------------------------*/
240/*---------------------------------------------------------------------------*/
241
242#endif /* CONNECTIVITYMANAGER_H_ */
Fichier de configuration d'Arcane.
Int32SharedArray m_removed_items
idem
Int32SharedArray m_added_items
Concatenation of all the family changes during the simulation.
IntegerSharedArray m_state_first_removed_item_index
Int32UniqueArray m_current_added_items
Current added items (no history)
IntegerSharedArray m_state_first_added_item_index
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é
virtual String fullName() const =0
Nom complet de la famille (avec celui du maillage)
Interface du gestionnaire de traces.
bool isUpToDateWithSourceFamily(IIncrementalItemConnectivity *connectivity) override
par rapport à la famille source et à la famille target
bool isUpToDateWithSourceFamily(IItemConnectivity *connectivity) override
par rapport à la famille source et à la famille target
bool isUpToDateWithTargetFamily(IIncrementalItemConnectivity *connectivity) override
par rapport à la famille source
void registerConnectivity(IItemConnectivity *connectivity) override
Enregistrement d'une connectivité
ItemConnectivityMng(ITraceMng *trace_mng)
bool isUpToDateWithTargetFamily(IItemConnectivity *connectivity) override
par rapport à la famille source
bool isUpToDate(IItemConnectivity *connectivity) override
Test si la connectivité est à jour par rapport à la famille source et à la famille target.
bool isUpToDate(IIncrementalItemConnectivity *connectivity) override
Test si la connectivité est à jour par rapport à la famille source et à la famille target.
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
SharedArray< Int32 > Int32SharedArray
Tableau dynamique à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:468
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:428
ArrayView< Int32 > Int32ArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:540
SharedArray< Integer > IntegerSharedArray
Tableau dynamique à une dimension d'entiers.
Definition UtilsTypes.h:474