Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
AllEnvData.cc
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/* AllEnvData.cc (C) 2000-2024 */
9/* */
10/* Information about environment values. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/NotImplementedException.h"
15#include "arcane/utils/ITraceMng.h"
16#include "arcane/utils/FunctorUtils.h"
17#include "arcane/utils/ArgumentException.h"
18#include "arcane/utils/OStringStream.h"
20#include "arcane/utils/ValueConvert.h"
21#include "arcane/utils/ArraySimdPadder.h"
22
23#include "arcane/core/IMesh.h"
24#include "arcane/core/IItemFamily.h"
25#include "arcane/core/ItemPrinter.h"
26#include "arcane/core/VariableBuildInfo.h"
27#include "arcane/core/internal/ItemGroupImplInternal.h"
28#include "arcane/core/materials/internal/IMeshMaterialVariableInternal.h"
29
30#include "arcane/materials/IMeshMaterialVariable.h"
31#include "arcane/materials/CellToAllEnvCellConverter.h"
32
33#include "arcane/materials/internal/MeshMaterialMng.h"
34#include "arcane/materials/internal/AllEnvData.h"
35#include "arcane/materials/internal/MaterialModifierOperation.h"
36#include "arcane/materials/internal/ConstituentConnectivityList.h"
37#include "arcane/materials/internal/ComponentItemListBuilder.h"
38#include "arcane/materials/internal/AllCellToAllEnvCellContainer.h"
39
40#include "arcane/accelerator/Scan.h"
41#include "arcane/accelerator/RunCommandLoop.h"
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
47namespace Arcane::Materials
48{
49
50/*---------------------------------------------------------------------------*/
51/*---------------------------------------------------------------------------*/
52
54{
55 public:
56
57 explicit RecomputeConstituentCellInfos(RunQueue& q)
58 : env_cell_indexes(q.allocationOptions())
59 , cells_nb_material(q.allocationOptions())
60 , m_queue(q)
61 {
62 }
63
64 public:
65
66 UniqueArray<Int32> env_cell_indexes;
67 UniqueArray<Int16> cells_nb_material;
68 RunQueue m_queue;
69};
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
73
74AllEnvData::
75AllEnvData(MeshMaterialMng* mmg)
76: TraceAccessor(mmg->traceMng())
77, m_material_mng(mmg)
78, m_item_internal_data(mmg)
79{
80 // \a m_component_connectivity_list uses a reference counter
81 // and must not be explicitly destroyed
82 m_component_connectivity_list = new ConstituentConnectivityList(m_material_mng);
83 m_component_connectivity_list_ref = m_component_connectivity_list->toSourceReference();
84
85 if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_ALLENVDATA_DEBUG_LEVEL", true))
86 m_verbose_debug_level = v.value();
87}
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
96endCreate(bool is_continue)
97{
98 m_item_internal_data.endCreate();
99 m_component_connectivity_list->endCreate(is_continue);
100}
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
104
105bool AllEnvData::
106_isFullVerbose() const
107{
108 return (m_verbose_debug_level > 1 || traceMng()->verbosityLevel() >= 5);
109}
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
113
114void AllEnvData::
115_computeNbEnvAndNbMatPerCell()
116{
117 ConstArrayView<MeshEnvironment*> true_environments(m_material_mng->trueEnvironments());
118
119 // Calculates the number of environments per cell, and for each
120 // environment, the number of materials per cell
121 for (MeshEnvironment* env : true_environments) {
122 env->computeNbMatPerCell();
123 }
124}
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
129void AllEnvData::
130_computeAndResizeEnvItemsInternal()
131{
132 // Calculates the number of environments per cell, and for each
133 // environment, the number of materials per cell
134 IMesh* mesh = m_material_mng->mesh();
135 const IItemFamily* cell_family = mesh->cellFamily();
136 ConstArrayView<MeshEnvironment*> true_environments(m_material_mng->trueEnvironments());
137
138 Integer nb_env = true_environments.size();
139 Integer total_env_cell = 0;
140 Integer total_mat_cell = 0;
141 info(4) << "NB_ENV = " << nb_env;
142 for (const MeshEnvironment* env : true_environments) {
143 CellGroup cells = env->cells();
144 Integer env_nb_cell = cells.size();
145 info(4) << "EnvName=" << cells.name() << " nb_env_cell=" << env_nb_cell << " nb_mat_cell=" << env->totalNbCellMat();
146 total_env_cell += env_nb_cell;
147 total_mat_cell += env->totalNbCellMat();
148 }
149
150 // We must add the information for AllEnvCell type cells
151 Int32 max_local_id = cell_family->maxLocalId();
152 info(4) << "RESIZE TotalEnvCell=" << total_env_cell
153 << " TotalMatCell=" << total_mat_cell
154 << " MaxLocalId=" << max_local_id;
155
156 // Resizes the info arrays
157 // WARNING: they must not be resized subsequently under penalty
158 // of invalidating everything.
159 m_item_internal_data.resizeComponentItemInternals(max_local_id, total_env_cell);
160
161 if (arcaneIsCheck()) {
162 Int32 computed_nb_mat = 0;
163 Int32 computed_nb_env = 0;
164 ConstArrayView<Int16> cells_nb_env = m_component_connectivity_list->cellsNbEnvironment();
165 ConstArrayView<Int16> cells_nb_mat = m_component_connectivity_list->cellsNbMaterial();
166 ENUMERATE_ (Cell, icell, cell_family->allItems()) {
167 Int32 lid = icell.itemLocalId();
168 computed_nb_env += cells_nb_env[lid];
169 computed_nb_mat += cells_nb_mat[lid];
170 }
171 Int32 computed_size = computed_nb_mat + computed_nb_env;
172 Int32 storage_size = total_mat_cell + total_env_cell;
173 info(4) << "storage_size=" << storage_size << " computed=" << computed_size
174 << " max_local_id=" << max_local_id << " internal_nb_mat=" << total_mat_cell << " internal_nb_env=" << total_env_cell
175 << " computed_nb_mat=" << computed_nb_mat << " computed_nb_env=" << computed_nb_env;
176 if (storage_size != computed_size)
177 ARCANE_FATAL("BAD STORAGE SIZE internal={0} connectivity={1}", storage_size, computed_size);
178 }
179}
180
181/*---------------------------------------------------------------------------*/
182/*---------------------------------------------------------------------------*/
183
189{
190 RunQueue queue(makeQueue(m_material_mng->runner()));
191 ConstArrayView<MeshEnvironment*> true_environments(m_material_mng->trueEnvironments());
192 auto clist = m_component_connectivity_list;
193 clist->removeAllConnectivities();
194 for (MeshEnvironment* env : true_environments) {
195 clist->addCellsToEnvironment(env->componentId(), env->cells().view().localIds(), queue);
196 for (MeshMaterial* mat : env->trueMaterials())
197 clist->addCellsToMaterial(mat->componentId(), mat->cells().view().localIds(), queue);
198 }
199}
200
201/*---------------------------------------------------------------------------*/
202/*---------------------------------------------------------------------------*/
203
204void AllEnvData::
205_rebuildMaterialsAndEnvironmentsFromGroups()
206{
207 ConstArrayView<MeshEnvironment*> true_environments(m_material_mng->trueEnvironments());
208 const bool is_full_verbose = _isFullVerbose();
209 ConstArrayView<Int16> cells_nb_env = m_component_connectivity_list->cellsNbEnvironment();
210 for (const MeshEnvironment* env : true_environments) {
211 MeshMaterialVariableIndexer* var_indexer = env->variableIndexer();
212 ComponentItemListBuilderOld list_builder(var_indexer, 0);
213 CellGroup cells = var_indexer->cells();
214 Integer var_nb_cell = cells.size();
215 info(4) << "ENV_INDEXER (V2) i=" << var_indexer->index() << " NB_CELL=" << var_nb_cell << " name=" << cells.name()
216 << " index=" << var_indexer->index();
217 if (is_full_verbose)
218 info(5) << "ENV_INDEXER (V2) name=" << cells.name() << " cells=" << cells.view().localIds();
219
220 ENUMERATE_CELL (icell, cells) {
221 if (cells_nb_env[icell.itemLocalId()] > 1)
222 list_builder.addPartialItem(icell.itemLocalId());
223 else
224 // I am the only environment of the cell so I take the global index
225 list_builder.addPureItem(icell.itemLocalId());
226 }
227 if (is_full_verbose)
228 info() << "MAT_NB_MULTIPLE_CELL (V2) mat=" << var_indexer->name()
229 << " nb_in_global=" << list_builder.pureMatVarIndexes().size()
230 << " (ids=" << list_builder.pureMatVarIndexes() << ")"
231 << " nb_in_multiple=" << list_builder.partialMatVarIndexes().size()
232 << " (ids=" << list_builder.partialLocalIds() << ")";
233 var_indexer->endUpdate(list_builder);
234 }
235
236 for (MeshEnvironment* env : true_environments)
237 env->computeItemListForMaterials(*m_component_connectivity_list);
238}
239
240/*---------------------------------------------------------------------------*/
241/*---------------------------------------------------------------------------*/
242
243void AllEnvData::
244_computeInfosForAllEnvCells1(RecomputeConstituentCellInfos& work_info)
245{
246 IMesh* mesh = m_material_mng->mesh();
247 IItemFamily* cell_family = mesh->cellFamily();
248 CellGroup all_cells = cell_family->allItems();
249 const Int32 nb_cell = all_cells.size();
250 const Int32 max_local_id = cell_family->maxLocalId();
251
252 SmallSpan<const Int16> cells_nb_env = m_component_connectivity_list->cellsNbEnvironment();
253
254 // Calculates for each cell its position in the environment array
255 // considering that the environments of each cell are stored consecutively
256 // in m_env_items_internal.
257
258 MemoryUtils::checkResizeArrayWithCapacity(work_info.env_cell_indexes, cells_nb_env.size());
259
260 bool do_old = (max_local_id != nb_cell);
261 if (do_old) {
262 Integer env_cell_index = 0;
263 ENUMERATE_CELL (icell, all_cells) {
264 Int32 lid = icell.itemLocalId();
265 Int32 nb_env = cells_nb_env[lid];
266 work_info.env_cell_indexes[lid] = env_cell_index;
267 env_cell_index += nb_env;
268 }
269 }
270 else {
271 // TODO: This only works if all_cells is compacted and
272 // local_id[i] <=> i.
273 Accelerator::GenericScanner scanner(work_info.m_queue);
274 SmallSpan<Int32> env_cell_indexes_view(work_info.env_cell_indexes);
275 Accelerator::ScannerSumOperator<Int32> op;
276 scanner.applyExclusive(0, cells_nb_env, env_cell_indexes_view, op, A_FUNCINFO);
277 }
278}
279
280/*---------------------------------------------------------------------------*/
281/*---------------------------------------------------------------------------*/
282
283void AllEnvData::
284_computeInfosForAllEnvCells2(RecomputeConstituentCellInfos& work_info)
285{
286 CellGroup all_cells = m_material_mng->mesh()->allCells();
287
288 SmallSpan<const Int16> cells_nb_env = m_component_connectivity_list->cellsNbEnvironment();
289
290 // Positions the info for AllEnvCell.
291 ComponentItemSharedInfo* all_env_shared_info = m_item_internal_data.allEnvSharedInfo();
292 auto command = makeCommand(work_info.m_queue);
293 SmallSpan<Int32> env_cell_indexes_view(work_info.env_cell_indexes);
294 command << RUNCOMMAND_ENUMERATE (Cell, cell_id, all_cells)
295 {
296 Int32 lid = cell_id;
297 Int16 n = cells_nb_env[lid];
298 matimpl::ConstituentItemBase ref_ii(all_env_shared_info, ConstituentItemIndex(lid));
299 ref_ii._setSuperAndGlobalItem({}, cell_id);
300 ref_ii._setVariableIndex(MatVarIndex(0, lid));
301 ref_ii._setNbSubItem(n);
302 if (n != 0)
303 ref_ii._setFirstSubItem(ConstituentItemIndex(env_cell_indexes_view[lid]));
304 };
305}
306
307/*---------------------------------------------------------------------------*/
308/*---------------------------------------------------------------------------*/
309
315{
316 ConstArrayView<MeshEnvironment*> true_environments(m_material_mng->trueEnvironments());
317 RunQueue queue(m_material_mng->runQueue());
318
319 IMesh* mesh = m_material_mng->mesh();
320 IItemFamily* cell_family = mesh->cellFamily();
321 const Int32 max_local_id = cell_family->maxLocalId();
322
323 for (MeshEnvironment* env : true_environments) {
324 const Int16 env_id = env->componentId();
325 const MeshMaterialVariableIndexer* var_indexer = env->variableIndexer();
326 CellGroup cells = env->cells();
327
328 env->resizeItemsInternal(var_indexer->nbItem());
329
330 info(4) << "COMPUTE (V2) env_cells env=" << env->name() << " nb_cell=" << cells.size()
331 << " index=" << var_indexer->index()
332 << " max_multiple_index=" << var_indexer->maxIndexInMultipleArray();
333
334 SmallSpan<const MatVarIndex> matvar_indexes(var_indexer->matvarIndexes());
335
336 Int32ConstArrayView local_ids = var_indexer->localIds();
337
338 const bool is_mono_mat = env->isMonoMaterial();
339 if (!is_mono_mat)
340 work_info.cells_nb_material.resize(max_local_id);
341
342 SmallSpan<Int16> cells_nb_mat_view = work_info.cells_nb_material.view();
343
344 if (!is_mono_mat)
345 m_component_connectivity_list->fillCellsNbMaterial(local_ids, env_id, cells_nb_mat_view, queue);
346
347 auto command = makeCommand(queue);
348 SmallSpan<Int32> current_pos_view(work_info.env_cell_indexes);
349 const Int32 nb_id = matvar_indexes.size();
350 ComponentItemSharedInfo* env_shared_info = m_item_internal_data.envSharedInfo();
351
352 Span<Int32> env_cells_local_id = cells._internalApi()->itemsLocalId();
353 SmallSpan<ConstituentItemIndex> env_id_list = env->componentData()->m_constituent_local_id_list.mutableLocalIds();
354 command << RUNCOMMAND_LOOP1(iter, nb_id)
355 {
356 auto [z] = iter();
357 MatVarIndex mvi = matvar_indexes[z];
358
359 Int32 lid = local_ids[z];
360 Int32 pos = current_pos_view[lid];
361 ++current_pos_view[lid];
362 Int16 nb_mat = (is_mono_mat) ? 1 : cells_nb_mat_view[z];
363
364 ConstituentItemIndex cii_pos(pos);
365 matimpl::ConstituentItemBase ref_ii(env_shared_info, cii_pos);
366 ConstituentItemIndex cii_lid(lid);
367 env_id_list[z] = cii_pos;
368
369 ref_ii._setSuperAndGlobalItem(cii_lid, ItemLocalId(lid));
370 ref_ii._setNbSubItem(nb_mat);
371 ref_ii._setVariableIndex(mvi);
372 ref_ii._setComponent(env_id);
373 // Le rang 0 met à jour le padding SIMD du groupe associé au matériau
374 if (z == 0)
375 ArraySimdPadder::applySimdPaddingView(env_cells_local_id);
376 };
378 }
379
380 // Positionne les infos pour les MatCell
381 {
382 Accelerator::RunQueuePool& queue_pool = m_material_mng->_internalApi()->asyncRunQueuePool();
383 for (MeshEnvironment* env : true_environments) {
384 env->computeMaterialIndexes(&m_item_internal_data, queue_pool[env->id()]);
385 }
386 queue_pool.barrier();
387 }
388}
389
390/*---------------------------------------------------------------------------*/
391/*---------------------------------------------------------------------------*/
392
399{
400 for (MeshEnvironment* env : m_material_mng->trueEnvironments()) {
401 Int32 index = 0;
402 Int32ConstArrayView indexer_local_ids = env->variableIndexer()->localIds();
403 ENUMERATE_COMPONENTCELL (icitem, env) {
404 ComponentCell cc = *icitem;
405 Int32 matvar_lid = cc.globalCell().localId();
406 Int32 direct_lid = indexer_local_ids[index];
407 if (matvar_lid != direct_lid)
408 ARCANE_FATAL("Incoherent localId() matvar_lid={0} direct_lid={1} index={2}",
409 matvar_lid, direct_lid, index);
410 ++index;
411 }
412 }
413}
414
415/*---------------------------------------------------------------------------*/
416/*---------------------------------------------------------------------------*/
417
434forceRecompute(bool compute_all)
435{
436 m_material_mng->incrementTimestamp();
437
438 ConstArrayView<MeshMaterialVariableIndexer*> vars_idx = m_material_mng->_internalApi()->variablesIndexer();
439 Integer nb_var = vars_idx.size();
440 Int64 mesh_timestamp = m_material_mng->mesh()->timestamp();
441 info(4) << "ForceRecompute NB_VAR_IDX=" << nb_var << " compute_all?=" << compute_all
442 << " mesh_timestamp=" << mesh_timestamp << " current_mesh_timestamp=" << m_current_mesh_timestamp;
443
444 // Si le maillage a changé, il y a certaines choses qu'il faut toujours recalculer
445 bool has_mesh_changed = m_current_mesh_timestamp != mesh_timestamp;
446 m_current_mesh_timestamp = mesh_timestamp;
447
448 const bool is_verbose_debug = m_verbose_debug_level > 0;
449
450 // Il faut compter le nombre total de mailles par milieu et par matériau
451
452 ConstArrayView<MeshEnvironment*> true_environments(m_material_mng->trueEnvironments());
453
454 if (compute_all)
456
457 // Calcule le nombre de milieux par maille, et pour chaque
458 // milieu le nombre de matériaux par maille
459 if (compute_all || has_mesh_changed)
460 _computeNbEnvAndNbMatPerCell();
461
462 _computeAndResizeEnvItemsInternal();
463
464 bool is_full_verbose = _isFullVerbose();
465
466 if (compute_all)
467 _rebuildMaterialsAndEnvironmentsFromGroups();
468
469 for (const MeshEnvironment* env : true_environments) {
470 const MeshMaterialVariableIndexer* var_indexer = env->variableIndexer();
471 CellGroup cells = var_indexer->cells();
472 Integer var_nb_cell = cells.size();
473 info(4) << "FINAL_INDEXER i=" << var_indexer->index() << " NB_CELL=" << var_nb_cell << " name=" << cells.name()
474 << " index=" << var_indexer->index();
475 if (is_full_verbose) {
476 Int32UniqueArray my_array(cells.view().localIds());
477 info(5) << "FINAL_INDEXER (V2) name=" << cells.name() << " cells=" << my_array;
478 info(4) << "FINAL_MAT_NB_MULTIPLE_CELL (V2) mat=" << var_indexer->name()
479 << " ids=" << var_indexer->matvarIndexes();
480 }
481 }
482
483 RunQueue& queue(m_material_mng->runQueue());
484
485 {
486 RecomputeConstituentCellInfos work_info(queue);
487 _computeInfosForAllEnvCells1(work_info);
488 _computeInfosForAllEnvCells2(work_info);
489 _computeInfosForEnvCells(work_info);
490 }
491
492 if (is_verbose_debug) {
493 _printAllEnvCells(m_material_mng->mesh()->allCells().view());
494 for (IMeshMaterial* material : m_material_mng->materials()) {
495 ENUMERATE_COMPONENTITEM (MatCell, imatcell, material) {
496 MatCell pmc = *imatcell;
497 info() << "CELL IN MAT vindex=" << pmc._varIndex();
498 }
499 }
500 }
501
502 {
503 for (MeshEnvironment* env : true_environments) {
504 env->componentData()->_rebuildPartData(queue);
505 for (MeshMaterial* mat : env->trueMaterials())
506 mat->componentData()->_rebuildPartData(queue);
507 }
508 }
509
510 if (arcaneIsCheck())
511 m_material_mng->checkValid();
512
513 m_material_mng->syncVariablesReferences(compute_all);
514
515 if (is_verbose_debug) {
516 OStringStream ostr;
517 m_material_mng->dumpInfos2(ostr());
518 info() << ostr.str();
519 }
520
521 // Vérifie la cohérence des localIds() du variableIndexer()
522 // avec la maille globale associée au milieu
523 if (arcaneIsCheck())
525
526 // Met à jour le AllCellToAllEnvCell s'il a été initialisé si la fonctionnalité est activé
527 if (m_material_mng->isCellToAllEnvCellForRunCommand()) {
528 auto* all_cell_to_all_env_cell(m_material_mng->_internalApi()->getAllCellToAllEnvCellContainer());
529 if (all_cell_to_all_env_cell)
530 all_cell_to_all_env_cell->bruteForceUpdate();
531 else
532 m_material_mng->_internalApi()->createAllCellToAllEnvCell();
533 }
534}
535
536/*---------------------------------------------------------------------------*/
537/*---------------------------------------------------------------------------*/
538
539void AllEnvData::
540recomputeIncremental()
541{
542 forceRecompute(false);
543 if (arcaneIsCheck())
544 _checkConnectivityCoherency();
545}
546
547/*---------------------------------------------------------------------------*/
548/*---------------------------------------------------------------------------*/
549
550void AllEnvData::
551_printAllEnvCells(CellVectorView ids)
552{
553 ConstArrayView<Int16> cells_nb_env = m_component_connectivity_list->cellsNbEnvironment();
554 ENUMERATE_ALLENVCELL (iallenvcell, m_material_mng->view(ids)) {
555 AllEnvCell all_env_cell = *iallenvcell;
556 Integer cell_nb_env = all_env_cell.nbEnvironment();
557 Cell cell = all_env_cell.globalCell();
558 info() << "CELL2 uid=" << ItemPrinter(cell)
559 << " nb_env=" << cells_nb_env[cell.localId()]
560 << " direct_nb_env=" << cell_nb_env;
561 for (Integer z = 0; z < cell_nb_env; ++z) {
562 EnvCell ec = all_env_cell.cell(z);
563 Integer cell_nb_mat = ec.nbMaterial();
564 info() << "CELL3 nb_mat=" << cell_nb_mat << " env_id=" << ec.environmentId();
565 for (Integer k = 0; k < cell_nb_mat; ++k) {
566 MatCell mc = ec.cell(k);
567 info() << "CELL4 mat_item=" << mc._varIndex() << " mat_id=" << mc.materialId();
568 }
569 }
570 }
571}
572
573/*---------------------------------------------------------------------------*/
574/*---------------------------------------------------------------------------*/
575
576void AllEnvData::
577_checkConnectivityCoherency()
578{
579 info() << "AllEnvData: checkCoherency()";
580 ConstArrayView<Int16> nb_mat_v2 = m_component_connectivity_list->cellsNbMaterial();
581 ConstArrayView<MeshEnvironment*> true_environments(m_material_mng->trueEnvironments());
582
583 ItemGroup all_cells = m_material_mng->mesh()->allCells();
584
585 Int32 nb_error = 0;
586
587 // Vérifie le nombre de matériaux par maille
588 ENUMERATE_CELL (icell, all_cells) {
589 Int32 ref_nb_mat = 0;
590 for (MeshEnvironment* env : true_environments) {
591 Int16 env_id = env->componentId();
592 ref_nb_mat += m_component_connectivity_list->cellNbMaterial(icell, env_id);
593 }
594 Int32 current_nb_mat = nb_mat_v2[icell.itemLocalId()];
595 if (ref_nb_mat != current_nb_mat) {
596 ++nb_error;
597 if (nb_error < 10)
598 error() << "Invalid values for nb_material cell=" << icell->uniqueId()
599 << " ref=" << ref_nb_mat << " current=" << current_nb_mat;
600 }
601 }
602
603 if (nb_error != 0)
604 ARCANE_FATAL("Invalid values for component connectivity nb_error={0}", nb_error);
605}
606
607/*---------------------------------------------------------------------------*/
608/*---------------------------------------------------------------------------*/
609
610} // End namespace Arcane::Materials
611
612/*---------------------------------------------------------------------------*/
613/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
#define ENUMERATE_(type, name, group)
Generic enumerator for an entity group.
#define ENUMERATE_CELL(name, group)
Generic enumerator for a cell group.
Types and macros to manage enumerations of entities on accelerators.
#define RUNCOMMAND_ENUMERATE(ItemTypeName, iter_name, item_group,...)
Macro to iterate over an accelerator on a group of entities.
Memory and allocator management functions.
#define RUNCOMMAND_LOOP1(iter_name, x1,...)
1D loop on accelerator with additional arguments.
void barrier() const
Forces waiting for all RunQueues.
MemoryAllocationOptions allocationOptions() const
Allocation options associated with this queue.
Definition RunQueue.cc:340
void resize(Int64 s)
Changes the number of elements in the array to s.
ArrayView< T > view() const
Mutable view of this array.
Cell of a mesh.
Definition Item.h:1300
Constant view of an array of type T.
constexpr Integer size() const noexcept
Number of elements in the array.
Template class for converting a type.
Interface of an entity family.
Definition IItemFamily.h:83
virtual Int32 maxLocalId() const =0
virtual CellGroup allCells()=0
Group of all cells.
void notifySimdPaddingDone()
Indicates that the SIMD padding of the entities has been performed.
SmallSpan< Int32 > itemsLocalId()
List of localId() of the group's entities.
const String & name() const
Group name.
Definition ItemGroup.h:81
ItemVectorView view() const
View of the group entities.
Definition ItemGroup.cc:580
Integer size() const
Number of elements in the group.
Definition ItemGroup.h:93
ItemGroupImplInternal * _internalApi() const
Internal Arcane API.
Definition ItemGroup.cc:643
IMesh * mesh() const
Mesh to which this group belongs (0 for the null group).
Definition ItemGroup.h:131
Index of an Item in a variable.
Definition ItemLocalId.h:42
Utility class for printing information about an entity.
Definition ItemPrinter.h:35
Int32ConstArrayView localIds() const
Array of local IDs of entities.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
Definition Item.h:233
Arcane cell with material and environment information.
__host__ __device__ Int32 nbEnvironment() const
Number of environments present in the cell.
EnvCell cell(Int32 i) const
i-th environment cell
void _checkLocalIdsCoherency() const
Checks the coherence of variableIndexer().localIds() with the global cell associated with the environ...
Int32 m_verbose_debug_level
Verbosity level.
Definition AllEnvData.h:82
void _rebuildIncrementalConnectivitiesFromGroups()
Rebuilds the incremental connectivities for groups.
void endCreate(bool is_continue)
Notification of the end of environment/material creation.
Definition AllEnvData.cc:96
void forceRecompute(bool compute_all)
Updates structures following a modification of material or environment cells.
void _computeInfosForEnvCells(RecomputeConstituentCellInfos &work_info)
Positions the info for EnvCells.
Helper class for building a list of ComponentItems for a MeshMaterialVariableIndexer.
Management of constituent connectivity lists.
Index of a constituent entity in the list of constituent entities.
Cell globalCell() const
Global cell.
__host__ __device__ MatVarIndex _varIndex() const
Arcane cell of an environment.
__host__ __device__ MatCell cell(Integer i) const
i-th material cell of this cell
__host__ __device__ Int32 environmentId() const
Environment identifier.
Represents a material in a multi-material cell.
__host__ __device__ Int32 materialId() const
Material identifier.
Represents an index on material and environment variables.
Implementation of a material manager.
AllEnvCellVectorView view(const CellGroup &cells) final
View of environment cells corresponding to the group cells.
void endUpdate(const ComponentItemListBuilderOld &builder)
Private functions but accessible to 'friend' classes.
const String & name() const
Name of the indexer.
General information about a constituent entity.
__host__ __device__ void _setVariableIndex(MatVarIndex index)
Positions the indexer in material variables.
__host__ __device__ void _setNbSubItem(Int16 nb_sub_item)
Positions the number of sub-components.
Output stream linked to a String.
View of an array of elements of type T.
Definition Span.h:805
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
Definition Span.h:327
View of an array of elements of type T.
Definition Span.h:635
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessage info() const
Flow for an information message.
TraceMessage error() const
Flow for an error message.
ITraceMng * traceMng() const
Trace manager.
1D data vector with value semantics (STL style).
#define ENUMERATE_COMPONENTITEM(ClassName_, iname, container,...)
Generic macro to iterate over entities of a material or an environment.
#define ENUMERATE_ALLENVCELL(iname,...)
Macro to iterate over all AllEnvCell cells of a group.
#define ENUMERATE_COMPONENTCELL(iname, component)
Macro to iterate over all ComponentCell cells of a component.
ItemGroupT< Cell > CellGroup
Group of cells.
Definition ItemTypes.h:184
ItemVectorViewT< Cell > CellVectorView
View over a vector of cells.
Definition ItemTypes.h:305
RunCommand makeCommand(const RunQueue &run_queue)
Creates a command associated with the queue run_queue.
RunQueue makeQueue(const Runner &runner)
Creates a queue associated with runner.
Always enables tracing in Arcane parts concerning materials.
Int32 checkResizeArrayWithCapacity(Array< DataType > &array, Int64 new_size, bool force_resize)
Resizes an array by adding a memory reserve.
bool arcaneIsCheck()
True if running in check mode.
Definition Misc.cc:66
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
Definition UtilsTypes.h:341
std::int16_t Int16
Signed integer type of 16 bits.
@ Cell
The mesh is AMR by cell.
Definition MeshKind.h:53
std::int32_t Int32
Signed integer type of 32 bits.