Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ConstituentItemBase.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* ConstituentItemBase.h (C) 2000-2024 */
9/* */
10/* General information about a constituent entity. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MATERIALS_CONSTITUENTITEMBASE_H
13#define ARCANE_CORE_MATERIALS_CONSTITUENTITEMBASE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/ItemInternal.h"
18#include "arcane/core/Item.h"
19#include "arcane/core/materials/ConstituentItemLocalId.h"
20#include "arcane/core/materials/ComponentItemInternal.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::Materials::matimpl
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
40class ARCANE_CORE_EXPORT ConstituentItemBase
41{
42 friend ComponentCell;
43 friend AllEnvCell;
44 friend EnvCell;
45 friend MatCell;
46 friend AllEnvData;
47 friend MeshMaterialMng;
48 friend ComponentItemSharedInfo;
49
50 friend MeshEnvironment;
51 friend MeshComponentData;
52 friend ComponentItemInternalData;
53
54 private:
55
56 ARCCORE_HOST_DEVICE constexpr ConstituentItemBase(ComponentItemSharedInfo* shared_info, ConstituentItemIndex id)
57 : m_constituent_item_index(id)
58 , m_shared_info(shared_info)
59 {
60 }
61
62 public:
63
65 ARCCORE_HOST_DEVICE MatVarIndex variableIndex() const
66 {
67 return m_shared_info->_varIndex(m_constituent_item_index);
68 }
69
70 ARCCORE_HOST_DEVICE ConstituentItemIndex constituentItemIndex() const
71 {
72 return m_constituent_item_index;
73 }
74
76 ARCCORE_HOST_DEVICE Int32 componentId() const
77 {
78 return m_shared_info->_componentId(m_constituent_item_index);
79 }
80
82 inline ARCCORE_HOST_DEVICE constexpr bool null() const
83 {
84 return m_constituent_item_index.isNull();
85 }
86
93 inline IMeshComponent* component() const
94 {
95 return m_shared_info->_component(m_constituent_item_index);
96 }
97
99 ARCCORE_HOST_DEVICE Int32 nbSubItem() const
100 {
101 return m_shared_info->_nbSubConstituent(m_constituent_item_index);
102 }
103
105 inline impl::ItemBase globalItemBase() const
106 {
107 return m_shared_info->_globalItemBase(m_constituent_item_index);
108 }
109
110 inline ARCCORE_HOST_DEVICE constexpr Int32 level() const
111 {
112 return m_shared_info->m_level;
113 }
114
117 {
118 return m_shared_info->_componentUniqueId(m_constituent_item_index);
119 }
120
121 public:
122
123 ARCCORE_HOST_DEVICE constexpr friend bool
124 operator==(const ConstituentItemBase& a, const ConstituentItemBase& b)
125 {
126 return ((a.m_constituent_item_index == b.m_constituent_item_index) && (a.m_shared_info == b.m_shared_info));
127 }
128 ARCCORE_HOST_DEVICE constexpr friend bool
129 operator!=(const ConstituentItemBase& a, const ConstituentItemBase& b)
130 {
131 return !(a == b);
132 }
133
134 private:
135
137 ARCCORE_HOST_DEVICE inline void _setVariableIndex(MatVarIndex index)
138 {
139 m_shared_info->_setVarIndex(m_constituent_item_index, index);
140 }
141
143 ARCCORE_HOST_DEVICE inline matimpl::ConstituentItemBase _superItemBase() const;
144
145 ARCCORE_HOST_DEVICE inline void _setSuperAndGlobalItem(ConstituentItemIndex cii, ItemLocalId ii)
146 {
147 m_shared_info->_setSuperItem(m_constituent_item_index, cii);
148 m_shared_info->_setGlobalItem(m_constituent_item_index, ii);
149 }
150
151 ARCCORE_HOST_DEVICE inline void _setGlobalItem(ItemLocalId ii)
152 {
153 m_shared_info->_setGlobalItem(m_constituent_item_index, ii);
154 }
155
157 inline ARCCORE_HOST_DEVICE ConstituentItemIndex _firstSubItemLocalId() const
158 {
159 return m_shared_info->_firstSubConstituentLocalId(m_constituent_item_index);
160 }
161
162 inline ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _subItemBase(Int32 i) const;
163
165 ARCCORE_HOST_DEVICE void _setNbSubItem(Int16 nb_sub_item)
166 {
167 m_shared_info->_setNbSubConstituent(m_constituent_item_index, nb_sub_item);
168 }
169
171 ARCCORE_HOST_DEVICE void _setFirstSubItem(ConstituentItemIndex first_sub_item)
172 {
173 m_shared_info->_setFirstSubConstituentLocalId(m_constituent_item_index, first_sub_item);
174 }
175
176 ARCCORE_HOST_DEVICE void _setComponent(Int16 component_id)
177 {
178 m_shared_info->_setComponentId(m_constituent_item_index, component_id);
179 }
180
181 private:
182
183 ConstituentItemIndex m_constituent_item_index;
184 ComponentItemSharedInfo* m_shared_info = ComponentItemSharedInfo::null_shared_info_pointer;
185};
186
187/*---------------------------------------------------------------------------*/
188/*---------------------------------------------------------------------------*/
189
190} // namespace Arcane::Materials::matimpl
191
192/*---------------------------------------------------------------------------*/
193/*---------------------------------------------------------------------------*/
194
195namespace Arcane::Materials
196{
197
198/*---------------------------------------------------------------------------*/
199/*---------------------------------------------------------------------------*/
200
201inline constexpr matimpl::ConstituentItemBase ComponentItemSharedInfo::
202_item(ConstituentItemIndex id)
203{
204 return matimpl::ConstituentItemBase(this, id);
205}
206
207ARCCORE_HOST_DEVICE inline matimpl::ConstituentItemBase ComponentItemSharedInfo::
208_superItemBase(ConstituentItemIndex id) const
209{
210 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
211 ConstituentItemIndex super_local_id(m_super_component_item_local_id_data[id.localId()]);
212 return m_super_component_item_shared_info->_item(super_local_id);
213}
214
215inline ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase ComponentItemSharedInfo::
216_subItemBase(ConstituentItemIndex id, Int32 sub_index) const
217{
218 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
219 ConstituentItemIndex lid(m_first_sub_constituent_item_id_data[id.localId()].localId() + sub_index);
220 return m_sub_component_item_shared_info->_item(lid);
221}
222
223/*---------------------------------------------------------------------------*/
224/*---------------------------------------------------------------------------*/
225
227_superItemBase() const
228{
229 return m_shared_info->_superItemBase(m_constituent_item_index);
230}
231
232inline ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase matimpl::ConstituentItemBase::
233_subItemBase(Int32 i) const
234{
235 return m_shared_info->_subItemBase(m_constituent_item_index, i);
236}
237
238/*---------------------------------------------------------------------------*/
239/*---------------------------------------------------------------------------*/
240
248class ARCANE_CORE_EXPORT ConstituentItemLocalIdListView
249{
250 friend class ConstituentItemLocalIdList;
251 friend class ComponentItemVectorView;
252 friend class MeshComponentPartData;
253 friend class ComponentPartItemVectorView;
254 friend class ComponentPartCellEnumerator;
255 friend class ComponentCellEnumerator;
256 friend class MeshEnvironment;
257
258 private:
259
260 ConstituentItemLocalIdListView() = default;
261 ConstituentItemLocalIdListView(ComponentItemSharedInfo* shared_info,
263 : m_component_shared_info(shared_info)
264 , m_ids(ids)
265 {
266#ifdef ARCANE_CHECK
267 _checkCoherency();
268#endif
269 }
270
271 private:
272
273 ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase _constituenItemBase(Int32 index) const
274 {
275 return m_component_shared_info->_item(m_ids[index]);
276 }
277 MatVarIndex _matVarIndex(Int32 index) const
278 {
279 return m_component_shared_info->_varIndex(m_ids[index]);
280 }
281 ConstituentItemLocalIdListView _subView(Int32 begin, Int32 size) const
282 {
283 return { m_component_shared_info, m_ids.subView(begin, size) };
284 }
286 bool _isSamePointerData(const ConstituentItemLocalIdListView& rhs) const
287 {
288 return (m_ids.data() == rhs.m_ids.data());
289 }
290 friend bool operator==(const ConstituentItemLocalIdListView& a,
292 {
293 bool t1 = a.m_component_shared_info == b.m_component_shared_info;
294 bool t2 = a.m_ids == b.m_ids;
295 return (t1 && t2);
296 }
297 friend bool operator!=(const ConstituentItemLocalIdListView& a,
299 {
300 return (!(a == b));
301 }
302
303 private:
304
305 // NOTE: This class is wrapped directly in C#.
306 // If the fields of this class are modified, the corresponding type must be modified
307 // in the wrapper.
308 ComponentItemSharedInfo* m_component_shared_info = nullptr;
309 ConstArrayView<ConstituentItemIndex> m_ids;
310
311 private:
312
313 void _checkCoherency() const;
314};
315
316/*---------------------------------------------------------------------------*/
317/*---------------------------------------------------------------------------*/
318
319} // End namespace Arcane::Materials
320
321/*---------------------------------------------------------------------------*/
322/*---------------------------------------------------------------------------*/
323
324#endif
Constant view of an array of type T.
Index of an Item in a variable.
Definition ItemLocalId.h:42
ConstituentItemIndex * m_first_sub_constituent_item_id_data
Id of the first sub-constituent entity.
ConstituentItemIndex * m_super_component_item_local_id_data
Id of the parent sub-constituent entity.
Index of a constituent entity in the list of constituent entities.
View of a ConstituentItemLocalIdList instance.
bool _isSamePointerData(const ConstituentItemLocalIdListView &rhs) const
For tests, verifies that the views point to the same data.
Interface of a component (material or environment) of a mesh.
Represents an index on material and environment variables.
General information about a constituent entity.
__host__ __device__ MatVarIndex variableIndex() const
Indexer in material variables.
IMeshComponent * component() const
Associated component.
__host__ __device__ constexpr bool null() const
Indicates if it is the null cell.
__host__ __device__ void _setVariableIndex(MatVarIndex index)
Positions the indexer in material variables.
__host__ __device__ matimpl::ConstituentItemBase _superItemBase() const
Parent component (0 if none).
__host__ __device__ ConstituentItemIndex _firstSubItemLocalId() const
First sub-component entity.
__host__ __device__ Int32 componentId() const
Component identifier.
__host__ __device__ Int32 nbSubItem() const
Number of sub-components.
__host__ __device__ void _setFirstSubItem(ConstituentItemIndex first_sub_item)
Positions the first sub-component.
__host__ __device__ void _setNbSubItem(Int16 nb_sub_item)
Positions the number of sub-components.
Int64 componentUniqueId() const
Unique ID of the component entity.
impl::ItemBase globalItemBase() const
Corresponding global entity.
Always enables tracing in Arcane parts concerning materials.
std::int64_t Int64
Signed integer type of 64 bits.
std::int16_t Int16
Signed integer type of 16 bits.
std::int32_t Int32
Signed integer type of 32 bits.