Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ItemGroup.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/* ItemGroup.h (C) 2000-2025 */
9/* */
10/* Mesh entity groups. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_ITEMGROUP_H
13#define ARCANE_ITEMGROUP_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/AutoRef.h"
18#include "arcane/utils/Iterator.h"
19
20#include "arcane/core/ItemGroupImpl.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33class ItemVectorView;
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39//NOTE: the more complete documentation is in ItemGroup.cc
40
50class ARCANE_CORE_EXPORT ItemGroup
51{
52 public:
53
55 ItemGroup();
56
58 // TODO: this constructor should be explicit to avoid implicit conversions
59 // but we haven't added it yet for compatibility reasons
60 /*explicit*/ ItemGroup(ItemGroupImpl* prv);
62 ItemGroup(const ItemGroup& from)
63 : m_impl(from.m_impl)
64 {}
65
67 ItemGroup& operator=(const ItemGroup& from) = default;
68
71
72 public:
73
75 inline bool null() const
76 {
77 return m_impl->null();
78 }
79
81 inline const String& name() const
82 {
83 return m_impl->name();
84 }
85
87 inline const String& fullName() const
88 {
89 return m_impl->fullName();
90 }
91
93 inline Integer size() const
94 {
95 m_impl->_checkNeedUpdateNoPadding();
96 return m_impl->size();
97 }
98
107 inline bool empty() const
108 {
109 m_impl->_checkNeedUpdateNoPadding();
110 return m_impl->empty();
111 }
112
114 inline eItemKind itemKind() const { return m_impl->itemKind(); }
115
116 public:
117
125 ItemGroupImpl* internal() const { return m_impl.get(); }
126
128 IItemFamily* itemFamily() const { return m_impl->itemFamily(); }
129
131 IMesh* mesh() const { return m_impl->mesh(); }
132
133 public:
134
135 // Items in the group owned by the subdomain
136 ItemGroup own() const;
137
138 // Items in the group not owned by the subdomain
139 ItemGroup ghost() const;
140
142 bool isOwn() const;
143
145 void setOwn(bool v);
146
147 // Items in the group lying on the boundary between two subdomains
148 // Implemented for faces only
149 ItemGroup interface() const;
150
152 NodeGroup nodeGroup() const;
153
155 EdgeGroup edgeGroup() const;
156
158 FaceGroup faceGroup() const;
159
161 CellGroup cellGroup() const;
162
169 FaceGroup innerFaceGroup() const;
170
177 FaceGroup outerFaceGroup() const;
178
181 CellGroup activeCellGroup() const;
182
184 CellGroup ownActiveCellGroup() const;
185
187 CellGroup levelCellGroup(const Integer& level) const;
188
190 CellGroup ownLevelCellGroup(const Integer& level) const;
191
197 FaceGroup activeFaceGroup() const;
198
204 FaceGroup ownActiveFaceGroup() const;
205
212 FaceGroup innerActiveFaceGroup() const;
213
220 FaceGroup outerActiveFaceGroup() const;
221
223
224 ItemGroup createSubGroup(const String& suffix, IItemFamily* family, ItemGroupComputeFunctor* functor) const;
225
227 ItemGroup findSubGroup(const String& suffix) const;
228
231 {
232 return m_impl->isLocalToSubDomain();
233 }
234
244 {
245 m_impl->setLocalToSubDomain(v);
246 }
247
257 void invalidate(bool force_recompute = false) { m_impl->invalidate(force_recompute); }
258
260 void addItems(Int32ConstArrayView items_local_id, bool check_if_present = true);
261
263 void removeItems(Int32ConstArrayView items_local_id, bool check_if_present = true);
264
266 void setItems(Int32ConstArrayView items_local_id);
267
273 void setItems(Int32ConstArrayView items_local_id, bool do_sort);
274
276 void checkValid();
277
279 void clear();
280
282 void applyOperation(IItemOperationByBasicType* operation) const;
283
285 ItemVectorView view() const;
286
288 bool isAllItems() const;
289
298 {
299 return m_impl->timestamp();
300 }
301
309 void incrementTimestamp() const;
310
313 {
314 return m_impl->localIdToIndex();
315 }
316
318 IVariableSynchronizer* synchronizer() const;
319
321 bool isAutoComputed() const;
322
324 bool hasSynchronizer() const;
325
327 bool checkIsSorted() const;
328
330 ItemVectorView _paddedView() const;
331
338 ItemVectorView _unpaddedView() const;
339
340 public:
341
343 ItemGroupImplInternal* _internalApi() const;
344
345 public:
346
348 ItemEnumerator enumerator() const;
349
350 private:
351
352 template <typename T>
355 ItemEnumerator _simdEnumerator() const;
356
357 protected:
358
361
362 protected:
363
366 {
367 return impl->itemKind() == ik ? impl : ItemGroupImpl::checkSharedNull();
368 }
369
370 ItemVectorView _view(bool do_padding) const;
371};
372
373/*---------------------------------------------------------------------------*/
374/*---------------------------------------------------------------------------*/
375
381inline bool
382operator==(const ItemGroup& g1, const ItemGroup& g2)
383{
384 return g1.internal() == g2.internal();
385}
386
394inline bool
395operator<(const ItemGroup& g1, const ItemGroup& g2)
396{
397 return g1.internal() < g2.internal();
398}
399
405inline bool
406operator!=(const ItemGroup& g1, const ItemGroup& g2)
407{
408 return g1.internal() != g2.internal();
409}
410
411/*---------------------------------------------------------------------------*/
412/*---------------------------------------------------------------------------*/
413
417template <typename T>
418class ItemGroupT
419: public ItemGroup
420{
421 public:
422
424 typedef ItemGroupT<T> ThatClass;
427
428 typedef typename TraitsType::ItemType ItemType;
429
430 typedef const ItemType* const_iterator;
431 typedef ItemType* iterator;
432 typedef ItemType value_type;
433 typedef const ItemType& const_reference;
434
435 public:
436
437 inline ItemGroupT() = default;
438 inline explicit ItemGroupT(ItemGroupImpl* from)
439 : ItemGroup(_check(from, TraitsType::kind()))
440 {}
441 inline ItemGroupT(const ItemGroup& from)
442 : ItemGroup(_check(from.internal(), TraitsType::kind()))
443 {}
444 inline ItemGroupT(const ItemGroupT<T>& from)
445 : ItemGroup(from)
446 {}
447 inline const ItemGroupT<T>& operator=(const ItemGroupT<T>& from)
448 {
449 m_impl = from.internal();
450 return (*this);
451 }
452 inline const ItemGroupT<T>& operator=(const ItemGroup& from)
453 {
454 _assign(from);
455 return (*this);
456 }
457
458 public:
459
460 ThatClass own() const
461 {
462 return ThatClass(ItemGroup::own());
463 }
464
465 ItemEnumeratorT<T> enumerator() const
466 {
467 return ItemEnumeratorT<T>::fromItemEnumerator(ItemGroup::enumerator());
468 }
469
470 protected:
471
472 void _assign(const ItemGroup& from)
473 {
474 m_impl = _check(from.internal(), TraitsType::kind());
475 }
476};
477
478/*---------------------------------------------------------------------------*/
479/*---------------------------------------------------------------------------*/
480
481} // End namespace Arcane
482
483/*---------------------------------------------------------------------------*/
484/*---------------------------------------------------------------------------*/
485
486#endif
Types and macros for iterating over mesh entities.
Declarations of types on entities.
Encapsulation of a pointer with a reference counter.
Definition AutoRef.h:43
Interface of an entity family.
Definition IItemFamily.h:83
Interface of an operator on entities sorted by type.
Interface of a variable synchronization service.
Enumerator over a list of entities.
Functor for calculating elements of a group.
Internal API of ItemGroupImpl in Arcane.
Brief: Implementation of a mesh entity group.
eItemKind itemKind() const
Type of the group. It is the type of its elements.
Reference to a group of a given kind.
Definition ItemGroup.h:420
ItemTraitsT< T > TraitsType
Type of the class containing the entity characteristics.
Definition ItemGroup.h:426
ItemGroupT< T > ThatClass
Type of this class.
Definition ItemGroup.h:424
Mesh entity group.
Definition ItemGroup.h:51
ItemEnumerator enumerator() const
Enumerator over the group entities.
Definition ItemGroup.cc:540
bool empty() const
Tests if the group is empty.
Definition ItemGroup.h:107
void setLocalToSubDomain(bool v)
Sets the boolean indicating if the group is local to the subdomain.
Definition ItemGroup.h:243
ItemGroupImpl * internal() const
Returns the group implementation.
Definition ItemGroup.h:125
static ItemGroupImpl * _check(ItemGroupImpl *impl, eItemKind ik)
Returns the group impl if it is of kind kt, the null group otherwise.
Definition ItemGroup.h:365
const String & name() const
Group name.
Definition ItemGroup.h:81
bool isLocalToSubDomain() const
True if the group is local to the subdomain.
Definition ItemGroup.h:230
void invalidate(bool force_recompute=false)
Invalidates the group.
Definition ItemGroup.h:257
Int64 timestamp() const
Definition ItemGroup.h:297
ItemGroup & operator=(const ItemGroup &from)=default
Assigns a reference to the group from to this instance.
const String & fullName() const
Group name.
Definition ItemGroup.h:87
SharedPtrT< GroupIndexTable > localIdToIndex() const
Table of local ids to a position for all entities in the group.
Definition ItemGroup.h:312
Integer size() const
Number of elements in the group.
Definition ItemGroup.h:93
IItemFamily * itemFamily() const
Entity family to which this group belongs (0 for the null group).
Definition ItemGroup.h:128
ItemGroup(const ItemGroup &from)
Constructs a reference to the group from.
Definition ItemGroup.h:62
AutoRefT< ItemGroupImpl > m_impl
Internal representation of the group.
Definition ItemGroup.h:360
eItemKind itemKind() const
Group kind. This is the kind of its elements.
Definition ItemGroup.h:114
bool null() const
true means the group is the null group
Definition ItemGroup.h:75
ItemEnumerator const_iter
Iteration range type (to be removed).
Definition ItemGroup.h:70
ItemGroup()
Constructs a null group.
Definition ItemGroup.cc:140
IMesh * mesh() const
Mesh to which this group belongs (0 for the null group).
Definition ItemGroup.h:131
ItemGroup own() const
Group equivalent to this one but containing only the local elements of the subdomain.
Definition ItemGroup.cc:182
Characteristics of mesh elements.
Definition ItemTypes.h:625
static eItemKind kind()
Entity kind.
Definition ItemTypes.h:629
View on a vector of entities.
ItemGroupT< Cell > CellGroup
Group of cells.
Definition ItemTypes.h:184
ItemGroupT< Face > FaceGroup
Group of faces.
Definition ItemTypes.h:179
ItemGroupT< Edge > EdgeGroup
Group of edges.
Definition ItemTypes.h:174
ItemGroupT< Node > NodeGroup
Group of nodes.
Definition ItemTypes.h:168
-- 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
bool operator<(const Item &item1, const Item &item2)
Compare two entities.
Definition Item.h:566
eItemKind
Mesh entity type.