Arcane  4.2.1.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::MatImpl
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
37template <typename ContainerType_>
39
40template <typename ConstituentContainerType_>
42{
43 using ThatContainer = ConstituentContainerType_;
44 using ValueType = ThatContainer::ValueType;
45 static constexpr bool IsSpan() { return false; }
46 static Int32 size(ThatContainer v)
47 {
48 return v.nbItem();
49 }
50};
51
52template <>
54: ConstituentItemIndexedSelectionViewTraitsBase<ComponentItemVectorView>
55{
56 static ARCCORE_HOST_DEVICE ComponentCell item(ComponentItemVectorView v, Int32 i)
57 {
58 return v.componentCell(i);
59 }
60};
61
62template <>
65{
66 static ARCCORE_HOST_DEVICE MatCell item(MatCellVectorView v, Int32 i)
67 {
68 return v.matCell(i);
69 }
70};
71
72template <>
75{
76 static ARCCORE_HOST_DEVICE EnvCell item(EnvCellVectorView v, Int32 i)
77 {
78 return v.envCell(i);
79 }
80};
81
83template <typename ConstituentItemType_>
85{
86 using ThatContainer = SmallSpan<const ConstituentItemType_>;
87 using ValueType = ConstituentItemType_;
88 static constexpr bool IsSpan() { return true; }
89 static ARCCORE_HOST_DEVICE Int32 size(ThatContainer v)
90 {
91 return v.size();
92 }
93 static ARCCORE_HOST_DEVICE ValueType item(ThatContainer v, Int32 i)
94 {
95 return v[i];
96 }
97};
98
99template <>
104template <>
109template <>
114
115/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
117
118} // namespace Arcane::Materials::Impl
119
120/*---------------------------------------------------------------------------*/
121/*---------------------------------------------------------------------------*/
122
123namespace Arcane::Materials
124{
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
132class ARCANE_CORE_EXPORT ConstituentItemIndexedSelectionViewBase
133{
134 public:
135
136 using IndexArrayView = const SmallSpan<const Int32>;
137
138 protected:
139
140 explicit ConstituentItemIndexedSelectionViewBase(SmallSpan<const Int32> indices);
141 explicit ConstituentItemIndexedSelectionViewBase(IMeshComponent* constituent, Int32 selection_size);
142
143 public:
144
146 ARCCORE_HOST_DEVICE Int32 size() const { return m_selection_view.size(); }
147
148 protected:
149
157};
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
174template <typename ContainerView_>
175class ConstituentItemIndexedSelectionView
176: public ConstituentItemIndexedSelectionViewBase
177{
178 public:
179
180 using ItemVecView = ContainerView_;
181 using ThatClass = ConstituentItemIndexedSelectionView;
183 using ValueType = TraitsType::ValueType;
184 static constexpr bool IsSpanContainer() { return TraitsType::IsSpan(); }
185
186 public:
187
188 ConstituentItemIndexedSelectionView(ItemVecView ecv, IndexArrayView indices)
189 : ConstituentItemIndexedSelectionViewBase(indices)
190 , m_container_view(ecv)
191 {
192 }
193
196 requires(IsSpanContainer())
197 : ConstituentItemIndexedSelectionViewBase(constituent, TraitsType::size(ecv))
198 , m_container_view(ecv)
199 {
200 }
201
202 protected:
203
205 explicit ConstituentItemIndexedSelectionView(ItemVecView view)
206 : ConstituentItemIndexedSelectionViewBase(view.component(), TraitsType::size(view))
207 , m_container_view(view)
208 {
209 }
210
211 public:
212
213 // nombre total de mailles du milieu
214 ARCCORE_HOST_DEVICE Int32 sourceSize() const { return TraitsType::size(m_container_view); }
215
216 // vue sur le vecteur de EnvCell d'origine (toutes les mailles du milieu)
217 ItemVecView sourceView() const { return m_container_view; }
218
219 // Liste des indices de la sélection.
220 IndexArrayView selectionView() const
221 {
223 }
224
225 ARCCORE_HOST_DEVICE ValueType operator[](Int32 i) const
226 {
227 return item(i);
228 }
229
230 ARCCORE_HOST_DEVICE ValueType item(Int32 i) const
231 {
232 ARCANE_CHECK_AT(i, size());
233 return TraitsType::item(m_container_view, m_selection_view[i]);
234 }
235
236 private:
237
239 ItemVecView m_container_view;
240};
241
242/*---------------------------------------------------------------------------*/
243/*---------------------------------------------------------------------------*/
244
248template <typename ContainerView_>
249class ConstituentItemIndexedSelectionEnumerator
250{
251 public:
252
254 using ThatClass = ConstituentItemIndexedSelectionEnumerator;
255
256 using ValueType = SelectionType::ValueType;
257
258 friend class EnumeratorTracer;
259 friend class EnumeratorBuilder<ValueType>;
260
261 private:
262
263 explicit ConstituentItemIndexedSelectionEnumerator(const SelectionType& v)
264 : m_size(v.size())
265 , m_container_with_selection(v)
266 {}
267
268 public:
269
270 static ThatClass create(SelectionType container)
271 {
272 return ThatClass(container);
273 }
274
275 public:
276
277 void operator++() { ++m_index; }
278 bool hasNext() const { return m_index < m_size; }
279
280 ValueType operator*() const
281 {
282 return m_container_with_selection.item(m_index);
283 }
284
285 Int32 index() const { return m_index; }
286
287 private:
288
289 Int32 m_index = 0;
290 Int32 m_size = 0;
291 SelectionType m_container_with_selection;
292};
293
294/*---------------------------------------------------------------------------*/
295/*---------------------------------------------------------------------------*/
296
300class ComponentCellVectorSelectionView
301: public ConstituentItemIndexedSelectionView<ComponentCellVectorView>
302{
303 using BaseClass = ConstituentItemIndexedSelectionView<ComponentCellVectorView>;
304
305 public:
306
307 ComponentCellVectorSelectionView(ComponentCellVectorView vector_view, SmallSpan<const Int32> indices)
308 : BaseClass(vector_view, indices)
309 {
310 }
311
314 : BaseClass(vector_view)
315 {
316 }
317};
318
319/*---------------------------------------------------------------------------*/
320/*---------------------------------------------------------------------------*/
321
325class EnvCellVectorSelectionView
326: public ConstituentItemIndexedSelectionView<EnvCellVectorView>
327{
328 using BaseClass = ConstituentItemIndexedSelectionView<EnvCellVectorView>;
329
330 public:
331
332 EnvCellVectorSelectionView(EnvCellVectorView vector_view, SmallSpan<const Int32> indices)
333 : BaseClass(vector_view, indices)
334 {
335 }
336
339 : BaseClass(vector_view)
340 {
341 }
342};
343
344/*---------------------------------------------------------------------------*/
345/*---------------------------------------------------------------------------*/
346
350class MatCellVectorSelectionView
351: public ConstituentItemIndexedSelectionView<MatCellVectorView>
352{
353 using BaseClass = ConstituentItemIndexedSelectionView<MatCellVectorView>;
354
355 public:
356
357 MatCellVectorSelectionView(MatCellVectorView vector_view, SmallSpan<const Int32> indices)
358 : BaseClass(vector_view, indices)
359 {
360 }
361
364 : BaseClass(vector_view)
365 {
366 }
367};
368
369/*---------------------------------------------------------------------------*/
370/*---------------------------------------------------------------------------*/
371
375{
376 return ConstituentItemIndexedSelectionEnumerator<ComponentCellVectorView>::create(container);
377}
378
382{
383 ConstituentItemIndexedSelectionView<ComponentCellVectorView> c2(container.sourceView(), container.selectionView());
384 return ConstituentItemIndexedSelectionEnumerator<ComponentCellVectorView>::create(c2);
385}
386
390{
391 return ConstituentItemIndexedSelectionEnumerator<EnvCellVectorView>::create(container);
392}
393
394/*---------------------------------------------------------------------------*/
395/*---------------------------------------------------------------------------*/
396
397} // namespace Arcane::Materials
398
399/*---------------------------------------------------------------------------*/
400/*---------------------------------------------------------------------------*/
401
402#endif
ComponentCellVectorSelectionView(ComponentCellVectorView vector_view)
Construit une sélection contenant tous les éléments de \view.
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 (qui doit dériver de ComponentCellVector...
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.
EnvCellVectorSelectionView(EnvCellVectorView vector_view)
Construit une sélection contenant tous les éléments de \view.
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.
MatCellVectorSelectionView(MatCellVectorView vector_view)
Construit une sélection contenant tous les éléments de \view.
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:802
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.
ConstituentItemIndexedSelectionEnumerator< ComponentCellVectorView > arcaneImplCreateConstituentEnumerator(ComponentCell, ComponentCellVectorSelectionView container)
Enumérateur sur une sélection d'un constituant.
ComponentItemVectorView ComponentCellVectorView
Type de la vue sur un ComponentCellVector.
MatItemVectorView MatCellVectorView
Type de la vue sur un MatCellVector.
std::int32_t Int32
Type entier signé sur 32 bits.
Caractéristiques pour le conteneur associé à ConstituentItemIndexedSelectionView.