Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ComponentItemListBuilder.h
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/* ComponentItemListBuilder.h (C) 2000-2024 */
9/* */
10/* Helper class for building a list of ComponentItems. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MATERIALS_INTERNAL_COMPONENTITEMLISTBUILDER_H
13#define ARCANE_MATERIALS_INTERNAL_COMPONENTITEMLISTBUILDER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array.h"
18#include "arcane/utils/NumArray.h"
19
20#include "arcane/core/materials/MatVarIndex.h"
21
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane::Materials
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
37class ARCANE_MATERIALS_EXPORT ComponentItemListBuilder
38{
39 public:
40
41 ComponentItemListBuilder();
42
43 public:
44
45 void preAllocate(Int32 nb_item)
46 {
47 m_partial_local_ids.resize(nb_item);
48 m_pure_indexes.resize(nb_item);
49 m_partial_indexes.resize(nb_item);
50 }
51
52 void resize(Int32 nb_pure, Int32 nb_partial)
53 {
54 m_partial_local_ids.resize(nb_partial);
55 m_pure_indexes.resize(nb_pure);
56 m_partial_indexes.resize(nb_partial);
57 }
58
59 public:
60
61 SmallSpan<Int32> pureIndexes() { return m_pure_indexes; }
62 SmallSpan<Int32> partialIndexes() { return m_partial_indexes; }
63 SmallSpan<Int32> partialLocalIds() { return m_partial_local_ids; }
64
65 SmallSpan<const Int32> pureIndexes() const { return m_pure_indexes; }
66 SmallSpan<const Int32> partialIndexes() const { return m_partial_indexes; }
67 SmallSpan<const Int32> partialLocalIds() const { return m_partial_local_ids; }
68
69 MeshMaterialVariableIndexer* indexer() const { return m_indexer; }
70 void setIndexer(MeshMaterialVariableIndexer* indexer) { m_indexer = indexer; }
71
72 private:
73
74 NumArray<Int32, MDDim1> m_partial_local_ids;
75 NumArray<Int32, MDDim1> m_pure_indexes;
76 NumArray<Int32, MDDim1> m_partial_indexes;
77
78 MeshMaterialVariableIndexer* m_indexer = nullptr;
79};
80
81/*---------------------------------------------------------------------------*/
82/*---------------------------------------------------------------------------*/
83
88class ARCANE_MATERIALS_EXPORT ComponentItemListBuilderOld
89{
90 public:
91
92 ComponentItemListBuilderOld(MeshMaterialVariableIndexer* var_indexer,
93 Integer begin_index_in_partial);
94
95 public:
96
98 void addPureItem(Int32 local_id)
99 {
100 m_pure_matvar_indexes.add(MatVarIndex(0, local_id));
101 }
102
104 void addPartialItem(Int32 local_id)
105 {
106 //TODO: when incremental deletion is implemented, it will be necessary
107 // to retrieve the correct index from the indexer's free index list.
108 m_partial_matvar_indexes.add(MatVarIndex(m_component_index, m_index_in_partial));
109 m_partial_local_ids.add(local_id);
110 ++m_index_in_partial;
111 }
112
113 public:
114
115 ConstArrayView<MatVarIndex> pureMatVarIndexes() const { return m_pure_matvar_indexes; }
116 ConstArrayView<MatVarIndex> partialMatVarIndexes() const { return m_partial_matvar_indexes; }
117 ConstArrayView<Int32> partialLocalIds() const { return m_partial_local_ids; }
118 MeshMaterialVariableIndexer* indexer() const { return m_indexer; }
119
120 private:
121
122 Integer m_component_index = -1;
123 Integer m_index_in_partial = -1;
124
125 UniqueArray<MatVarIndex> m_pure_matvar_indexes;
126
127 UniqueArray<MatVarIndex> m_partial_matvar_indexes;
128 UniqueArray<Int32> m_partial_local_ids;
129
130 MeshMaterialVariableIndexer* m_indexer = nullptr;
131};
132
133/*---------------------------------------------------------------------------*/
134/*---------------------------------------------------------------------------*/
135
136} // End namespace Arcane::Materials
137
138/*---------------------------------------------------------------------------*/
139/*---------------------------------------------------------------------------*/
140
141#endif
Constant view of an array of type T.
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.
Represents an index on material and environment variables.
Multi-dimensional arrays for numerical types accessible on accelerators.
View of an array of elements of type T.
Definition Span.h:805
Always enables tracing in Arcane parts concerning materials.
class ARCANE_MATERIALS_EXPORT(64) SimdMatVarIndex
SIMD indexer on a component.
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.