Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MeshPartialVariableScalarRef.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/* MeshPartialVariableScalarRef.inst.h (C) 2000-2025 */
9/* */
10/* Implementation of classes deriving from MeshPartialVariableScalarRef. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/MeshPartialVariableScalarRef.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, 1, 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: PrivateVariableScalarT<DataType>(vbi, _buildVariableInfo(vbi, ik))
57{
58 this->_internalInit();
59 internalSetUsed(this->isUsed());
60}
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65template <class DataType>
68: PrivateVariableScalarT<DataType>(var)
69{
70 this->_internalInit();
71 internalSetUsed(this->isUsed());
72}
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77template <class DataType>
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 PrivateVariableScalarT<DataType>::operator=(rhs);
106 m_table = rhs.m_table;
107 //this->updateFromInternal();
108}
109
110/*---------------------------------------------------------------------------*/
111/*---------------------------------------------------------------------------*/
112
113template <class DataType> void
115fill(const DataType& v)
116{
117 this->m_private_part->fill(v);
118}
119
120/*---------------------------------------------------------------------------*/
121/*---------------------------------------------------------------------------*/
122
123template <typename DataType> void
124ItemPartialVariableScalarRefT<DataType>::
125copy(const ItemPartialVariableScalarRefT<DataType>& v)
126{
127 //TODO: utiliser memcpy()
128 ENUMERATE_ITEM (iitem, this->itemGroup()) {
129 operator[](iitem) = 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 eDataType dt = VariableDataTypeTraitsT<DataType>::type();
152 return VariableTypeInfo(ik, dt, 1, 0, true);
153}
154
155/*---------------------------------------------------------------------------*/
156/*---------------------------------------------------------------------------*/
157
158template <class ItemType, class DataType>
161{
162 return new ThatClass(vb);
163}
164
165/*---------------------------------------------------------------------------*/
166/*---------------------------------------------------------------------------*/
167
168template <class ItemType, class DataType>
171: ItemPartialVariableScalarRefT<DataType>(vb, ItemTraitsT<ItemType>::kind())
172{
173 // Normally, this class should handle the initialization, but
174 // since this class is just a wrapper around ItemVariableScalarRefT
175 // and does nothing else, we leave the initialization to the base class,
176 // which allows for generic variable creation on a mesh entity
177 // based on its type.
178}
179
180/*---------------------------------------------------------------------------*/
181/*---------------------------------------------------------------------------*/
182
183template <class ItemType, class DataType>
186: ItemPartialVariableScalarRefT<DataType>(rhs)
187{
188 // Normally, this class should handle the initialization, but
189 // since this class is just a wrapper around ItemVariableScalarRefT
190 // and does nothing else, we leave the initialization to the base class,
191 // which allows for generic variable creation on a mesh entity
192 // based on its type.
193}
194
195/*---------------------------------------------------------------------------*/
196/*---------------------------------------------------------------------------*/
197
198template <class ItemType, class DataType> void
204
205/*---------------------------------------------------------------------------*/
206/*---------------------------------------------------------------------------*/
207
208template <class ItemType, class DataType> auto
210itemGroup() const -> GroupType
211{
212 return GroupType(this->m_private_part->itemGroup());
213}
214
215/*---------------------------------------------------------------------------*/
216/*---------------------------------------------------------------------------*/
217
218} // End namespace Arcane
219
220/*---------------------------------------------------------------------------*/
221/*---------------------------------------------------------------------------*/
#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
Partial scalar variable on a mesh entity type.
ItemPartialVariableScalarRefT(const VariableBuildInfo &vb, eItemKind ik)
Constructs a reference to the variable specified in vb.
void operator=(const ItemPartialVariableScalarRefT< DataType > &rhs)
Copy operator.
Characteristics of mesh elements.
Definition ItemTypes.h:625
static eItemKind kind()
Entity kind.
Definition ItemTypes.h:629
Scalar variable on a mesh entity type.
void refersTo(const MeshPartialVariableScalarRefT< ItemType, DataType > &rhs)
Positions the instance reference to the variable 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)
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