12#ifndef ARCANE_CORE_MATERIALS_CONSTITUENTITEMINDEXEDSELECTIONVIEW_H
13#define ARCANE_CORE_MATERIALS_CONSTITUENTITEMINDEXEDSELECTIONVIEW_H
17#include "arcane/core/materials/MaterialsCoreGlobal.h"
18#include "arcane/core/materials/ComponentItemVectorView.h"
23namespace Arcane::Materials::Impl
37template <
typename ContainerType_>
40template <
typename ConstituentContainerType_>
43 using ThatContainer = ConstituentContainerType_;
44 using ValueType = ThatContainer::ValueType;
45 static constexpr bool IsSpan() {
return false; }
46 static Int32 size(ThatContainer v)
83template <
typename ConstituentItemType_>
87 using ValueType = ConstituentItemType_;
88 static constexpr bool IsSpan() {
return true; }
89 static ARCCORE_HOST_DEVICE
Int32 size(ThatContainer v)
93 static ARCCORE_HOST_DEVICE ValueType item(ThatContainer v,
Int32 i)
132class ARCANE_CORE_EXPORT ConstituentItemIndexedSelectionViewBase
141 explicit ConstituentItemIndexedSelectionViewBase(
IMeshComponent* constituent,
Int32 selection_size);
174template <
typename ContainerView_>
175class ConstituentItemIndexedSelectionView
176:
public ConstituentItemIndexedSelectionViewBase
180 using ItemVecView = ContainerView_;
181 using ThatClass = ConstituentItemIndexedSelectionView;
183 using ValueType = TraitsType::ValueType;
184 static constexpr bool IsSpanContainer() {
return TraitsType::IsSpan(); }
188 ConstituentItemIndexedSelectionView(ItemVecView ecv, IndexArrayView indices)
189 : ConstituentItemIndexedSelectionViewBase(indices)
190 , m_container_view(ecv)
196 requires(IsSpanContainer())
197 : ConstituentItemIndexedSelectionViewBase(constituent, TraitsType::
size(ecv))
198 , m_container_view(ecv)
206 : ConstituentItemIndexedSelectionViewBase(view.component(), TraitsType::
size(view))
207 , m_container_view(view)
214 ARCCORE_HOST_DEVICE
Int32 sourceSize()
const {
return TraitsType::size(m_container_view); }
217 ItemVecView sourceView()
const {
return m_container_view; }
220 IndexArrayView selectionView()
const
225 ARCCORE_HOST_DEVICE ValueType operator[](
Int32 i)
const
230 ARCCORE_HOST_DEVICE ValueType item(
Int32 i)
const
232 ARCANE_CHECK_AT(i,
size());
239 ItemVecView m_container_view;
248template <
typename ContainerView_>
249class ConstituentItemIndexedSelectionEnumerator
254 using ThatClass = ConstituentItemIndexedSelectionEnumerator;
256 using ValueType = SelectionType::ValueType;
258 friend class EnumeratorTracer;
263 explicit ConstituentItemIndexedSelectionEnumerator(
const SelectionType& v)
265 , m_container_with_selection(v)
270 static ThatClass create(SelectionType container)
272 return ThatClass(container);
277 void operator++() { ++m_index; }
278 bool hasNext()
const {
return m_index < m_size; }
280 ValueType operator*()
const
282 return m_container_with_selection.item(m_index);
285 Int32 index()
const {
return m_index; }
291 SelectionType m_container_with_selection;
300class ComponentCellVectorSelectionView
301:
public ConstituentItemIndexedSelectionView<ComponentCellVectorView>
303 using BaseClass = ConstituentItemIndexedSelectionView<ComponentCellVectorView>;
308 : BaseClass(vector_view, indices)
314 : BaseClass(vector_view)
325class EnvCellVectorSelectionView
326:
public ConstituentItemIndexedSelectionView<EnvCellVectorView>
328 using BaseClass = ConstituentItemIndexedSelectionView<EnvCellVectorView>;
333 : BaseClass(vector_view, indices)
339 : BaseClass(vector_view)
350class MatCellVectorSelectionView
351:
public ConstituentItemIndexedSelectionView<MatCellVectorView>
353 using BaseClass = ConstituentItemIndexedSelectionView<MatCellVectorView>;
358 : BaseClass(vector_view, indices)
364 : BaseClass(vector_view)
376 return ConstituentItemIndexedSelectionEnumerator<ComponentCellVectorView>::create(container);
384 return ConstituentItemIndexedSelectionEnumerator<ComponentCellVectorView>::create(c2);
391 return ConstituentItemIndexedSelectionEnumerator<EnvCellVectorView>::create(container);
Selection over a ComponentCellVectorView.
ComponentCellVectorSelectionView(ComponentCellVectorView vector_view)
Constructs a selection containing all elements of \view.
View over a vector of entities of a component.
__host__ __device__ ComponentCell componentCell(Int32 index) const
Returns the index-th ComponentCell of the view.
Enumerator over the elements of a ConstituentItemIndexedSelectionView.
__host__ __device__ Int32 size() const
number of selected EnvCells
SmallSpan< const Int32 > m_selection_view
Selection.
View over a subset of a ConstituentItem container.
ConstituentItemIndexedSelectionView(ItemVecView view)
Constructs a selection containing all elements of \view (which must derive from ComponentCellVectorVi...
ConstituentItemIndexedSelectionView(IMeshComponent *constituent, SmallSpan< const ValueType > ecv)
Constructor from a view of ConstituentCell, MatCell or EnvCell.
Represents a component of a multi-material cell.
Selection over an EnvCellVectorView.
EnvCellVectorSelectionView(EnvCellVectorView vector_view)
Constructs a selection containing all elements of \view.
Arcane cell of an environment.
__host__ __device__ EnvCell envCell(Int32 index) const
Retrieves the index-th EnvCell of the view.
Interface of a component (material or environment) of a mesh.
Partial specialization for a SmallSpan<T>.
MatCellVectorSelectionView(MatCellVectorView vector_view)
Constructs a selection containing all elements of \view.
Represents a material in a multi-material cell.
__host__ __device__ MatCell matCell(Int32 index) const
Retrieves the index-th MatCell of the view.
View of an array of elements of type T.
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
constexpr ConstArrayView< value_type > constSmallView() const
Constant view of this view.
Always enables tracing in Arcane parts concerning materials.
EnvItemVectorView EnvCellVectorView
View type for an EnvCellVector.
ConstituentItemIndexedSelectionEnumerator< ComponentCellVectorView > arcaneImplCreateConstituentEnumerator(ComponentCell, ComponentCellVectorSelectionView container)
Enumerator over a constituent selection.
ComponentItemVectorView ComponentCellVectorView
View type for a ComponentCellVector.
MatItemVectorView MatCellVectorView
View type for a MatCellVector.
std::int32_t Int32
Signed integer type of 32 bits.
Characteristics for the container associated with ConstituentItemIndexedSelectionView.