Arcane  v3.16.8.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ItemPairEnumerator.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* ItemPairEnumerator.h (C) 2000-2025 */
9/* */
10/* Enumérateur sur un tableau de tableau d'entités du maillage. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITEMPAIRENUMERATOR_H
13#define ARCANE_CORE_ITEMPAIRENUMERATOR_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/Item.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29class ItemInternal;
30class ItemItemArray;
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
37class ARCANE_CORE_EXPORT ItemPairEnumerator
38{
39 public:
40
41 typedef ItemInternal* ItemInternalPtr;
42
43 public:
44
45 ItemPairEnumerator(const ItemPairGroup& array);
46 ItemPairEnumerator() = default;
47
48 public:
49
50 inline void operator++()
51 {
52 ++m_current;
53 }
54 inline bool hasNext() const
55 {
56 return m_current < m_end;
57 }
58 inline Int32 itemLocalId() const
59 {
60 return m_items_local_id[m_current];
61 }
62 inline Int32 index() const
63 {
64 return m_current;
65 }
66 inline ItemEnumerator subItems() const
67 {
68 return { m_sub_items_shared_info, _ids() };
69 }
70 inline Item operator*() const
71 {
72 return Item(m_items_local_id[m_current], m_items_shared_info);
73 }
74 inline Integer nbSubItem() const
75 {
76 return static_cast<Int32>(m_indexes[m_current + 1] - m_indexes[m_current]);
77 }
78
80 operator ItemLocalId() const { return ItemLocalId{ itemLocalId() }; }
81
82 protected:
83
84 Int32 m_current = 0;
85 Int32 m_end = 0;
86 Int64ConstArrayView m_indexes;
87 Int32ConstArrayView m_items_local_id;
88 Span<const Int32> m_sub_items_local_id;
89 ItemSharedInfo* m_items_shared_info = ItemSharedInfo::nullInstance();
90 ItemSharedInfo* m_sub_items_shared_info = ItemSharedInfo::nullInstance();
91
92 protected:
93
94 Item _currentItem() const
95 {
96 return Item(m_items_local_id[m_current], m_items_shared_info);
97 }
98 ConstArrayView<Int32> _ids() const
99 {
100 return ConstArrayView<Int32>(nbSubItem(), m_sub_items_local_id.data() + m_indexes[m_current]);
101 }
102};
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
110template <typename ItemType>
111class ItemPairEnumeratorSubT
112: public ItemPairEnumerator
113{
114 public:
115
116 ItemPairEnumeratorSubT(const ItemPairGroup& array)
117 : ItemPairEnumerator(array)
118 {
119 }
120
121 public:
122
123 inline ItemType operator*() const
124 {
125 return ItemType(this->_currentItem());
126 }
128 operator ItemLocalIdT<ItemType>() const { return ItemLocalIdT<ItemType>{ this->itemLocalId() }; }
129};
130
131/*---------------------------------------------------------------------------*/
132/*---------------------------------------------------------------------------*/
137template <typename ItemType, typename SubItemType>
138class ItemPairEnumeratorT
139: public ItemPairEnumeratorSubT<ItemType>
140{
141 using BaseClass = ItemPairEnumeratorSubT<ItemType>;
142
143 public:
144
145 ItemPairEnumeratorT(const ItemPairGroupT<ItemType, SubItemType>& array)
146 : ItemPairEnumeratorSubT<ItemType>(array)
147 {
148 }
149
150 ItemEnumeratorT<SubItemType> subItems() const
151 {
152 return { this->m_sub_items_shared_info, this->_ids() };
153 }
154};
155
156/*---------------------------------------------------------------------------*/
157/*---------------------------------------------------------------------------*/
158
159} // End namespace Arcane
160
161/*---------------------------------------------------------------------------*/
162/*---------------------------------------------------------------------------*/
163
164#endif
Types et macros pour itérer sur les entités du maillage.
Enumérateur sur une liste typée d'entités de type ItemType.
Enumérateur sur une liste d'entités.
Structure interne d'une entité de maillage.
Index d'une entité ItemType dans une variable.
Definition ItemLocalId.h:90
Index d'un Item dans une variable.
Definition ItemLocalId.h:41
Référence à un groupe d'un genre donné.
Tableau de listes d'entités.
Structure interne partagée d'une entité de maillage.
Classe de base d'un élément de maillage.
Definition Item.h:83
constexpr __host__ __device__ pointer data() const noexcept
Pointeur sur le début de la vue.
Definition Span.h:422
Vue d'un tableau d'éléments de type T.
Definition Span.h:513
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:569
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:567
std::int32_t Int32
Type entier signé sur 32 bits.