Arcane  4.1.12.0
User 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{
27class IncrementalItemConnectivityBase;
28}
29
30namespace Arcane
31{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37/*!
38 * \internal
39 * \brief Views of containers holding connectivity.
40 * This class allows the containers used to be opaque outside of Arcane
41 * to facilitate their eventual change.
42 */
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;
50 friend mesh::IncrementalItemConnectivityBase;
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
73 /*!
74 * \brief Checks that the two instances \a this and \a rhs have the same values.
75 *
76 * Throws a FatalErrorException if not.
77 */
78 void checkSame(ItemConnectivityContainerView rhs) const;
79
80 private:
81
82 //! List of entities connected to the entity with localId() \a lid
83 template <typename ItemType> constexpr ARCCORE_HOST_DEVICE
85 itemsIds(ItemLocalId lid) const
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
95 //! \a index-th entity connected to the entity with localId() \a lid
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
106 //! Array of indices in the connectivity table
107 constexpr ARCCORE_HOST_DEVICE SmallSpan<const Int32>
108 indexes() const { return { m_indexes, m_nb_item }; }
109
110 //! Array of the number of entities connected to another entity.
111 constexpr ARCCORE_HOST_DEVICE SmallSpan<const Int32>
112 nbConnectedItems() const { return { m_nb_connected_items, m_nb_item }; }
113
114 //! Number of entities
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
131 friend class MutableIndexedParticleCellConnectivityView;
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.
void checkSame(ItemConnectivityContainerView rhs) const
Checks that the two instances this and rhs have the same values.
Typed view over a list of connectivity entities.
Index of an Item in a variable.
Definition ItemLocalId.h:42
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.