Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MeshPartialVariableScalarRef.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/* MeshPartialVariableScalarRef.h (C) 2000-2025 */
9/* */
10/* Class managing a partial scalar variable on a mesh entity. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MESHPARTIALVARIABLESCALARREF_H
13#define ARCANE_CORE_MESHPARTIALVARIABLESCALARREF_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/FatalErrorException.h"
18
19#include "arcane/core/MeshVariableRef.h"
20#include "arcane/core/PrivateVariableScalar.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 PrivateVariableScalarT<DataTypeT>
42{
43 public:
44
45 typedef DataTypeT DataType;
46 typedef UniqueArray<DataType> ValueType;
47 typedef const DataType& ConstReturnReferenceType;
48 typedef DataType& ReturnReferenceType;
49
50 protected:
51
52 typedef PrivateVariableScalarT<DataType> BaseClass;
53 typedef typename BaseClass::PrivatePartType PrivatePartType;
54 typedef typename BaseClass::DataTypeReturnReference DataTypeReturnReference;
55
56 public:
57
61 explicit ARCANE_CORE_EXPORT ItemPartialVariableScalarRefT(IVariable* var);
64
65 protected:
66
68 ARCANE_CORE_EXPORT void operator=(const ItemPartialVariableScalarRefT<DataType>& rhs);
69
70 public:
71
72 ARCANE_CORE_EXPORT void fill(const DataType& value);
73 ARCANE_CORE_EXPORT void copy(const ItemPartialVariableScalarRefT<DataType>& v);
74 ARCANE_CORE_EXPORT void internalSetUsed(bool v);
75
76 public:
77
78 const DataType& operator[](const Item& i) const
79 {
80 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
81 ARCANE_ASSERT((m_table.isUsed()), ("GroupIndexTable expired"));
82 const GroupIndexTable& table = *m_table;
83 return this->_value(table[i.localId()]);
84 }
85 DataTypeReturnReference operator[](const Item& i)
86 {
87 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
88 ARCANE_ASSERT((m_table.isUsed()), ("GroupIndexTable expired"));
89 const GroupIndexTable& table = *m_table;
90 return this->_value(table[i.localId()]);
91 }
92
93 const DataType& operator[](const ItemGroupRangeIterator& i) const
94 {
95 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
96 return this->_value(i.index());
97 }
98 const DataType& operator[](const ItemEnumerator& i) const
99 {
100 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND((*i));
101 ARCANE_CHECK_ENUMERATOR(i, this->itemGroup());
102 return this->_value(i.index());
103 }
104 const DataType& operator[](ItemEnumeratorIndex i) const
105 {
106 return this->_value(i.index());
107 }
108 const DataType& operator[](const ItemPairEnumerator& i) const
109 {
110 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND((*i));
111 return this->_value(i.index());
112 }
113
114 DataTypeReturnReference operator[](const ItemGroupRangeIterator& i)
115 {
116 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND(i);
117 return this->_value(i.index());
118 }
119 DataTypeReturnReference operator[](const ItemEnumerator& i)
120 {
121 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND((*i));
122 ARCANE_CHECK_ENUMERATOR(i, this->itemGroup());
123 return this->_value(i.index());
124 }
125 DataTypeReturnReference operator[](ItemEnumeratorIndex i)
126 {
127 return this->_value(i.index());
128 }
129 DataTypeReturnReference operator[](const ItemPairEnumerator& i)
130 {
131 ARCANE_CHECK_VALID_ITEM_AND_GROUP_KIND((*i));
132 return this->_value(i.index());
133 }
134
135 public:
136
138 GroupIndexTableView tableView() const { return m_table->view(); }
139
140 protected:
141
143
144 protected:
145
146 static VariableInfo _buildVariableInfo(const VariableBuildInfo& vbi, eItemKind ik);
147 static VariableTypeInfo _buildVariableTypeInfo(eItemKind ik);
148};
149
150/*---------------------------------------------------------------------------*/
151/*---------------------------------------------------------------------------*/
152
157template <typename ItemTypeT, typename DataTypeT>
159: public ItemPartialVariableScalarRefT<DataTypeT>
160{
161 public:
162
163 typedef DataTypeT DataType;
164 typedef ItemTypeT ItemType;
165 typedef UniqueArray<DataType> ValueType;
166 typedef const DataType& ConstReturnReferenceType;
167 typedef DataType& ReturnReferenceType;
168 typedef ItemLocalIdT<ItemType> ItemLocalIdType;
169
171
172 typedef typename ItemTraitsT<ItemType>::ItemGroupType GroupType;
173
175 typedef typename BaseClass::DataTypeReturnReference DataTypeReturnReference;
176
177 public:
178
185
186 public:
187
188 const DataType& operator[](const ItemLocalIdType& i) const
189 {
190 ARCANE_ASSERT((this->m_table.isUsed()), ("GroupIndexTable expired"));
191 const GroupIndexTable& table = *this->m_table;
192 return this->_value(table[i.asInt32()]);
193 }
194 DataTypeReturnReference operator[](const ItemLocalIdType& i)
195 {
196 ARCANE_ASSERT((this->m_table.isUsed()), ("GroupIndexTable expired"));
197 const GroupIndexTable& table = *this->m_table;
198 return this->_value(table[i.asInt32()]);
199 }
200
201 const DataType& operator[](const ItemGroupRangeIteratorT<ItemType>& i) const
202 {
203 return this->_value(i.index());
204 }
205 DataTypeReturnReference operator[](const ItemGroupRangeIteratorT<ItemType>& i)
206 {
207 return this->_value(i.index());
208 }
209 const DataType& operator[](const ItemEnumeratorT<ItemType>& i) const
210 {
211 ARCANE_CHECK_ENUMERATOR(i, this->itemGroup());
212 return this->_value(i.index());
213 }
214 const DataType& operator[](ItemEnumeratorIndexT<ItemType> i) const
215 {
216 return this->_value(i.index());
217 }
218 DataTypeReturnReference operator[](const ItemEnumeratorT<ItemType>& i)
219 {
220 ARCANE_CHECK_ENUMERATOR(i, this->itemGroup());
221 return this->_value(i.index());
222 }
223 DataTypeReturnReference operator[](ItemEnumeratorIndexT<ItemType> i)
224 {
225 return this->_value(i.index());
226 }
227 const DataType& operator[](const ItemPairEnumeratorSubT<ItemType>& i) const
228 {
229 return this->_value(i.index());
230 }
231 DataTypeReturnReference operator[](const ItemPairEnumeratorSubT<ItemType>& i)
232 {
233 return this->_value(i.index());
234 }
235
237 ARCANE_CORE_EXPORT GroupType itemGroup() const;
238
239 private:
240
241 static VariableFactoryRegisterer m_auto_registerer;
242 //static VariableInfo _buildVariableInfo(const VariableBuildInfo& vbi);
243 static VariableTypeInfo _buildVariableTypeInfo();
244 static VariableRef* _autoCreate(const VariableBuildInfo& vb);
245};
246
247/*---------------------------------------------------------------------------*/
248/*---------------------------------------------------------------------------*/
249
250} // End namespace Arcane
251
252/*---------------------------------------------------------------------------*/
253/*---------------------------------------------------------------------------*/
254
255#endif
Types and macros for iterating over mesh entities.
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
ItemPartialVariableScalarRefT(const VariableBuildInfo &vb, eItemKind ik)
Constructs a reference to the variable specified in vb.
GroupIndexTableView tableView() const
View of the group's redirection table.
ItemPartialVariableScalarRefT(IVariable *var)
Constructs a reference from var.
void operator=(const ItemPartialVariableScalarRefT< DataType > &rhs)
Copy operator.
ItemPartialVariableScalarRefT(const ItemPartialVariableScalarRefT< 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 MeshPartialVariableScalarRefT< ItemType, DataType > &rhs)
Positions the instance reference to the variable rhs.
MeshPartialVariableScalarRefT(const MeshPartialVariableScalarRefT< ItemType, DataType > &rhs)
Constructs a reference from rhs.
MeshPartialVariableScalarRefT(const VariableBuildInfo &vb)
Constructs a reference to the variable specified in vb.
GroupType itemGroup() const
Group associated with the quantity.
PrivateVariableScalarT(const VariableBuildInfo &vb, const VariableInfo &vi)
1D 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.