Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MeshPartialVariableArrayRef.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/* MeshPartialVariableArrayRef.h (C) 2000-2025 */
9/* */
10/* Class managing a partial array variable on a mesh entity. */
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
39template <typename DataTypeT>
41: public PrivateVariableArrayT<DataTypeT>
42{
43 public:
44
45 typedef DataTypeT DataType;
46 typedef UniqueArray2<DataType> ValueType;
47 typedef ConstArrayView<DataType> ConstReturnReferenceType;
48 typedef ArrayView<DataType> ReturnReferenceType;
49
50 protected:
51
52 typedef PrivateVariableArrayT<DataType> BaseClass;
53 typedef typename BaseClass::PrivatePartType PrivatePartType;
54
55 typedef ArrayView<DataType> ArrayType;
56 typedef ConstArrayView<DataType> ConstArrayType;
57
58 public:
59
61 ARCANE_CORE_EXPORT ItemPartialVariableArrayRefT(const VariableBuildInfo& vb, eItemKind ik);
62
64 explicit ARCANE_CORE_EXPORT ItemPartialVariableArrayRefT(IVariable* var);
65
68
69 protected:
70
72 ARCANE_CORE_EXPORT void operator=(const ItemPartialVariableArrayRefT<DataType>& rhs);
73
74 public:
75
76 ARCANE_CORE_EXPORT void fill(const DataType& value);
77 ARCANE_CORE_EXPORT void copy(const ItemPartialVariableArrayRefT<DataType>& v);
78 ARCANE_CORE_EXPORT void internalSetUsed(bool v);
79
80 public:
81
82 ConstArrayType operator[](const Item& i) const
83 {
84 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
85 ARCANE_ASSERT((m_table.isUsed()), ("GroupIndexTable expired"));
86 const GroupIndexTable& table = *m_table;
87 return this->m_view[table[i.localId()]];
88 }
89 ArrayType operator[](const Item& i)
90 {
91 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
92 ARCANE_ASSERT((m_table.isUsed()), ("GroupIndexTable expired"));
93 const GroupIndexTable& table = *m_table;
94 return this->m_view[table[i.localId()]];
95 }
96 ConstArrayType operator[](const ItemGroupRangeIterator& i) const
97 {
98 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
99 return this->m_view[i.index()];
100 }
101 ArrayType operator[](const ItemGroupRangeIterator& i)
102 {
103 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
104 return this->m_view[i.index()];
105 }
106 ConstArrayType operator[](const ItemEnumerator& i) const
107 {
108 ARCANE_CHECK_ENUMERATOR(i, this->itemGroup());
109 return this->m_view[i.index()];
110 }
111 ArrayType operator[](const ItemEnumerator& i)
112 {
113 ARCANE_CHECK_ENUMERATOR(i, this->itemGroup());
114 return this->m_view[i.index()];
115 }
116 ConstArrayType operator[](ItemEnumeratorIndex i) const
117 {
118 return this->m_view[i.index()];
119 }
120 ArrayType operator[](ItemEnumeratorIndex i)
121 {
122 return this->m_view[i.index()];
123 }
124
125 public:
126
128 GroupIndexTableView tableView() const { return m_table->view(); }
129
130 protected:
131
133
134 protected:
135
136 static VariableInfo _buildVariableInfo(const VariableBuildInfo& vbi, eItemKind ik);
137 static VariableTypeInfo _buildVariableTypeInfo(eItemKind ik);
138};
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
147template <typename ItemTypeT, typename DataTypeT>
149: public ItemPartialVariableArrayRefT<DataTypeT>
150{
151 public:
152
153 typedef DataTypeT DataType;
154 typedef ItemTypeT ItemType;
155 typedef UniqueArray2<DataType> ValueType;
156 typedef ConstArrayView<DataType> ConstReturnReferenceType;
157 typedef ArrayView<DataType> ReturnReferenceType;
158 typedef ItemLocalIdT<ItemType> ItemLocalIdType;
159
160 public:
161
163
164 typedef typename ItemTraitsT<ItemType>::ItemGroupType GroupType;
165
167
168 typedef ArrayView<DataType> ArrayType;
169 typedef ConstArrayView<DataType> ConstArrayType;
170
171 public:
172
174 ARCANE_CORE_EXPORT MeshPartialVariableArrayRefT(const VariableBuildInfo& vb);
179
180 public:
181
182 ConstArrayType operator[](const ItemLocalIdType& i) const
183 {
184 ARCANE_ASSERT((this->m_table.isUsed()), ("GroupIndexTable expired"));
185 const GroupIndexTable& table = *this->m_table;
186 return this->m_view[table[i.asInt32()]];
187 }
188 ArrayType operator[](const ItemLocalIdType& i)
189 {
190 ARCANE_ASSERT((this->m_table.isUsed()), ("GroupIndexTable expired"));
191 const GroupIndexTable& table = *this->m_table;
192 return this->m_view[table[i.asInt32()]];
193 }
194 ConstArrayType operator[](const ItemGroupRangeIteratorT<ItemType>& i) const
195 {
196 return this->m_view[i.index()];
197 }
198 ArrayType operator[](const ItemGroupRangeIteratorT<ItemType>& i)
199 {
200 return this->m_view[i.index()];
201 }
202 ConstArrayType operator[](const ItemPairEnumeratorSubT<ItemType>& i) const
203 {
204 return this->m_view[i.index()];
205 }
206 ArrayType operator[](const ItemPairEnumeratorSubT<ItemType>& i)
207 {
208 return this->m_view[i.index()];
209 }
210 ConstArrayType operator[](const ItemEnumeratorT<ItemType>& i) const
211 {
212 ARCANE_CHECK_ENUMERATOR(i, this->itemGroup());
213 return this->m_view[i.index()];
214 }
215 ArrayType operator[](const ItemEnumeratorT<ItemType>& i)
216 {
217 ARCANE_CHECK_ENUMERATOR(i, this->itemGroup());
218 return this->m_view[i.index()];
219 }
220 ConstArrayType operator[](ItemEnumeratorIndexT<ItemType> i) const
221 {
222 return this->m_view[i.index()];
223 }
224 ArrayType operator[](ItemEnumeratorIndexT<ItemType> i)
225 {
226 return this->m_view[i.index()];
227 }
228
230 ARCANE_CORE_EXPORT GroupType itemGroup() const;
231
232 private:
233
234 static VariableFactoryRegisterer m_auto_registerer;
235 static VariableInfo _buildVariableInfo(const VariableBuildInfo& vbi);
236 static VariableTypeInfo _buildVariableTypeInfo();
237 static VariableRef* _autoCreate(const VariableBuildInfo& vb);
238};
239
240/*---------------------------------------------------------------------------*/
241/*---------------------------------------------------------------------------*/
242
243} // End namespace Arcane
244
245/*---------------------------------------------------------------------------*/
246/*---------------------------------------------------------------------------*/
247
248#endif
Types and macros for iterating over mesh entities.
Modifiable view of an array of type T.
Constant view of an array of type T.
Base class of a hash table between group items and their positions in the table.
Interface of a variable.
Definition IVariable.h:40
Index of an ItemType entity in a variable.
Definition ItemLocalId.h:92
ItemPartialVariableArrayRefT(const VariableBuildInfo &vb, eItemKind ik)
Constructs a reference to the variable specified in vb.
GroupIndexTableView tableView() const
View of the group indirection table.
void operator=(const ItemPartialVariableArrayRefT< DataType > &rhs)
Copy assignment operator.
ItemPartialVariableArrayRefT(IVariable *var)
Constructs a reference from var.
ItemPartialVariableArrayRefT(const ItemPartialVariableArrayRefT< DataType > &rhs)
Constructs a reference from rhs.
Characteristics of mesh elements.
Definition ItemTypes.h:625
Base class for a mesh element.
Definition Item.h:84
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
Definition Item.h:233
void refersTo(const MeshPartialVariableArrayRefT< ItemType, DataType > &rhs)
Positions the instance reference to the variable rhs.
MeshPartialVariableArrayRefT(const VariableBuildInfo &vb)
Constructs a reference to the variable specified in vb.
MeshPartialVariableArrayRefT(const MeshPartialVariableArrayRefT< ItemType, DataType > &rhs)
Constructs a reference from rhs.
GroupType itemGroup() const
Group associated with the quantity.
2D data vector with value semantics (STL style).
Parameters necessary for building a variable.
Information characterizing a variable.
Reference to a variable.
Definition VariableRef.h:56
Information characterizing the type of a variable.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
eItemKind
Mesh entity type.