Arcane  v3.16.9.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MeshVariableScalarRef.inst.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* Variable scalaire du maillage. */
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}
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
192{
193 return BaseClass::_internalVariableTypeInfo(ItemTraitsT<ItemType>::kind());
194}
195
196/*---------------------------------------------------------------------------*/
197/*---------------------------------------------------------------------------*/
198
199template<class ItemType,class DataType>
200VariableRef* MeshVariableScalarRefT<ItemType,DataType>::
201_autoCreate(const VariableBuildInfo& vb)
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)
234 // Normalement, c'est à cette classe de faire l'initilisation mais
235 // comme cette classe est juste un wrapper autour de ItemVariableScalarRefT
236 // et ne fait rien d'autre, on laisse l'initialisation à la classe de base,
237 // ce qui permet de fabriquer de manière générique une variable sur
238 // une entité du maillage à partir de son genre.
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/*---------------------------------------------------------------------------*/
292template<class ItemType,class DataTypeT> void
295{
296 this->m_private_part->swapValues(*(rhs.m_private_part));
297}
298
299/*---------------------------------------------------------------------------*/
300/*---------------------------------------------------------------------------*/
301
302#define ARCANE_INSTANTIATE_MESHVARIABLE_SCALAR(datatype) \
303template class ARCANE_TEMPLATE_EXPORT ItemVariableScalarRefT<datatype>;\
304template class ARCANE_TEMPLATE_EXPORT ItemPartialVariableScalarRefT<datatype>;\
305template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<Node,datatype>; \
306template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<Edge,datatype>; \
307template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<Face,datatype>; \
308template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<Cell,datatype>; \
309template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<Particle,datatype>; \
310template class ARCANE_TEMPLATE_EXPORT MeshVariableScalarRefT<DoF,datatype>; \
311template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<Node,datatype>; \
312template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<Edge,datatype>; \
313template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<Face,datatype>; \
314template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<Cell,datatype>; \
315template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<Particle,datatype>; \
316template class ARCANE_TEMPLATE_EXPORT MeshPartialVariableScalarRefT<DoF,datatype>
317
318/*---------------------------------------------------------------------------*/
319/*---------------------------------------------------------------------------*/
320
321} // End namespace Arcane
322
323/*---------------------------------------------------------------------------*/
324/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
#define ENUMERATE_ITEM(name, group)
Enumérateur générique d'un groupe de noeuds.
File d'exécution pour un accélérateur.
Informations de type pour un conteneur de données.
Interface d'une variable.
Definition IVariable.h:39
Groupe d'entités de maillage.
Definition ItemGroup.h:49
Caractéristiques des éléments du maillage.
Definition ItemTypes.h:621
static eItemKind kind()
Genre de l'entité
Definition ItemTypes.h:624
Variable scalaire sur un type d'entité du maillage.
void operator=(const ItemVariableScalarRefT< DataTypeT > &rhs)
Positionne la référence de l'instance à la variable rhs.
const DataType & operator[](ItemLocalId item) const
ItemVariableScalarRefT(const VariableBuildInfo &b, eItemKind ik)
Construit une référence à la variable spécifiée dans vb.
Variable scalaire sur un type d'entité du maillage.
GroupType itemGroup() const
Groupe associé à la grandeur.
MeshVariableScalarRefT(const VariableBuildInfo &vb)
void refersTo(const MeshVariableScalarRefT< ItemType, DataTypeT > &rhs)
Positionne la référence de l'instance à la variable rhs.
void swapValues(MeshVariableScalarRefT< ItemType, DataType > &rhs)
Échange les valeurs de la variable rhs avec celles de l'instance.
void updateFromInternal()
Mise à jour à partir de la partie interne.
PrivateVariableScalarT(const VariableBuildInfo &vb, const VariableInfo &vi)
IData * data() override
Données associées à la variable.
Paramètres nécessaires à la construction d'une variable.
Enregistreur d'une fabrique de variables.
Infos caractérisant une variable.
Informations caractérisant le type d'une variable.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
eItemKind
Genre d'entité de maillage.
eDataType
Type d'une donnée.
Definition DataTypes.h:39