Arcane  v3.15.3.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ConstituentItemSharedInfo.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* ConstituentItemSharedInfo.h (C) 2000-2024 */
9/* */
10/* Informations partagées pour les structures de 'ConstituentItem' */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MATERIALS_CONSTITUENTITEMSHAREDINFO_H
13#define ARCANE_CORE_MATERIALS_CONSTITUENTITEMSHAREDINFO_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/ItemInternal.h"
18#include "arcane/core/Item.h"
19#include "arcane/core/materials/ConstituentItemLocalId.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane::Materials
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29/*!
30 * \internal
31 * \brief Index d'une entité constituant dans la liste des entités constituants.
32 *
33 * L'index est propre à chaque type d'entité consituant (AllEnvCell, EnvCell, MatCell).
34 * La liste est gérée par ComponentIemtInternalData.
35 */
36class ARCANE_CORE_EXPORT ConstituentItemIndex
37{
38 public:
39
40 ConstituentItemIndex() = default;
41 explicit ARCCORE_HOST_DEVICE constexpr ConstituentItemIndex(Int32 id)
42 : m_id(id)
43 {}
44 ARCCORE_HOST_DEVICE constexpr Int32 localId() const { return m_id; }
45 ARCCORE_HOST_DEVICE friend constexpr bool operator==(ConstituentItemIndex a,
47 {
48 return a.m_id == b.m_id;
49 }
50 ARCCORE_HOST_DEVICE friend constexpr bool operator!=(ConstituentItemIndex a,
52 {
53 return a.m_id != b.m_id;
54 }
55 ARCANE_CORE_EXPORT friend std::ostream&
56 operator<<(std::ostream& o, const ConstituentItemIndex& id);
57
58 ARCCORE_HOST_DEVICE constexpr bool isNull() const { return m_id == (-1); }
59
60 private:
61
62 Int32 m_id = -1;
63};
64
65/*---------------------------------------------------------------------------*/
66/*---------------------------------------------------------------------------*/
67/*!
68 * \brief Conteneur pour les données des constituants.
69 */
70class ARCANE_CORE_EXPORT ComponentItemSharedInfoStorageView
71{
72 // Les champs de cette classe sont des tableaux dont la taille est
73 // \a m_storage_size et qui peuvent être indexés par une entité nulle
74 // (ConstituentItemIndex==(-1)).
75 // Le conteneur est géré par ComponenItemInternalData.
76 // Seuls ComponentItemSharedInfo et ComponenItemInternalData
77 // doivent accéder aux champs de cette classe
78
79 // TODO: Utiliser stockage avec un seul élément pour le nullComponent
80
81 friend class ComponentItemInternalData;
83
84 private:
85
86 Int32 m_storage_size = 0;
87 //! Id de la première entité sous-constituant
88 ConstituentItemIndex* m_first_sub_constituent_item_id_data = nullptr;
89 //! Index du constituant (IMeshComponent)
90 Int16* m_component_id_data = nullptr;
91 //! Nombre d'entités sous-constituant
92 Int16* m_nb_sub_constituent_item_data = nullptr;
93 //! localId() de l'entité globale associée
94 Int32* m_global_item_local_id_data = nullptr;
95 //! Id de l'entité sous-constituant parente
96 ConstituentItemIndex* m_super_component_item_local_id_data = nullptr;
97 //! MatVarIndex de l'entité
98 MatVarIndex* m_var_index_data = nullptr;
99};
100
101/*---------------------------------------------------------------------------*/
102/*---------------------------------------------------------------------------*/
103/*!
104 * \internal
105 * \brief Informations partagées sur les 'ComponentItem'.
106 *
107 * Il y a 3 instances de cette classe : une pour les AllEnvCell, une pour les
108 * EnvCell et une pour les MatCell. Ces instances sont gérées par la classe
109 * ComponentItemInternalData. Il est possible de conserver un pointeur sur
110 * les intances de cette classe car ils sont valides durant toute la vie
111 * d'un MeshMaterialMng.
112 */
113class ARCANE_CORE_EXPORT ConstituentItemSharedInfo
115{
116 friend ComponentItemInternalData;
118 friend ConstituentItemLocalIdList;
119 friend ConstituentItemLocalIdListView;
121 friend ConstituentItem;
124 friend ConstituentItemVectorImpl;
125
126 static const int MAT_INDEX_OFFSET = 10;
127
128 private:
129
130 //! Pour l'entité nulle
131 static ComponentItemSharedInfo null_shared_info;
132 static ComponentItemSharedInfo* null_shared_info_pointer;
133 static ComponentItemSharedInfo* _nullInstance() { return null_shared_info_pointer; }
134 static void _setNullInstance();
135
136 private:
137
138 inline constexpr matimpl::ConstituentItemBase _item(ConstituentItemIndex id);
139 inline ARCCORE_HOST_DEVICE ConstituentItemIndex _firstSubConstituentLocalId(ConstituentItemIndex id) const
140 {
141 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
142 return m_first_sub_constituent_item_id_data[id.localId()];
143 }
144 inline ARCCORE_HOST_DEVICE void
145 _setFirstSubConstituentLocalId(ConstituentItemIndex id, ConstituentItemIndex first_id)
146 {
147 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
148 m_first_sub_constituent_item_id_data[id.localId()] = first_id;
149 }
150 inline ARCCORE_HOST_DEVICE Int16 _nbSubConstituent(ConstituentItemIndex id) const
151 {
152 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
153 return m_nb_sub_constituent_item_data[id.localId()];
154 }
155 ARCCORE_HOST_DEVICE inline void _setNbSubConstituent(ConstituentItemIndex id, Int16 n)
156 {
157 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
158 m_nb_sub_constituent_item_data[id.localId()] = n;
159 }
160 inline ARCCORE_HOST_DEVICE Int16 _componentId(ConstituentItemIndex id) const
161 {
162 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
163 return m_component_id_data[id.localId()];
164 }
165 ARCCORE_HOST_DEVICE inline void _setComponentId(ConstituentItemIndex id, Int16 component_id)
166 {
167 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
168 m_component_id_data[id.localId()] = component_id;
169 }
170 IMeshComponent* _component(ConstituentItemIndex id) const
171 {
172 return m_components[_componentId(id)];
173 }
174 impl::ItemBase _globalItemBase(ConstituentItemIndex id) const
175 {
176 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
177 return impl::ItemBase(m_global_item_local_id_data[id.localId()], m_item_shared_info);
178 }
179 ARCCORE_HOST_DEVICE Int32 _globalItemId(ConstituentItemIndex id) const
180 {
181 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
182 return m_global_item_local_id_data[id.localId()];
183 }
185 {
186 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
187 m_global_item_local_id_data[id.localId()] = global_item_lid.localId();
188 }
190
192 {
193 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
194 m_super_component_item_local_id_data[id.localId()] = super_id;
195 }
197
199 {
200 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
201 return m_var_index_data[id.localId()];
202 }
204 {
205 ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
206 m_var_index_data[id.localId()] = mv_index;
207 }
208
209 //! Numéro unique de l'entité component
210 Int64 _componentUniqueId(ConstituentItemIndex id) const
211 {
212 // TODO: Vérifier que arrayIndex() ne dépasse pas (1<<MAT_INDEX_OFFSET)
213 impl::ItemBase item_base(_globalItemBase(id));
214 return (Int64)m_var_index_data[id.localId()].arrayIndex() + ((Int64)item_base.uniqueId() << MAT_INDEX_OFFSET);
215 }
216
218 {
219 Int32 local_id = id.localId();
220 ARCCORE_CHECK_RANGE(local_id, -1, m_storage_size);
221
222 m_var_index_data[local_id].reset();
223 m_first_sub_constituent_item_id_data[local_id] = {};
224 m_nb_sub_constituent_item_data[local_id] = 0;
225 m_component_id_data[local_id] = -1;
226 m_global_item_local_id_data[local_id] = NULL_ITEM_LOCAL_ID;
227 m_super_component_item_local_id_data[local_id] = {};
228 }
229
230 private:
231
232 // NOTE : Cette classe est partagée avec le wrapper C#
233 // Toute modification de la structure interne doit être reportée
234 // dans la structure C# correspondante
235 ItemSharedInfo* m_item_shared_info = ItemSharedInfo::nullInstance();
236 Int16 m_level = (-1);
238 ComponentItemSharedInfo* m_super_component_item_shared_info = null_shared_info_pointer;
239 ComponentItemSharedInfo* m_sub_component_item_shared_info = null_shared_info_pointer;
240};
241
242/*---------------------------------------------------------------------------*/
243/*---------------------------------------------------------------------------*/
244
245} // End namespace Arcane::Materials
246
247/*---------------------------------------------------------------------------*/
248/*---------------------------------------------------------------------------*/
249
250#include "arcane/core/materials/ConstituentItemBase.h"
251
252/*---------------------------------------------------------------------------*/
253/*---------------------------------------------------------------------------*/
254
255#endif
Classe de base pour les entités du maillage.
Index d'un Item dans une variable.
Definition ItemLocalId.h:41
Enumérateur sur les constituants d'une maille.
Conteneur pour les données des constituants.
Représente un composant d'une maille multi-matériau.
Interface d'un composant (matériau ou milieu) d'un maillage.
Représente un index sur les variables matériaux et milieux.
Référence à une instance.
Active toujours les traces dans les parties Arcane concernant les matériaux.