Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
core/materials/ComponentItem.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 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/* ComponentItem.h (C) 2000-2024 */
9/* */
10/* Entité représentant un constituant d'une maille multi-matériaux. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MATERIALS_COMPONENTITEM_H
13#define ARCANE_CORE_MATERIALS_COMPONENTITEM_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/materials/ComponentItemInternal.h"
18
19#include "arcane/Item.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane::Materials
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
51class ARCANE_CORE_EXPORT ComponentCell
52{
53 // Pour accéder à _internal()
54 friend class CellComponentCellEnumerator;
55 friend class EnvCellVector;
56 friend class MatCellVector;
57 friend class MeshMaterialMng;
58 friend class AllEnvCell;
59 friend class EnvCell;
60 friend class MatCell;
61 friend class ConstituentItemVectorImpl;
62
63 public:
64
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)
68 {}
69
70 ARCCORE_HOST_DEVICE ComponentCell()
71 {
72#ifndef ARCCORE_DEVICE_CODE
73 m_shared_info = ComponentItemSharedInfo::_nullInstance();
74#endif
75 }
76
77 public:
78
80 ARCCORE_HOST_DEVICE operator ComponentItemLocalId() const { return ComponentItemLocalId{ _varIndex() }; }
81
82 public:
83
85 ARCCORE_HOST_DEVICE MatVarIndex _varIndex() const { return m_shared_info->_varIndex(m_constituent_item_index); }
86
87 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase constituentItemBase() const { return { m_shared_info, m_constituent_item_index }; }
88
93 IMeshComponent* component() const { return m_shared_info->_component(m_constituent_item_index); }
94
96 ARCCORE_HOST_DEVICE Int32 componentId() const { return m_shared_info->_componentId(m_constituent_item_index); }
97
99 ARCCORE_HOST_DEVICE bool null() const { return m_constituent_item_index.isNull(); }
100
102 ARCCORE_HOST_DEVICE ComponentCell superCell() const { return ComponentCell(_superItemBase()); }
103
105 ARCCORE_HOST_DEVICE Int32 level() const { return m_shared_info->m_level; }
106
108 ARCCORE_HOST_DEVICE Int32 nbSubItem() const { return m_shared_info->_nbSubConstituent(m_constituent_item_index); }
109
112 {
113 return Cell(m_shared_info->_globalItemBase(m_constituent_item_index));
114 }
115
117 ARCCORE_HOST_DEVICE CellLocalId globalCellId() const
118 {
119 return CellLocalId(m_shared_info->_globalItemId(m_constituent_item_index));
120 }
121
130 Int64 componentUniqueId() const { return m_shared_info->_componentUniqueId(m_constituent_item_index); }
131
133 ARCCORE_HOST_DEVICE inline CellComponentCellEnumerator subItems() const;
134
135 protected:
136
137 static ARCCORE_HOST_DEVICE void _checkLevel([[maybe_unused]] matimpl::ConstituentItemBase item_base,
139 {
140#if !defined(ARCCORE_DEVICE_CODE)
141 if (item_base.null())
142 return;
143 Int32 lvl = item_base.level();
144 if (lvl != expected_level)
145 _badConversion(item_base, lvl, expected_level);
146#endif
147 }
148 static void _badConversion(matimpl::ConstituentItemBase item_base, Int32 level, Int32 expected_level);
149
150 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _subItemBase(Int32 index) const
151 {
152 return m_shared_info->_subItemBase(m_constituent_item_index, index);
153 }
154 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _superItemBase() const
155 {
156 return m_shared_info->_superItemBase(m_constituent_item_index);
157 }
158 ARCCORE_HOST_DEVICE ConstituentItemIndex _firstSubConstituentLocalId() const
159 {
160 return m_shared_info->_firstSubConstituentLocalId(m_constituent_item_index);
161 }
162
163 protected:
164
165 ConstituentItemIndex m_constituent_item_index;
166 ComponentItemSharedInfo* m_shared_info = nullptr;
167
168 private:
169
171 ARCCORE_HOST_DEVICE ConstituentItemIndex _constituentItemIndex() const
172 {
173 return m_constituent_item_index;
174 }
175};
176
177/*---------------------------------------------------------------------------*/
178/*---------------------------------------------------------------------------*/
182class ARCANE_CORE_EXPORT CellComponentCellEnumerator
183{
184 friend class EnumeratorTracer;
185
186 public:
187
189 {};
191 {
192 friend class CellComponentCellEnumerator;
193
194 public:
195
196 using iterator_category = std::forward_iterator_tag;
198
199 private:
200
201 ARCCORE_HOST_DEVICE explicit Iterator(CellComponentCellEnumerator enumerator)
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)
206 {}
207
208 public:
209
210 ARCCORE_HOST_DEVICE void operator++() { ++m_index; }
211 ARCCORE_HOST_DEVICE ComponentCell operator*() const
212 {
213 ARCANE_CHECK_AT(m_index, m_size);
214 return ComponentCell(_currentSubItemBase());
215 }
216 ARCCORE_HOST_DEVICE operator ComponentItemLocalId() const
217 {
218 return ComponentItemLocalId(_varIndex());
219 }
220 friend ARCCORE_HOST_DEVICE bool operator==(const Iterator& x, const Sentinel&)
221 {
222 return x.m_index == x.m_size;
223 }
224
225 private:
226
227 Int32 m_index = 0;
228 Int32 m_size = 0;
229 Int32 m_first_sub_index = -1;
230 ComponentItemSharedInfo* m_sub_constituent_shared_info = nullptr;
231
232 private:
233
234 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _currentSubItemBase() const
235 {
236 return m_sub_constituent_shared_info->_item(ConstituentItemIndex(m_first_sub_index + m_index));
237 }
238 ARCCORE_HOST_DEVICE MatVarIndex _varIndex() const
239 {
240 return m_sub_constituent_shared_info->_varIndex(ConstituentItemIndex(m_first_sub_index + m_index));
241 }
242 };
243
244 template <typename ConstituentItemType>
245 class IteratorT : public Iterator
246 {
247 public:
248
251
252 private:
253
254 ARCCORE_HOST_DEVICE explicit IteratorT(CellComponentCellEnumeratorT<ConstituentItemType> enumerator)
255 : Iterator(enumerator)
256 {}
257
258 public:
259
260 ARCCORE_HOST_DEVICE ConstituentItemType operator*() const
261 {
262 ARCANE_CHECK_AT(m_index, m_size);
263 return ConstituentItemType(_currentSubItemBase());
264 }
265 };
266
267 public:
268
269 ARCCORE_HOST_DEVICE explicit CellComponentCellEnumerator(ComponentCell super_item)
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)
273 {
274 }
275
276 public:
277
278 ARCCORE_HOST_DEVICE void operator++() { ++m_index; }
279 ARCCORE_HOST_DEVICE bool hasNext() const { return m_index < m_size; }
280
281 ARCCORE_HOST_DEVICE ComponentCell operator*() const
282 {
283 ARCANE_CHECK_AT(m_index, m_size);
284 return ComponentCell(_currentSubItemBase());
285 }
286 ARCCORE_HOST_DEVICE MatVarIndex _varIndex() const
287 {
288 return m_sub_constituent_shared_info->_varIndex(ConstituentItemIndex(m_first_sub_index + m_index));
289 }
290 ARCCORE_HOST_DEVICE Int32 index() const { return m_index; }
291 ARCCORE_HOST_DEVICE operator ComponentItemLocalId() const
292 {
293 return ComponentItemLocalId(_varIndex());
294 }
295 ARCCORE_HOST_DEVICE Iterator begin() const { return Iterator(*this); }
296 ARCCORE_HOST_DEVICE Sentinel end() const { return {}; }
297
298 protected:
299
300 Int32 m_index = 0;
301 Int32 m_size = 0;
302 Int32 m_first_sub_index = -1;
303 ComponentItemSharedInfo* m_sub_constituent_shared_info = nullptr;
304
305 protected:
306
307 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _currentSubItemBase() const
308 {
309 return m_sub_constituent_shared_info->_item(ConstituentItemIndex(m_first_sub_index + m_index));
310 }
311};
312
313/*---------------------------------------------------------------------------*/
314/*---------------------------------------------------------------------------*/
318template <typename ComponentCellType> class CellComponentCellEnumeratorT
320{
321 public:
322
324
325 public:
326
327 explicit ARCCORE_HOST_DEVICE CellComponentCellEnumeratorT(ComponentCell super_item)
329 {}
330
331 public:
332
333 ARCCORE_HOST_DEVICE ComponentCellType operator*() const
334 {
335 ARCANE_CHECK_AT(m_index, m_size);
336 return ComponentCellType(_currentSubItemBase());
337 }
338 ARCCORE_HOST_DEVICE IteratorType begin() const { return IteratorType(*this); }
339 ARCCORE_HOST_DEVICE Sentinel end() const { return {}; }
340};
341
342/*---------------------------------------------------------------------------*/
343/*---------------------------------------------------------------------------*/
344
346subItems() const
347{
348 return CellComponentCellEnumerator(*this);
349}
350
351/*---------------------------------------------------------------------------*/
352/*---------------------------------------------------------------------------*/
353
354} // End namespace Arcane::Materials
355
356/*---------------------------------------------------------------------------*/
357/*---------------------------------------------------------------------------*/
358
359#endif
Maille d'un maillage.
Definition Item.h:1178
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Maille arcane avec info matériaux et milieux.
Enumérateur typés sur les mailles composants d'une maille.
Enumérateur sur les constituants d'une maille.
Représente un composant d'une maille multi-matériau.
ARCCORE_HOST_DEVICE Int32 nbSubItem() const
Nombre de sous-éléments.
IMeshComponent * component() const
Constituant associé.
ARCCORE_HOST_DEVICE CellLocalId globalCellId() const
localId() de la maille globale
ARCCORE_HOST_DEVICE MatVarIndex _varIndex() const
ARCCORE_HOST_DEVICE CellComponentCellEnumerator subItems() const
Liste des sous-constituents de cette entité
Int64 componentUniqueId() const
Numéro unique de l'entité constituant.
ARCCORE_HOST_DEVICE Int32 componentId() const
Identifiant du composant dans la liste des composants de ce type.
ARCCORE_HOST_DEVICE ConstituentItemIndex _constituentItemIndex() const
ARCCORE_HOST_DEVICE bool null() const
Indique s'il s'agit de la maille nulle.
ARCCORE_HOST_DEVICE Int32 level() const
Niveau hiérarchique de l'entité
ARCCORE_HOST_DEVICE ComponentCell superCell() const
Maille de niveau supérieur dans la hiérarchie.
Index d'un Item matériaux dans une variable.
Informations partagées sur les 'ComponentItem'.
Index d'une entité constituant dans la liste des entités constituants.
Implémentation de ComponentItemVector.
Vecteur sur les entités d'un milieu.
Maille arcane d'un milieu.
Interface d'un composant (matériau ou milieu) d'un maillage.
Vecteur sur les entités d'un matériau.
Représente un matériau d'une maille multi-matériau.
Représente un index sur les variables matériaux et milieux.
Implémentation d'un gestion des matériaux.
Informations générique sur une entité d'un constituant.
Active toujours les traces dans les parties Arcane concernant les matériaux.