57 friend class MeshMaterialMng;
61 friend class ConstituentItemVectorImpl;
65 ARCCORE_HOST_DEVICE
ComponentCell(
const matimpl::ConstituentItemBase& mii)
66 : m_constituent_item_index(mii.m_constituent_item_index)
67 , m_shared_info(mii.m_shared_info)
72#ifndef ARCCORE_DEVICE_CODE
73 m_shared_info = ComponentItemSharedInfo::_nullInstance();
85 ARCCORE_HOST_DEVICE
MatVarIndex _varIndex()
const {
return m_shared_info->_varIndex(m_constituent_item_index); }
87 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase constituentItemBase()
const {
return { m_shared_info, m_constituent_item_index }; }
96 ARCCORE_HOST_DEVICE Int32
componentId()
const {
return m_shared_info->_componentId(m_constituent_item_index); }
99 ARCCORE_HOST_DEVICE
bool null()
const {
return m_constituent_item_index.isNull(); }
105 ARCCORE_HOST_DEVICE Int32
level()
const {
return m_shared_info->m_level; }
108 ARCCORE_HOST_DEVICE Int32
nbSubItem()
const {
return m_shared_info->_nbSubConstituent(m_constituent_item_index); }
113 return Cell(m_shared_info->_globalItemBase(m_constituent_item_index));
119 return CellLocalId(m_shared_info->_globalItemId(m_constituent_item_index));
130 Int64
componentUniqueId()
const {
return m_shared_info->_componentUniqueId(m_constituent_item_index); }
137 static ARCCORE_HOST_DEVICE
void _checkLevel([[maybe_unused]] matimpl::ConstituentItemBase item_base,
138 [[maybe_unused]] Int32 expected_level)
140#if !defined(ARCCORE_DEVICE_CODE)
141 if (item_base.null())
143 Int32 lvl = item_base.level();
144 if (lvl != expected_level)
145 _badConversion(item_base, lvl, expected_level);
148 static void _badConversion(matimpl::ConstituentItemBase item_base, Int32 level, Int32 expected_level);
150 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _subItemBase(Int32 index)
const
152 return m_shared_info->_subItemBase(m_constituent_item_index, index);
154 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _superItemBase()
const
156 return m_shared_info->_superItemBase(m_constituent_item_index);
158 ARCCORE_HOST_DEVICE ConstituentItemIndex _firstSubConstituentLocalId()
const
160 return m_shared_info->_firstSubConstituentLocalId(m_constituent_item_index);
165 ConstituentItemIndex m_constituent_item_index;
166 ComponentItemSharedInfo* m_shared_info =
nullptr;
171 ARCCORE_HOST_DEVICE ConstituentItemIndex _constituentItemIndex()
const
173 return m_constituent_item_index;
196 using iterator_category = std::forward_iterator_tag;
202 : m_index(enumerator.m_index)
203 , m_size(enumerator.m_size)
204 , m_first_sub_index(enumerator.m_first_sub_index)
205 , m_sub_constituent_shared_info(enumerator.m_sub_constituent_shared_info)
210 ARCCORE_HOST_DEVICE
void operator++() { ++m_index; }
213 ARCANE_CHECK_AT(m_index, m_size);
220 friend ARCCORE_HOST_DEVICE
bool operator==(
const Iterator& x,
const Sentinel&)
222 return x.m_index == x.m_size;
229 Int32 m_first_sub_index = -1;
234 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _currentSubItemBase()
const
240 return m_sub_constituent_shared_info->_varIndex(
ConstituentItemIndex(m_first_sub_index + m_index));
244 template <
typename ConstituentItemType>
249 using value_type = ConstituentItemType;
260 ARCCORE_HOST_DEVICE ConstituentItemType
operator*()
const
262 ARCANE_CHECK_AT(m_index, m_size);
263 return ConstituentItemType(_currentSubItemBase());
270 : m_size(super_item.nbSubItem())
271 , m_first_sub_index(super_item._firstSubConstituentLocalId().localId())
272 , m_sub_constituent_shared_info(super_item.m_shared_info->m_sub_component_item_shared_info)
278 ARCCORE_HOST_DEVICE
void operator++() { ++m_index; }
279 ARCCORE_HOST_DEVICE
bool hasNext()
const {
return m_index < m_size; }
281 ARCCORE_HOST_DEVICE ComponentCell operator*()
const
283 ARCANE_CHECK_AT(m_index, m_size);
284 return ComponentCell(_currentSubItemBase());
286 ARCCORE_HOST_DEVICE MatVarIndex _varIndex()
const
288 return m_sub_constituent_shared_info->_varIndex(ConstituentItemIndex(m_first_sub_index + m_index));
290 ARCCORE_HOST_DEVICE Int32 index()
const {
return m_index; }
291 ARCCORE_HOST_DEVICE
operator ComponentItemLocalId()
const
293 return ComponentItemLocalId(_varIndex());
295 ARCCORE_HOST_DEVICE Iterator begin()
const {
return Iterator(*
this); }
296 ARCCORE_HOST_DEVICE Sentinel end()
const {
return {}; }
302 Int32 m_first_sub_index = -1;
303 ComponentItemSharedInfo* m_sub_constituent_shared_info =
nullptr;
307 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _currentSubItemBase()
const
309 return m_sub_constituent_shared_info->_item(ConstituentItemIndex(m_first_sub_index + m_index));