Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
VariableSynchronizerComputeList.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/* VariableSynchronizerComputeList.h (C) 2000-2024 */
9/* */
10/* Calculation of the list of entities to synchronize. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13#ifndef ARCANE_IMPL_INTERNAL_VARIABLESYNCHRONIZERCOMPUTELIST_H
14#define ARCANE_IMPL_INTERNAL_VARIABLESYNCHRONIZERCOMPUTELIST_H
15/*---------------------------------------------------------------------------*/
16/*---------------------------------------------------------------------------*/
17
18#include "arcane/utils/TraceAccessor.h"
19#include "arcane/utils/Array.h"
20
21#include "arcane/core/ItemGroup.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane
27{
28class IParallelMng;
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
37class ARCANE_IMPL_EXPORT VariableSynchronizerComputeList
38: public TraceAccessor
39{
40 class RankInfo
41 {
42 public:
43
44 RankInfo() = default;
45 explicit RankInfo(Int32 arank)
46 : m_rank(arank)
47 {}
48
49 public:
50
51 Int32 rank() const { return m_rank; }
52 void setRank(Int32 arank) { m_rank = arank; }
53
59 bool operator<(const RankInfo& ar) const
60 {
61 return m_rank < ar.m_rank;
62 }
63
64 private:
65
66 Int32 m_rank = A_NULL_RANK;
67 };
68
69 class GhostRankInfo
70 : public RankInfo
71 {
72 public:
73
74 GhostRankInfo() = default;
75 explicit GhostRankInfo(Int32 arank)
76 : RankInfo(arank)
77 , m_nb_item(0)
78 {}
79 GhostRankInfo(Int32 arank, Integer nb_item)
80 : RankInfo(arank)
81 , m_nb_item(nb_item)
82 {}
83
84 public:
85
86 void setInfos(Int32 arank, SharedArray<Int32>& local_ids)
87 {
88 setRank(arank);
89 m_nb_item = local_ids.size();
90 m_local_ids = local_ids;
91 }
92 Int32ConstArrayView localIds() const { return m_local_ids; }
93 Integer nbItem() const { return m_nb_item; }
94 void resize() { m_unique_ids.resize(m_nb_item); }
95 Int64ArrayView uniqueIds() { return m_unique_ids; }
96
97 private:
98
99 Integer m_nb_item = 0;
100 SharedArray<Int32> m_local_ids;
101 SharedArray<Int64> m_unique_ids;
102 };
103
104 class ShareRankInfo
105 : public RankInfo
106 {
107 public:
108
109 ShareRankInfo() = default;
110 ShareRankInfo(Int32 arank, Integer nb_item)
111 : RankInfo(arank)
112 , m_nb_item(nb_item)
113 {}
114 explicit ShareRankInfo(Int32 arank)
115 : RankInfo(arank)
116 {}
117
118 public:
119
120 void setInfos(Int32 arank, SharedArray<Int32>& local_ids)
121 {
122 setRank(arank);
123 m_nb_item = local_ids.size();
124 m_local_ids = local_ids;
125 }
126 Int32ConstArrayView localIds() const { return m_local_ids; }
127 void setLocalIds(SharedArray<Int32>& v) { m_local_ids = v; }
128 Integer nbItem() const { return m_nb_item; }
129 void resize() { m_unique_ids.resize(m_nb_item); }
130 Int64ArrayView uniqueIds() { return m_unique_ids; }
131
132 private:
133
134 Integer m_nb_item = 0;
135 SharedArray<Int32> m_local_ids;
136 SharedArray<Int64> m_unique_ids;
137 };
138
139 public:
140
141 explicit VariableSynchronizerComputeList(VariableSynchronizer* var_sync);
142
143 public:
144
145 void compute();
146
147 private:
148
149 VariableSynchronizer* m_synchronizer;
150 IParallelMng* m_parallel_mng = nullptr;
151 ItemGroup m_item_group;
152 bool m_is_verbose = false;
153 bool m_is_debug = false;
154
155 private:
156
157 void _createList(UniqueArray<SharedArray<Int32>>& boundary_items);
158 void _checkValid(ArrayView<GhostRankInfo> ghost_ranks_info,
159 ArrayView<ShareRankInfo> share_ranks_info);
160 void _printSyncList();
161};
162
163/*---------------------------------------------------------------------------*/
164/*---------------------------------------------------------------------------*/
165
166} // End namespace Arcane
167
168/*---------------------------------------------------------------------------*/
169/*---------------------------------------------------------------------------*/
170
171#endif
Integer size() const
Number of elements in the vector.
Modifiable view of an array of type T.
Interface of the parallelism manager for a subdomain.
Mesh entity group.
Definition ItemGroup.h:51
1D vector of data with reference semantics.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
1D data vector with value semantics (STL style).
bool operator<(const RankInfo &ar) const
Comparison operator. An instance is considered less than another if its associated subdomain is small...
void _createList(UniqueArray< SharedArray< Int32 > > &boundary_items)
void compute()
Creation of the synchronization element list.
Interface of a variable synchronization service.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ArrayView< Int64 > Int64ArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:451
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
std::int32_t Int32
Signed integer type of 32 bits.