12#ifndef ARCANE_CORE_MATERIALS_COMPONENTITEMINTERNAL_H
13#define ARCANE_CORE_MATERIALS_COMPONENTITEMINTERNAL_H
17#include "arcane/core/ItemInternal.h"
18#include "arcane/core/Item.h"
19#include "arcane/core/materials/MatVarIndex.h"
27class MeshComponentData;
30class ComponentItemInternalData;
34 class ConstituentItemBase;
54 ARCCORE_HOST_DEVICE
constexpr Int32 localId()
const {
return m_id; }
58 return a.m_id == b.m_id;
63 return a.m_id != b.m_id;
65 ARCANE_CORE_EXPORT
friend std::ostream&
68 ARCCORE_HOST_DEVICE
constexpr bool isNull()
const {
return m_id == (-1); }
91 friend class ComponentItemInternalData;
96 Int32 m_storage_size = 0;
100 Int16* m_component_id_data =
nullptr;
102 Int16* m_nb_sub_constituent_item_data =
nullptr;
104 Int32* m_global_item_local_id_data =
nullptr;
126 friend class ComponentItemInternalData;
128 friend class ConstituentItemLocalIdList;
129 friend class ConstituentItemLocalIdListView;
130 friend matimpl::ConstituentItemBase;
134 friend class ConstituentItemVectorImpl;
136 static const int MAT_INDEX_OFFSET = 10;
144 static void _setNullInstance();
151 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
152 return m_first_sub_constituent_item_id_data[
id.localId()];
154 inline ARCCORE_HOST_DEVICE
void
157 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
158 m_first_sub_constituent_item_id_data[
id.localId()] = first_id;
162 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
163 return m_nb_sub_constituent_item_data[
id.localId()];
167 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
168 m_nb_sub_constituent_item_data[
id.localId()] = n;
172 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
173 return m_component_id_data[
id.localId()];
177 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
178 m_component_id_data[
id.localId()] = component_id;
182 return m_components[_componentId(
id)];
186 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
187 return impl::ItemBase(m_global_item_local_id_data[
id.localId()], m_item_shared_info);
191 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
192 return m_global_item_local_id_data[
id.localId()];
196 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
197 m_global_item_local_id_data[
id.localId()] = global_item_lid.localId();
199 ARCCORE_HOST_DEVICE
inline matimpl::ConstituentItemBase _superItemBase(
ConstituentItemIndex id)
const;
203 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
204 m_super_component_item_local_id_data[
id.localId()] = super_id;
206 inline ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _subItemBase(
ConstituentItemIndex id, Int32 sub_index)
const;
210 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
211 return m_var_index_data[
id.localId()];
215 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
216 m_var_index_data[
id.localId()] = mv_index;
224 return (Int64)m_var_index_data[
id.localId()].arrayIndex() + ((Int64)item_base.
uniqueId() << MAT_INDEX_OFFSET);
229 Int32 local_id =
id.localId();
230 ARCCORE_CHECK_RANGE(local_id, -1, m_storage_size);
232 m_var_index_data[local_id].reset();
233 m_first_sub_constituent_item_id_data[local_id] = {};
234 m_nb_sub_constituent_item_data[local_id] = 0;
235 m_component_id_data[local_id] = -1;
236 m_global_item_local_id_data[local_id] = NULL_ITEM_LOCAL_ID;
237 m_super_component_item_local_id_data[local_id] = {};
245 ItemSharedInfo* m_item_shared_info = ItemSharedInfo::nullInstance();
246 Int16 m_level = (-1);
257namespace Arcane::Materials::matimpl
271class ARCANE_CORE_EXPORT ConstituentItemBase
277 friend Arcane::Materials::AllEnvData;
278 friend Arcane::Materials::MeshMaterialMng;
281 friend Arcane::Materials::MeshEnvironment;
282 friend Arcane::Materials::MeshComponentData;
283 friend Arcane::Materials::ComponentItemInternalData;
288 : m_constituent_item_index(id)
289 , m_shared_info(shared_info)
296 ARCCORE_HOST_DEVICE MatVarIndex variableIndex()
const
298 return m_shared_info->_varIndex(m_constituent_item_index);
301 ARCCORE_HOST_DEVICE ConstituentItemIndex constituentItemIndex()
const
303 return m_constituent_item_index;
307 ARCCORE_HOST_DEVICE Int32 componentId()
const
309 return m_shared_info->_componentId(m_constituent_item_index);
313 inline ARCCORE_HOST_DEVICE
constexpr bool null()
const
315 return m_constituent_item_index.isNull();
324 inline IMeshComponent* component()
const
326 return m_shared_info->_component(m_constituent_item_index);
330 ARCCORE_HOST_DEVICE Int32 nbSubItem()
const
332 return m_shared_info->_nbSubConstituent(m_constituent_item_index);
336 inline impl::ItemBase globalItemBase()
const
338 return m_shared_info->_globalItemBase(m_constituent_item_index);
341 inline ARCCORE_HOST_DEVICE
constexpr Int32 level()
const
343 return m_shared_info->m_level;
347 inline Int64 componentUniqueId()
const
349 return m_shared_info->_componentUniqueId(m_constituent_item_index);
354 ARCCORE_HOST_DEVICE
constexpr friend bool
355 operator==(
const ConstituentItemBase& a,
const ConstituentItemBase& b)
357 return ((a.m_constituent_item_index == b.m_constituent_item_index) && (a.m_shared_info == b.m_shared_info));
359 ARCCORE_HOST_DEVICE
constexpr friend bool
360 operator!=(
const ConstituentItemBase& a,
const ConstituentItemBase& b)
368 ARCCORE_HOST_DEVICE
inline void _setVariableIndex(MatVarIndex index)
370 m_shared_info->_setVarIndex(m_constituent_item_index, index);
374 ARCCORE_HOST_DEVICE
inline matimpl::ConstituentItemBase _superItemBase()
const;
376 ARCCORE_HOST_DEVICE
inline void _setSuperAndGlobalItem(ConstituentItemIndex cii, ItemLocalId ii)
378 m_shared_info->_setSuperItem(m_constituent_item_index, cii);
379 m_shared_info->_setGlobalItem(m_constituent_item_index, ii);
382 ARCCORE_HOST_DEVICE
inline void _setGlobalItem(ItemLocalId ii)
384 m_shared_info->_setGlobalItem(m_constituent_item_index, ii);
388 inline ARCCORE_HOST_DEVICE ConstituentItemIndex _firstSubItemLocalId()
const
390 return m_shared_info->_firstSubConstituentLocalId(m_constituent_item_index);
393 inline ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _subItemBase(Int32 i)
const;
396 ARCCORE_HOST_DEVICE
void _setNbSubItem(Int16 nb_sub_item)
398 m_shared_info->_setNbSubConstituent(m_constituent_item_index, nb_sub_item);
402 ARCCORE_HOST_DEVICE
void _setFirstSubItem(ConstituentItemIndex first_sub_item)
404 m_shared_info->_setFirstSubConstituentLocalId(m_constituent_item_index, first_sub_item);
407 ARCCORE_HOST_DEVICE
void _setComponent(Int16 component_id)
409 m_shared_info->_setComponentId(m_constituent_item_index, component_id);
414 ConstituentItemIndex m_constituent_item_index;
415 ComponentItemSharedInfo* m_shared_info = ComponentItemSharedInfo::null_shared_info_pointer;
432inline constexpr matimpl::ConstituentItemBase ComponentItemSharedInfo::
433_item(ConstituentItemIndex
id)
435 return matimpl::ConstituentItemBase(
this,
id);
438ARCCORE_HOST_DEVICE
inline matimpl::ConstituentItemBase ComponentItemSharedInfo::
439_superItemBase(ConstituentItemIndex
id)
const
441 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
442 ConstituentItemIndex super_local_id(m_super_component_item_local_id_data[
id.localId()]);
443 return m_super_component_item_shared_info->_item(super_local_id);
446inline ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase ComponentItemSharedInfo::
447_subItemBase(ConstituentItemIndex
id,Int32 sub_index)
const
449 ARCCORE_CHECK_RANGE(
id.localId(), -1, m_storage_size);
450 ConstituentItemIndex lid(m_first_sub_constituent_item_id_data[
id.localId()].localId() + sub_index);
451 return m_sub_component_item_shared_info->_item(lid);
457inline ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase matimpl::ConstituentItemBase::
458_superItemBase()
const
460 return m_shared_info->_superItemBase(m_constituent_item_index);
463inline ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase matimpl::ConstituentItemBase::
464_subItemBase(Int32 i)
const
466 return m_shared_info->_subItemBase(m_constituent_item_index, i);
479class ARCANE_CORE_EXPORT ConstituentItemLocalIdListView
481 friend class ConstituentItemLocalIdList;
482 friend class ComponentItemVectorView;
483 friend class MeshComponentPartData;
484 friend class ComponentPartItemVectorView;
485 friend class ComponentPartCellEnumerator;
486 friend class ComponentCellEnumerator;
487 friend class MeshEnvironment;
491 ConstituentItemLocalIdListView() =
default;
492 ConstituentItemLocalIdListView(ComponentItemSharedInfo* shared_info,
493 ConstArrayView<ConstituentItemIndex> ids)
494 : m_component_shared_info(shared_info)
504 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _constituenItemBase(Int32 index)
const
506 return m_component_shared_info->_item(m_ids[index]);
508 MatVarIndex _matVarIndex(Int32 index)
const
510 return m_component_shared_info->_varIndex(m_ids[index]);
512 ConstituentItemLocalIdListView _subView(Int32 begin, Int32 size)
const
514 return { m_component_shared_info, m_ids.subView(begin, size) };
517 bool _isSamePointerData(
const ConstituentItemLocalIdListView& rhs)
const
519 return (m_ids.data() == rhs.m_ids.data());
521 friend bool operator==(
const ConstituentItemLocalIdListView& a,
522 const ConstituentItemLocalIdListView& b)
524 bool t1 = a.m_component_shared_info == b.m_component_shared_info;
525 bool t2 = a.m_ids == b.m_ids;
528 friend bool operator!=(
const ConstituentItemLocalIdListView& a,
529 const ConstituentItemLocalIdListView& b)
539 ComponentItemSharedInfo* m_component_shared_info =
nullptr;
540 ConstArrayView<ConstituentItemIndex> m_ids;
544 void _checkCoherency()
const;
Classe de base pour les entités du maillage.
ItemUniqueId uniqueId() const
Numéro unique de l'entité
Index d'un Item dans une variable.
Maille arcane avec info matériaux et milieux.
Enumérateur sur les constituants d'une maille.
Conversion de 'Cell' en 'AllEnvCell'.
Représente un composant d'une maille multi-matériau.
Conteneur pour les données des constituants.
Maille arcane d'un milieu.
Interface d'un composant (matériau ou milieu) d'un maillage.
Représente un matériau d'une maille multi-matériau.
Représente un index sur les variables matériaux et milieux.
Vue constante d'un tableau de type T.
Active toujours les traces dans les parties Arcane concernant les matériaux.
std::ostream & operator<<(std::ostream &ostr, eItemKind item_kind)
Opérateur de sortie sur un flot.