Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MeshVariableScalarRef.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/* MeshVariableScalarRef.inst.h (C) 2000-2025 */
9/* */
10/* Mesh scalar variable. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/MeshVariableScalarRef.h"
15
16#include "arcane/core/ItemGroup.h"
17#include "arcane/core/VariableScalar.h"
18#include "arcane/core/VariableDataTypeTraits.h"
19#include "arcane/core/VariableTypeInfo.h"
20#include "arcane/core/VariableBuildInfo.h"
21#include "arcane/core/VariableInfo.h"
22#include "arcane/core/VariableFactoryRegisterer.h"
23#include "arcane/core/internal/IDataInternal.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34template <typename DataType> VariableTypeInfo
37{
38 eDataType dt = VariableDataTypeTraitsT<DataType>::type();
39 return VariableTypeInfo(ik, dt, 1, 0, false);
40}
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
45template <typename DataType> VariableInfo
48{
49 VariableTypeInfo vti = _internalVariableTypeInfo(ik);
50 DataStorageTypeInfo sti = vti._internalDefaultDataStorage();
51 return VariableInfo(vbi.name(), vbi.itemFamilyName(), vbi.itemGroupName(), vbi.meshName(), vti, sti);
52}
53
54/*---------------------------------------------------------------------------*/
55/*---------------------------------------------------------------------------*/
56
57template <class DataTypeT>
60: PrivateVariableScalarT<DataTypeT>(vb, _internalVariableInfo(vb, ik))
61{
62 if (!vb.isNull()) {
63 this->_internalInit();
64 if (this->m_private_part->isPartial())
65 ARCANE_FATAL("Can not assign a partial variable to a full variable");
66 }
67}
68
69/*---------------------------------------------------------------------------*/
70/*---------------------------------------------------------------------------*/
71
72template <class DataTypeT>
75: PrivateVariableScalarT<DataTypeT>(var)
76{
77 this->_internalInit();
78 if (this->m_private_part->isPartial())
79 ARCANE_FATAL("Can not assign a partial variable to a full variable");
80}
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
85template <class DataTypeT>
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95template <class DataTypeT> void
97fill(const DataTypeT& v)
98{
99 this->m_private_part->fill(v, this->m_private_part->itemGroup());
100}
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
104
105template <class DataTypeT> void
107fill(const DataTypeT& value, const ItemGroup& group)
108{
109 ENUMERATE_ITEM (iitem, group) {
110 operator[](iitem) = value;
111 }
112}
113
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
117template <typename DataTypeT> void
120{
121 ENUMERATE_ITEM (iitem, group) {
122 operator[](iitem) = v[iitem];
123 }
124}
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
129template <typename DataTypeT> void
132{
133 if (!queue) {
134 copy(v);
135 return;
136 }
137 impl::copyContiguousData(this->m_private_part->data(), v.m_private_part->data(), *queue);
138}
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
143template <class DataTypeT> void
145fill(const DataTypeT& v, RunQueue* queue)
146{
147 if (!queue) {
148 fill(v);
149 return;
150 }
151 impl::fillContiguousData<DataTypeT>(this->m_private_part->data(), v, *queue);
152}
153
154/*---------------------------------------------------------------------------*/
155/*---------------------------------------------------------------------------*/
156
157template <class DataTypeT> void
160{
161 BaseClass::operator=(rhs);
162 this->m_private_part = rhs.m_private_part;
163 this->updateFromInternal();
164}
165
166/*---------------------------------------------------------------------------*/
167/*---------------------------------------------------------------------------*/
168
169/*---------------------------------------------------------------------------*/
170/*---------------------------------------------------------------------------*/
171
172template <class ItemType, class DataType> VariableFactoryRegisterer
174m_auto_registerer(_autoCreate, _internalVariableTypeInfo());
175
176/*---------------------------------------------------------------------------*/
177/*---------------------------------------------------------------------------*/
178
179template <typename ItemType, typename DataType> VariableInfo
182{
183 return BaseClass::_internalVariableInfo(vbi, ItemTraitsT<ItemType>::kind());
184}
185
186/*---------------------------------------------------------------------------*/
187/*---------------------------------------------------------------------------*/
188
189template <typename ItemType, typename DataType> VariableTypeInfo
190MeshVariableScalarRefT<ItemType, DataType>::
191_internalVariableTypeInfo()
192{
193 return BaseClass::_internalVariableTypeInfo(ItemTraitsT<ItemType>::kind());
194}
195
196/*---------------------------------------------------------------------------*/
197/*---------------------------------------------------------------------------*/
198
199template <class ItemType, class DataType>
202{
203 return new ThatClass(vb);
204}
205
206/*---------------------------------------------------------------------------*/
207/*---------------------------------------------------------------------------*/
208
209template <class ItemType, class DataTypeT>
215
216/*---------------------------------------------------------------------------*/
217/*---------------------------------------------------------------------------*/
218
219template <class ItemType, class DataTypeT>
225
226/*---------------------------------------------------------------------------*/
227/*---------------------------------------------------------------------------*/
228
229template <class ItemType, class DataTypeT>
232: ItemVariableScalarRefT<DataTypeT>(rhs)
233{
234 // Normally, this class should handle the initialization, but
235 // since this class is just a wrapper around ItemVariableScalarRefT
236 // and does nothing else, we leave the initialization to the base class,
237 // which allows for generic variable creation on a mesh entity
238 // based on its type.
239}
240
241/*---------------------------------------------------------------------------*/
242/*---------------------------------------------------------------------------*/
243
244template <class ItemType, class DataTypeT> void
250
251/*---------------------------------------------------------------------------*/
252/*---------------------------------------------------------------------------*/
253
254template <class ItemType, class DataTypeT>
255typename Arcane::MeshVariableScalarRefT<ItemType, DataTypeT>::GroupType
257itemGroup() const
258{
259 return GroupType(BaseClass::itemGroup());
260}
261
262/*---------------------------------------------------------------------------*/
263/*---------------------------------------------------------------------------*/
264
265template <class ItemType, class DataTypeT> void
267setIsSynchronized(const GroupType& group)
268{
269 this->m_private_part->setIsSynchronized(group);
270}
271
272/*---------------------------------------------------------------------------*/
273/*---------------------------------------------------------------------------*/
274
275template <class ItemType, class DataTypeT> void
276MeshVariableScalarRefT<ItemType, DataTypeT>::
277setIsSynchronized()
278{
279 this->m_private_part->setIsSynchronized();
280}
281
282/*---------------------------------------------------------------------------*/
283/*---------------------------------------------------------------------------*/
284
293template <class ItemType, class DataTypeT> void
296{
297 this->m_private_part->swapValues(*(rhs.m_private_part));
298}
299
300/*---------------------------------------------------------------------------*/
301/*---------------------------------------------------------------------------*/
302
303#define ARCANE_INSTANTIATE_MESHVARIABLE_SCALAR(datatype) \
304 template class ARCANE_TEMPLATE_EXPORT ItemVariableScalarRefT<datatype>; \
305 template class ARCANE_TEMPLATE_EXPORT ItemPartialVariableScalarRefT<datatype>; \
306 template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<Node, datatype>; \
307 template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<Edge, datatype>; \
308 template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<Face, datatype>; \
309 template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<Cell, datatype>; \
310 template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<Particle, datatype>; \
311 template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<DoF, datatype>; \
312 template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<Node, datatype>; \
313 template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<Edge, datatype>; \
314 template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<Face, datatype>; \
315 template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<Cell, datatype>; \
316 template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<Particle, datatype>; \
317 template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<DoF, datatype>
318
319/*---------------------------------------------------------------------------*/
320/*---------------------------------------------------------------------------*/
321
322} // End namespace Arcane
323
324/*---------------------------------------------------------------------------*/
325/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
#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
Mesh entity group.
Definition ItemGroup.h:51
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 operator=(const ItemVariableScalarRefT< DataTypeT > &rhs)
Positions the instance reference to the variable rhs.
ItemVariableScalarRefT()
Default constructor.
const DataType & operator[](ItemLocalId item) const
ItemVariableScalarRefT(const VariableBuildInfo &b, eItemKind ik)
Constructs a reference to the variable specified in vb.
Scalar variable on a mesh entity type.
MeshVariableScalarRefT()
Default constructor.
GroupType itemGroup() const
Group associated with the quantity.
MeshVariableScalarRefT(const VariableBuildInfo &vb)
Constructs a reference to the variable specified in vb.
void refersTo(const MeshVariableScalarRefT< ItemType, DataTypeT > &rhs)
Positions the instance reference to the variable rhs.
void swapValues(MeshVariableScalarRefT< ItemType, DataType > &rhs)
Swaps the values of the variable rhs with those of the instance.
PrivateVariableScalarT(const VariableBuildInfo &vb, const VariableInfo &vi)
IData * data() override
Data associated with the variable.
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