Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
LoadBalanceMng.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* LoadBalanceMng.cc (C) 2000-2024 */
9/* */
10/* Gestionnaire pour le partitionnement et l'équilibrage de charge. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/impl/LoadBalanceMng.h"
15
16#include "arcane/utils/ValueConvert.h"
17
18#include "arcane/impl/internal/LoadBalanceMngInternal.h"
19
20#include "arcane/core/ISubDomain.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31bool LoadBalanceMng::
32_isLegacyInit()
33{
34 // Si la variable d'environnement est définie, utilise l'initialisation historique
35 // (avant la version 3.14 d'octobre 2024). Cette initialisation utilisait par
36 // défaut la quantité de mémoire allouée par les variables pour le partitionnement ce
37 // qui faisait que le partitionnement n'était pas répétable entre mode check/release
38 // ou en fonction des modules chargés (car le nombre de variables est différent).
39 if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_USE_LEGACY_INIT_LOADBALANCEMNG", true))
40 return (v.value() != 0);
41 return false;
42}
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
47LoadBalanceMng::
48LoadBalanceMng(ISubDomain* sd)
49: m_mesh_handle(sd->defaultMeshHandle())
50{
51 bool is_legacy_init = _isLegacyInit();
52 // Avec l'initialisation historique, la valeur par défaut est d'utiliser la
53 // mémoire comme critère.
54 bool use_mass_as_criterion = is_legacy_init;
55 _init(use_mass_as_criterion, is_legacy_init);
56}
57
58/*---------------------------------------------------------------------------*/
59/*---------------------------------------------------------------------------*/
60
61LoadBalanceMng::
62LoadBalanceMng(ISubDomain* sd, bool use_mass_as_criterion)
63: m_mesh_handle(sd->defaultMeshHandle())
64{
65 bool is_legacy_init = _isLegacyInit();
66 _init(use_mass_as_criterion, is_legacy_init);
67}
68
69/*---------------------------------------------------------------------------*/
70/*---------------------------------------------------------------------------*/
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
75void LoadBalanceMng::
76_init(bool use_mass_as_criterion, bool is_legacy_init)
77{
78 m_internal = makeRef(new LoadBalanceMngInternal(use_mass_as_criterion, is_legacy_init));
79 m_internal->reset(m_mesh_handle.mesh());
80}
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
85void LoadBalanceMng::
86reset()
87{
88 m_internal->reset(m_mesh_handle.mesh());
89}
90
91/*---------------------------------------------------------------------------*/
92/*---------------------------------------------------------------------------*/
93
94void LoadBalanceMng::
95initAccess(IMesh* mesh)
96{
97 m_internal->initAccess(mesh);
98}
99
100/*---------------------------------------------------------------------------*/
101/*---------------------------------------------------------------------------*/
102
103void LoadBalanceMng::
104endAccess()
105{
106 m_internal->endAccess();
107}
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
112void LoadBalanceMng::
113addMass(VariableCellInt32& count, const String& entity)
114{
115 m_internal->addMass(count, m_mesh_handle.mesh(), entity);
116}
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
121void LoadBalanceMng::
122addCriterion(VariableCellInt32& count)
123{
124 m_internal->addCriterion(count, m_mesh_handle.mesh());
125}
126
127/*---------------------------------------------------------------------------*/
128/*---------------------------------------------------------------------------*/
129
130void LoadBalanceMng::
131addCriterion(VariableCellReal& count)
132{
133 m_internal->addCriterion(count, m_mesh_handle.mesh());
134}
135
136/*---------------------------------------------------------------------------*/
137/*---------------------------------------------------------------------------*/
138
139void LoadBalanceMng::
140addCommCost(VariableFaceInt32& count, const String& entity)
141{
142 m_internal->addCommCost(count, m_mesh_handle.mesh(), entity);
143}
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
147
148Integer LoadBalanceMng::
149nbCriteria()
150{
151 return m_internal->nbCriteria(m_mesh_handle.mesh());
152}
153
154/*---------------------------------------------------------------------------*/
155/*---------------------------------------------------------------------------*/
156
157void LoadBalanceMng::
158notifyEndPartition()
159{
160 m_internal->notifyEndPartition();
161}
162
163/*---------------------------------------------------------------------------*/
164/*---------------------------------------------------------------------------*/
165
166void LoadBalanceMng::
167setMassAsCriterion(bool active)
168{
169 m_internal->setMassAsCriterion(m_mesh_handle.mesh(), active);
170}
171
172/*---------------------------------------------------------------------------*/
173/*---------------------------------------------------------------------------*/
174
175void LoadBalanceMng::
176setNbCellsAsCriterion(bool active)
177{
178 m_internal->setNbCellsAsCriterion(m_mesh_handle.mesh(), active);
179}
180
181/*---------------------------------------------------------------------------*/
182/*---------------------------------------------------------------------------*/
183
184void LoadBalanceMng::
185setCellCommContrib(bool active)
186{
187 m_internal->setCellCommContrib(m_mesh_handle.mesh(), active);
188}
189
190/*---------------------------------------------------------------------------*/
191/*---------------------------------------------------------------------------*/
192
193bool LoadBalanceMng::
194cellCommContrib() const
195{
196 return m_internal->cellCommContrib(m_mesh_handle.mesh());
197}
198
199/*---------------------------------------------------------------------------*/
200/*---------------------------------------------------------------------------*/
201
202void LoadBalanceMng::
203setComputeComm(bool active)
204{
205 m_internal->setComputeComm(m_mesh_handle.mesh(), active);
206}
207
208/*---------------------------------------------------------------------------*/
209/*---------------------------------------------------------------------------*/
210
211const VariableFaceReal& LoadBalanceMng::
212commCost() const
213{
214 return m_internal->commCost(m_mesh_handle.mesh());
215}
216
217/*---------------------------------------------------------------------------*/
218/*---------------------------------------------------------------------------*/
219
220const VariableCellReal& LoadBalanceMng::
221massWeight() const
222{
223 return m_internal->massWeight(m_mesh_handle.mesh());
224}
225
226/*---------------------------------------------------------------------------*/
227/*---------------------------------------------------------------------------*/
228
229const VariableCellReal& LoadBalanceMng::
230massResWeight() const
231{
232 return m_internal->massResWeight(m_mesh_handle.mesh());
233}
234
235/*---------------------------------------------------------------------------*/
236/*---------------------------------------------------------------------------*/
237
238const VariableCellArrayReal& LoadBalanceMng::
239mCriteriaWeight() const
240{
241 return m_internal->mCriteriaWeight(m_mesh_handle.mesh());
242}
243
244/*---------------------------------------------------------------------------*/
245/*---------------------------------------------------------------------------*/
246
247ILoadBalanceMngInternal* LoadBalanceMng::
248_internalApi()
249{
250 return m_internal.get();
251}
252
253/*---------------------------------------------------------------------------*/
254/*---------------------------------------------------------------------------*/
255
256/*---------------------------------------------------------------------------*/
257/*---------------------------------------------------------------------------*/
258
259extern "C++" ILoadBalanceMng*
260arcaneCreateLoadBalanceMng(ISubDomain* sd)
261{
263 return lbm;
264}
265
266/*---------------------------------------------------------------------------*/
267/*---------------------------------------------------------------------------*/
268
269} // namespace Arcane
270
271/*---------------------------------------------------------------------------*/
272/*---------------------------------------------------------------------------*/
API interne à Arcane de ILoadBalanceMng.
Interface d'enregistrement des variables pour l'equilibrage de charge.
Interface du gestionnaire d'un sous-domaine.
Definition ISubDomain.h:74
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Implantation standard d'une interface d'enregistrement des variables pour l'équilibrage de charge.
Chaîne de caractères unicode.
MeshVariableScalarRefT< Cell, Real > VariableCellReal
Grandeur au centre des mailles de type réel.
MeshVariableScalarRefT< Face, Real > VariableFaceReal
Grandeur aux faces de type réel.
MeshVariableArrayRefT< Cell, Real > VariableCellArrayReal
Grandeur au centre des mailles de type tableau de réel.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Créé une référence sur un pointeur.