Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ItemConnectivityContainerView.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/* ItemConnectivityContainerView.h (C) 2000-2026 */
9/* */
10/* Views of containers holding connectivity. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITEMCONNECTIVITYCONTAINERVIEW_H
13#define ARCANE_CORE_ITEMCONNECTIVITYCONTAINERVIEW_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/Span.h"
18
20#include "arcane/core/ItemLocalId.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::mesh
26{
28}
29
30namespace Arcane
31{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
43class ARCANE_CORE_EXPORT ItemConnectivityContainerView
44{
45 // List of classes that have the right to create or directly retrieve
46 // instances of this class
47 friend ItemInternalConnectivityList;
48 friend IndexedItemConnectivityViewBase;
49 friend IndexedItemConnectivityViewBase2;
51 template <typename ItemType1, typename ItemType2>
52 friend class IndexedItemConnectivityGenericViewT;
53
54 private:
55
56 ItemConnectivityContainerView() = default;
57 ItemConnectivityContainerView(SmallSpan<Int32> _list,
59 SmallSpan<const Int32> _nb_connected_item)
60 : m_list_data(_list.data())
61 , m_indexes(_indexes.data())
62 , m_nb_connected_items(_nb_connected_item.data())
63 , m_list_data_size(_list.size())
64 , m_nb_item(_nb_connected_item.size())
65 {
66#ifdef ARCANE_CHECK
67 _checkSize(_indexes.size(), _nb_connected_item.size());
68#endif
69 }
70
71 public:
72
78 void checkSame(ItemConnectivityContainerView rhs) const;
79
80 private:
81
83 template <typename ItemType> constexpr ARCCORE_HOST_DEVICE
86 {
87 ARCANE_CHECK_AT(lid.localId(), m_nb_item);
88 Int32 x = m_indexes[lid];
89 ARCANE_CHECK_AT(x, m_list_data_size);
90 auto* p = &m_list_data[x];
91 // TODO: LOCAL_ID_OFFSET
92 return { p, m_nb_connected_items[lid], 0 };
93 }
94
96 template <typename ItemLocalIdType> constexpr ARCCORE_HOST_DEVICE
97 ItemLocalIdType
98 itemId(ItemLocalId lid, Int32 index) const
99 {
100 ARCANE_CHECK_AT(lid.localId(), m_nb_item);
101 Int32 x = m_indexes[lid] + index;
102 ARCANE_CHECK_AT(x, m_list_data_size);
103 return ItemLocalIdType(m_list_data[x]);
104 }
105
107 constexpr ARCCORE_HOST_DEVICE SmallSpan<const Int32>
108 indexes() const { return { m_indexes, m_nb_item }; }
109
111 constexpr ARCCORE_HOST_DEVICE SmallSpan<const Int32>
112 nbConnectedItems() const { return { m_nb_connected_items, m_nb_item }; }
113
115 constexpr ARCCORE_HOST_DEVICE Int32 nbItem() const { return m_nb_item; }
116
117 private:
118
119 Int32* m_list_data = nullptr;
120 const Int32* m_indexes = nullptr;
121 const Int32* m_nb_connected_items = nullptr;
122 Int32 m_list_data_size = 0;
123 Int32 m_nb_item = 0;
124
125 private:
126
127 void _checkSize(Int32 indexes_size, Int32 nb_connected_item_size);
128
129 private:
130
132 // Only to position the cell a particle belongs to
133 ARCCORE_HOST_DEVICE void _setParticleCellId(ItemLocalId particle_lid, CellLocalId cell_lid) const
134 {
135 ARCANE_CHECK_AT(particle_lid.localId(), m_nb_item);
136 m_list_data[m_indexes[particle_lid]] = cell_lid;
137 }
138};
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
143} // End namespace Arcane
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
147
148#endif
Declarations of types on entities.
Types and functions associated with the classes SpanImpl, SmallSpan and Span.
constexpr __host__ __device__ Int32 nbItem() const
Number of entities.
constexpr __host__ __device__ SmallSpan< const Int32 > nbConnectedItems() const
Array of the number of entities connected to another entity.
void checkSame(ItemConnectivityContainerView rhs) const
Checks that the two instances this and rhs have the same values.
constexpr __host__ __device__ ItemLocalIdType itemId(ItemLocalId lid, Int32 index) const
index-th entity connected to the entity with localId() lid
constexpr __host__ __device__ ItemLocalIdListViewT< ItemType > itemsIds(ItemLocalId lid) const
List of entities connected to the entity with localId() lid.
constexpr __host__ __device__ SmallSpan< const Int32 > indexes() const
Array of indices in the connectivity table.
Connectivity information, for an entity family, allowing transition between old and new connectivity ...
Typed view over a list of connectivity entities.
Index of an Item in a variable.
Definition ItemLocalId.h:42
Editable view of Particle->Cell connectivity.
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
Base class for incremental item->item[] connectivities.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int32_t Int32
Signed integer type of 32 bits.