14#include "arcane/materials/internal/MeshMaterialSynchronizer.h"
16#include "arcane/VariableTypes.h"
17#include "arcane/IParallelMng.h"
18#include "arcane/ItemPrinter.h"
19#include "arcane/IMesh.h"
21#include "arcane/materials/CellToAllEnvCellConverter.h"
22#include "arcane/materials/MatItemEnumerator.h"
23#include "arcane/materials/MeshMaterialModifier.h"
25#include "arcane/core/ItemGenericInfoListView.h"
35MeshMaterialSynchronizer::
36MeshMaterialSynchronizer(IMeshMaterialMng* material_mng)
37: TraceAccessor(material_mng->traceMng())
38, m_material_mng(material_mng)
40 if (Convert::Type<Int32>::tryParseFromEnvironment(
"ARCANE_ACC_MAT_SYNCHRONIZER",
true)) {
41 m_synchronizer =
new AcceleratorMeshMaterialSynchronizerImpl(material_mng);
42 info() <<
"using ACC material synchronizer";
45 m_synchronizer =
new LegacyMeshMaterialSynchronizerImpl(material_mng);
46 info() <<
"using DEFAULT material synchronizer";
53MeshMaterialSynchronizer::
54~MeshMaterialSynchronizer()
56 delete m_synchronizer;
62bool MeshMaterialSynchronizer::
63synchronizeMaterialsInCells()
65 return m_synchronizer->synchronizeMaterialsInCells();
75void MeshMaterialSynchronizer::
76checkMaterialsInCells(Integer max_print)
89 IMesh* mesh = m_material_mng->mesh();
90 if (!mesh->parallelMng()->isParallel())
92 m_material_mng->checkValid();
93 info(4) <<
"CheckMaterialsInCells";
94 VariableCellInt32 indexes(VariableBuildInfo(mesh,
"ArcaneMaterialPresenceIndexes"));
95 _checkComponents(indexes,m_material_mng->materialsAsComponents(),max_print);
96 _checkComponents(indexes,m_material_mng->environmentsAsComponents(),max_print);
102void MeshMaterialSynchronizer::
103_checkComponents(VariableCellInt32& indexes,
104 ConstArrayView<IMeshComponent*> components,
107 IMesh* mesh = m_material_mng->mesh();
108 Integer nb_component = components.size();
111 info() <<
"Checking components nb=" << nb_component;
113 CellToAllEnvCellConverter all_env_cell_converter(m_material_mng);
115 for( Integer i=0; i<nb_component; ++i ){
117 IMeshComponent* c = components[i];
119 ComponentCell cc = *iccell;
120 indexes[cc.globalCell()] = i;
123 indexes.synchronize();
126 AllEnvCell all_env_cell = *iallenvcell;
127 Cell cell = all_env_cell.globalCell();
128 bool has_sync_mat = (indexes[cell]==i);
129 ComponentCell cc = c->findComponentCell(all_env_cell);
130 bool has_component = !cc.null();
131 if (has_sync_mat!=has_component){
133 if (max_print<0 || nb_error<max_print)
134 error() <<
"Bad component synchronisation for i=" << i
135 <<
" name=" << c->name()
136 <<
" cell_uid=" << cell.uniqueId()
137 <<
" sync_mat=" << has_sync_mat
138 <<
" has_component=" << has_component;
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
MeshVariableScalarRefT< Cell, Int32 > VariableCellInt32
Grandeur au centre des mailles de type entier 32 bits.
Active toujours les traces dans les parties Arcane concernant les matériaux.
Int32 Integer
Type représentant un entier.