Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ItemLocalId.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/* ItemLocalId.h (C) 2000-2025 */
9/* */
10/* Local ID of a mesh entity. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITEMLOCALID_H
13#define ARCANE_CORE_ITEMLOCALID_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/ArrayView.h"
18
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26class ItemSharedInfo;
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31// TODO: deprecate constructors that take an argument
32// an ItemEnumerator
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
41class ARCANE_CORE_EXPORT ItemLocalId
42{
43 public:
44
45 ItemLocalId() = default;
46 constexpr ARCCORE_HOST_DEVICE explicit ItemLocalId(Int32 id)
47 : m_local_id(id)
48 {}
49 // The definition of this constructor is in ItemInternal.h
50 inline ItemLocalId(ItemInternal* item);
51 inline ItemLocalId(ItemConnectedEnumerator enumerator);
52 template <typename ItemType> inline ItemLocalId(ItemEnumeratorT<ItemType> enumerator);
53 template <typename ItemType> inline ItemLocalId(ItemConnectedEnumeratorT<ItemType> enumerator);
54 inline ItemLocalId(Item item);
55 constexpr ARCCORE_HOST_DEVICE operator Int32() const { return m_local_id; }
56 constexpr ARCCORE_HOST_DEVICE Int32 asInt32() const { return m_local_id; }
57 constexpr ARCCORE_HOST_DEVICE Int32 asInteger() const { return m_local_id; }
58
59 public:
60
61 constexpr ARCCORE_HOST_DEVICE Int32 localId() const { return m_local_id; }
62 constexpr ARCCORE_HOST_DEVICE bool isNull() const { return m_local_id == NULL_ITEM_LOCAL_ID; }
63
64 public:
65
67 {
68 auto* ptr = reinterpret_cast<const ItemLocalId*>(v.data());
69 return { ptr, v.size() };
70 }
72 {
73 auto* ptr = reinterpret_cast<const Int32*>(v.data());
74 return { ptr, v.size() };
75 }
76
77 private:
78
79 Int32 m_local_id = NULL_ITEM_LOCAL_ID;
80};
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
89template <typename ItemType_>
90class ItemLocalIdT
91: public ItemLocalId
92{
93 public:
94
95 using ItemType = ItemType_;
96 using ThatClass = ItemLocalIdT<ItemType>;
97
98 public:
99
100 ItemLocalIdT() = default;
101 constexpr ARCCORE_HOST_DEVICE explicit ItemLocalIdT(Int32 id)
102 : ItemLocalId(id)
103 {}
104 inline ItemLocalIdT(ItemInternal* item);
105 inline ItemLocalIdT(ItemConnectedEnumeratorT<ItemType> enumerator);
106 inline ItemLocalIdT(ItemType item);
107
108 public:
109
111 {
112 auto* ptr = reinterpret_cast<const ThatClass*>(v.data());
113 return { ptr, v.size() };
114 }
115
117 {
118 auto* ptr = reinterpret_cast<const Int32*>(v.data());
119 return { ptr, v.size() };
120 }
121
122 public:
123
124 ARCANE_DEPRECATED_REASON("Y2022: Use strongly typed 'ItemEnumeratorT<ItemType>' or 'ItemType'")
125 inline ItemLocalIdT(ItemEnumerator enumerator);
126};
127
128/*---------------------------------------------------------------------------*/
129/*---------------------------------------------------------------------------*/
130
137class ARCANE_CORE_EXPORT ItemLocalIdToItemConverter
138{
139 template <typename ItemType_> friend class ItemLocalIdToItemConverterT;
140
141 public:
142
143 explicit ItemLocalIdToItemConverter(IItemFamily* family);
152
153 public:
154
156 inline constexpr ARCCORE_HOST_DEVICE Item operator[](ItemLocalId local_id) const;
158 inline constexpr ARCCORE_HOST_DEVICE Item operator[](Int32 local_id) const;
159
160 private:
161
162 ItemSharedInfo* m_item_shared_info = nullptr;
163};
164
165/*---------------------------------------------------------------------------*/
166/*---------------------------------------------------------------------------*/
167
174template <typename ItemType_> class ItemLocalIdToItemConverterT
175: public ItemLocalIdToItemConverter
176{
177 public:
178
179 using ItemType = ItemType_;
180 using ItemLocalIdType = ItemLocalIdT<ItemType>;
181
182 public:
183
184 using ItemLocalIdToItemConverter::ItemLocalIdToItemConverter;
185
186 public:
187
189 inline constexpr ARCCORE_HOST_DEVICE ItemType operator[](ItemLocalIdType local_id) const;
191 inline constexpr ARCCORE_HOST_DEVICE ItemType operator[](Int32 local_id) const;
192};
193
194/*---------------------------------------------------------------------------*/
195/*---------------------------------------------------------------------------*/
196
205
214
223
232
241
250
251/*---------------------------------------------------------------------------*/
252/*---------------------------------------------------------------------------*/
253
254} // namespace Arcane
255
256/*---------------------------------------------------------------------------*/
257/*---------------------------------------------------------------------------*/
258
259#endif
Declarations of types on entities.
Class to convert a CellLocalId to a cell.
Cell of a mesh.
Definition Item.h:1300
Class to convert a DoFLocalId to a degree of freedom.
degree of freedom class.
Definition Item.h:1649
Class to convert an EdgeLocalId to an edge.
Edge of a cell.
Definition Item.h:875
Class to convert a FaceLocalId to a face.
Face of a cell.
Definition Item.h:1032
Interface of an entity family.
Definition IItemFamily.h:83
Enumerator over a typed list of connected entities of type ItemType.
Enumerator over a list of entities connected to another.
Enumerator over a typed list of entities of type ItemType.
Enumerator over a list of entities.
Internal structure of a mesh entity.
Index of an ItemType entity in a variable.
Definition ItemLocalId.h:92
Class to convert an ItemLocalId to an entity (Item).
constexpr __host__ __device__ ItemType operator[](ItemLocalIdType local_id) const
Entity of local ID local_id.
Definition Item.h:1924
ItemLocalIdToItemConverter()=default
Default constructor.
constexpr __host__ __device__ Item operator[](ItemLocalId local_id) const
Entity of local ID local_id.
Definition Item.h:1905
Index of an Item in a variable.
Definition ItemLocalId.h:42
Internal shared structure of a mesh entity.
Base class for a mesh element.
Definition Item.h:84
Class to convert a NodeLocalId to an edge.
Node of a mesh.
Definition Item.h:598
Class to convert a ParticleLocalId to a particle.
Particle.
Definition Item.h:1529
View of an array of elements of type T.
Definition Span.h:805
constexpr __host__ __device__ pointer data() const noexcept
Pointer to the start of the view.
Definition Span.h:539
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
Definition Span.h:327
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int32_t Int32
Signed integer type of 32 bits.