Arcane  v3.16.8.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
MeshPartialVariableArrayRef.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* MeshPartialVariableArrayRef.h (C) 2000-2025 */
9/* */
10/* Classe gérant une variable partielle array sur une entité du maillage. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MESHPARTIALVARIABLEARRAYREF_H
13#define ARCANE_CORE_MESHPARTIALVARIABLEARRAYREF_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/FatalErrorException.h"
18
19#include "arcane/core/MeshVariableRef.h"
20#include "arcane/core/PrivateVariableArray.h"
22#include "arcane/core/ItemGroupRangeIterator.h"
23#include "arcane/core/ItemPairEnumerator.h"
24#include "arcane/core/GroupIndexTable.h"
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Arcane
30{
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34/*!
35 * \ingroup Variable
36 * \brief Variable partielle scalaire sur un type d'entité du maillage.
37 */
38template<typename DataTypeT>
40: public PrivateVariableArrayT<DataTypeT>
41{
42 public:
43
44 typedef DataTypeT DataType;
45 typedef UniqueArray2<DataType> ValueType;
46 typedef ConstArrayView<DataType> ConstReturnReferenceType;
47 typedef ArrayView<DataType> ReturnReferenceType;
48
49 protected:
50
51 typedef PrivateVariableArrayT<DataType> BaseClass;
52 typedef typename BaseClass::PrivatePartType PrivatePartType;
53
54 typedef ArrayView<DataType> ArrayType;
55 typedef ConstArrayView<DataType> ConstArrayType;
56
57 public:
58
59 //! Construit une référence à la variable spécifiée dans \a vb
61
62 //! Construit une référence à partir de \a var
63 explicit ARCANE_CORE_EXPORT ItemPartialVariableArrayRefT(IVariable* var);
64
65 //! Construit une référence à partir de \a rhs
67
68 protected:
69
70 //! Opérateur de recopie
71 ARCANE_CORE_EXPORT void operator=(const ItemPartialVariableArrayRefT<DataType>& rhs);
72
73 public:
74
75 ARCANE_CORE_EXPORT void fill(const DataType& value);
76 ARCANE_CORE_EXPORT void copy(const ItemPartialVariableArrayRefT<DataType>& v);
77 ARCANE_CORE_EXPORT void internalSetUsed(bool v);
78
79 public:
80
81 ConstArrayType operator[](const Item& i) const
82 {
83 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
84 ARCANE_ASSERT((m_table.isUsed()),("GroupIndexTable expired"));
85 const GroupIndexTable& table = *m_table;
86 return this->m_view[table[i.localId()]];
87 }
88 ArrayType operator[](const Item& i)
89 {
90 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
91 ARCANE_ASSERT((m_table.isUsed()),("GroupIndexTable expired"));
92 const GroupIndexTable& table = *m_table;
93 return this->m_view[table[i.localId()]];
94 }
95 ConstArrayType operator[](const ItemGroupRangeIterator& i) const
96 {
97 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
98 return this->m_view[i.index()];
99 }
100 ArrayType operator[](const ItemGroupRangeIterator& i)
101 {
102 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
103 return this->m_view[i.index()];
104 }
105 ConstArrayType operator[](const ItemEnumerator& i) const
106 {
107 ARCANE_CHECK_ENUMERATOR(i,this->itemGroup());
108 return this->m_view[i.index()];
109 }
110 ArrayType operator[](const ItemEnumerator& i)
111 {
112 ARCANE_CHECK_ENUMERATOR(i,this->itemGroup());
113 return this->m_view[i.index()];
114 }
115 ConstArrayType operator[](ItemEnumeratorIndex i) const
116 {
117 return this->m_view[i.index()];
118 }
119 ArrayType operator[](ItemEnumeratorIndex i)
120 {
121 return this->m_view[i.index()];
122 }
123
124 public:
125
126 //! Vue sur table d'indirection du groupe.
127 GroupIndexTableView tableView() const { return m_table->view(); }
128
129 protected:
130
132
133 protected:
134
135 static VariableInfo _buildVariableInfo(const VariableBuildInfo& vbi,eItemKind ik);
136 static VariableTypeInfo _buildVariableTypeInfo(eItemKind ik);
137};
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141/*!
142 * \ingroup Variable
143 * \brief Variable scalaire sur un type d'entité du maillage.
144 */
145template<typename ItemTypeT,typename DataTypeT>
147: public ItemPartialVariableArrayRefT<DataTypeT>
148{
149 public:
150
151 typedef DataTypeT DataType;
152 typedef ItemTypeT ItemType;
153 typedef UniqueArray2<DataType> ValueType;
154 typedef ConstArrayView<DataType> ConstReturnReferenceType;
155 typedef ArrayView<DataType> ReturnReferenceType;
156 typedef ItemLocalIdT<ItemType> ItemLocalIdType;
157
158 public:
159
161
162 typedef typename ItemTraitsT<ItemType>::ItemGroupType GroupType;
163
165
166 typedef ArrayView<DataType> ArrayType;
167 typedef ConstArrayView<DataType> ConstArrayType;
168
169 public:
170
171 //! Construit une référence à la variable spécifiée dans \a vb
172 ARCANE_CORE_EXPORT MeshPartialVariableArrayRefT(const VariableBuildInfo& vb);
173 //! Construit une référence à partir de \a rhs
175 //! Positionne la référence de l'instance à la variable \a rhs.
177
178 public:
179
180 ConstArrayType operator[](const ItemLocalIdType& i) const
181 {
182 ARCANE_ASSERT((this->m_table.isUsed()),("GroupIndexTable expired"));
183 const GroupIndexTable& table = *this->m_table;
184 return this->m_view[table[i.asInt32()]];
185 }
186 ArrayType operator[](const ItemLocalIdType& i)
187 {
188 ARCANE_ASSERT((this->m_table.isUsed()),("GroupIndexTable expired"));
189 const GroupIndexTable& table = *this->m_table;
190 return this->m_view[table[i.asInt32()]];
191 }
192 ConstArrayType operator[](const ItemGroupRangeIteratorT<ItemType>& i) const
193 {
194 return this->m_view[i.index()];
195 }
196 ArrayType operator[](const ItemGroupRangeIteratorT<ItemType>& i)
197 {
198 return this->m_view[i.index()];
199 }
200 ConstArrayType operator[](const ItemPairEnumeratorSubT<ItemType>& i) const
201 {
202 return this->m_view[i.index()];
203 }
204 ArrayType operator[](const ItemPairEnumeratorSubT<ItemType>& i)
205 {
206 return this->m_view[i.index()];
207 }
208 ConstArrayType operator[](const ItemEnumeratorT<ItemType>& i) const
209 {
210 ARCANE_CHECK_ENUMERATOR(i,this->itemGroup());
211 return this->m_view[i.index()];
212 }
213 ArrayType operator[](const ItemEnumeratorT<ItemType>& i)
214 {
215 ARCANE_CHECK_ENUMERATOR(i,this->itemGroup());
216 return this->m_view[i.index()];
217 }
218 ConstArrayType operator[](ItemEnumeratorIndexT<ItemType> i) const
219 {
220 return this->m_view[i.index()];
221 }
222 ArrayType operator[](ItemEnumeratorIndexT<ItemType> i)
223 {
224 return this->m_view[i.index()];
225 }
226
227 //! Groupe associé à la grandeur
228 ARCANE_CORE_EXPORT GroupType itemGroup() const;
229
230 private:
231
232 static VariableFactoryRegisterer m_auto_registerer;
233 static VariableInfo _buildVariableInfo(const VariableBuildInfo& vbi);
234 static VariableTypeInfo _buildVariableTypeInfo();
235 static VariableRef* _autoCreate(const VariableBuildInfo& vb);
236};
237
238/*---------------------------------------------------------------------------*/
239/*---------------------------------------------------------------------------*/
240
241} // End namespace Arcane
242
243/*---------------------------------------------------------------------------*/
244/*---------------------------------------------------------------------------*/
245
246#endif
Types et macros pour itérer sur les entités du maillage.
Vue modifiable d'un tableau d'un type T.
Vue constante d'un tableau de type T.
Interface d'une variable.
Definition IVariable.h:39
Index d'une entité ItemType dans une variable.
Definition ItemLocalId.h:90
ItemPartialVariableArrayRefT(const VariableBuildInfo &vb, eItemKind ik)
Construit une référence à la variable spécifiée dans vb.
GroupIndexTableView tableView() const
Vue sur table d'indirection du groupe.
void operator=(const ItemPartialVariableArrayRefT< DataType > &rhs)
Opérateur de recopie.
ItemPartialVariableArrayRefT(IVariable *var)
Construit une référence à partir de var.
ItemPartialVariableArrayRefT(const ItemPartialVariableArrayRefT< DataType > &rhs)
Construit une référence à partir de rhs.
Classe de base d'un élément de maillage.
Definition Item.h:83
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
Definition Item.h:219
void refersTo(const MeshPartialVariableArrayRefT< ItemType, DataType > &rhs)
Positionne la référence de l'instance à la variable rhs.
MeshPartialVariableArrayRefT(const VariableBuildInfo &vb)
Construit une référence à la variable spécifiée dans vb.
MeshPartialVariableArrayRefT(const MeshPartialVariableArrayRefT< ItemType, DataType > &rhs)
Construit une référence à partir de rhs.
GroupType itemGroup() const
Groupe associé à la grandeur.
Vecteur de données 2D avec sémantique par valeur (style STL).
Paramètres nécessaires à la construction d'une variable.
Infos caractérisant une variable.
Référence à une variable.
Definition VariableRef.h:56
Informations caractérisant le type d'une variable.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
eItemKind
Genre d'entité de maillage.