Arcane  4.2.3.0
User documentation
Loading...
Searching...
No Matches
IIncrementalItemConnectivity.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/* IIncrementalItemConnectivity.h (C) 2000-2024 */
9/* */
10/* Incremental entity connectivity interface. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_IINCREMENTALITEMCONNECTIVITY_H
13#define ARCANE_CORE_IINCREMENTALITEMCONNECTIVITY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/ArrayView.h"
18
20#include "arcane/core/IItemConnectivityAccessor.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::mesh
26{
27class ItemFamily;
28}
29
30namespace Arcane
31{
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36/*!
37 * \brief Interface for the source of an incremental connectivity
38 */
39class ARCANE_CORE_EXPORT IIncrementalItemSourceConnectivity
40{
42
43 //! For access to _internalNotifySourceItemsAdded() when a family allocates a batch
44 friend class mesh::ItemFamily;
45
46 protected:
47
48 virtual ~IIncrementalItemSourceConnectivity() = default;
49
50 public:
51
52 //! Source family
53 virtual IItemFamily* sourceFamily() const = 0;
54
55 //TODO: use an event-based mechanism.
56 //! Notifies the connectivity that the source family has been compacted.
57 virtual void notifySourceFamilyLocalIdChanged(Int32ConstArrayView new_to_old_ids) = 0;
58
59 //! Notifies the connectivity that an entity has been added to the source family.
60 virtual void notifySourceItemAdded(ItemLocalId item) = 0;
61
62 /*!
63 * \brief Reserves memory for \a n source entities.
64 *
65 * Calling this method is optional but prevents multiple
66 * reallocations during successive calls to notifySourceItemAdded().
67 *
68 * If \a pre_alloc_connectivity is true, it also pre-allocates the list of
69 * connectivities based on the value of preAllocatedSize(). For example,
70 * if preAllocatedSize() is 4 and \a n is 10000, we will pre-allocate
71 * for 40000 connectivities. To avoid unnecessary memory overconsumption,
72 * connectivities should only be pre-allocated if we are sure we will use them.
73 */
74 virtual void reserveMemoryForNbSourceItems(Int32 n, bool pre_alloc_connectivity);
75
76 //! Notifies the connectivity that a read has been performed from a dump
77 virtual void notifyReadFromDump() = 0;
78
79 //! Returns a reference to the instance
81
82 private:
83
84 // Interfaces reserved to Arcane
85
86 //! Notifies the connectivity that the entities \a items have been added to the source family
87 virtual void _internalNotifySourceItemsAdded(Int32ConstArrayView items);
88};
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
93/*!
94 * \brief Interface for the target of an incremental connectivity
95 */
96class ARCANE_CORE_EXPORT IIncrementalItemTargetConnectivity
97{
99
100 protected:
101
102 virtual ~IIncrementalItemTargetConnectivity() = default;
103
104 public:
105
106 //TODO: use an event-based mechanism.
107 //! Notifies the connectivity that the target family has been compacted.
109
110 //! Returns a reference to the instance
112};
113
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
117/*!
118 * \brief Interface for managing an incremental connectivity.
119 *
120 * A connectivity links two families: a source (sourceFamily()) and
121 * a target (targetFamily()).
122 */
123class ARCANE_CORE_EXPORT IIncrementalItemConnectivity
127{
129
130 public:
131
132 //TODO make 'protected' once everyone uses the reference counter
134
135 public:
136
137 //! Name of the connectivity
138 virtual String name() const = 0;
139
140 //! List of families (sourceFamily() + targetFamily())
142
143 //! Target family
144 virtual IItemFamily* targetFamily() const = 0;
145
146 //! Adds the entity with localId() \a target_local_id to the connectivity of \a source_item
147 virtual void addConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id) = 0;
148
149 /*!
150 * \brief Allocates and positions entities connected to \a source_item.
151 *
152 * If there were already entities connected to \a source_item, they are removed.
153 * \a target_local_ids contains the list of local IDs of entities to add.
154 * This method is equivalent to calling the following code but allows for memory
155 * management optimizations:
156 * \code
157 * IIncrementalItemConnectivity* c = ...;
158 * c->removeConnectedItems(source_item);
159 * for( Int32 x : target_local_ids )
160 * c->addConnectedItem(source_item,ItemLocalId{x});
161 * \endcode
162 */
163 virtual void setConnectedItems(ItemLocalId source_item, Int32ConstArrayView target_local_ids);
164
165 //! Removes the entity with localId() \a target_local_id from the connectivity of \a source_item
166 virtual void removeConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id) = 0;
167
168 //! Removes all entities connected to \a source_item
169 virtual void removeConnectedItems(ItemLocalId source_item) = 0;
170
171 //! Replaces the entity at index \a index of \a source_item with the entity with localId() \a target_local_id
172 virtual void replaceConnectedItem(ItemLocalId source_item, Integer index, ItemLocalId target_local_id) = 0;
173
174 //! Replaces the entities of \a source_item with the entities with localId() \a target_local_ids
175 virtual void replaceConnectedItems(ItemLocalId source_item, Int32ConstArrayView target_local_ids) = 0;
176
177 //! Tests the existence of a connectivity between \a source_item and the entity with localId() \a target_local_id
178 virtual bool hasConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id) const = 0;
179
180 /*!
181 * \brief Maximum number of entities connected to a source entity.
182 *
183 * This value may be greater than the current maximum number of connected entities
184 * if removeConnectedItem() and removeConnectedItems() have been called.
185 */
186 virtual Int32 maxNbConnectedItem() const = 0;
187
188 //! Number of entities pre-allocated for the connectivity of each entity
189 virtual Integer preAllocatedSize() const = 0;
190
191 //! Sets the number of entities to pre-allocate for the connectivity of each entity
192 virtual void setPreAllocatedSize(Integer value) = 0;
193
194 //! Dumps statistics on usage and memory used to the stream \a out
195 virtual void dumpStats(std::ostream& out) const = 0;
196
197 //! Internal Arcane API
198 virtual IIncrementalItemConnectivityInternal* _internalApi() = 0;
199};
200
201/*---------------------------------------------------------------------------*/
202/*---------------------------------------------------------------------------*/
203
204} // End namespace Arcane
205
206/*---------------------------------------------------------------------------*/
207/*---------------------------------------------------------------------------*/
208
209#endif
Declarations of types on entities.
#define ARCCORE_DECLARE_REFERENCE_COUNTED_INCLASS_METHODS()
Macro to declare the virtual methods managing reference counters.
Constant view of an array of type T.
Interface for managing an incremental connectivity.
virtual bool hasConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id) const =0
Tests the existence of a connectivity between source_item and the entity with localId() target_local_...
virtual void replaceConnectedItem(ItemLocalId source_item, Integer index, ItemLocalId target_local_id)=0
Replaces the entity at index index of source_item with the entity with localId() target_local_id.
virtual String name() const =0
Name of the connectivity.
virtual void dumpStats(std::ostream &out) const =0
Dumps statistics on usage and memory used to the stream out.
virtual ConstArrayView< IItemFamily * > families() const =0
List of families (sourceFamily() + targetFamily()).
virtual void replaceConnectedItems(ItemLocalId source_item, Int32ConstArrayView target_local_ids)=0
Replaces the entities of source_item with the entities with localId() target_local_ids.
virtual void removeConnectedItems(ItemLocalId source_item)=0
Removes all entities connected to source_item.
virtual void removeConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id)=0
Removes the entity with localId() target_local_id from the connectivity of source_item.
virtual void addConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id)=0
Adds the entity with localId() target_local_id to the connectivity of source_item.
virtual IItemFamily * targetFamily() const =0
Target family.
virtual IIncrementalItemConnectivityInternal * _internalApi()=0
Internal Arcane API.
virtual Int32 maxNbConnectedItem() const =0
Maximum number of entities connected to a source entity.
virtual void setConnectedItems(ItemLocalId source_item, Int32ConstArrayView target_local_ids)
Allocates and positions entities connected to source_item.
virtual void setPreAllocatedSize(Integer value)=0
Sets the number of entities to pre-allocate for the connectivity of each entity.
virtual Integer preAllocatedSize() const =0
Number of entities pre-allocated for the connectivity of each entity.
Interface for the source of an incremental connectivity.
virtual void notifyReadFromDump()=0
Notifies the connectivity that a read has been performed from a dump.
virtual void reserveMemoryForNbSourceItems(Int32 n, bool pre_alloc_connectivity)
Reserves memory for n source entities.
virtual IItemFamily * sourceFamily() const =0
Source family.
virtual void notifySourceFamilyLocalIdChanged(Int32ConstArrayView new_to_old_ids)=0
Notifies the connectivity that the source family has been compacted.
virtual void notifySourceItemAdded(ItemLocalId item)=0
Notifies the connectivity that an entity has been added to the source family.
virtual Ref< IIncrementalItemSourceConnectivity > toSourceReference()=0
Returns a reference to the instance.
Interface for the target of an incremental connectivity.
virtual void notifyTargetFamilyLocalIdChanged(Int32ConstArrayView old_to_new_ids)=0
Notifies the connectivity that the target family has been compacted.
virtual Ref< IIncrementalItemTargetConnectivity > toTargetReference()=0
Returns a reference to the instance.
Interface to manage access to a connectivity.
Interface of an entity family.
Definition IItemFamily.h:85
Index of an Item in a variable.
Definition ItemLocalId.h:42
Reference to an instance.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:476
std::int32_t Int32
Signed integer type of 32 bits.