Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ItemGroupInternal.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/* ItemGroupInternal.h (C) 2000-2025 */
9/* */
10/* Internal part of ItemGroup. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_INTERNAL_ITEMGROUPINTERNAL_H
13#define ARCANE_CORE_INTERNAL_ITEMGROUPINTERNAL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
20#include "arcane/core/VariableTypes.h"
21#include "arcane/core/internal/ItemGroupImplInternal.h"
22
23#include <map>
24#include <mutex>
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Arcane
30{
31class ItemGroupImpl;
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
50class ItemGroupSubPartsByType
51{
52 public:
53
54 explicit ItemGroupSubPartsByType(ItemGroupInternal* igi);
55
56 public:
57
58 void setImpl(ItemGroupImpl* group_impl) { m_group_impl = group_impl; }
59 void clear()
60 {
61 m_children_by_type.clear();
63 }
64 void applyOperation(IItemOperationByBasicType* operation);
65 bool isUseV2ForApplyOperation() const { return m_use_v2_for_apply_operation; }
66
67 void _computeChildrenByTypeV1();
68
69 private:
70
71 void _initChildrenByTypeV2();
72 void _computeChildrenByTypeV2();
73 void _initChildrenByTypeV1();
74
75 private:
76
79
86
94
104
107
108 bool m_is_debug_apply_operation = false;
109
110 ItemGroupInternal* m_group_internal = nullptr;
111
114};
115
116/*---------------------------------------------------------------------------*/
117/*---------------------------------------------------------------------------*/
135class ItemGroupInternal
136{
137 friend class ItemGroupImplInternal;
138
139 public:
140
148 {
149 public:
150
151 class ScopedLock
152 {
153 public:
154
155 explicit ScopedLock(const CheckNeedUpdateMutex& mutex)
156 : m_update_mutex(mutex)
157 {
158 m_update_mutex._lock();
159 }
160 ~ScopedLock()
161 {
162 m_update_mutex._unlock();
163 }
164
165 private:
166
167 const CheckNeedUpdateMutex& m_update_mutex;
168 };
169
170 public:
171
173 {
174 delete m_mutex;
175 }
176 void create()
177 {
178 m_mutex = new std::mutex();
179 }
180
181 private:
182
183 std::mutex* m_mutex = nullptr;
184
185 private:
186
187 void _lock() const
188 {
189 if (m_mutex)
190 m_mutex->lock();
191 }
192 void _unlock() const
193 {
194 if (m_mutex)
195 m_mutex->unlock();
196 }
197 };
198
199 public:
200
201 ItemGroupInternal();
202 ItemGroupInternal(IItemFamily* family, const String& name);
203 ItemGroupInternal(IItemFamily* family, ItemGroupImpl* parent, const String& name);
204 ~ItemGroupInternal();
205
206 public:
207
208 const String& name() const { return m_name; }
209 const String& fullName() const { return m_full_name; }
210 bool null() const { return m_is_null; }
211 IMesh* mesh() const { return m_mesh; }
212 eItemKind kind() const { return m_kind; }
213 Integer maxLocalId() const;
214 ItemInternalList items() const;
215 ItemInfoListView itemInfoListView() const;
216
217 Int32ArrayView itemsLocalId() { return *m_items_local_id; }
218 Int32ConstArrayView itemsLocalId() const { return *m_items_local_id; }
219 Int32Array& mutableItemsLocalId() { return *m_items_local_id; }
220 VariableArrayInt32* variableItemsLocalid() { return m_variable_items_local_id; }
221
222 Int64 timestamp() const { return m_timestamp; }
223 bool isContiguous() const { return m_is_contiguous; }
224 void checkIsContiguous();
225
226 void updateTimestamp()
227 {
228 ++m_timestamp;
229 m_is_contiguous = false;
230 }
231
232 void setNeedRecompute()
233 {
234 // NOTE: normally, this value should only be set to 'true' for
235 // recalculated groups (which have a parent or for which 'm_compute_functor' is
236 // not null). However, this method is also called on the group of all entities
237 // and perhaps other groups.
238 // Changing this behavior risks impacting a lot of code, so it should be
239 // properly verified before making this modification.
240 m_need_recompute = true;
241 }
242
244 void applySimdPadding();
245
247 bool isAllItems() const { return m_is_all_items; }
248 bool isOwn() const { return m_is_own; }
249 Int32 nbItem() const { return itemsLocalId().size(); }
250 void checkValid();
251
252 public:
253
254 void _removeItems(SmallSpan<const Int32> items_local_id);
255
256 private:
257
258 void _notifyDirectRemoveItems(SmallSpan<const Int32> removed_ids, Int32 nb_remaining);
259
260 public:
261
262 ItemGroupImplInternal m_internal_api;
263 IMesh* m_mesh = nullptr;
265 ItemGroupImpl* m_parent = nullptr;
268 bool m_is_null = true;
271 bool m_is_own = false;
272
273 private:
274
276
277 public:
278
291 // FIXME we can avoid storing these groups by introducing predicates
292 // on the parent groups
299 std::map<Integer, ItemGroupImpl*> m_level_cell_group;
300 std::map<Integer, ItemGroupImpl*> m_own_level_cell_group;
301
303 std::map<String, AutoRefT<ItemGroupImpl>> m_sub_groups;
304 bool m_need_recompute = false;
306 bool m_transaction_mode = false;
309 bool m_is_all_items = false;
313
314 // Previously in DynamicMeshKindInfo
315 UniqueArray<Int32> m_items_index_in_all_group;
316
317 std::map<const void*, IItemGroupObserver*> m_observers;
318 bool m_observer_need_info = false;
319 void notifyExtendObservers(const Int32ConstArrayView* info);
320 void notifyReduceObservers(const Int32ConstArrayView* info);
321 void notifyCompactObservers(const Int32ConstArrayView* info);
322 void notifyInvalidateObservers();
323
324 void resetSubGroups();
325
326 public:
327
329 Array<Int32>* m_items_local_id = &m_local_buffer;
330 VariableArrayInt32* m_variable_items_local_id = nullptr;
331 bool m_is_contiguous = false;
333 bool m_is_print_check_simd_padding = false;
334 bool m_is_print_apply_simd_padding = false;
335 bool m_is_print_stack_apply_simd_padding = false;
336
337 public:
338
341
342 public:
343
346
347 private:
348
349 void _init();
350};
351
352/*---------------------------------------------------------------------------*/
353/*---------------------------------------------------------------------------*/
354
355} // namespace Arcane
356
357/*---------------------------------------------------------------------------*/
358/*---------------------------------------------------------------------------*/
359
360#endif
Declarations of Arcane's general types.
Memory and allocator management functions.
Base class for 1D data vectors.
Interface of an entity family.
Definition IItemFamily.h:83
Interface of an operator on entities sorted by type.
Brief: Implementation of a mesh entity group.
Mutex to protect calls to ItemGroupImpl::_checkNeedUpdate().
Implementation of the ItemGroupImpl class.
ItemGroupImpl * m_node_group
Node group.
std::map< Integer, ItemGroupImpl * > m_own_level_cell_group
Level owned cell group.
String m_full_name
Full name of the group.
String m_variable_name
Parent group (null group if none).
IMesh * m_mesh
Associated group manager.
SharedPtrT< GroupIndexTable > m_group_index_table
Hash table of item local id to its enumeration position.
ItemGroupImpl * m_interface_group
Items on the boundary of two subdomains.
bool m_is_check_simd_padding
True if the localIds are consecutive.
bool m_need_invalidate_on_recompute
True if invalidate observers must be activated upon recalculation.
bool m_need_recompute
True if the group needs to be recalculated.
eItemKind m_kind
Kind of the group entities.
ItemGroupImpl * m_inner_face_group
Inner face group.
Int64 m_timestamp
Time of the last modification.
std::map< String, AutoRefT< ItemGroupImpl > > m_sub_groups
Set of all sub-groups.
bool m_transaction_mode
True if the group is in direct transaction mode.
bool m_is_own
true if the group contains only entities owned by us.
Ref< IVariableSynchronizer > m_synchronizer
Group synchronizer.
void checkUpdateSimdPadding()
Fills the last elements of the group to have a complete SIMD vector.
bool m_observer_need_info
Synthesis of observer need for transition information.
void applySimdPadding()
Apply padding for vectorization.
ItemGroupImpl * m_ghost_group
Items not owned by the subdomain.
bool m_is_local_to_sub_domain
True if the group is local to the subdomain.
bool m_is_all_items
Indicates if it is the group of all entities.
ItemGroupImpl * m_own_group
Items owned by the subdomain.
IItemFamily * m_item_family
Associated family.
ItemGroupImpl * m_edge_group
Edge group.
ItemGroupImpl * m_face_group
Face group.
std::map< Integer, ItemGroupImpl * > m_level_cell_group
Level cell group.
Int64 m_simd_timestamp
Time of the last modification for SIMD info calculation.
Array< Int32 > * m_items_local_id
List of local IDs of the entities in this group.
std::map< const void *, IItemGroupObserver * > m_observers
localids -> index (ONLY ALLITEMS)
IFunctor * m_compute_functor
Group computation function.
bool m_is_constituent_group
Indicates if the group is associated with a constituent (IMeshComponent).
CheckNeedUpdateMutex m_check_need_update_mutex
Mutex to protect updates.
ItemGroupImpl * m_inner_active_face_group
Active inner face group.
ItemGroupImpl * m_own_active_cell_group
Active owned cell group.
bool m_is_null
true if the group is null
ItemGroupImpl * m_cell_group
Cell group.
ItemGroupImpl * m_active_cell_group
AMR.
ItemGroupImpl * m_own_active_face_group
Active owned face group.
ItemGroupImpl * m_active_face_group
Active face group.
ItemGroupSubPartsByType m_sub_parts_by_type
Sub-part of a group based on its type.
ItemGroupImpl * m_outer_active_face_group
Active outer face group.
void checkIsContiguous()
Checks that the localIds() are contiguous.
String m_name
Name of the group.
Management of sub-parts of a group based on the type of its elements.
ItemGroupImpl * m_group_impl
To be deleted when version V1 is removed.
UniqueArray< UniqueArray< Int32 > > m_children_by_type_ids
List of localIds by entity type.
bool m_use_v2_for_apply_operation
True if version 2 of the management is used for applyOperation().
Int64 m_children_by_type_ids_computed_timestamp
Timestamp indicating when the list of child ids was calculated.
UniqueArray< ItemGroupImpl * > m_children_by_type
List of children of this group by entity type.
ItemTypeId m_unique_children_type
Indicates the type of the entities in the group.
Type of an entity (Item).
Definition ItemTypeId.h:33
Reference to an instance.
1D data vector with value semantics (STL style).
VariableRefArrayT< Int32 > VariableArrayInt32
Array variable of 32-bit integer type.
MemoryAllocationOptions getAllocatorForMostlyReadOnlyData()
Default allocator for mostly read-only data.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
ConstArrayView< ItemInternal * > ItemInternalList
Type of the internal list of entities.
Definition ItemTypes.h:466
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:453
eItemKind
Mesh entity type.
@ IK_Unknown
Unknown or uninitialized mesh entity.
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
Definition UtilsTypes.h:127
std::int32_t Int32
Signed integer type of 32 bits.