Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
IIndexManager.h
1#pragma once
2
3#include <memory> // for std::shared_ptr.
4#include <vector>
5
6#include <alien/utils/Precomp.h>
7
8/*---------------------------------------------------------------------------*/
9/*---------------------------------------------------------------------------*/
10
11namespace Alien
12{
13
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17/*---------------------------------------------------------------------------*/
18/*---------------------------------------------------------------------------*/
19
29{
30 public:
33 {
34 public:
35 class Item
36 {
37 public:
38 Item(Arccore::Int64 uniqueId, Arccore::Integer owner)
39 : m_unique_id(uniqueId)
40 , m_owner(owner)
41 {}
42
43 public:
44 Arccore::Int64 uniqueId() const { return m_unique_id; }
45 Arccore::Integer owner() const { return m_owner; }
46
47 private:
48 Arccore::Int64 m_unique_id;
49 Arccore::Integer m_owner;
50 };
51
52 public:
53 virtual ~IAbstractFamily() = default;
54
55 public:
57 virtual IAbstractFamily* clone() const = 0;
58
59 public:
61 virtual Arccore::Int32 maxLocalId() const = 0;
63 virtual void uniqueIdToLocalId(Arccore::ArrayView<Arccore::Int32> localIds,
64 Arccore::ConstArrayView<Arccore::Int64> uniqueIds) const = 0;
66 virtual Item item(Arccore::Int32 localId) const = 0;
69 virtual Arccore::SharedArray<Arccore::Integer> owners(
70 Arccore::ConstArrayView<Arccore::Int32> localIds) const = 0;
72 virtual Arccore::SharedArray<Arccore::Int64> uids(
73 Arccore::ConstArrayView<Arccore::Int32> localIds) const = 0;
75 virtual Arccore::SharedArray<Arccore::Int32> allLocalIds() const = 0;
76 };
77
78 protected:
81 {
82 public:
84 virtual ~EntryImpl() = default;
86 virtual Arccore::ConstArrayView<Arccore::Integer> getOwnIndexes() const = 0;
88 virtual Arccore::ConstArrayView<Arccore::Integer> getAllIndexes() const = 0;
90 virtual Arccore::ConstArrayView<Arccore::Integer> getOwnLocalIds() const = 0;
92 virtual Arccore::ConstArrayView<Arccore::Integer> getAllLocalIds() const = 0;
94 virtual Arccore::String getName() const = 0;
96 virtual Arccore::Integer getKind() const = 0;
98 virtual const IAbstractFamily& getFamily() const = 0;
100 virtual void addTag(
101 const Arccore::String& tagname, const Arccore::String& tagvalue) = 0;
103 virtual void removeTag(const Arccore::String& tagname) = 0;
105 virtual bool hasTag(const Arccore::String& tagname) = 0;
107 virtual Arccore::String tagValue(const Arccore::String& tagname) = 0;
109 virtual IIndexManager* manager() const = 0;
110 };
111
112 public:
114
117 class Entry
118 {
119 protected:
122
123 public:
126 : m_impl(nullptr)
127 {}
128
130 Entry(const Entry& en) = default;
131
133 explicit Entry(EntryImpl* impl)
134 : m_impl(impl)
135 {}
136
139 {
140 if (this != &en)
141 m_impl = en.m_impl;
142 return *this;
143 }
144
146 EntryImpl* internal() const { return m_impl; }
147
149 bool null() const { return m_impl == nullptr; }
150
151 void nullify() { m_impl = nullptr; }
152
154 Arccore::ConstArrayView<Arccore::Integer> getOwnIndexes() const
155 {
156 return m_impl->getOwnIndexes();
157 }
158
160 Arccore::ConstArrayView<Arccore::Integer> getAllIndexes() const
161 {
162 return m_impl->getAllIndexes();
163 }
164
166 Arccore::ConstArrayView<Arccore::Integer> getOwnLocalIds() const
167 {
168 return m_impl->getOwnLocalIds();
169 }
170
172 Arccore::ConstArrayView<Arccore::Integer> getAllLocalIds() const
173 {
174 return m_impl->getAllLocalIds();
175 }
176
178 Arccore::String getName() const { return m_impl->getName(); }
179
181 Arccore::Integer getKind() const { return m_impl->getKind(); }
182
184 const IAbstractFamily& getFamily() const { return m_impl->getFamily(); }
185
187
188 void addTag(const Arccore::String& tagname, const Arccore::String& tagvalue)
189 {
190 return m_impl->addTag(tagname, tagvalue);
191 }
192
194 void removeTag(const Arccore::String& tagname) { return m_impl->removeTag(tagname); }
195
197 bool hasTag(const Arccore::String& tagname) { return m_impl->hasTag(tagname); }
198
200 Arccore::String tagValue(const Arccore::String& tagname)
201 {
202 return m_impl->tagValue(tagname);
203 }
204
205
207 IIndexManager* manager() const { return m_impl->manager(); }
208 };
209
211 class EntryEnumeratorImpl
212 {
213 public:
214 EntryEnumeratorImpl() = default;
215 virtual ~EntryEnumeratorImpl() = default;
216 virtual void moveNext() = 0;
217 virtual bool hasNext() const = 0;
218 virtual EntryImpl* get() const = 0;
219 };
220
222
224 {
225 protected:
226 std::shared_ptr<EntryEnumeratorImpl> m_impl;
227
228 public:
230 EntryEnumerator(const EntryEnumerator& e) = default;
231
233 explicit EntryEnumerator(IIndexManager const* manager)
234 : m_impl(manager->enumerateEntry().m_impl)
235 {}
236
238 : m_impl(impl)
239 {}
240
241 void operator++() { m_impl->moveNext(); }
243 bool hasNext() const { return m_impl->hasNext(); }
245 Entry operator*() const { return Entry(m_impl->get()); }
247 EntryImpl* operator->() const { return m_impl->get(); }
249 Arccore::Integer count() const
250 {
251 Arccore::Integer my_size = 0;
252 for (EntryEnumerator i = *this; i.hasNext(); ++i)
253 ++my_size;
254 return my_size;
255 }
256 bool null() { return m_impl == nullptr; }
257 };
258
259 public:
261 IIndexManager() = default;
262
264 virtual ~IIndexManager() = default;
265
267 virtual bool isPrepared() const = 0;
268
270
271 virtual void init() = 0;
272
274 virtual void prepare() = 0;
275
277 virtual void setTraceMng(Arccore::ITraceMng* traceMng) = 0;
278
280
281 virtual void stats(Arccore::Integer& globalSize, Arccore::Integer& minLocalIndex,
282 Arccore::Integer& localSize) const = 0;
283
285
286 virtual Arccore::Integer globalSize() const = 0;
287
289
290 virtual Arccore::Integer minLocalIndex() const = 0;
291
293
294 virtual Arccore::Integer localSize() const = 0;
295
297 virtual EntryEnumerator enumerateEntry() const = 0;
298
300 virtual Entry getEntry(const Arccore::String& name) const = 0;
301
302 typedef Entry ScalarIndexSet;
303 typedef Arccore::UniqueArray<ScalarIndexSet> VectorIndexSet;
304
306 // virtual ScalarIndexSet buildScalarIndexSet(const String name,Arcane::IItemFamily *
307 // item_family) = 0;
308 // virtual void defineIndex(ScalarIndexSet& set , const Arcane::ItemGroup & itemGroup)
309 // =
310 // 0;
311 // virtual ScalarIndexSet buildScalarIndexSet(const String name, const
312 // Arcane::ItemGroup
313 // & itemGroup) = 0;
314
316 virtual ScalarIndexSet buildScalarIndexSet(const Arccore::String& name,
317 Arccore::ConstArrayView<Arccore::Integer> localIds,
318 const IAbstractFamily& family) = 0;
319
322 virtual ScalarIndexSet buildScalarIndexSet(
323 const Arccore::String& name, const IAbstractFamily& family) = 0;
324
326
327 // virtual VectorIndexSet buildVectorIndexSet(const String name, const
328 // Arcane::ItemGroup
329 // & itemGroup, const Integer n) = 0;
331
332 virtual VectorIndexSet buildVectorIndexSet(const Arccore::String& name,
333 Arccore::ConstArrayView<Arccore::Integer> localIds,
334 const IAbstractFamily& family,
335 Arccore::Integer n) = 0;
336
339
340 virtual VectorIndexSet buildVectorIndexSet(
341 const Arccore::String& name, const IAbstractFamily& family, Arccore::Integer n) = 0;
342
344
345 // virtual void removeIndex(const ScalarIndexSet & entry, const Arcane::ItemGroup &
346 // itemGroup) = 0;
347
348 // virtual Integer getIndex(const Entry & entry, const Item & item) const = 0 ;
349
351 // virtual void getIndex(const ScalarIndexSet & entry, const Arcane::ItemVectorView &
352 // items, ArrayView<Integer> indexes) const = 0;
353
355 virtual Arccore::UniqueArray<Arccore::Integer> getIndexes(
356 const ScalarIndexSet& entry) const = 0;
357
359 virtual Arccore::UniqueArray2<Arccore::Integer> getIndexes(
360 const VectorIndexSet& entry) const = 0;
361
363 virtual Alien::IMessagePassingMng* parallelMng() const = 0;
364
367 virtual void setMaxNullIndexOpt(bool flag) = 0;
368
370 virtual Arccore::Integer nullIndex() const = 0;
371
372 public:
374
378 virtual void keepAlive(const IAbstractFamily* family) = 0;
379};
380
381/*---------------------------------------------------------------------------*/
382/*---------------------------------------------------------------------------*/
383
384} // namespace Alien
385
386/*---------------------------------------------------------------------------*/
387/*---------------------------------------------------------------------------*/
Interface d'implementation de EntryEnumerator.
Classe d'énumération des Entry connues.
Arccore::Integer count() const
Nombre d'élément dans l'énumérateur.
EntryEnumerator(EntryEnumeratorImpl *impl)
Constructeur par implémentation.
void operator++()
Avance l'énumérateur.
EntryEnumerator(const EntryEnumerator &e)=default
Constructeur par copie.
Entry operator*() const
Déréférencement.
EntryEnumerator(IIndexManager const *manager)
Constructeur par consultation de l'IndexManager.
bool hasNext() const
Teste l'existence d'un élément suivant.
EntryImpl * operator->() const
Déréférencement indirect.
Interface d'implémentation de Entry.
virtual IIndexManager * manager() const =0
Référentiel du manager associé
virtual ~EntryImpl()=default
Destructeur.
virtual Arccore::ConstArrayView< Arccore::Integer > getAllIndexes() const =0
Retourne la liste des Index de l'Entry (own + ghost).
virtual Arccore::String tagValue(const Arccore::String &tagname)=0
Lecture d'un tag.
virtual void removeTag(const Arccore::String &tagname)=0
Suppression d'un tag.
virtual Arccore::ConstArrayView< Arccore::Integer > getOwnLocalIds() const =0
Retourne la liste des Items de l'Entry.
virtual void addTag(const Arccore::String &tagname, const Arccore::String &tagvalue)=0
Ajout d'un tag.
virtual Arccore::ConstArrayView< Arccore::Integer > getAllLocalIds() const =0
Retourne la liste des Items de l'Entry (own + ghost).
virtual bool hasTag(const Arccore::String &tagname)=0
Test d'existance d'un tag.
virtual Arccore::String getName() const =0
Retourne le nom de l'entrée.
virtual Arccore::ConstArrayView< Arccore::Integer > getOwnIndexes() const =0
Retourne la liste des Index de l'Entry.
virtual Arccore::Integer getKind() const =0
Retourne le type de support de l'Entry.
virtual const IAbstractFamily & getFamily() const =0
Retourne la famille abstraite de l'Entry.
Classe de représentation des Entry.
bool null() const
Indique si l'entrée est définie.
EntryImpl * internal() const
Accès interne à l'implementation.
Arccore::ConstArrayView< Arccore::Integer > getOwnIndexes() const
Ensemble des indices 'own' gérés par cette entrée.
Entry()
Constructeur par défaut.
IIndexManager * manager() const
Référentiel du manager associé
Entry(const Entry &en)=default
Constructeur par copie.
const IAbstractFamily & getFamily() const
Retourne la famille abstraite de l'Entry.
Arccore::Integer getKind() const
Support de l'entrée (en terme d'item).
Arccore::ConstArrayView< Arccore::Integer > getAllLocalIds() const
Ensemble des items 'own + ghost' gérés par cette entrée.
Arccore::String tagValue(const Arccore::String &tagname)
Acces en lecture à un tag.
Entry(EntryImpl *impl)
Constructeur.
bool hasTag(const Arccore::String &tagname)
Test d'existance d'un tag.
EntryImpl * m_impl
Implémentation de ce type d'entrée.
void addTag(const Arccore::String &tagname, const Arccore::String &tagvalue)
Ajout d'un tag.
Arccore::ConstArrayView< Arccore::Integer > getOwnLocalIds() const
Ensemble des items 'own' gérés par cette entrée.
void removeTag(const Arccore::String &tagname)
Suppression d'un tag.
Arccore::String getName() const
Nom de l'entrée.
Entry & operator=(const Entry &en)
Opérateur de copie.
Arccore::ConstArrayView< Arccore::Integer > getAllIndexes() const
Ensemble des indices 'own + ghost' gérés par cette entrée (.
Interface des familles abstraites pour l'indexation de items.
virtual Arccore::SharedArray< Arccore::Int64 > uids(Arccore::ConstArrayView< Arccore::Int32 > localIds) const =0
Retourne l'ensemble des uniqueIds d'un ensemble d'item décrits par leur localIds.
virtual IAbstractFamily * clone() const =0
Construit un clone de cet objet.
virtual Arccore::Int32 maxLocalId() const =0
Identifiant maximal des localIds pour cette famille.
virtual void uniqueIdToLocalId(Arccore::ArrayView< Arccore::Int32 > localIds, Arccore::ConstArrayView< Arccore::Int64 > uniqueIds) const =0
Convertit des uniqueIds en localIds. Erreur fatale si un item n'est pas retrouvé
virtual Item item(Arccore::Int32 localId) const =0
Retourne un objet Item à partir de son localId.
virtual Arccore::SharedArray< Arccore::Integer > owners(Arccore::ConstArrayView< Arccore::Int32 > localIds) const =0
virtual Arccore::SharedArray< Arccore::Int32 > allLocalIds() const =0
Retourne l'ensemble des identifiants locaux de la famille.
virtual VectorIndexSet buildVectorIndexSet(const Arccore::String &name, const IAbstractFamily &family, Arccore::Integer n)=0
virtual void setTraceMng(Arccore::ITraceMng *traceMng)=0
Définit le gestionnaire de trace.
virtual ScalarIndexSet buildScalarIndexSet(const Arccore::String &name, const IAbstractFamily &family)=0
virtual Arccore::Integer localSize() const =0
Retourne l'indice minimum local.
virtual Arccore::Integer globalSize() const =0
Retourne la taille globale.
virtual void keepAlive(const IAbstractFamily *family)=0
Permet de gérer la mort d'une famille associée à l'index-manager.
virtual Entry getEntry(const Arccore::String &name) const =0
Retourne l'entrée associée à un nom.
virtual VectorIndexSet buildVectorIndexSet(const Arccore::String &name, Arccore::ConstArrayView< Arccore::Integer > localIds, const IAbstractFamily &family, Arccore::Integer n)=0
Construit une nouvelle entrée vectorielle sur des items du maillage.
virtual void init()=0
Initialisation les structures.
virtual void prepare()=0
Préparation : fixe l'indexation (fin des définitions).
virtual Arccore::UniqueArray< Arccore::Integer > getIndexes(const ScalarIndexSet &entry) const =0
Demande de dé-indexation d'une partie d'une entrée.
virtual bool isPrepared() const =0
Indique si la phase de préparation est achevée.
virtual Arccore::Integer minLocalIndex() const =0
Retourne l'indice minimum local.
virtual Arccore::UniqueArray2< Arccore::Integer > getIndexes(const VectorIndexSet &entry) const =0
Fournit une table de translation indexé par les items.
virtual Alien::IMessagePassingMng * parallelMng() const =0
Donne le gestionnaire parallèle ayant servi à l'indexation.
virtual void stats(Arccore::Integer &globalSize, Arccore::Integer &minLocalIndex, Arccore::Integer &localSize) const =0
Statistiques d'indexation.
virtual void setMaxNullIndexOpt(bool flag)=0
virtual ~IIndexManager()=default
Destructeur.
virtual ScalarIndexSet buildScalarIndexSet(const Arccore::String &name, Arccore::ConstArrayView< Arccore::Integer > localIds, const IAbstractFamily &family)=0
Construit une nouvelle entrée scalaire sur des items du maillage.
virtual Arccore::Integer nullIndex() const =0
return value of null index
virtual EntryEnumerator enumerateEntry() const =0
Construction d'un enumerateur sur les Entry.
IIndexManager()=default
Constructeur par défaut.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17