Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
VariableRefArray2.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/* VariableRefArray2.cc (C) 2000-2021 */
9/* */
10/* Class managing a reference to a 2D array variable. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/VariableRefArray2.h"
15
16#include "arcane/utils/FatalErrorException.h"
17
18#include "arcane/core/Array2Variable.h"
19#include "arcane/core/VariableBuildInfo.h"
20#include "arcane/core/VariableInfo.h"
21#include "arcane/core/VariableDataTypeTraits.h"
22#include "arcane/core/IParallelMng.h"
23#include "arcane/core/VariableFactoryRegisterer.h"
24#include "arcane/core/internal/IDataInternal.h"
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Arcane
30{
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
35template <class DataType> VariableFactoryRegisterer
37m_auto_registerer(_autoCreate, _internalVariableTypeInfo());
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
42template <typename DataType> VariableTypeInfo
45{
46 return VariableTypeInfo(IK_Unknown, VariableDataTypeTraitsT<DataType>::type(), 2, 0, false);
47}
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
51
52template <typename DataType> VariableInfo
55{
56 VariableTypeInfo vti = _internalVariableTypeInfo();
57 DataStorageTypeInfo sti = vti._internalDefaultDataStorage();
58 return VariableInfo(vbi.name(), vbi.itemFamilyName(), vbi.itemGroupName(), vbi.meshName(), vti, sti);
59}
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64template <class DataType> VariableRef*
67{
68 return new ThatClass(vb);
69}
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
73
74template <typename DataType>
77: VariableRef(vbi)
78, m_private_part(PrivatePartType::getReference(vbi, _internalVariableInfo(vbi)))
79{
80 _internalInit(m_private_part);
81}
82
83/*---------------------------------------------------------------------------*/
84/*---------------------------------------------------------------------------*/
85
86template <class DataType>
89: VariableRef(rhs)
90, Array2View<DataType>(rhs)
91, m_private_part(rhs.m_private_part)
92{
94}
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
98
99template <class DataType> VariableRefArray2T<DataType>::
101: VariableRef(var)
102, m_private_part(PrivatePartType::getReference(var))
103{
104 this->_internalInit(this->m_private_part);
105}
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
109
110template <class DataType> void
113{
115 m_private_part = rhs.m_private_part;
117}
118
119/*---------------------------------------------------------------------------*/
120/*---------------------------------------------------------------------------*/
121
122template <typename DataType> VariableRefArray2T<DataType>::
124{
125}
126
127/*---------------------------------------------------------------------------*/
128/*---------------------------------------------------------------------------*/
129
130template <class DataType> void
133{
135 m_private_part = rhs.m_private_part;
137}
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
142template <typename DataType> void
145{
146 m_private_part->directResize(s);
147}
148
149/*---------------------------------------------------------------------------*/
150/*---------------------------------------------------------------------------*/
151
152template <typename DataType> void
154resize(Integer dim1_size, Integer dim2_size)
155{
156 m_private_part->directResize(dim1_size, dim2_size);
157}
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
162template <typename DataType> void
164fill(const DataType& value)
165{
166 m_private_part->trueData()->_internal()->_internalDeprecatedValue().fill(value);
167}
168
169/*---------------------------------------------------------------------------*/
170/*---------------------------------------------------------------------------*/
171
172template <typename DataType> void VariableRefArray2T<DataType>::
174{
175 ArrayBase::operator=(m_private_part->valueView());
177}
178
179/*---------------------------------------------------------------------------*/
180/*---------------------------------------------------------------------------*/
181
182template <typename T> auto VariableRefArray2T<T>::
184{
185 return _internalTrueData()->_internalDeprecatedValue();
186}
187
188/*---------------------------------------------------------------------------*/
189/*---------------------------------------------------------------------------*/
190
191template <typename T> IArray2DataInternalT<T>*
194{
195 if (!(property() & IVariable::PPrivate))
196 ARCANE_FATAL("variable '{0}': getting internal data container is only valid on private variable", name());
197 return m_private_part->trueData()->_internal();
198}
199
200/*---------------------------------------------------------------------------*/
201/*---------------------------------------------------------------------------*/
202
203template class VariableRefArray2T<Byte>;
204template class VariableRefArray2T<Real>;
205template class VariableRefArray2T<Int16>;
206template class VariableRefArray2T<Int32>;
207template class VariableRefArray2T<Int64>;
208template class VariableRefArray2T<Real2>;
209template class VariableRefArray2T<Real3>;
210template class VariableRefArray2T<Real2x2>;
211template class VariableRefArray2T<Real3x3>;
212
213/*---------------------------------------------------------------------------*/
214/*---------------------------------------------------------------------------*/
215
216} // End namespace Arcane
217
218/*---------------------------------------------------------------------------*/
219/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
constexpr Array2View(T *ptr, Integer dim1_size, Integer dim2_size)
Type information for a data container.
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.
Two-dimensional array variable.
void refersTo(const VariableRefArray2T< DataType > &rhs)
Positions the instance reference to the variable rhs.
VariableRefArray2T(const VariableBuildInfo &vb)
Constructs a reference to a 2D array variable specified in vb.
virtual void resize(Integer new_size)
Reallocates the number of elements in the first dimension of the array.
void fill(const DataType &value)
Fills the variable with the value value.
ContainerType & internalContainer()
Returns the container of the variable's values.
Array2< DataType > ContainerType
Type of the class managing the variable value.
void operator=(const VariableRefArray2T< DataType > &rhs)
Copy assignment operator.
virtual void updateFromInternal()
Updates from the internal part.
virtual ~VariableRefArray2T()
Frees resources.
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.
void _internalInit(IVariable *)
Internal initialization of the variable.
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.