Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
VariableRefArray.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* VariableRefArray.cc (C) 2000-2021 */
9/* */
10/* Référence à une variable tableau 1D. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/VariableRefArray.h"
15
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/FatalErrorException.h"
18
19#include "arcane/VariableArray.h"
20#include "arcane/VariableRefArrayLock.h"
21#include "arcane/VariableBuildInfo.h"
22#include "arcane/VariableInfo.h"
23#include "arcane/VariableDataTypeTraits.h"
24#include "arcane/ISubDomain.h"
25#include "arcane/VariableFactoryRegisterer.h"
26#include "arcane/core/internal/IDataInternal.h"
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Arcane
32{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37template <typename DataType>
38VariableFactoryRegisterer
39VariableRefArrayT<DataType>::
40m_auto_registerer(_autoCreate, _internalVariableTypeInfo());
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
45template <typename DataType>
46VariableTypeInfo
47VariableRefArrayT<DataType>::
48_internalVariableTypeInfo()
49{
50 return VariableTypeInfo(IK_Unknown, VariableDataTypeTraitsT<DataType>::type(), 1, 0, false);
51}
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
56template <typename DataType>
57VariableInfo
58VariableRefArrayT<DataType>::
59_internalVariableInfo(const VariableBuildInfo& vbi)
60{
61 VariableTypeInfo vti = _internalVariableTypeInfo();
62 DataStorageTypeInfo sti = vti._internalDefaultDataStorage();
63 return VariableInfo(vbi.name(), vbi.itemFamilyName(), vbi.itemGroupName(), vbi.meshName(), vti, sti);
64}
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69template <typename DataType>
73{
74 return new ThatClass(vb);
75}
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
80template <typename DataType>
83: VariableRef(vbi)
84, m_private_part(PrivatePartType::getReference(vbi, _internalVariableInfo(vbi)))
85{
86 this->_internalInit(m_private_part);
87}
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
92template <class DataType>
95: VariableRef(rhs)
96, ArrayView<DataType>(rhs)
97, m_private_part(rhs.m_private_part)
98{
100}
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
104
105template <class DataType>
108: VariableRef(var)
109, m_private_part(PrivatePartType::getReference(var))
111 this->_internalInit(this->m_private_part);
112}
113
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
117template <class DataType>
120{
122 m_private_part = rhs.m_private_part;
123 updateFromInternal();
124}
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128/*!
129 * Libère la mémoire allouée.
130 */
131template <typename DataType>
136
137/*---------------------------------------------------------------------------*/
138/*---------------------------------------------------------------------------*/
139
140template <typename DataType>
142resize(Integer s)
143{
144 m_private_part->resize(s);
145}
146
147/*---------------------------------------------------------------------------*/
148/*---------------------------------------------------------------------------*/
149
150template <typename DataType>
152resizeWithReserve(Integer s, Integer nb_additional)
153{
154 m_private_part->resizeWithReserve(s, nb_additional);
155}
156
157/*---------------------------------------------------------------------------*/
158/*---------------------------------------------------------------------------*/
159
160template <typename DataType>
163{
164 ArrayBase::setArray(m_private_part->valueView());
165 BaseClass::updateFromInternal();
166}
167
168/*---------------------------------------------------------------------------*/
169/*---------------------------------------------------------------------------*/
170
171template <typename DataType>
172typename VariableRefArrayT<DataType>::LockType
174lock()
175{
176 return LockType(m_private_part->trueData()->_internal()->_internalDeprecatedValue(), m_private_part);
177}
178
179/*---------------------------------------------------------------------------*/
180/*---------------------------------------------------------------------------*/
181
182template <typename T>
186{
187 return _internalTrueData()->_internalDeprecatedValue();
188}
189
190/*---------------------------------------------------------------------------*/
191/*---------------------------------------------------------------------------*/
192
193template <typename T> IArrayDataInternalT<T>*
196{
197 if (!(property() & IVariable::PPrivate))
198 ARCANE_FATAL("variable '{0}': getting internal data container is only valid on private variable", name());
199 return m_private_part->trueData()->_internal();
200}
201
202/*---------------------------------------------------------------------------*/
203/*---------------------------------------------------------------------------*/
204
205template class VariableRefArrayT<Byte>;
206template class VariableRefArrayT<Real>;
207template class VariableRefArrayT<Int16>;
208template class VariableRefArrayT<Int32>;
209template class VariableRefArrayT<Int64>;
210template class VariableRefArrayT<String>;
211template class VariableRefArrayT<Real2>;
212template class VariableRefArrayT<Real3>;
213template class VariableRefArrayT<Real2x2>;
214template class VariableRefArrayT<Real3x3>;
215
216/*---------------------------------------------------------------------------*/
217/*---------------------------------------------------------------------------*/
218
219} // End namespace Arcane
220
221/*---------------------------------------------------------------------------*/
222/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
@ PPrivate
Indique que la variable est privée.
Definition IVariable.h:114
Paramètres nécessaires à la construction d'une variable.
void updateFromInternal() override
Mise à jour à partir de la partie interne.
ContainerType & internalContainer()
Retourne le conteneur des valeurs de cette variable.
VariableRefArrayT(const VariableBuildInfo &vb)
Construit une référence à une variable tableau spécifiée dans vb.
virtual void resizeWithReserve(Integer new_size, Integer nb_additional)
Redimensionne le tableau pour contenir new_size éléments.
~VariableRefArrayT() override
Libère les ressources.
virtual void resize(Integer new_size)
Redimensionne le tableau pour contenir new_size éléments.
Array< DataType > ContainerType
Type de la classe gérant la valeur de la variable.
void refersTo(const VariableRefArrayT< DataType > &rhs)
Positionne la référence de l'instance à la variable rhs.
Référence à une variable.
Definition VariableRef.h:56
VariableRef & operator=(const VariableRef &from)
Opérateur de recopie.
Vue modifiable d'un tableau d'un type T.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
@ IK_Unknown
Entité de maillage de genre inconnu ou non initialisé