Arcane  4.1.11.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ConstituentItemIndexedSelectionView.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* ConstituentItemIndexedSelectionView.h (C) 2000-2026 */
9/* */
10/* Vue sur un sous ensemble d'un conteneur de ConstituentItem. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MATERIALS_CONSTITUENTITEMINDEXEDSELECTIONVIEW_H
13#define ARCANE_CORE_MATERIALS_CONSTITUENTITEMINDEXEDSELECTIONVIEW_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/materials/MaterialsCoreGlobal.h"
18#include "arcane/core/materials/ComponentItemVectorView.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane::Materials::Impl
24{
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
35template <typename ContainerType_>
37
38template <typename ConstituentContainerType_>
40{
41 using ThatContainer = ConstituentContainerType_;
42 using ValueType = ThatContainer::ValueType;
43 static constexpr bool IsSpan() { return false; }
44 static Int32 size(ThatContainer v)
45 {
46 return v.nbItem();
47 }
48};
49
50template <>
52: ConstituentItemIndexedSelectionViewTraitsBase<ComponentItemVectorView>
53{
54 static ARCCORE_HOST_DEVICE ComponentCell item(ComponentItemVectorView v, Int32 i)
55 {
56 return v.componentCell(i);
57 }
58};
59
60template <>
63{
64 static ARCCORE_HOST_DEVICE MatCell item(MatCellVectorView v, Int32 i)
65 {
66 return v.matCell(i);
67 }
68};
69
70template <>
73{
74 static ARCCORE_HOST_DEVICE EnvCell item(EnvCellVectorView v, Int32 i)
75 {
76 return v.envCell(i);
77 }
78};
79
81template <typename ConstituentItemType_>
83{
84 using ThatContainer = SmallSpan<const ConstituentItemType_>;
85 using ValueType = ConstituentItemType_;
86 static constexpr bool IsSpan() { return true; }
87 static ARCCORE_HOST_DEVICE Int32 size(ThatContainer v)
88 {
89 return v.size();
90 }
91 static ARCCORE_HOST_DEVICE ValueType item(ThatContainer v, Int32 i)
92 {
93 return v[i];
94 }
95};
96
97template <>
102template <>
107template <>
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116} // namespace Arcane::Materials::Impl
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
121namespace Arcane::Materials
122{
123
124/*---------------------------------------------------------------------------*/
125/*---------------------------------------------------------------------------*/
129class ARCANE_CORE_EXPORT ConstituentItemIndexedSelectionViewBase
130{
131 public:
132
133 using IndexArrayView = const SmallSpan<const Int32>;
134
135 protected:
136
137 explicit ConstituentItemIndexedSelectionViewBase(SmallSpan<const Int32> indices);
138 explicit ConstituentItemIndexedSelectionViewBase(IMeshComponent* constituent, Int32 selection_size);
139
140 public:
141
143 ARCCORE_HOST_DEVICE Int32 size() const { return m_selection_view.size(); }
144
145 protected:
146
154};
155
156/*---------------------------------------------------------------------------*/
157/*---------------------------------------------------------------------------*/
170template <typename ContainerView_>
171class ConstituentItemIndexedSelectionView
172: public ConstituentItemIndexedSelectionViewBase
173{
174 public:
175
176 using ItemVecView = ContainerView_;
177 using ThatClass = ConstituentItemIndexedSelectionView;
179 using ValueType = TraitsType::ValueType;
180 static constexpr bool IsSpanContainer() { return TraitsType::IsSpan(); }
181
182 public:
183
184 ConstituentItemIndexedSelectionView(ItemVecView ecv, IndexArrayView indices)
185 : ConstituentItemIndexedSelectionViewBase(indices)
186 , m_container_view(ecv)
187 {
188 }
189
191 explicit ConstituentItemIndexedSelectionView(ItemVecView view)
192 requires(!IsSpanContainer())
193 : ConstituentItemIndexedSelectionViewBase(view.component(), TraitsType::size(view))
194 , m_container_view(view)
195 {
196 }
197
200 requires(IsSpanContainer())
201 : ConstituentItemIndexedSelectionViewBase(constituent, TraitsType::size(ecv))
202 , m_container_view(ecv)
203 {
204 }
205
206 // nombre total de mailles du milieu
207 ARCCORE_HOST_DEVICE Int32 sourceSize() const { return TraitsType::size(m_container_view); }
208
209 // vue sur le vecteur de EnvCell d'origine (toutes les mailles du milieu)
210 ItemVecView sourceView() const { return m_container_view; }
211
212 // Liste des indices de la sélection.
213 IndexArrayView selectionView() const
214 {
216 }
217
218 ARCCORE_HOST_DEVICE ValueType operator[](Int32 i) const
219 {
220 return item(i);
221 }
222
223 ARCCORE_HOST_DEVICE ValueType item(Int32 i) const
224 {
225 ARCANE_CHECK_AT(i, size());
226 return TraitsType::item(m_container_view, m_selection_view[i]);
227 }
228
229 private:
230
232 ItemVecView m_container_view;
233};
234
235/*---------------------------------------------------------------------------*/
236/*---------------------------------------------------------------------------*/
240template <typename ContainerView_>
241class ConstituentItemIndexedSelectionEnumerator
242{
243 public:
244
246 using ThatClass = ConstituentItemIndexedSelectionEnumerator;
247
248 using ValueType = SelectionType::ValueType;
249
250 friend class EnumeratorTracer;
251 friend class EnumeratorBuilder<ValueType>;
252
253 private:
254
255 explicit ConstituentItemIndexedSelectionEnumerator(const SelectionType& v)
256 : m_size(v.size())
257 , m_container_with_selection(v)
258 {}
259
260 public:
261
262 static ThatClass create(SelectionType container)
263 {
264 return ThatClass(container);
265 }
266
267 public:
268
269 void operator++() { ++m_index; }
270 bool hasNext() const { return m_index < m_size; }
271
272 ValueType operator*() const
273 {
274 return m_container_with_selection.item(m_index);
275 }
276
277 Int32 index() const { return m_index; }
278
279 private:
280
281 Int32 m_index = 0;
282 Int32 m_size = 0;
283 SelectionType m_container_with_selection;
284};
285
286/*---------------------------------------------------------------------------*/
287/*---------------------------------------------------------------------------*/
291{
292 return ConstituentItemIndexedSelectionEnumerator<ComponentCellVectorView>::create(container);
293}
294
297{
298 ConstituentItemIndexedSelectionView<ComponentCellVectorView> c2(container.sourceView(), container.selectionView());
299 return ConstituentItemIndexedSelectionEnumerator<ComponentCellVectorView>::create(c2);
300}
301
304{
305 return ConstituentItemIndexedSelectionEnumerator<EnvCellVectorView>::create(container);
306}
307
308/*---------------------------------------------------------------------------*/
309/*---------------------------------------------------------------------------*/
310
311} // namespace Arcane::Materials
312
313/*---------------------------------------------------------------------------*/
314/*---------------------------------------------------------------------------*/
315
316#endif
Vue sur un vecteur sur les entités d'un composant.
__host__ __device__ ComponentCell componentCell(Int32 index) const
Retourne la index-ème ComponentCell de la vue.
Enumérateur sur les éléments d'un ConstituentItemIndexedSelectionView.
__host__ __device__ Int32 size() const
nombre de EnvCell sélectionnées
Vue sur un sous ensemble d'un conteneur de ConstituentItem.
ConstituentItemIndexedSelectionView(ItemVecView view)
Construit une sélection contenant tous les éléments de \view.
ConstituentItemIndexedSelectionView(IMeshComponent *constituent, SmallSpan< const ValueType > ecv)
Constructeur à partir d'une vue de ConstituentCell, de MatCell ou EnvCell.
Représente un composant d'une maille multi-matériau.
Maille arcane d'un milieu.
__host__ __device__ EnvCell envCell(Int32 index) const
Récupère la index-ème EnvCell de la vue.
Interface d'un composant (matériau ou milieu) d'un maillage.
Représente un matériau d'une maille multi-matériau.
__host__ __device__ MatCell matCell(Int32 index) const
Récupère la index-ème MatCell de la vue.
Vue d'un tableau d'éléments de type T.
Definition Span.h:801
constexpr __host__ __device__ SizeType size() const noexcept
Retourne la taille du tableau.
Definition Span.h:325
constexpr ConstArrayView< value_type > constSmallView() const
Vue constante sur cette vue.
Definition Span.h:399
Active toujours les traces dans les parties Arcane concernant les matériaux.
EnvItemVectorView EnvCellVectorView
Type de la vue sur un EnvCellVector.
MatItemVectorView MatCellVectorView
Type de la vue sur un MatCellVector.
ConstituentItemIndexedSelectionEnumerator< ComponentCellVectorView > arcaneImplCreateConstituentEnumerator(ComponentCell, ConstituentItemIndexedSelectionView< ComponentCellVectorView > container)
Enumérateur sur une sélection d'un constituant.
std::int32_t Int32
Type entier signé sur 32 bits.
Caractéristiques pour le conteneur associé à ConstituentItemIndexedSelectionView.