Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ComponentItemInternalData.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/* ComponentItemInternalData.h (C) 2000-2024 */
9/* */
10/* Management of 'ComponentItemInternal' lists. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MATERIALS_INTERNAL_COMPONENTITEMINTERNALDATA_H
13#define ARCANE_MATERIALS_INTERNAL_COMPONENTITEMINTERNALDATA_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/Array.h"
19#include "arcane/utils/NumArray.h"
20
22#include "arcane/core/materials/ComponentItemInternal.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane::Materials
28{
29class MeshMaterialMng;
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
39{
40 public:
41
43 {};
44 class Iterator
45 {
46 friend ComponentItemInternalRange;
47
48 private:
49
50 Iterator(Int32 current_value, Int32 last_value)
51 : m_current_value(current_value)
52 , m_last_value(last_value)
53 {}
54
55 public:
56
57 ConstituentItemIndex operator*() const { return ConstituentItemIndex(m_current_value); }
58 void operator++() { ++m_current_value; }
59 bool operator==(const Sentinel&) const
60 {
61 return m_current_value == m_last_value;
62 }
63 bool operator!=(const Sentinel&) const
64 {
65 return m_current_value != m_last_value;
66 }
67
68 private:
69
70 Int32 m_current_value = 0;
71 Int32 m_last_value = 0;
72 };
73
74 public:
75
76 ARCCORE_HOST_DEVICE ConstituentItemIndex operator[](Int32 index) const
77 {
78 ARCANE_CHECK_AT(index, m_nb_value);
79 return ConstituentItemIndex(m_first_index + index);
80 }
81
82 public:
83
84 void setRange(Int32 first_index, Int32 nb_value)
85 {
86 m_first_index = first_index;
87 m_nb_value = nb_value;
88 }
89 Iterator begin() const
90 {
91 return Iterator(m_first_index, m_first_index + m_nb_value);
92 }
93 Sentinel end() const
94 {
95 return {};
96 }
97 Int32 size() const { return m_nb_value; }
98 ConstituentItemIndex firstValue() const { return ConstituentItemIndex(m_first_index); }
99
100 private:
101
102 Int32 m_first_index = -1;
103 Int32 m_nb_value = 0;
104};
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
108
116class ComponentItemInternalData
117: public TraceAccessor
118{
119 public:
120
122 class Storage
123 {
124 public:
125
126 explicit Storage(const MemoryAllocationOptions& alloc_info, const String& base_name);
127
128 public:
129
130 void resize(Int32 new_size, ComponentItemSharedInfo* shared_info, RunQueue& queue);
131 Int32 size() const { return m_size; }
132
133 private:
134
135 Int32 m_size = 0;
136 UniqueArray<ConstituentItemIndex> m_first_sub_constituent_item_id_list;
137 UniqueArray<ConstituentItemIndex> m_super_component_item_local_id_list;
138 UniqueArray<Int16> m_component_id_list;
139 UniqueArray<Int16> m_nb_sub_constituent_item_list;
140 UniqueArray<Int32> m_global_item_local_id_list;
141 UniqueArray<MatVarIndex> m_var_index_list;
142
143 private:
144
145 static MemoryAllocationOptions _allocInfo(const MemoryAllocationOptions& alloc_info,
146 const String& base_name, const String& name);
147 };
148
149 public:
150
151 explicit ComponentItemInternalData(MeshMaterialMng* mm);
152
153 public:
154
156 void endCreate();
157
158 public:
159
161 void resizeComponentItemInternals(Int32 max_local_id, Int32 total_env_cell);
162
164 ComponentItemSharedInfo* sharedInfo(Int16 level) { return &m_shared_infos[level]; }
165 ComponentItemSharedInfo* allEnvSharedInfo() { return sharedInfo(LEVEL_ALLENVIRONMENT); }
166 ComponentItemSharedInfo* envSharedInfo() { return sharedInfo(LEVEL_ENVIRONMENT); }
167 ComponentItemSharedInfo* matSharedInfo() { return sharedInfo(LEVEL_MATERIAL); }
168
169 private:
170
171 MeshMaterialMng* m_material_mng = nullptr;
172
175
176 ComponentItemInternalRange m_all_env_items_internal_range;
177 ComponentItemInternalRange m_env_items_internal_range;
178
179 Storage m_all_env_storage;
180 Storage m_env_storage;
181 Storage m_mat_storage;
182
183 private:
184
185 void _initSharedInfos();
186 static MemoryAllocationOptions _allocOptions();
187
188 public:
189
191 void _resetItemsInternal();
192};
193
194/*---------------------------------------------------------------------------*/
195/*---------------------------------------------------------------------------*/
196
197} // namespace Arcane::Materials
198
199/*---------------------------------------------------------------------------*/
200/*---------------------------------------------------------------------------*/
201
202#endif
Container for ComponentItemSharedInfo information.
void endCreate()
Notification of the end of environment/material creation.
void resizeComponentItemInternals(Int32 max_local_id, Int32 total_env_cell)
Resizes the structures allocating 'ComponentItemInternal'.
void _resetItemsInternal()
Resets ComponentItemInternal associated with EnvCell and AllEnvCell.
ComponentItemSharedInfo * sharedInfo(Int16 level)
Shared instance associated with the level.
UniqueArray< ComponentItemSharedInfo > m_shared_infos
List of shared information.
Interval of constituent identifiers in the ComponentItemInternal list.
Index of a constituent entity in the list of constituent entities.
Implementation of a material manager.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
1D data vector with value semantics (STL style).
Always enables tracing in Arcane parts concerning materials.
std::int16_t Int16
Signed integer type of 16 bits.
std::int32_t Int32
Signed integer type of 32 bits.