Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MeshEnvironment.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/* MeshEnvironment.cc (C) 2000-2025 */
9/* */
10/* Mesh environment. */
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/PlatformUtils.h"
20#include "arcane/utils/ArraySimdPadder.h"
21
22#include "arcane/core/IMesh.h"
23#include "arcane/core/IItemFamily.h"
24#include "arcane/core/VariableBuildInfo.h"
25#include "arcane/core/ItemGroupObserver.h"
26#include "arcane/core/internal/ItemGroupImplInternal.h"
27#include "arcane/core/materials/internal/IMeshMaterialVariableInternal.h"
28#include "arcane/core/materials/internal/IMeshMaterialMngInternal.h"
29
30#include "arcane/materials/IMeshMaterialMng.h"
31#include "arcane/materials/MatItemEnumerator.h"
32#include "arcane/materials/ComponentItemVectorView.h"
33#include "arcane/materials/IMeshMaterialVariable.h"
34#include "arcane/materials/ComponentPartItemVectorView.h"
35
36#include "arcane/materials/internal/MeshEnvironment.h"
37#include "arcane/materials/internal/MeshMaterial.h"
38#include "arcane/materials/internal/ComponentItemListBuilder.h"
39#include "arcane/materials/internal/ComponentItemInternalData.h"
40#include "arcane/materials/internal/ConstituentConnectivityList.h"
41#include "arcane/materials/internal/ConstituentItemVectorImpl.h"
42#include "arcane/materials/internal/MeshComponentPartData.h"
43
44#include "arcane/accelerator/RunQueue.h"
45#include "arcane/accelerator/RunCommandLoop.h"
46#include "arcane/accelerator/Scan.h"
47#include "arcane/accelerator/SpanViews.h"
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
51
52namespace Arcane::Materials
53{
54
55/*---------------------------------------------------------------------------*/
56/*---------------------------------------------------------------------------*/
57
58class MeshEnvironmentObserver
59: public TraceAccessor
60, public IItemGroupObserver
61{
62 public:
63
64 MeshEnvironmentObserver(MeshEnvironment* env, ITraceMng* tm)
65 : TraceAccessor(tm)
66 , m_environment(env)
67 {}
68
69 public:
70
71 void executeExtend(const Int32ConstArrayView* info1) override
72 {
73 if (info1) {
74 //info(4) << "EXTEND_ENV " << m_environment->name() << " ids=" << (*info1);
75 if (m_environment->materialMng()->isInMeshMaterialExchange())
76 info() << "EXTEND_ENV_IN_LOADBALANCE " << m_environment->name()
77 << " ids=" << (*info1);
78 }
79 }
80 void executeReduce(const Int32ConstArrayView* info1) override
81 {
82 if (info1) {
83 //info(4) << "REDUCE_ENV " << m_environment->name() << " ids=" << (*info1);
84 if (m_environment->materialMng()->isInMeshMaterialExchange())
85 info() << "REDUCE_ENV_IN_LOADBALANCE " << m_environment->name()
86 << " ids=" << (*info1);
87 }
88 }
89 void executeCompact(const Int32ConstArrayView* info1) override
90 {
91 info(4) << "COMPACT_ENV " << m_environment->name();
92 if (!info1)
93 ARCANE_FATAL("No info available");
94 Int32ConstArrayView old_to_new_ids(*info1);
95 m_environment->notifyLocalIdsChanged(old_to_new_ids);
96 }
97 void executeInvalidate() override
98 {
99 info() << "WARNING: invalidate() is invalid on an environment group! partial values may be corrupted"
100 << " env=" << m_environment->name();
101 }
102 bool needInfo() const override { return true; }
103
104 private:
105
106 MeshEnvironment* m_environment;
107};
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
115MeshEnvironment::
116MeshEnvironment(IMeshMaterialMng* mm, const String& name, Int16 env_id)
117: TraceAccessor(mm->traceMng())
118, m_material_mng(mm)
119, m_data(this, name, env_id, mm->_internalApi()->componentItemSharedInfo(LEVEL_ENVIRONMENT), false)
120, m_non_const_this(this)
121, m_internal_api(this)
122{
123}
124
125/*---------------------------------------------------------------------------*/
126/*---------------------------------------------------------------------------*/
127
128/*---------------------------------------------------------------------------*/
129/*---------------------------------------------------------------------------*/
130
132build()
133{
134 IMesh* mesh = m_material_mng->mesh();
135 IItemFamily* cell_family = mesh->cellFamily();
136 String group_name = m_material_mng->name() + "_" + name();
137 CellGroup cells = cell_family->findGroup(group_name, true);
138 cells._internalApi()->setAsConstituentGroup();
139
140 if (m_material_mng->isMeshModificationNotified()) {
141 m_group_observer = new MeshEnvironmentObserver(this, traceMng());
142 cells.internal()->attachObserver(this, m_group_observer);
143 }
144
145 m_data._setItems(cells);
146}
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/
150
151void MeshEnvironment::
152addMaterial(MeshMaterial* mm)
153{
154 m_materials.add(mm);
155 m_true_materials.add(mm);
156}
157
158/*---------------------------------------------------------------------------*/
159/*---------------------------------------------------------------------------*/
160
161void MeshEnvironment::
162setVariableIndexer(MeshMaterialVariableIndexer* idx)
163{
164 m_data._setVariableIndexer(idx);
165 idx->setCells(m_data.items());
166 idx->setIsEnvironment(true);
167
168 // If there is only one material, that material's variable indexer is
169 // also 'idx' but with a different associated group. To ensure consistency,
170 // we must ensure that this material also has the same group.
171 // TODO: to guarantee consistency, the entity group should be removed
172 // from m_data.
173 if (m_true_materials.size() == 1)
174 m_true_materials[0]->componentData()->_setItems(m_data.items());
175 m_data._buildPartData();
176 for (MeshMaterial* mat : m_true_materials)
177 mat->componentData()->_buildPartData();
178}
179
180/*---------------------------------------------------------------------------*/
181/*---------------------------------------------------------------------------*/
182
185{
186 info(4) << "ComputeNbMatPerCell env=" << name();
187 Integer nb_mat = m_materials.size();
188 Integer total = 0;
189 for (Integer i = 0; i < nb_mat; ++i) {
190 IMeshMaterial* mat = m_materials[i];
191 CellGroup mat_cells = mat->cells();
192 total += mat_cells.size();
193 }
194 m_total_nb_cell_mat = total;
195}
196
197/*---------------------------------------------------------------------------*/
198/*---------------------------------------------------------------------------*/
199
209{
210 info(4) << "Compute (V2) indexes for environment name=" << name();
211 const bool is_mono_mat = isMonoMaterial();
212 if (is_mono_mat) {
213 _computeMaterialIndexesMonoMat(item_internal_data, queue);
214 }
215 else
216 _computeMaterialIndexes(item_internal_data, queue);
217}
218
219/*---------------------------------------------------------------------------*/
220/*---------------------------------------------------------------------------*/
221
222void MeshEnvironment::
223_computeMaterialIndexes(ComponentItemInternalData* item_internal_data, RunQueue& queue)
224{
225 IItemFamily* cell_family = cells().itemFamily();
226 Integer max_local_id = cell_family->maxLocalId();
227
228 ComponentItemInternalRange mat_items_internal_range = m_mat_internal_data_range;
229
231 cells_index.resize(max_local_id);
233 cells_pos.resize(max_local_id);
234
235 // TODO: look into how to remove this cells_env array which is normally not useful
236 // because we should be able to directly use m_items_internal
238 cells_env.resize(max_local_id);
239
240 Int32ConstArrayView local_ids = variableIndexer()->localIds();
241 ConstituentItemLocalIdListView constituent_item_list_view = m_data.constituentItemListView();
242 const bool do_old = false;
243 if (do_old) {
244 Integer cell_index = 0;
245 for (Integer z = 0, nb = local_ids.size(); z < nb; ++z) {
246 Int32 lid = local_ids[z];
247 matimpl::ConstituentItemBase env_item = constituent_item_list_view._constituenItemBase(z);
248 Int32 nb_mat = env_item.nbSubItem();
249 cells_index[lid] = cell_index;
250 cell_index += nb_mat;
251 }
252 }
253 else {
254 // Calculate the index of the first MatCell for each Cell.
255 Int32 nb_id = local_ids.size();
256 {
257 Accelerator::GenericScanner scanner(queue);
258 auto cells_index_view = viewOut(queue, cells_index);
259
260 auto getter = [=] ARCCORE_HOST_DEVICE(Int32 index) -> Int32 {
261 return constituent_item_list_view._constituenItemBase(index).nbSubItem();
262 };
263 auto setter = [=] ARCCORE_HOST_DEVICE(Int32 index, Int32 value) {
264 Int32 lid = local_ids[index];
265 cells_index_view[lid] = value;
266 };
267 Accelerator::ScannerSumOperator<Int32> op;
268 scanner.applyWithIndexExclusive(nb_id, 0, getter, setter, op, A_FUNCINFO);
269 }
270 }
271 {
272 auto command = makeCommand(queue);
273 auto cells_env_view = viewOut(command, cells_env);
274 auto cells_index_view = viewIn(command, cells_index);
275 auto cells_pos_view = viewOut(command, cells_pos);
276 Int32 nb_id = local_ids.size();
277 command << RUNCOMMAND_LOOP1(iter, nb_id)
278 {
279 auto [z] = iter();
280 Int32 lid = local_ids[z];
281 matimpl::ConstituentItemBase env_item = constituent_item_list_view._constituenItemBase(z);
282 Int32 nb_mat = env_item.nbSubItem();
283 Int32 cell_index = cells_index_view[lid];
284 cells_pos_view[lid] = cell_index;
285 if (nb_mat != 0) {
286 env_item._setFirstSubItem(mat_items_internal_range[cell_index]);
287 }
288 cells_env_view[lid] = env_item.constituentItemIndex();
289 };
290 }
291 {
292 Integer nb_mat = m_true_materials.size();
293 ComponentItemInternalRange mat_item_internal_range = m_mat_internal_data_range;
294 for (Integer i = 0; i < nb_mat; ++i) {
295 MeshMaterial* mat = m_true_materials[i];
296 Int16 mat_id = mat->componentId();
297 const MeshMaterialVariableIndexer* var_indexer = mat->variableIndexer();
298 CellGroup mat_cells = mat->cells();
299 info(4) << "COMPUTE (V2) mat_cells mat=" << mat->name() << " nb_cell=" << mat_cells.size()
300 << " mat_id=" << mat_id << " index=" << var_indexer->index() << " is_async=" << queue.isAsync();
301
302 mat->resizeItemsInternal(var_indexer->nbItem());
303
304 auto command = makeCommand(queue);
305 auto matvar_indexes = viewIn(command, var_indexer->matvarIndexes());
306 auto local_ids = viewIn(command, var_indexer->localIds());
307 SmallSpan<Int32> cells_pos_view(cells_pos);
308 auto cells_env_view = viewIn(command, cells_env);
309 ComponentItemSharedInfo* mat_shared_info = item_internal_data->matSharedInfo();
310 SmallSpan<ConstituentItemIndex> mat_id_list = mat->componentData()->m_constituent_local_id_list.mutableLocalIds();
311 const Int32 nb_id = local_ids.size();
312 Span<Int32> mat_cells_local_id = mat_cells._internalApi()->itemsLocalId();
313 command << RUNCOMMAND_LOOP1(iter, nb_id)
314 {
315 auto [z] = iter();
316 MatVarIndex mvi = matvar_indexes[z];
317 Int32 lid = local_ids[z];
318 Int32 pos = cells_pos_view[lid];
319 ++cells_pos_view[lid];
320 ConstituentItemIndex cii = mat_item_internal_range[pos];
321 matimpl::ConstituentItemBase ref_ii(mat_shared_info, cii);
322 mat_id_list[z] = cii;
323 ref_ii._setSuperAndGlobalItem(cells_env_view[lid], ItemLocalId(lid));
324 ref_ii._setComponent(mat_id);
325 ref_ii._setVariableIndex(mvi);
326 // The 0th rank updates the SIMD padding of the group associated with the material
327 if (z == 0)
328 ArraySimdPadder::applySimdPaddingView(mat_cells_local_id);
329 };
330 mat_cells._internalApi()->notifySimdPaddingDone();
331 }
332 }
333 // The RunQueue is asynchronous. This barrier is necessary to prevent a
334 // crash if the memory pool is used.
335 queue.barrier();
336}
337
338/*---------------------------------------------------------------------------*/
339/*---------------------------------------------------------------------------*/
340
348{
349 ConstituentItemLocalIdListView constituent_item_list_view = m_data.constituentItemListView();
350
351 MeshMaterial* mat = m_true_materials[0];
352 const Int16 mat_id = mat->componentId();
353 const MeshMaterialVariableIndexer* var_indexer = mat->variableIndexer();
354 CellGroup mat_cells = mat->cells();
355 info(4) << "COMPUTE (V2) mat_cells mat=" << mat->name() << " nb_cell=" << mat_cells.size()
356 << " mat_id=" << mat_id << " index=" << var_indexer->index();
357
358 mat->resizeItemsInternal(var_indexer->nbItem());
359
360 auto command = makeCommand(queue);
361 auto matvar_indexes = viewIn(command, var_indexer->matvarIndexes());
362 auto local_ids = viewIn(command, var_indexer->localIds());
363 ComponentItemSharedInfo* mat_shared_info = item_internal_data->matSharedInfo();
364 ComponentItemInternalRange mat_item_internal_range = m_mat_internal_data_range;
365 SmallSpan<ConstituentItemIndex> mat_id_list = mat->componentData()->m_constituent_local_id_list.mutableLocalIds();
366 const Int32 nb_id = local_ids.size();
367 Span<Int32> mat_cells_local_id = mat_cells._internalApi()->itemsLocalId();
368 command << RUNCOMMAND_LOOP1(iter, nb_id)
369 {
370 auto [z] = iter();
371 MatVarIndex mvi = matvar_indexes[z];
372 const Int32 lid = local_ids[z];
373 const Int32 pos = z;
374 matimpl::ConstituentItemBase env_item = constituent_item_list_view._constituenItemBase(z);
375 ConstituentItemIndex cii = mat_item_internal_range[pos];
376 env_item._setFirstSubItem(cii);
377
378 matimpl::ConstituentItemBase ref_ii(mat_shared_info, cii);
379 mat_id_list[z] = cii;
380 ref_ii._setSuperAndGlobalItem(env_item.constituentItemIndex(), ItemLocalId(lid));
381 ref_ii._setComponent(mat_id);
382 ref_ii._setVariableIndex(mvi);
383 // The range 0 updates the SIMD padding of the group associated with the material
384 if (z == 0)
385 ArraySimdPadder::applySimdPaddingView(mat_cells_local_id);
386 };
387 mat_cells._internalApi()->notifySimdPaddingDone();
388}
389
390/*---------------------------------------------------------------------------*/
391/*---------------------------------------------------------------------------*/
392
399{
400 info(4) << "ComputeItemListForMaterials (V2)";
401 ConstArrayView<Int16> nb_env_per_cell = connectivity_list.cellsNbEnvironment();
402 const Int16 env_id = componentId();
403 // Calculation for the number of mixed cells per material
404 // TODO: to be done in MeshMaterialVariableIndexer
405 for (MeshMaterial* mat : m_true_materials) {
406 MeshMaterialVariableIndexer* var_indexer = mat->variableIndexer();
407 CellGroup cells = var_indexer->cells();
408 Integer var_nb_cell = cells.size();
409
410 ComponentItemListBuilderOld list_builder(var_indexer, 0);
411
412 info(4) << "MAT_INDEXER mat=" << mat->name() << " NB_CELL=" << var_nb_cell << " name=" << cells.name();
413 ENUMERATE_CELL (icell, cells) {
414 Int32 lid = icell.itemLocalId();
415 // We only take the global index if we are the only material and the only
416 // environment of the cell. Otherwise, we take a multiple index
417 if (nb_env_per_cell[lid] > 1 || connectivity_list.cellNbMaterial(icell, env_id) > 1)
418 list_builder.addPartialItem(lid);
419 else
420 list_builder.addPureItem(lid);
421 }
422
423 if (traceMng()->verbosityLevel() >= 5)
424 info() << "MAT_NB_MULTIPLE_CELL (V2) mat=" << var_indexer->name()
425 << " nb_in_global=" << list_builder.pureMatVarIndexes().size()
426 << " (ids=" << list_builder.pureMatVarIndexes() << ")"
427 << " nb_in_multiple=" << list_builder.partialMatVarIndexes().size()
428 << " (ids=" << list_builder.partialLocalIds() << ")";
429 var_indexer->endUpdate(list_builder);
430 }
431}
432
433/*---------------------------------------------------------------------------*/
434/*---------------------------------------------------------------------------*/
435
436void MeshEnvironment::
437notifyLocalIdsChanged(Int32ConstArrayView old_to_new_ids)
438{
439 // NOTE:
440 // This method is called when there is mesh compaction
441 // and the entity group associated with this environment has just been compacted.
442 // Since there are currently no observers for the addition
443 // or removal of group cells, it is possible
444 // that when this method is called, the environment and material information
445 // is not up to date (for example, the list of local_ids
446 // in m_variable_indexer does not have the same values as cells().
447 // For now, this is not very serious because everything is overwritten after
448 // every modification to a material or an environment.
449 // In the future, this will need to be taken into account when the addition
450 // or removal of material cells is optimized.
451 info(4) << "Changing (V3) local ids references env=" << name();
452 info(4) << "CurrentCells name=" << cells().name()
453 << " n=" << cells().view().localIds().size();
454 info(4) << "MatVarIndex name=" << cells().name()
455 << " n=" << variableIndexer()->matvarIndexes().size();
456 Integer nb_mat = m_true_materials.size();
457 info(4) << "NotifyLocalIdsChanged env=" << name() << " nb_mat=" << nb_mat
458 << " old_to_new_ids.size=" << old_to_new_ids.size();
459
460 // If the environment has only one material, they share the same variable_indexer
461 // so the IDs only need to be changed once. However, the
462 // m_items_internal array is not shared between the material
463 // and the environment, so the information must be recalculated separately.
464 // It must be done for the environment before updating the material information because
465 // once this is done, the value m_variable_indexer->m_local_ids_in_indexes_view
466 // will have changed, and it will no longer be possible to determine the correspondence
467 // between the new and old localId
468
469 if (nb_mat == 1) {
470 m_data._changeLocalIdsForInternalList(old_to_new_ids);
471 MeshMaterial* true_mat = m_true_materials[0];
472 _changeIds(true_mat->componentData(), old_to_new_ids);
473 }
474 else {
475 // Change material information
476 for (Integer i = 0; i < nb_mat; ++i) {
477 MeshMaterial* true_mat = m_true_materials[i];
478 info(4) << "ChangeIds MAT i=" << i << " MAT=" << true_mat->name();
479 _changeIds(true_mat->componentData(), old_to_new_ids);
480 }
481 // Change environment information
482 _changeIds(componentData(), old_to_new_ids);
483 }
484
485 // Rebuild information on pure and mixed cells.
486 // This must be done once all values are updated.
487 {
488 RunQueue& queue = m_material_mng->_internalApi()->runQueue();
489 for (Integer i = 0; i < nb_mat; ++i) {
490 MeshMaterial* true_mat = m_true_materials[i];
491 true_mat->componentData()->_rebuildPartData(queue);
492 }
493 componentData()->_rebuildPartData(queue);
494 }
495
496 checkValid();
497}
498
499/*---------------------------------------------------------------------------*/
500/*---------------------------------------------------------------------------*/
501
502void MeshEnvironment::
503_changeIds(MeshComponentData* cdata, Int32ConstArrayView old_to_new_ids)
504{
505 info(4) << "ChangeIds() (V4) for name=" << cdata->name();
506 info(4) << "Use new version for ChangeIds()";
507
508 cdata->_changeLocalIdsForInternalList(old_to_new_ids);
509 cdata->variableIndexer()->changeLocalIds(old_to_new_ids);
510}
511
512/*---------------------------------------------------------------------------*/
513/*---------------------------------------------------------------------------*/
514
516findEnvCell(AllEnvCell c) const
517{
518 Int32 env_id = m_data.componentId();
519 ENUMERATE_CELL_ENVCELL (ienvcell, c) {
520 EnvCell ec = *ienvcell;
521 Int32 eid = ec.environmentId();
522 if (eid == env_id)
523 return ec;
524 }
525 return EnvCell();
526}
527
528/*---------------------------------------------------------------------------*/
529/*---------------------------------------------------------------------------*/
530
531ComponentCell MeshEnvironment::
533{
534 return findEnvCell(c);
535}
536
537/*---------------------------------------------------------------------------*/
538/*---------------------------------------------------------------------------*/
539
541envView() const
542{
543 return { m_non_const_this, variableIndexer()->matvarIndexes(),
544 constituentItemListView(), variableIndexer()->localIds() };
545}
546
547/*---------------------------------------------------------------------------*/
548/*---------------------------------------------------------------------------*/
549
551view() const
552{
553 return envView();
554}
555
556/*---------------------------------------------------------------------------*/
557/*---------------------------------------------------------------------------*/
558
559void MeshEnvironment::
560resizeItemsInternal(Integer nb_item)
561{
562 m_data._resizeItemsInternal(nb_item);
563}
564
565/*---------------------------------------------------------------------------*/
566/*---------------------------------------------------------------------------*/
567
569pureItems() const
570{
571 return m_data._partData()->pureView();
572}
573
574/*---------------------------------------------------------------------------*/
575/*---------------------------------------------------------------------------*/
576
578impureItems() const
579{
580 return m_data._partData()->impureView();
581}
582
583/*---------------------------------------------------------------------------*/
584/*---------------------------------------------------------------------------*/
585
587partItems(eMatPart part) const
588{
589 return m_data._partData()->partView(part);
590}
591
592/*---------------------------------------------------------------------------*/
593/*---------------------------------------------------------------------------*/
594
596pureEnvItems() const
597{
598 return { m_non_const_this, m_data._partData()->pureView() };
599}
600
601/*---------------------------------------------------------------------------*/
602/*---------------------------------------------------------------------------*/
603
605impureEnvItems() const
606{
607 return { m_non_const_this, m_data._partData()->impureView() };
608}
609
610/*---------------------------------------------------------------------------*/
611/*---------------------------------------------------------------------------*/
612
614partEnvItems(eMatPart part) const
615{
616 return { m_non_const_this, m_data._partData()->partView(part) };
617}
618
619/*---------------------------------------------------------------------------*/
620/*---------------------------------------------------------------------------*/
621
624{
625 if (!arcaneIsCheck())
626 return;
627
628 m_data.checkValid();
629
630 for (IMeshMaterial* mat : m_materials) {
631 mat->checkValid();
632 }
633}
634
635/*---------------------------------------------------------------------------*/
636/*---------------------------------------------------------------------------*/
637
639isMonoMaterial() const
640{
641 bool is_mono_mat = (nbMaterial() == 1 && (cells().size() == totalNbCellMat()));
642 return is_mono_mat;
643}
644
645/*---------------------------------------------------------------------------*/
646/*---------------------------------------------------------------------------*/
647
653
654/*---------------------------------------------------------------------------*/
655/*---------------------------------------------------------------------------*/
656
663
664/*---------------------------------------------------------------------------*/
665/*---------------------------------------------------------------------------*/
666
673
674/*---------------------------------------------------------------------------*/
675/*---------------------------------------------------------------------------*/
676
677} // End namespace Arcane::Materials
678
679/*---------------------------------------------------------------------------*/
680/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
#define ENUMERATE_CELL(name, group)
Generic enumerator for a cell group.
Memory and allocator management functions.
#define RUNCOMMAND_LOOP1(iter_name, x1,...)
1D loop on accelerator with additional arguments.
bool isAsync() const
Indicates if the execution queue is asynchronous.
Definition RunQueue.cc:320
void barrier() const
Blocks until all commands associated with the queue are finished.
Definition RunQueue.cc:159
Constant view of an array of type T.
constexpr Integer size() const noexcept
Number of elements in the array.
Interface of an entity family.
Definition IItemFamily.h:83
virtual ItemGroup findGroup(const String &name) const =0
Searches for a group.
virtual Int32 maxLocalId() const =0
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
IItemFamily * itemFamily() const
Entity family to which this group belongs (0 for the null group).
Definition ItemGroup.h:128
ItemGroupImplInternal * _internalApi() const
Internal Arcane API.
Definition ItemGroup.cc:643
Index of an Item in a variable.
Definition ItemLocalId.h:42
Int32ConstArrayView localIds() const
Array of local IDs of entities.
Arcane cell with material and environment information.
Management of 'ComponentItemInternal' lists.
Interval of constituent identifiers in the ComponentItemInternal list.
Helper class for building a list of ComponentItems for a MeshMaterialVariableIndexer.
void addPureItem(Int32 local_id)
Adds the entity with localId() local_id to the list of pure entities.
void addPartialItem(Int32 local_id)
Adds the entity with localId() local_id to the list of partial entities.
View over a vector of entities of a component.
Management of constituent connectivity lists.
Int16 cellNbMaterial(CellLocalId cell_id, Int16 env_id)
Number of materials of the cell cell_id for environment index env_id.
Index of a constituent entity in the list of constituent entities.
View of a ConstituentItemLocalIdList instance.
Arcane cell of an environment.
__host__ __device__ Int32 environmentId() const
Environment identifier.
View over the impure part of the entities of an environment.
View over a vector of entities of an environment.
View over pure or partial entities of an environment.
View over the pure part of the entities of an environment.
virtual CellGroup cells() const =0
Group of cells for this material.
Interface for the material and environment manager of a mesh.
Represents an index on material and environment variables.
Data of a constituent (material or medium) of a mesh.
void _changeLocalIdsForInternalList(Int32ConstArrayView old_to_new_ids)
Updates the constituent's m_items_internal after a change in local numbering.
ConstituentItemLocalIdList m_constituent_local_id_list
List of ConstituentItemIndex for this constituent.
bool needInfo() const override
Indicates whether the observer will need transition information.
void executeReduce(const Int32ConstArrayView *info1) override
Execute the action associated with the extension.
void executeInvalidate() override
Execute the action associated with invalidation.
void executeExtend(const Int32ConstArrayView *info1) override
Execute the action associated with the extension.
void executeCompact(const Int32ConstArrayView *info1) override
Executes the action associated with compaction.
MeshMaterialVariableIndexer * variableIndexer() const override
Indexer to access partial variables.
Ref< IConstituentItemVectorImpl > createItemVectorImpl() const override
Create an instance of the 'ConstituentItemVectorImpl' implementation.
Int32 variableIndexerIndex() const override
Index to access partial variables.
void _computeMaterialIndexesMonoMat(ComponentItemInternalData *item_internal_data, RunQueue &queue)
Calculates material information for mono-materials.
IMeshMaterialMng * m_material_mng
Material manager.
void checkValid() override
Checks that the component is valid.
void build()
Public functions but reserved for IMeshMaterialMng.
ComponentItemVectorView view() const override
View associated with this component.
ComponentPartItemVectorView partItems(eMatPart part) const override
View on the pure or impure part of the component's entities.
ComponentImpurePartItemVectorView impureItems() const override
View on the list of impure (partial) entities of the component.
EnvImpurePartItemVectorView impureEnvItems() const override
View of the list of impure (partial) entities in the environment.
EnvPartItemVectorView partEnvItems(eMatPart part) const override
View of the pure or impure part of the environment entities.
void computeItemListForMaterials(const ConstituentConnectivityList &connectivity_list)
Calculation for the environment material cells and their location in the variable indexing table.
void computeMaterialIndexes(ComponentItemInternalData *item_internal_data, RunQueue &queue)
Calculates material information.
ComponentCell findComponentCell(AllEnvCell c) const override
Cell of this component for cell c.
Integer totalNbCellMat() const
Total number of cells for all materials.
EnvCell findEnvCell(AllEnvCell c) const override
Cell of this environment for cell c.
CellGroup cells() const override
Group of cells for this material.
void computeNbMatPerCell()
Recalculates the number of cells per material and the total number of cells.
ComponentPurePartItemVectorView pureItems() const override
View on the list of pure entities (associated with the global cell) of the component.
Integer nbMaterial() const override
Number of materials in the environment.
EnvPurePartItemVectorView pureEnvItems() const override
View of the list of pure entities (associated with the global cell) in the environment.
EnvItemVectorView envView() const override
View associated with this environment.
Integer m_total_nb_cell_mat
Total number of cells for all materials.
ITraceMng * traceMng() override
Associated trace manager.
bool isMonoMaterial() const
Indicates if the environment is mono-material.
String name() const override
Component name.
void endUpdate(const ComponentItemListBuilderOld &builder)
Private functions but accessible to 'friend' classes.
const String & name() const
Name of the indexer.
String name() const override
Component name.
CellGroup cells() const override
Group of cells for this material.
General information about a constituent entity.
__host__ __device__ void _setVariableIndex(MatVarIndex index)
Positions the indexer in material variables.
__host__ __device__ Int32 nbSubItem() const
Number of sub-components.
__host__ __device__ void _setFirstSubItem(ConstituentItemIndex first_sub_item)
Positions the first sub-component.
Reference to an instance.
View of an array of elements of type T.
Definition Span.h:805
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.
1D data vector with value semantics (STL style).
#define ENUMERATE_CELL_ENVCELL(iname, all_env_cell)
Macro to iterate over all EnvCell cells of a cell.
ItemGroupT< Cell > CellGroup
Group of cells.
Definition ItemTypes.h:184
RunCommand makeCommand(const RunQueue &run_queue)
Creates a command associated with the queue run_queue.
Always enables tracing in Arcane parts concerning materials.
MatItemVariableScalarOutViewT< Cell, DataType > viewOut(CellMaterialVariableScalarRef< DataType > &var)
Write view.
MatItemVariableScalarInViewT< Cell, DataType > viewIn(const CellMaterialVariableScalarRef< DataType > &var)
Read view.
eMatPart
Part of a component.
IMemoryAllocator * getDefaultDataAllocator()
Default allocator for data.
bool arcaneIsCheck()
True if running in check mode.
Definition Misc.cc:66
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
std::int16_t Int16
Signed integer type of 16 bits.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
std::int32_t Int32
Signed integer type of 32 bits.