Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
GhostLayerFromConnectivityComputer.cc
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/* ReplicatedGhostDoFBuilder.cc (C) 2000-2017 */
9/* */
10/* Implementation of a ghost creation policy for connectivity */
11/*------------------------------------------------------------------------------*/
12/*------------------------------------------------------------------------------*/
13
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/mesh/GhostLayerFromConnectivityComputer.h"
18#include "arcane/core/IItemFamily.h"
19#include "arcane/core/IParallelMng.h"
20#include "arcane/core/IVariableSynchronizer.h"
21
22#include <algorithm>
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
29: m_connectivity(item_to_dofs)
30, m_trace_mng(m_connectivity->sourceFamily()->traceMng())
31{
32 _computeSharedItems();
33}
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38void Arcane::GhostLayerFromConnectivityComputer::
39_computeSharedItems()
40{
41 m_shared_items.clear();
42 m_shared_items_connected_items.clear();
43 // Policy: the shared items of the To family are those connected to the shared items of the from family
44 // Note here that the shared items array contains items from the To family
45 Arcane::IItemFamily* item_family = m_connectivity->sourceFamily();
46 Arcane::IVariableSynchronizer* synchronizer = item_family->allItemsSynchronizer();
47 Arcane::Int32ConstArrayView ranks = synchronizer->communicatingRanks();
48 m_shared_items.resize(synchronizer->parallelMng()->commSize());
49 m_shared_items_connected_items.resize(synchronizer->parallelMng()->commSize());
50
51 for (Arcane::Integer i = 0; i < ranks.size(); ++i) {
52 Arcane::ItemVectorView from_family_shared_items_view = item_family->view(synchronizer->sharedItems(i));
53 Arcane::ConnectivityItemVector con_items(m_connectivity);
54 Arcane::Int32Array& shared_items = m_shared_items[ranks[i]];
55 Arcane::Int32Array& shared_items_connected_items = m_shared_items_connected_items[ranks[i]];
56
57 ENUMERATE_ITEM (from_family_item, from_family_shared_items_view) {
58 ENUMERATE_ITEM (to_family_item, con_items.connectedItems(from_family_item)) {
59 shared_items.add(to_family_item.localId());
60 shared_items_connected_items.add(from_family_item.localId());
61 }
62 }
63 }
64}
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
70updateConnectivity(Int32ConstArrayView ghost_items, Int64ConstArrayView ghost_items_connected_items)
71{
72 // Very simple case : ghost_items are connected to the items to witch they where connected in their owner
73 // => ghost_items_connected items are present as ghost item in the current sub-domain
74 Arcane::Int32SharedArray ghost_items_connected_items_lids(ghost_items_connected_items.size());
75 bool do_fatal = true;
76 m_connectivity->sourceFamily()->itemsUniqueIdToLocalId(ghost_items_connected_items_lids, ghost_items_connected_items, do_fatal);
77 m_connectivity->updateConnectivity(ghost_items_connected_items_lids, ghost_items);
78}
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
86{
87 return m_connectivity->sourceFamily()->allItemsSynchronizer()->communicatingRanks();
88}
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
95sharedItems(const Integer rank, const String& family_name)
96{
97 ARCANE_ASSERT((family_name == m_connectivity->targetFamily()->name()),
98 (String::format("Error : asking shared item for the family {0} that is not the ToFamily ({1}) of the connectivity", family_name, m_connectivity->targetFamily()->name()).localstr()))
99 _computeSharedItems();
100 return m_shared_items[rank];
101}
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
108sharedItemsConnectedItems(const Integer rank, const String& family_name)
109{
110 ARCANE_ASSERT((family_name == m_connectivity->sourceFamily()->name()),
111 (String::format("Error : asking shared item connected items for the family {0} that is not the FromFamily ({1}) of the connectivity", family_name, m_connectivity->sourceFamily()->name()).localstr()))
112 return m_shared_items_connected_items[rank];
113}
114
115/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
#define ENUMERATE_ITEM(name, group)
Generic enumerator for a node group.
void add(ConstReferenceType val)
Adds element val to the end of the array.
Manages the retrieval of connectivity information.
constexpr Integer size() const noexcept
Number of elements in the array.
Int32ConstArrayView sharedItems(const Integer rank, const String &family_name)
gives the local_ids of the items of the family family_name shared for the connectivity with the rank ...
void updateConnectivity(Int32ConstArrayView ghost_items, Int64ConstArrayView ghost_items_connected_items)
updates the connectivity by connecting the added ghost items.
Int32ConstArrayView sharedItemsConnectedItems(const Integer rank, const String &family_name)
gives the local_ids of the items of the family family_name connected with the sharedItems(rank).
Int32ConstArrayView communicatingRanks()
Interface IItemConnectivityGhostPolicy.
Interface to manage connectivity.
virtual IItemFamily * sourceFamily() const =0
Source family.
Interface of an entity family.
Definition IItemFamily.h:83
virtual IVariableSynchronizer * allItemsSynchronizer()=0
Synchronizer on all entities of the family.
virtual ItemVectorView view(Int32ConstArrayView local_ids)=0
View on the entities.
virtual Int32 commSize() const =0
Number of instances in the communicator.
Interface of a variable synchronization service.
virtual Int32ConstArrayView communicatingRanks()=0
Ranks of subdomains with which communication occurs.
virtual IParallelMng * parallelMng()=0
Associated parallel manager.
virtual Int32ConstArrayView sharedItems(Int32 index)=0
List of local IDs of entities shared with a subdomain.
View on a vector of entities.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:480
SharedArray< Int32 > Int32SharedArray
Dynamic 1D array of 32-bit integers.
Definition UtilsTypes.h:381
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
Definition UtilsTypes.h:127