Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
VariableRefScalar.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 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/* VariableRefScalar.cc (C) 2000-2023 */
9/* */
10/* Référence à une variable scalaire. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/VariableRefScalar.h"
15#include "arcane/VariableScalar.h"
16#include "arcane/VariableBuildInfo.h"
17#include "arcane/VariableInfo.h"
18#include "arcane/VariableDataTypeTraits.h"
19#include "arcane/VariableFactoryRegisterer.h"
20#include "arcane/IParallelMng.h"
21#include "arcane/IVariableMng.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32template<typename DataType> VariableFactoryRegisterer
33VariableRefScalarT<DataType>::
34m_auto_registerer(_autoCreate,_buildVariableTypeInfo());
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39template<typename DataType> VariableTypeInfo
40VariableRefScalarT<DataType>::
41_buildVariableTypeInfo()
42{
43 return VariableTypeInfo(IK_Unknown,VariableDataTypeTraitsT<DataType>::type(),0,0,false);
44}
45
46/*---------------------------------------------------------------------------*/
47/*---------------------------------------------------------------------------*/
48
49template<typename DataType> VariableInfo
50VariableRefScalarT<DataType>::
51_buildVariableInfo(const VariableBuildInfo& vbi)
52{
53 VariableTypeInfo vti = _buildVariableTypeInfo();
54 DataStorageTypeInfo sti = vti._internalDefaultDataStorage();
55 return VariableInfo(vbi.name(),vbi.itemFamilyName(),vbi.itemGroupName(),vbi.meshName(),vti,sti);
56}
57
58/*---------------------------------------------------------------------------*/
59/*---------------------------------------------------------------------------*/
61template<typename DataType> VariableRef*
65 return new ThatClass(vb);
66}
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70
71template<typename DataType>
74: VariableRef(vb)
75, m_private_part(PrivatePartType::getReference(vb,_buildVariableInfo(vb)))
76{
77 _internalInit(m_private_part);
78}
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
83template<typename DataType>
86: VariableRef(var)
87, m_private_part(PrivatePartType::getReference(var))
88{
89 _internalInit(m_private_part);
90}
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95template<class DataType>
98: VariableRef(rhs)
99, m_private_part(rhs.m_private_part)
100{
102}
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107template<class DataType> void
110{
112 m_private_part = rhs.m_private_part;
113 updateFromInternal();
114}
115
116/*---------------------------------------------------------------------------*/
117/*---------------------------------------------------------------------------*/
118
119template<typename DataType> void
121assign(const DataType& v)
122{
123 m_private_part->value() = v;
124 m_private_part->syncReferences();
125}
126
127/*---------------------------------------------------------------------------*/
128/*---------------------------------------------------------------------------*/
129
130namespace
131{
132template<typename T>
134{
135 ARCANE_UNUSED(value);
136 ARCANE_UNUSED(pm);
137 ARCANE_UNUSED(t);
139
140template<typename T>
141void _reduce(T& value,IParallelMng* pm,IParallelMng::eReduceType t,TrueType)
142{
143 T r = value;
144 value = pm->reduce(t,r);
145}
146}
147
148
149template<typename DataType> void
152{
153 typedef typename VariableDataTypeTraitsT<ElementType>::HasReduce HasReduce;
154 ElementType v = m_private_part->value();
155 _reduce(v,variableMng()->parallelMng(),type,HasReduce());
156 assign(v);
157}
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
162template<typename T> void
165{
166 BaseClass::updateFromInternal();
167}
168
169/*---------------------------------------------------------------------------*/
170/*---------------------------------------------------------------------------*/
171/*!
172 * \brief Échange les valeurs de la variable \a rhs avec celles de l'instance.
173 */
174template<typename DataType> void
177{
178 this->m_private_part->swapValues(*(rhs.m_private_part));
179}
180
181/*---------------------------------------------------------------------------*/
182/*---------------------------------------------------------------------------*/
183
184template class VariableRefScalarT<Byte>;
185template class VariableRefScalarT<Real>;
186template class VariableRefScalarT<Int16>;
187template class VariableRefScalarT<Int32>;
188template class VariableRefScalarT<Int64>;
189template class VariableRefScalarT<String>;
190template class VariableRefScalarT<Real2>;
191template class VariableRefScalarT<Real3>;
192template class VariableRefScalarT<Real2x2>;
193template class VariableRefScalarT<Real3x3>;
194
195/*---------------------------------------------------------------------------*/
196/*---------------------------------------------------------------------------*/
197
198} // End namespace Arcane
199
200/*---------------------------------------------------------------------------*/
201/*---------------------------------------------------------------------------*/
Interface du gestionnaire de parallélisme pour un sous-domaine.
virtual char reduce(eReduceType rt, char v)=0
Effectue la réduction de type rt sur le réel v et retourne la valeur.
Paramètres nécessaires à la construction d'une variable.
Référence à une variable scalaire.
void refersTo(const VariableRefScalarT< DataType > &rhs)
Positionne la référence de l'instance à la variable rhs.
void swapValues(VariableRefScalarT< DataType > &rhs)
Échange les valeurs de la variable rhs avec celles de l'instance.
VariableRefScalarT()
Constructeur vide.
void reduce(Parallel::eReduceType type)
Effectue une réduction de type type sur la variable.
void assign(const DataType &v)
Affecte à la variable la valeur v.
virtual void updateFromInternal()
Mise à jour à partir de la partie interne.
DataType ElementType
Type des éléments de la variable.
Référence à une variable.
Definition VariableRef.h:56
VariableRef & operator=(const VariableRef &from)
Opérateur de recopie.
void _internalInit(IVariable *)
Initialisation interne de la variable.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
@ IK_Unknown
Entité de maillage de genre inconnu ou non initialisé
eReduceType
Types des réductions supportées.