Arcane  4.1.13.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
192 requires(IsSpanContainer())
193 : ConstituentItemIndexedSelectionViewBase(constituent, TraitsType::size(ecv))
194 , m_container_view(ecv)
195 {
196 }
197
198 protected:
199
201 explicit ConstituentItemIndexedSelectionView(ItemVecView view)
202 : ConstituentItemIndexedSelectionViewBase(view.component(), TraitsType::size(view))
203 , m_container_view(view)
204 {
205 }
206
207 public:
208
209 // nombre total de mailles du milieu
210 ARCCORE_HOST_DEVICE Int32 sourceSize() const { return TraitsType::size(m_container_view); }
211
212 // vue sur le vecteur de EnvCell d'origine (toutes les mailles du milieu)
213 ItemVecView sourceView() const { return m_container_view; }
214
215 // Liste des indices de la sélection.
216 IndexArrayView selectionView() const
217 {
219 }
220
221 ARCCORE_HOST_DEVICE ValueType operator[](Int32 i) const
222 {
223 return item(i);
224 }
225
226 ARCCORE_HOST_DEVICE ValueType item(Int32 i) const
227 {
228 ARCANE_CHECK_AT(i, size());
229 return TraitsType::item(m_container_view, m_selection_view[i]);
230 }
231
232 private:
233
235 ItemVecView m_container_view;
236};
237
238/*---------------------------------------------------------------------------*/
239/*---------------------------------------------------------------------------*/
243template <typename ContainerView_>
244class ConstituentItemIndexedSelectionEnumerator
245{
246 public:
247
249 using ThatClass = ConstituentItemIndexedSelectionEnumerator;
250
251 using ValueType = SelectionType::ValueType;
252
253 friend class EnumeratorTracer;
254 friend class EnumeratorBuilder<ValueType>;
255
256 private:
257
258 explicit ConstituentItemIndexedSelectionEnumerator(const SelectionType& v)
259 : m_size(v.size())
260 , m_container_with_selection(v)
261 {}
262
263 public:
264
265 static ThatClass create(SelectionType container)
266 {
267 return ThatClass(container);
268 }
269
270 public:
271
272 void operator++() { ++m_index; }
273 bool hasNext() const { return m_index < m_size; }
274
275 ValueType operator*() const
276 {
277 return m_container_with_selection.item(m_index);
278 }
279
280 Int32 index() const { return m_index; }
281
282 private:
283
284 Int32 m_index = 0;
285 Int32 m_size = 0;
286 SelectionType m_container_with_selection;
287};
288
289/*---------------------------------------------------------------------------*/
290/*---------------------------------------------------------------------------*/
294class ComponentCellVectorSelectionView
295: public ConstituentItemIndexedSelectionView<ComponentCellVectorView>
296{
297 using BaseClass = ConstituentItemIndexedSelectionView<ComponentCellVectorView>;
298
299 public:
300
301 ComponentCellVectorSelectionView(ComponentCellVectorView vector_view, SmallSpan<const Int32> indices)
302 : BaseClass(vector_view, indices)
303 {
304 }
305
308 : BaseClass(vector_view)
309 {
310 }
311};
312
313/*---------------------------------------------------------------------------*/
314/*---------------------------------------------------------------------------*/
318class EnvCellVectorSelectionView
319: public ConstituentItemIndexedSelectionView<EnvCellVectorView>
320{
321 using BaseClass = ConstituentItemIndexedSelectionView<EnvCellVectorView>;
322
323 public:
324
325 EnvCellVectorSelectionView(EnvCellVectorView vector_view, SmallSpan<const Int32> indices)
326 : BaseClass(vector_view, indices)
327 {
328 }
329
332 : BaseClass(vector_view)
333 {
334 }
335};
336
337/*---------------------------------------------------------------------------*/
338/*---------------------------------------------------------------------------*/
342class MatCellVectorSelectionView
343: public ConstituentItemIndexedSelectionView<MatCellVectorView>
344{
345 using BaseClass = ConstituentItemIndexedSelectionView<MatCellVectorView>;
346
347 public:
348
349 MatCellVectorSelectionView(MatCellVectorView vector_view, SmallSpan<const Int32> indices)
350 : BaseClass(vector_view, indices)
351 {
352 }
353
356 : BaseClass(vector_view)
357 {
358 }
359};
360
361/*---------------------------------------------------------------------------*/
362/*---------------------------------------------------------------------------*/
363
367{
368 return ConstituentItemIndexedSelectionEnumerator<ComponentCellVectorView>::create(container);
369}
370
374{
375 ConstituentItemIndexedSelectionView<ComponentCellVectorView> c2(container.sourceView(), container.selectionView());
376 return ConstituentItemIndexedSelectionEnumerator<ComponentCellVectorView>::create(c2);
377}
378
382{
383 return ConstituentItemIndexedSelectionEnumerator<EnvCellVectorView>::create(container);
384}
385
386/*---------------------------------------------------------------------------*/
387/*---------------------------------------------------------------------------*/
388
389} // namespace Arcane::Materials
390
391/*---------------------------------------------------------------------------*/
392/*---------------------------------------------------------------------------*/
393
394#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: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.
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.