Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MeshPartialVariableArrayRef.inst.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.inst.h (C) 2000-2025 */
9/* */
10/* Implementation of classes deriving from MeshPartialVariableArrayRef. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/MeshPartialVariableArrayRef.h"
15#include "arcane/core/ItemGroup.h"
16#include "arcane/core/IMesh.h"
17#include "arcane/core/VariableBuildInfo.h"
18#include "arcane/core/VariableDataTypeTraits.h"
19#include "arcane/core/IParallelMng.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30template <typename DataType> VariableTypeInfo
33{
34 eDataType dt = VariableDataTypeTraitsT<DataType>::type();
35 return VariableTypeInfo(ik, dt, 2, 0, true);
36}
37
38/*---------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------*/
40
41template <typename DataType> VariableInfo
44{
45 VariableTypeInfo vti = _buildVariableTypeInfo(ik);
46 DataStorageTypeInfo sti = vti._internalDefaultDataStorage();
47 return VariableInfo(vbi.name(), vbi.itemFamilyName(), vbi.itemGroupName(), vbi.meshName(), vti, sti);
48}
49
50/*---------------------------------------------------------------------------*/
51/*---------------------------------------------------------------------------*/
52
53template <class DataType>
56: PrivateVariableArrayT<DataType>(vb, _buildVariableInfo(vb, ik))
57{
58 this->_internalInit();
59 internalSetUsed(this->isUsed());
60}
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65template <class DataType>
68: PrivateVariableArrayT<DataType>(var)
69{
70 this->_internalInit();
71 internalSetUsed(this->isUsed());
72}
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77template <class DataType>
80: PrivateVariableArrayT<DataType>(rhs)
81{
82 internalSetUsed(this->isUsed());
83}
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
88template <typename DataType> void
90internalSetUsed(bool v)
91{
92 if (v)
93 m_table = this->itemGroup().localIdToIndex();
94 else
95 m_table.reset();
96}
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101template <class DataType> void
104{
105 PrivateVariableArrayT<DataType>::operator=(rhs);
106 m_table = rhs.m_table;
107}
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
112template <class DataType> void
114fill(const DataType& v)
115{
116 ENUMERATE_ITEM (iitem, this->itemGroup()) {
117 operator[](iitem).fill(v);
118 }
119}
120
121/*---------------------------------------------------------------------------*/
122/*---------------------------------------------------------------------------*/
123
124template <typename DataType> void
127{
128 ENUMERATE_ITEM (iitem, this->itemGroup()) {
129 operator[](iitem).copy(v[iitem]);
130 }
131}
132
133/*---------------------------------------------------------------------------*/
134/*---------------------------------------------------------------------------*/
135
136/*---------------------------------------------------------------------------*/
137/*---------------------------------------------------------------------------*/
138
139template <class ItemType, class DataType> VariableFactoryRegisterer
141m_auto_registerer(_autoCreate, _buildVariableTypeInfo());
142
143/*---------------------------------------------------------------------------*/
144/*---------------------------------------------------------------------------*/
145
146template <typename ItemType, typename DataType> VariableTypeInfo
149{
151 return BaseClass::_buildVariableTypeInfo(ik);
152}
153
154/*---------------------------------------------------------------------------*/
155/*---------------------------------------------------------------------------*/
156
157template <typename ItemType, typename DataType> VariableInfo
160{
162 return BaseClass::_buildVariableInfo(vbi, ik);
163}
164
165/*---------------------------------------------------------------------------*/
166/*---------------------------------------------------------------------------*/
167
168template <class ItemType, class DataType> VariableRef*
171{
172 return new ThatClass(vb);
173}
174
175/*---------------------------------------------------------------------------*/
176/*---------------------------------------------------------------------------*/
177
178template <class ItemType, class DataType>
181: ItemPartialVariableArrayRefT<DataType>(vb, ItemTraitsT<ItemType>::kind())
182{
183 // Normally, this class should handle the initialization, but
184 // since this class is just a wrapper around ItemVariableArrayRefT
185 // and does nothing else, we leave the initialization to the base class,
186 // which allows a variable to be generically created on a mesh entity based on its type.
187}
188
189/*---------------------------------------------------------------------------*/
190/*---------------------------------------------------------------------------*/
191
192template <class ItemType, class DataType>
195: ItemPartialVariableArrayRefT<DataType>(rhs)
196{
197 // Normally, this class should handle the initialization, but
198 // since this class is just a wrapper around ItemVariableArrayRefT
199 // and does nothing else, we leave the initialization to the base class,
200 // which allows a variable to be generically created on a mesh entity based on its type.
201}
202
203/*---------------------------------------------------------------------------*/
204/*---------------------------------------------------------------------------*/
205
206template <class ItemType, class DataType> void
212
213/*---------------------------------------------------------------------------*/
214/*---------------------------------------------------------------------------*/
215
216template <class ItemType, class DataType>
217typename Arcane::MeshPartialVariableArrayRefT<ItemType, DataType>::GroupType
219itemGroup() const
220{
221 return GroupType(this->m_private_part->itemGroup());
222}
223
224/*---------------------------------------------------------------------------*/
225/*---------------------------------------------------------------------------*/
226
227} // End namespace Arcane
228
229/*---------------------------------------------------------------------------*/
230/*---------------------------------------------------------------------------*/
#define ENUMERATE_ITEM(name, group)
Generic enumerator for a node group.
Type information for a data container.
Interface of a variable.
Definition IVariable.h:40
Scalar partial variable on a mesh entity type.
ItemPartialVariableArrayRefT(const VariableBuildInfo &vb, eItemKind ik)
Constructs a reference to the variable specified in vb.
void operator=(const ItemPartialVariableArrayRefT< DataType > &rhs)
Copy assignment operator.
Characteristics of mesh elements.
Definition ItemTypes.h:625
static eItemKind kind()
Entity kind.
Definition ItemTypes.h:629
Scalar partial variable on a mesh entity type.
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.
GroupType itemGroup() const
Group associated with the quantity.
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.
eDataType
Data type.
Definition DataTypes.h:41