52class ARCANE_CORE_EXPORT ConstituentItem
55 friend CellComponentCellEnumerator;
58 friend MeshMaterialMng;
62 friend ConstituentItemVectorImpl;
67 : m_constituent_item_index(mii.m_constituent_item_index)
68 , m_shared_info(mii.m_shared_info)
71 ARCCORE_HOST_DEVICE ConstituentItem()
73#ifndef ARCCORE_DEVICE_CODE
74 m_shared_info = ComponentItemSharedInfo::_nullInstance();
81 ARCCORE_HOST_DEVICE
operator ComponentItemLocalId()
const {
return ComponentItemLocalId{
_varIndex() }; }
86 ARCCORE_HOST_DEVICE
MatVarIndex _varIndex()
const {
return m_shared_info->_varIndex(m_constituent_item_index); }
97 ARCCORE_HOST_DEVICE
Int32 componentId()
const {
return m_shared_info->_componentId(m_constituent_item_index); }
100 ARCCORE_HOST_DEVICE
bool null()
const {
return m_constituent_item_index.isNull(); }
103 ARCCORE_HOST_DEVICE ComponentCell
superCell()
const {
return ComponentCell(_superItemBase()); }
106 ARCCORE_HOST_DEVICE
Int32 level()
const {
return m_shared_info->m_level; }
109 ARCCORE_HOST_DEVICE
Int32 nbSubItem()
const {
return m_shared_info->_nbSubConstituent(m_constituent_item_index); }
114 return Cell(m_shared_info->_globalItemBase(m_constituent_item_index));
120 return CellLocalId(m_shared_info->_globalItemId(m_constituent_item_index));
136 ARCANE_CORE_EXPORT
friend std::ostream&
137 operator<<(std::ostream& o,
const ComponentCell& mvi);
142 [[maybe_unused]]
Int32 expected_level)
144#if !defined(ARCCORE_DEVICE_CODE)
145 if (item_base.null())
147 Int32 lvl = item_base.level();
148 if (lvl != expected_level)
149 _badConversion(item_base, lvl, expected_level);
156 return m_shared_info->_subItemBase(m_constituent_item_index, index);
158 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _superItemBase()
const
162 ARCCORE_HOST_DEVICE ConstituentItemIndex _firstSubConstituentLocalId()
const
164 return m_shared_info->_firstSubConstituentLocalId(m_constituent_item_index);
169 ConstituentItemIndex m_constituent_item_index;
170 ComponentItemSharedInfo* m_shared_info =
nullptr;
177 return m_constituent_item_index;
187class ARCANE_CORE_EXPORT CellComponentCellEnumerator
189 friend class EnumeratorTracer;
197 friend class CellComponentCellEnumerator;
201 using iterator_category = std::forward_iterator_tag;
202 using value_type = ComponentCell;
206 ARCCORE_HOST_DEVICE
explicit Iterator(CellComponentCellEnumerator enumerator)
207 : m_index(enumerator.m_index)
208 , m_size(enumerator.m_size)
209 , m_first_sub_index(enumerator.m_first_sub_index)
210 , m_sub_constituent_shared_info(enumerator.m_sub_constituent_shared_info)
215 ARCCORE_HOST_DEVICE
void operator++() { ++m_index; }
216 ARCCORE_HOST_DEVICE ComponentCell operator*()
const
218 ARCANE_CHECK_AT(m_index, m_size);
219 return ComponentCell(_currentSubItemBase());
221 ARCCORE_HOST_DEVICE
operator ComponentItemLocalId()
const
223 return ComponentItemLocalId(_varIndex());
225 friend ARCCORE_HOST_DEVICE
bool operator==(
const Iterator& x,
const Sentinel&)
227 return x.m_index == x.m_size;
234 Int32 m_first_sub_index = -1;
235 ComponentItemSharedInfo* m_sub_constituent_shared_info =
nullptr;
245 return m_sub_constituent_shared_info->_varIndex(
ConstituentItemIndex(m_first_sub_index + m_index));
249 template <
typename ConstituentItemType>
250 class IteratorT :
public Iterator
254 using value_type = ConstituentItemType;
260 : Iterator(enumerator)
265 ARCCORE_HOST_DEVICE ConstituentItemType operator*()
const
267 ARCANE_CHECK_AT(m_index, m_size);
268 return ConstituentItemType(_currentSubItemBase());
274 ARCCORE_HOST_DEVICE
explicit CellComponentCellEnumerator(ComponentCell super_item)
275 : m_size(super_item.nbSubItem())
276 , m_first_sub_index(super_item._firstSubConstituentLocalId().localId())
277 , m_sub_constituent_shared_info(super_item.m_shared_info->m_sub_component_item_shared_info)
283 ARCCORE_HOST_DEVICE
void operator++() { ++m_index; }
284 ARCCORE_HOST_DEVICE
bool hasNext()
const {
return m_index < m_size; }
286 ARCCORE_HOST_DEVICE ComponentCell operator*()
const
288 ARCANE_CHECK_AT(m_index, m_size);
289 return ComponentCell(_currentSubItemBase());
291 ARCCORE_HOST_DEVICE MatVarIndex _varIndex()
const
293 return m_sub_constituent_shared_info->_varIndex(ConstituentItemIndex(m_first_sub_index + m_index));
295 ARCCORE_HOST_DEVICE Int32 index()
const {
return m_index; }
296 ARCCORE_HOST_DEVICE
operator ComponentItemLocalId()
const
298 return ComponentItemLocalId(_varIndex());
300 ARCCORE_HOST_DEVICE Iterator begin()
const {
return Iterator(*
this); }
301 ARCCORE_HOST_DEVICE Sentinel end()
const {
return {}; }
307 Int32 m_first_sub_index = -1;
308 ComponentItemSharedInfo* m_sub_constituent_shared_info =
nullptr;
312 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _currentSubItemBase()
const
314 return m_sub_constituent_shared_info->_item(ConstituentItemIndex(m_first_sub_index + m_index));
324template <
typename ComponentCellType>
class CellComponentCellEnumeratorT
325:
public CellComponentCellEnumerator
333 explicit ARCCORE_HOST_DEVICE CellComponentCellEnumeratorT(ComponentCell super_item)
334 : CellComponentCellEnumerator(super_item)
339 ARCCORE_HOST_DEVICE ComponentCellType operator*()
const
341 ARCANE_CHECK_AT(m_index, m_size);
342 return ComponentCellType(_currentSubItemBase());
344 ARCCORE_HOST_DEVICE IteratorType begin()
const {
return IteratorType(*
this); }
345 ARCCORE_HOST_DEVICE
Sentinel end()
const {
return {}; }