14#include "arcane/mesh/ItemConnectivitySynchronizer.h"
15#include "arcane/mesh/IItemConnectivityGhostPolicy.h"
31: m_connectivity(connectivity)
32, m_ghost_policy(ghost_policy)
33, m_parallel_mng(m_connectivity->targetFamily()->
mesh()->parallelMng())
34, m_added_ghost(m_parallel_mng->commSize())
46 extra_ghost_mng.addExtraGhostItemsBuilder(
this);
47 extra_ghost_mng.computeExtraGhostItems();
54 m_data_to_send.clear();
56 m_data_to_send.resize(m_parallel_mng->commSize());
57 const Int32 my_rank = m_parallel_mng->commRank();
60 Int32Array& data_to_send = m_data_to_send[rank];
61 Int32SharedArray shared_items = m_ghost_policy->sharedItems(rank, m_connectivity->targetFamily()->name());
62 Int32SharedArray shared_items_connected_items = m_ghost_policy->sharedItemsConnectedItems(rank, m_connectivity->sourceFamily()->name());
63 _getItemToSend(shared_items, shared_items_connected_items, rank);
64 data_to_send.
add(shared_items.
size());
66 data_to_send.
addRange(shared_items_connected_items);
78 Integer nb_shared_item = ghost_item_info[0];
86 ENUMERATE_ITEM (item, m_connectivity->targetFamily()->view(shared_item_lids)) {
87 shared_item_uids[i++] = item->uniqueId().asInt64();
89 ENUMERATE_ITEM (item, m_connectivity->sourceFamily()->view(shared_item_connected_item_lids)) {
90 shared_item_connected_item_uids[j++] = item->uniqueId().asInt64();
94 buffer->
setMode(ISerializer::ModeReserve);
97 buffer->
reserveSpan(shared_item_connected_item_uids);
104 buffer->
putSpan(shared_item_uids);
105 buffer->
putSpan(shared_item_connected_item_uids);
106 buffer->
putSpan(shared_item_owners);
112void ItemConnectivitySynchronizer::
124 buffer->
getSpan(shared_item_uids);
125 buffer->
getSpan(shared_item_connected_items_uids);
126 buffer->
getSpan(shared_items_owners);
131 _removeDuplicatedValues(shared_item_uids_to_add, shared_item_owners_to_add);
135 m_connectivity->
targetFamily()->
addGhostItems(shared_item_uids_to_add, shared_item_lids_added, shared_item_owners_to_add);
140 bool do_fatal =
true;
144 m_ghost_policy->
updateConnectivity(shared_item_lids, shared_item_connected_items_uids);
150void ItemConnectivitySynchronizer::
154 Int32UniqueArray non_null_shared_items, non_null_shared_items_connected_items;
155 non_null_shared_items.
reserve(shared_items.size());
156 non_null_shared_items_connected_items.reserve(shared_items_connected_items.size());
158 for (
auto item : shared_items) {
159 if (item != NULL_ITEM_LOCAL_ID) {
160 non_null_shared_items.add(shared_items[i]);
161 non_null_shared_items_connected_items.add(shared_items_connected_items[i]);
165 shared_items.copy(non_null_shared_items);
166 shared_items_connected_items.copy(non_null_shared_items_connected_items);
169 ItemVectorView shared_items_view = m_connectivity->targetFamily()->view(shared_items);
170 for (
Integer i = 0; i < shared_items_view.size(); ++i)
171 shared_items_uids[i] = shared_items_view[i].uniqueId().asInt64();
172 std::set<Int64>& added_ghost = m_added_ghost[rank];
175 for (
Integer i = shared_items_uids.size() - 1; i >= 0; --i) {
176 if (!added_ghost.insert(shared_items_uids[i]).second) {
178 shared_items.remove(i);
179 shared_items_connected_items.remove(i);
187void ItemConnectivitySynchronizer::
191 std::set<Int64> shared_uids_set;
192 for (
Integer i = shared_item_uids.size() - 1; i >= 0; --i) {
193 if (!shared_uids_set.insert(shared_item_uids[i]).second) {
195 shared_item_uids.remove(i);
196 shared_item_owners.remove(i);
207 return m_connectivity->targetFamily()->mesh()->subDomain();
Integer size() const
Number of elements in the vector.
void addRange(ConstReferenceType val, Int64 n)
Adds n elements of value val to the end of 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.
constexpr Integer size() const noexcept
Number of elements in the array.
constexpr ConstArrayView< T > subConstView(Integer abegin, Integer asize) const noexcept
Sub-view (constant) starting from element abegin and containing asize elements.
virtual void updateConnectivity(Int32ConstArrayView ghost_items, Int64ConstArrayView ghost_items_connected_items)=0
updates the connectivity by connecting the added ghost items.
Interface to manage connectivity.
virtual IItemFamily * targetFamily() const =0
Target family.
virtual void itemsUniqueIdToLocalId(Int32ArrayView local_ids, Int64ConstArrayView unique_ids, bool do_fatal=true) const =0
Converts an array of unique numbers to local numbers.
virtual void addGhostItems(Int64ConstArrayView unique_ids, Int32ArrayView items, Int32ConstArrayView owners)=0
Allocates ghost entities.
virtual void endUpdate()=0
Notifies the end of modification of the entity list.
void reserveInt64(Int64 n)
Reserve for n Int64.
@ ModePut
The serializer expects reserve().
@ ModeGet
The serializer expects get().
virtual Int64 getInt64()=0
Retrieve a size.
virtual void allocateBuffer()=0
Allocates the serializer memory.
virtual void putSpan(Span< const Real > values)
Add the array values.
virtual void getSpan(Span< Real > values)
Retrieve the array values.
virtual void reserveSpan(eBasicDataType dt, Int64 n)=0
Reserves memory for n values of dt.
virtual void setMode(eMode new_mode)=0
Sets the current mode.
virtual void putInt64(Int64 value)=0
Add the integer value.
Interface of the subdomain manager.
void computeExtraItemsToSend()
Interface IExtraGhostItemsBuilder.
ItemConnectivitySynchronizer(IItemConnectivity *connectivity, IItemConnectivityGhostPolicy *ghost_policy)
void serializeGhostItems(ISerializer *buffer, Int32ConstArrayView ghost_item_lids)
Interface IExtraGhostItemsAdder : add extra ghost in TargetFamily.
void synchronize()
Interface IConnectivitySynchronizer.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
SharedArray< Int64 > Int64SharedArray
Dynamic 1D array of 64-bit integers.
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.
SharedArray< Int32 > Int32SharedArray
Dynamic 1D array of 32-bit integers.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
SharedArray< Integer > IntegerSharedArray
Dynamic 1D array of integers.
std::int32_t Int32
Signed integer type of 32 bits.