14#include "arcane/mesh/ItemGroupsSynchronize.h"
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/Math.h"
20#include "arcane/core/IMesh.h"
21#include "arcane/core/IItemFamily.h"
22#include "arcane/core/VariableBuildInfo.h"
23#include "arcane/core/ItemPrinter.h"
25#include "arcane/mesh/CommonItemGroupFilterer.h"
39, m_item_family(item_family)
42 item_family->itemKind())
53, m_item_family(item_family)
56 item_family->itemKind())
64ItemGroupsSynchronize::
65~ItemGroupsSynchronize()
72void ItemGroupsSynchronize::
78 if (!group.internal()->needSynchronization())
90 ItemGroup all_items = m_item_family->allItems();
96 ARCANE_ASSERT((!group.null()), (
"Null group in ItemGroupsSynchronize"));
98 group_filterer.addGroupToFilter(group);
106 group_items.
reserve(m_item_family->maxLocalId());
108 const Integer max_aggregate_size =
110 const Integer aggregate_count =
111 (groups.
size() / max_aggregate_size) +
112 ((groups.
size() % max_aggregate_size) ? 1 : 0);
114 for (
Integer i_aggregate = 0; i_aggregate < aggregate_count; ++i_aggregate) {
115 const Integer first_group = i_aggregate * max_aggregate_size;
117 groups.
size() - first_group);
119 for (
Integer i_group = 0; i_group < current_aggregate_size; ++i_group) {
121 ItemGroup group = groups[first_group + i_group];
123 m_var[iitem] |= current_mask;
130 for (
Integer i_group = 0; i_group < current_aggregate_size; ++i_group) {
132 ItemGroup group = groups[first_group + i_group];
139 if ((m_var[iitem] & current_mask) == 0) {
140 group_items.
add(iitem.itemLocalId());
143 m_var[iitem] &= ~current_mask;
151 if ((m_var[iitem] & current_mask) != 0) {
152 group_items.
add(iitem.itemLocalId());
156 debug() <<
"Incremental synchronization for the group <" << group.
name() <<
">"
157 <<
" old=" << current_size <<
" new=" << group.
size()
158 <<
" added=" << group_items.
size() <<
" removed=" << removed_size;
164 if ((m_var[iitem] & current_mask) != 0) {
165 group_items.
add(iitem.itemLocalId());
170 debug() <<
"Direct synchronization for the group <" << group.
name() <<
">"
171 <<
" old=" << current_size <<
" new=" << group.
size();
185 for (
const ItemGroup& group : m_item_family->groups()) {
192 Integer diff = m_var.checkIfSync(10);
194 error() <<
"Group is not in sync (name=" << group.name()
195 <<
", nb_diff=" << diff <<
")";
Integer size() const
Number of elements in the vector.
void clear()
Removes the elements from the array.
void add(ConstReferenceType val)
Adds element val to the end of the array.
void reserve(Int64 new_capacity)
Reserves memory for new_capacity elements.
void clear()
Removes all elements from the collection.
Interface of an entity family.
virtual ItemGroupCollection groups() const =0
Collection of groups in this family.
bool hasInfoObserver() const
Indicates if the content of this group is observed.
ItemGroupImpl * internal() const
Returns the group implementation.
const String & name() const
Group name.
void removeItems(Int32ConstArrayView items_local_id, bool check_if_present=true)
Removes entities.
Integer size() const
Number of elements in the group.
void setItems(Int32ConstArrayView items_local_id)
Sets the entities of the group.
void addItems(Int32ConstArrayView items_local_id, bool check_if_present=true)
Adds entities.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flow for a debug message.
TraceMessage error() const
Flow for an error message.
ITraceMng * traceMng() const
Trace manager.
1D data vector with value semantics (STL style).
Parameters necessary for building a variable.
Utility class for common groups across all parts of a mesh.
void applyFiltering()
Filters the common groups.
Integer checkSynchronize()
Checks if the groups are synchronized.
ItemGroupsSynchronize(IItemFamily *item_family)
Create an instance to synchronize all groups of the family item_family.
Int32 IntAggregator
Type used for aggregating group communications.
void synchronize()
Synchronizes the groups.
__host__ __device__ Real2 min(Real2 a, Real2 b)
Returns the minimum of two Real2.
bool arcaneIsCheck()
True if running in check mode.
Collection< ItemGroup > ItemGroupCollection
Collection of mesh item groups.
Int32 Integer
Type representing an integer.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.