Arcane  4.1.11.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
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)
Enumérateur générique d'un groupe de noeuds.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Gère la récupération des informations de connectivité.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
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 pour gérer une connectivité.
virtual IItemFamily * sourceFamily() const =0
Famille source.
Interface d'une famille d'entités.
Definition IItemFamily.h:84
virtual IVariableSynchronizer * allItemsSynchronizer()=0
Synchroniseur sur toutes les entités de la famille.
virtual ItemVectorView view(Int32ConstArrayView local_ids)=0
Vue sur les entités.
virtual Int32 commSize() const =0
Nombre d'instance dans le communicateur.
Interface d'un service de synchronisation de variable.
virtual Int32ConstArrayView communicatingRanks()=0
Rangs des sous-domaines avec lesquels on communique.
virtual IParallelMng * parallelMng()=0
Gestionnaire parallèle associé
virtual Int32ConstArrayView sharedItems(Int32 index)=0
Liste des ids locaux des entités partagées avec un sous-domaine.
Vue sur un vecteur d'entités.
Chaîne de caractères unicode.
Int32 Integer
Type représentant un entier.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:482
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:480
SharedArray< Int32 > Int32SharedArray
Tableau dynamique à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:381
Array< Int32 > Int32Array
Tableau dynamique à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:127