14#include "arcane/materials/internal/MeshMaterialSynchronizer.h"
16#include "arcane/materials/CellToAllEnvCellConverter.h"
17#include "arcane/materials/MatItemEnumerator.h"
18#include "arcane/materials/MeshMaterialModifier.h"
20#include "arcane/utils/HashSuite.h"
22#include "arcane/core/VariableTypes.h"
23#include "arcane/core/IParallelMng.h"
24#include "arcane/core/ItemPrinter.h"
25#include "arcane/core/IMesh.h"
26#include "arcane/core/ItemGenericInfoListView.h"
36MeshMaterialSynchronizer::
37MeshMaterialSynchronizer(IMeshMaterialMng* material_mng)
38: TraceAccessor(material_mng->traceMng())
39, m_material_mng(material_mng)
41 if (Convert::Type<Int32>::tryParseFromEnvironment(
"ARCANE_ACC_MAT_SYNCHRONIZER",
true)) {
42 m_synchronizer =
new AcceleratorMeshMaterialSynchronizerImpl(material_mng);
43 info() <<
"using ACC material synchronizer";
46 m_synchronizer =
new LegacyMeshMaterialSynchronizerImpl(material_mng);
47 info() <<
"using DEFAULT material synchronizer";
54MeshMaterialSynchronizer::
55~MeshMaterialSynchronizer()
57 delete m_synchronizer;
63bool MeshMaterialSynchronizer::
64synchronizeMaterialsInCells()
66 return m_synchronizer->synchronizeMaterialsInCells();
76void MeshMaterialSynchronizer::
90 IMesh* mesh = m_material_mng->mesh();
93 m_material_mng->checkValid();
95 info(4) <<
"CheckMaterialsInCells";
98 _checkComponents(indexes, m_material_mng->materialsAsComponents(),
max_print);
99 _checkComponents(indexes, m_material_mng->environmentsAsComponents(),
max_print);
108void MeshMaterialSynchronizer::
113 IMesh* mesh = m_material_mng->mesh();
126 indexes[
cc.globalCell()] = i;
129 indexes.synchronize();
140 error() <<
"Bad component synchronisation for i=" << i
141 <<
" name=" <<
c->name()
152void MeshMaterialSynchronizer::
153_checkComponentsInGhostCells(VariableCellInt64& hashes, Integer max_print)
155 IMesh* mesh = m_material_mng->mesh();
159 AllEnvCell all_env_cell = *iallenvcell;
160 Cell cell = all_env_cell.globalCell();
162 IntegerHashSuite hash_suite;
164 Int32 nb_env = all_env_cell.nbEnvironment();
165 hash_suite.add(nb_env);
167 for (Integer i = 0; i < nb_env; ++i) {
168 EnvCell env_cell = all_env_cell.cell(i);
169 Int32 nb_matt = env_cell.nbMaterial();
170 hash_suite.add(nb_matt);
172 for (Integer j = 0; j < nb_matt; ++j) {
173 MatCell mat = env_cell.cell(j);
174 Int32 id = mat.materialId();
179 hashes[cell] = hash_suite.hash();
182 hashes.synchronize();
185 AllEnvCell all_env_cell = *iallenvcell;
186 Cell cell = all_env_cell.globalCell();
190 IntegerHashSuite hash_suite;
192 Int32 nb_env = all_env_cell.nbEnvironment();
193 hash_suite.add(nb_env);
195 for (Integer i = 0; i < nb_env; ++i) {
196 EnvCell env_cell = all_env_cell.cell(i);
197 Int32 nb_matt = env_cell.nbMaterial();
198 hash_suite.add(nb_matt);
200 for (Integer j = 0; j < nb_matt; ++j) {
201 MatCell mat = env_cell.cell(j);
202 Int32 id = mat.materialId();
206 if (hashes[cell] != hash_suite.hash()) {
208 if (max_print < 0 || nb_error < max_print) {
209 error() <<
"Bad components synchronization -- Cell : " << cell <<
" -- Hash : " << hash_suite.hash();
214 ARCANE_FATAL(
"Bad components synchronization -- Nb error : {0}", nb_error);
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
virtual CellGroup allCells()=0
Groupe de toutes les mailles.
virtual IParallelMng * parallelMng()=0
Gestionnaire de parallèlisme.
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Maille arcane avec info matériaux et milieux.
Conversion de 'Cell' en 'AllEnvCell'.
Représente un composant d'une maille multi-matériau.
Interface d'un composant (matériau ou milieu) d'un maillage.
Paramètres nécessaires à la construction d'une variable.
Active toujours les traces dans les parties Arcane concernant les matériaux.
Int32 Integer
Type représentant un entier.