Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
VariableRefArray.cc
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/* VariableRefArray.cc (C) 2000-2024 */
9/* */
10/* Reference to a 1D array variable. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/VariableRefArray.h"
15
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/FatalErrorException.h"
18
19#include "arcane/core/VariableArray.h"
20#include "arcane/core/VariableRefArrayLock.h"
21#include "arcane/core/VariableBuildInfo.h"
22#include "arcane/core/VariableInfo.h"
23#include "arcane/core/VariableDataTypeTraits.h"
24#include "arcane/core/ISubDomain.h"
25#include "arcane/core/VariableFactoryRegisterer.h"
26#include "arcane/core/internal/IDataInternal.h"
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Arcane
32{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37template <typename DataType>
40m_auto_registerer(_autoCreate, _internalVariableTypeInfo());
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
45template <typename DataType>
49{
50 return VariableTypeInfo(IK_Unknown, VariableDataTypeTraitsT<DataType>::type(), 1, 0, false);
51}
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
56template <typename DataType>
60{
61 VariableTypeInfo vti = _internalVariableTypeInfo();
62 DataStorageTypeInfo sti = vti._internalDefaultDataStorage();
63 return VariableInfo(vbi.name(), vbi.itemFamilyName(), vbi.itemGroupName(), vbi.meshName(), vti, sti);
64}
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69template <typename DataType>
73{
74 return new ThatClass(vb);
75}
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
79
80template <typename DataType>
83: VariableRef(vbi)
84, m_private_part(PrivatePartType::getReference(vbi, _internalVariableInfo(vbi)))
85{
86 this->_internalInit(m_private_part);
87}
88
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))
110{
111 this->_internalInit(this->m_private_part);
112}
113
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
117template <class DataType>
120{
122 m_private_part = rhs.m_private_part;
124}
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
132template <typename DataType>
137
138/*---------------------------------------------------------------------------*/
139/*---------------------------------------------------------------------------*/
140
141template <typename DataType>
144{
145 m_private_part->resize(s);
146}
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/
150
151template <typename DataType>
153resizeWithReserve(Integer s, Integer nb_additional)
154{
155 m_private_part->resizeWithReserve(s, nb_additional);
156}
157
158/*---------------------------------------------------------------------------*/
159/*---------------------------------------------------------------------------*/
160
161template <typename DataType>
164{
165 ArrayBase::setArray(m_private_part->valueView());
167}
168
169/*---------------------------------------------------------------------------*/
170/*---------------------------------------------------------------------------*/
171
172template <typename DataType>
173typename VariableRefArrayT<DataType>::LockType
175lock()
176{
177 return LockType(m_private_part->trueData()->_internal()->_internalDeprecatedValue(), m_private_part);
178}
179
180/*---------------------------------------------------------------------------*/
181/*---------------------------------------------------------------------------*/
182
183template <typename T>
187{
188 return _internalTrueData()->_internalDeprecatedValue();
189}
190
191/*---------------------------------------------------------------------------*/
192/*---------------------------------------------------------------------------*/
193
194template <typename T> IArrayDataInternalT<T>*
197{
198 if (!(property() & IVariable::PPrivate))
199 ARCANE_FATAL("variable '{0}': getting internal data container is only valid on private variable", name());
200 return m_private_part->trueData()->_internal();
201}
202
203/*---------------------------------------------------------------------------*/
204/*---------------------------------------------------------------------------*/
205
206ARCANE_INTERNAL_INSTANTIATE_TEMPLATE_FOR_NUMERIC_DATATYPE(VariableRefArrayT);
207template class VariableRefArrayT<String>;
208
209/*---------------------------------------------------------------------------*/
210/*---------------------------------------------------------------------------*/
211
212} // End namespace Arcane
213
214/*---------------------------------------------------------------------------*/
215/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
constexpr ArrayView() noexcept
Constructs an empty view.
Type information for a data container.
Interface for an array data of type T.
Interface of a variable.
Definition IVariable.h:40
@ PPrivate
Indicates that the variable is private.
Definition IVariable.h:103
Parameters necessary for building a variable.
Information characterizing a variable.
IArrayDataInternalT< T > * _internalTrueData()
void updateFromInternal() override
Updates from the internal part.
ContainerType & internalContainer()
Returns the container of this variable's values.
VariableRefArrayT(const VariableBuildInfo &vb)
Constructs a reference to a 1D array variable specified in vb.
virtual void resizeWithReserve(Integer new_size, Integer nb_additional)
Resizes the array to contain new_size elements.
~VariableRefArrayT() override
Frees resources.
virtual void resize(Integer new_size)
Resizes the array to contain new_size elements.
Array< DataType > ContainerType
Type of the class managing the variable value.
void refersTo(const VariableRefArrayT< DataType > &rhs)
Positions the instance's reference to the variable rhs.
Reference to a variable.
Definition VariableRef.h:56
virtual void updateFromInternal()
Updates from the internal part.
VariableRef(const VariableBuildInfo &vbi)
Constructs a reference to a variable with the infos vbi.
VariableRef & operator=(const VariableRef &from)
Copy assignment operator.
virtual int property() const
Variable properties.
void _internalInit(IVariable *)
Internal initialization of the variable.
String name() const
Variable name.
Information characterizing the type of a variable.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
@ IK_Unknown
Unknown or uninitialized mesh entity.