Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MeshVariableArrayRef.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/* MeshVariableArrayRef.h (C) 2000-2024 */
9/* */
10/* Class managing a vector variable on a mesh entity. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MESHVARIABLEARRAYREF_H
13#define ARCANE_CORE_MESHVARIABLEARRAYREF_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/PrivateVariableArray.h"
19#include "arcane/core/ItemGroupRangeIterator.h"
20#include "arcane/core/ItemPairEnumerator.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
34template <class DataTypeT>
36: public PrivateVariableArrayT<DataTypeT>
37{
38 public:
39
40 typedef DataTypeT DataType;
41 typedef UniqueArray2<DataType> ValueType;
42 typedef ConstArrayView<DataType> ConstReturnReferenceType;
43 typedef ArrayView<DataType> ReturnReferenceType;
44
45 protected:
46
47 typedef PrivateVariableArrayT<DataType> BaseClass;
48 typedef typename BaseClass::PrivatePartType PrivatePartType;
49
50 typedef ArrayView<DataType> ArrayType;
51 typedef ConstArrayView<DataType> ConstArrayType;
52
53 public:
54
56 ARCANE_CORE_EXPORT ItemVariableArrayRefT(const VariableBuildInfo& b, eItemKind ik);
57
59 explicit ARCANE_CORE_EXPORT ItemVariableArrayRefT(IVariable* var);
60
62 ARCANE_CORE_EXPORT ItemVariableArrayRefT(const ItemVariableArrayRefT<DataType>& rhs);
63
64 protected:
65
68
69 public:
70
72 ConstArrayType operator[](ItemLocalId item) const { return this->m_view[item.localId()]; }
73
75 ArrayType operator[](ItemLocalId item) { return this->m_view[item.localId()]; }
76
78 const DataType operator()(ItemLocalId item, Int32 i) const { return this->m_view.item(item.localId(), i); }
79
81 DataType& operator()(ItemLocalId item, Int32 i) { return this->m_view[item.localId()][i]; }
82
83 public:
84
86 ARCANE_CORE_EXPORT void copy(const ItemVariableArrayRefT<DataType>& v);
88 ARCANE_CORE_EXPORT void copy(const ItemVariableArrayRefT<DataType>& v, const ItemGroup& group);
94 ARCANE_CORE_EXPORT void copy(const ItemVariableArrayRefT<DataType>& v, RunQueue* queue);
96 ARCANE_CORE_EXPORT void fill(const DataType& value);
98 ARCANE_CORE_EXPORT void fill(const DataType& value, const ItemGroup& group);
100 ARCANE_CORE_EXPORT void fill(const DataType& value, RunQueue* queue);
101
102 public:
103
104 static ARCANE_CORE_EXPORT VariableInfo _internalVariableInfo(const VariableBuildInfo& vbi, eItemKind ik);
105 static ARCANE_CORE_EXPORT VariableTypeInfo _internalVariableTypeInfo(eItemKind ik);
106};
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
115template <class ItemTypeT, class DataTypeT>
117: public ItemVariableArrayRefT<DataTypeT>
118{
119 public:
120
121 typedef DataTypeT DataType;
122 typedef ItemTypeT ItemType;
123 typedef UniqueArray2<DataType> ValueType;
124 typedef ConstArrayView<DataType> ConstReturnReferenceType;
125 typedef ArrayView<DataType> ReturnReferenceType;
126
127 protected:
128
129 typedef MeshVariableRef BaseClass;
130
131 typedef Array2View<DataType> ArrayBase;
132
133 typedef ArrayView<DataType> ArrayType;
134 typedef ConstArrayView<DataType> ConstArrayType;
135
136 typedef Array2VariableT<DataType> PrivatePartType;
137
138 typedef typename ItemTraitsT<ItemType>::ItemGroupType GroupType;
139 typedef typename ItemTypeT::LocalIdType ItemLocalIdType;
140
142
143 public:
144
146 ARCANE_CORE_EXPORT MeshVariableArrayRefT(const VariableBuildInfo& b);
148 explicit ARCANE_CORE_EXPORT MeshVariableArrayRefT(IVariable* var);
152 ARCANE_CORE_EXPORT void refersTo(const MeshVariableArrayRefT<ItemType, DataType>& rhs);
153
154 ThatClass& operator=(const ThatClass& rhs) = delete; // Forbidden.
155
156 public:
157
159 ConstArrayType operator[](ItemLocalIdType item) const { return this->m_view[item.localId()]; }
160
162 ArrayType operator[](ItemLocalIdType item) { return this->m_view[item.localId()]; }
163
165 const DataType operator()(ItemLocalIdType item, Int32 i) const { return this->m_view[item.localId()][i]; }
166
168 DataType& operator()(ItemLocalIdType item, Int32 i) { return this->m_view[item.localId()][i]; }
169
170 public:
171
173 ARCANE_CORE_EXPORT GroupType itemGroup() const;
175
176 public:
177
178 static ARCANE_CORE_EXPORT VariableTypeInfo _internalVariableTypeInfo();
179 static ARCANE_CORE_EXPORT VariableInfo _internalVariableInfo(const VariableBuildInfo& vbi);
180
181 private:
182
183 static VariableFactoryRegisterer m_auto_registerer;
184 static VariableRef* _autoCreate(const VariableBuildInfo& vb);
185};
186
187/*---------------------------------------------------------------------------*/
188/*---------------------------------------------------------------------------*/
189
190} // End namespace Arcane
191
192/*---------------------------------------------------------------------------*/
193/*---------------------------------------------------------------------------*/
194
195#endif
Types and macros for iterating over mesh entities.
Variable on a 2D array.
Modifiable view of an array of type T.
Constant view of an array of type T.
Interface of a variable.
Definition IVariable.h:40
Mesh entity group.
Definition ItemGroup.h:51
Index of an Item in a variable.
Definition ItemLocalId.h:42
Characteristics of mesh elements.
Definition ItemTypes.h:625
Array variable on a mesh entity type.
void copy(const ItemVariableArrayRefT< DataType > &v)
Copies the values of v into this variable.
ArrayType operator[](ItemLocalId item)
Modifiable value of entity item.
ItemVariableArrayRefT(const VariableBuildInfo &b, eItemKind ik)
Constructs a reference to the variable specified in vb.
DataType & operator()(ItemLocalId item, Int32 i)
Modifiable value of the i-th value of entity item.
ConstArrayType operator[](ItemLocalId item) const
Read-only value of entity item.
ItemVariableArrayRefT< DataType > & operator=(const ItemVariableArrayRefT< DataType > &rhs)
Positions the instance reference to the variable rhs.
const DataType operator()(ItemLocalId item, Int32 i) const
Read-only value of the i-th value of entity item.
void fill(const DataType &value)
Fills the variable with the value value.
MeshVariableArrayRefT(const MeshVariableArrayRefT< ItemType, DataType > &rhs)
Constructs a reference from rhs.
GroupType itemGroup() const
Group associated with the quantity.
const DataType operator()(ItemLocalIdType item, Int32 i) const
Read-only value of the i-th value of entity item.
MeshVariableArrayRefT(IVariable *var)
Constructs a reference from var.
void swapValues(MeshVariableArrayRefT< ItemType, DataType > &rhs)
Swaps the values of the variable rhs with those of the instance.
ArrayType operator[](ItemLocalIdType item)
Modifiable value of entity item.
DataType & operator()(ItemLocalIdType item, Int32 i)
Modifiable value of the i-th value of entity item.
ConstArrayType operator[](ItemLocalIdType item) const
Read-only value of entity item.
void refersTo(const MeshVariableArrayRefT< ItemType, DataType > &rhs)
Positions the instance reference to the variable rhs.
MeshVariableArrayRefT(const VariableBuildInfo &b)
Constructs a reference to the variable specified in vb.
Base class for a variable on mesh entities.
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.
std::int32_t Int32
Signed integer type of 32 bits.