@@ -171,6 +171,8 @@ class MaterialHeatTestModule
171
171
RunQueue m_queue;
172
172
Runner m_sequential_runner;
173
173
UniqueArray<MeshMaterialVariableRef*> m_additional_variables;
174
+ bool m_is_init_with_zero = false ;
175
+ bool m_is_check_init_new_cells = false ;
174
176
175
177
private:
176
178
@@ -210,6 +212,15 @@ MaterialHeatTestModule(const ModuleBuildInfo& mbi)
210
212
if (auto v = Convert::Type<Int32>::tryParseFromEnvironment (" ARCANE_PROFILE_HEATTEST" , true ))
211
213
if (v.value () != 0 )
212
214
m_profiling_service = platform::getProfilingService ();
215
+ if (auto v = Convert::Type<Int32>::tryParseFromEnvironment (" ARCANE_MATERIAL_NEW_ITEM_INIT" , true )) {
216
+ Int32 vv = v.value ();
217
+ // 0 -> initialisation à partir de la maille globale et pas de vérification
218
+ // 1 -> initialisation à zéro et pas de vérification
219
+ // 2 -> initialisation à zéro et vérification
220
+ // 3 -> initialisation à partir de la maille globale et vérification
221
+ m_is_init_with_zero = (vv == 1 || vv == 2 );
222
+ m_is_check_init_new_cells = (vv == 2 || vv == 3 );
223
+ }
213
224
}
214
225
215
226
/* ---------------------------------------------------------------------------*/
@@ -248,6 +259,7 @@ buildInit()
248
259
m_material_mng->setModificationFlags (flags);
249
260
m_material_mng->setMeshModificationNotified (true );
250
261
m_material_mng->setUseMaterialValueWhenRemovingPartialValue (true );
262
+ m_material_mng->setDataInitialisationWithZero (m_is_init_with_zero);
251
263
if (subDomain ()->isContinue ()) {
252
264
mm->recreateFromDump ();
253
265
}
@@ -305,7 +317,7 @@ buildInit()
305
317
for (Int32 i = 0 ; i < nb_var_to_add; ++i) {
306
318
String var_name = " MaterialAdditionalArrayVar" + String::fromNumber (i);
307
319
auto * v = new MaterialVariableCellArrayInt32 (VariableBuildInfo (mesh, var_name));
308
- v->resize (1 + (i% 3 ));
320
+ v->resize (1 + (i % 3 ));
309
321
m_additional_variables.add (v);
310
322
v->globalVariable ().fill (i + 5 );
311
323
v->fillPartialValuesWithSuperValues (LEVEL_ALLENVIRONMENT);
@@ -512,29 +524,56 @@ _initNewCells(const HeatObject& heat_object, MaterialWorkArray& wa)
512
524
{
513
525
RunQueue* queue = this ->acceleratorMng ()->defaultQueue ();
514
526
527
+ bool init_with_zero = m_material_mng->isDataInitialisationWithZero ();
528
+
515
529
// Initialise les nouvelles valeurs partielles
516
530
IMeshMaterial* current_mat = heat_object.material ;
517
531
Int32 mat_id = current_mat->id ();
518
532
CellToAllEnvCellConverter all_env_cell_converter (m_material_mng);
519
533
SmallSpan<const Int32> ids (wa.mat_cells_to_add .constView ());
520
534
const Int32 nb_id = ids.size ();
535
+ const bool do_check = m_is_check_init_new_cells;
536
+ if (do_check) {
537
+ // Vérifie que la nouvelle valeur est initialisée avec 0 (si init_with_zero
538
+ // est vrai) où qu'elle est initialisée avec la valeur globale
539
+ auto command = makeCommand (queue);
540
+ auto out_mat_temperature = viewInOut (command, m_mat_temperature);
541
+ Accelerator::ReducerSum2<Int32> sum_error (command);
542
+ command << RUNCOMMAND_LOOP1 (iter, nb_id, sum_error)
543
+ {
544
+ auto [i] = iter ();
545
+ AllEnvCell all_env_cell = all_env_cell_converter[CellLocalId (ids[i])];
546
+ MatCell mc = _getMatCell (all_env_cell, mat_id);
547
+ MatVarIndex mvi = mc._varIndex ();
548
+ if (mvi.arrayIndex () != 0 ) {
549
+ Real v = out_mat_temperature[mc];
550
+ if (init_with_zero) {
551
+ if (v != 0.0 )
552
+ sum_error.combine (1 );
553
+ // ARCANE_FATAL("Bad mat temperature (should be 0) i={0} v={1} mc={2}", i, v, mc);
554
+ }
555
+ else {
556
+ Real global_v = out_mat_temperature[CellLocalId (mc.globalCellId ())];
557
+ if (v != global_v)
558
+ sum_error.combine (1 );
559
+ // ARCANE_FATAL("Bad mat temperature i={0} v={1} mc={2} expected_v={3}", i, v, mc, global_v);
560
+ }
561
+ }
562
+ };
563
+ Int32 nb_error = sum_error.reducedValue ();
564
+ if (nb_error != 0 )
565
+ ARCANE_FATAL (" Errors with new cells nb_error={0}" , nb_error);
566
+ }
521
567
{
522
568
auto command = makeCommand (queue);
523
569
auto in_value_to_add = viewIn (command, wa.mat_cells_to_add_value );
524
570
auto out_mat_temperature = viewInOut (command, m_mat_temperature);
525
571
command << RUNCOMMAND_LOOP1 (iter, nb_id)
526
572
{
527
573
auto [i] = iter ();
528
-
529
- // for (Int32 i = 0, n = ids.size(); i < n; ++i) {
530
574
AllEnvCell all_env_cell = all_env_cell_converter[CellLocalId (ids[i])];
531
575
MatCell mc = _getMatCell (all_env_cell, mat_id);
532
- // Teste que la maille n'est pas nulle.
533
- // Ne devrait pas arriver car on l'a ajouté juste avant
534
- // if (mc.null())
535
- // ARCANE_FATAL("Internal invalid null mat cell");
536
576
out_mat_temperature[mc] = in_value_to_add[i];
537
- // }
538
577
};
539
578
}
540
579
}
0 commit comments