Arcane  4.1.12.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
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31/*!
32 * \brief Interface for the source of an incremental connectivity
33 */
34class ARCANE_CORE_EXPORT IIncrementalItemSourceConnectivity
35{
37
38 protected:
39
40 virtual ~IIncrementalItemSourceConnectivity() = default;
41
42 public:
43
44 //! Source family
45 virtual IItemFamily* sourceFamily() const = 0;
46
47 //TODO: use an event-based mechanism.
48 //! Notifies the connectivity that the source family has been compacted.
49 virtual void notifySourceFamilyLocalIdChanged(Int32ConstArrayView new_to_old_ids) = 0;
50
51 //! Notifies the connectivity that an entity has been added to the source family.
52 virtual void notifySourceItemAdded(ItemLocalId item) = 0;
53
54 /*!
55 * \brief Reserves memory for \a n source entities.
56 *
57 * Calling this method is optional but prevents multiple
58 * reallocations during successive calls to notifySourceItemAdded().
59 *
60 * If \a pre_alloc_connectivity is true, it also pre-allocates the list of
61 * connectivities based on the value of preAllocatedSize(). For example,
62 * if preAllocatedSize() is 4 and \a n is 10000, we will pre-allocate
63 * for 40000 connectivities. To avoid unnecessary memory overconsumption,
64 * connectivities should only be pre-allocated if we are sure we will use them.
65 */
66 virtual void reserveMemoryForNbSourceItems(Int32 n, bool pre_alloc_connectivity);
67
68 //! Notifies the connectivity that a read has been performed from a dump
69 virtual void notifyReadFromDump() = 0;
70
71 //! Returns a reference to the instance
73
74 private:
75
76 // Interfaces reserved to Arcane
77
78 //! Notifies the connectivity that the entities \a items have been added to the source family
79 virtual void _internalNotifySourceItemsAdded(Int32ConstArrayView items);
80};
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
85/*!
86 * \brief Interface for the target of an incremental connectivity
87 */
88class ARCANE_CORE_EXPORT IIncrementalItemTargetConnectivity
89{
91
92 protected:
93
94 virtual ~IIncrementalItemTargetConnectivity() = default;
95
96 public:
97
98 //TODO: use an event-based mechanism.
99 //! Notifies the connectivity that the target family has been compacted.
101
102 //! Returns a reference to the instance
104};
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
108
109/*!
110 * \brief Interface for managing an incremental connectivity.
111 *
112 * A connectivity links two families: a source (sourceFamily()) and
113 * a target (targetFamily()).
114 */
115class ARCANE_CORE_EXPORT IIncrementalItemConnectivity
119{
121
122 public:
123
124 //TODO make 'protected' once everyone uses the reference counter
126
127 public:
128
129 //! Name of the connectivity
130 virtual String name() const = 0;
131
132 //! List of families (sourceFamily() + targetFamily())
134
135 //! Target family
136 virtual IItemFamily* targetFamily() const = 0;
137
138 //! Adds the entity with localId() \a target_local_id to the connectivity of \a source_item
139 virtual void addConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id) = 0;
140
141 /*!
142 * \brief Allocates and positions entities connected to \a source_item.
143 *
144 * If there were already entities connected to \a source_item, they are removed.
145 * \a target_local_ids contains the list of local IDs of entities to add.
146 * This method is equivalent to calling the following code but allows for memory
147 * management optimizations:
148 * \code
149 * IIncrementalItemConnectivity* c = ...;
150 * c->removeConnectedItems(source_item);
151 * for( Int32 x : target_local_ids )
152 * c->addConnectedItem(source_item,ItemLocalId{x});
153 * \endcode
154 */
155 virtual void setConnectedItems(ItemLocalId source_item, Int32ConstArrayView target_local_ids);
156
157 //! Removes the entity with localId() \a target_local_id from the connectivity of \a source_item
158 virtual void removeConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id) = 0;
159
160 //! Removes all entities connected to \a source_item
161 virtual void removeConnectedItems(ItemLocalId source_item) = 0;
162
163 //! Replaces the entity at index \a index of \a source_item with the entity with localId() \a target_local_id
164 virtual void replaceConnectedItem(ItemLocalId source_item, Integer index, ItemLocalId target_local_id) = 0;
165
166 //! Replaces the entities of \a source_item with the entities with localId() \a target_local_ids
167 virtual void replaceConnectedItems(ItemLocalId source_item, Int32ConstArrayView target_local_ids) = 0;
168
169 //! Tests the existence of a connectivity between \a source_item and the entity with localId() \a target_local_id
170 virtual bool hasConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id) const = 0;
171
172 /*!
173 * \brief Maximum number of entities connected to a source entity.
174 *
175 * This value may be greater than the current maximum number of connected entities
176 * if removeConnectedItem() and removeConnectedItems() have been called.
177 */
178 virtual Int32 maxNbConnectedItem() const = 0;
179
180 //! Number of entities pre-allocated for the connectivity of each entity
181 virtual Integer preAllocatedSize() const = 0;
182
183 //! Sets the number of entities to pre-allocate for the connectivity of each entity
184 virtual void setPreAllocatedSize(Integer value) = 0;
185
186 //! Dumps statistics on usage and memory used to the stream \a out
187 virtual void dumpStats(std::ostream& out) const = 0;
188
189 //! Internal Arcane API
190 virtual IIncrementalItemConnectivityInternal* _internalApi() = 0;
191};
192
193/*---------------------------------------------------------------------------*/
194/*---------------------------------------------------------------------------*/
195
196} // End namespace Arcane
197
198/*---------------------------------------------------------------------------*/
199/*---------------------------------------------------------------------------*/
200
201#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:83
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:482
std::int32_t Int32
Signed integer type of 32 bits.