Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
PrivateVariableArray.h
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/* PrivateVariableArray.h (C) 2000-2023 */
9/* */
10/* Class managing an array variable on a mesh entity. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_PRIVATEVARIABLEARRAY_H
13#define ARCANE_CORE_PRIVATEVARIABLEARRAY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/MeshVariableRef.h"
18
19#include "arcane/core/Array2Variable.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30/*!
31 * \ingroup Variable
32 * \brief Class for factoring scalar variables on mesh entities.
33 */
34template <typename DataType>
35class PrivateVariableArrayT
36: public MeshVariableRef
37{
38 protected:
39
40 typedef DataType& DataTypeReturnReference;
41 typedef Array2VariableT<DataType> PrivatePartType;
42
43 protected:
44
45 ARCANE_CORE_EXPORT PrivateVariableArrayT(const VariableBuildInfo& vb, const VariableInfo& vi);
46 ARCANE_CORE_EXPORT PrivateVariableArrayT(const PrivateVariableArrayT& rhs);
47 ARCANE_CORE_EXPORT PrivateVariableArrayT(IVariable* var);
48
49 ARCANE_CORE_EXPORT void operator=(const PrivateVariableArrayT& rhs);
50
51 public:
52
53 Array2View<DataType> asArray() { return m_view; }
54 ConstArray2View<DataType> asArray() const { return m_view; }
55
56 Integer totalNbElement() const { return m_view.totalNbElement(); }
57
58 Integer arraySize() const { return m_view.dim2Size(); }
59
60 bool isArrayVariable() const { return true; }
61
62 ARCANE_CORE_EXPORT void updateFromInternal();
63
64 ARCANE_CORE_EXPORT ItemGroup itemGroup() const;
65
66 /*
67 * \brief Resizes the number of elements in the array.
68 *
69 * The first dimension always remains equal to the number of mesh elements.
70 * Only the second component is resized.
71 * \warning resizing does not preserve previous values...
72 */
73 ARCANE_CORE_EXPORT void resize(Int32 dim2_size);
74
75 /*
76 * \brief Resizes the number of elements in the array.
77 *
78 * \sa resize(Int32)
79 */
80 ARCANE_CORE_EXPORT void resizeAndReshape(const ArrayShape& shape);
81
82 public:
83
84 SmallSpan2<DataType> _internalSpan() { return m_view; }
85 SmallSpan2<const DataType> _internalSpan() const { return m_view; }
86 SmallSpan2<const DataType> _internalConstSpan() const { return m_view; }
87
88 protected:
89
90 void _internalInit() { MeshVariableRef::_internalInit(m_private_part); }
91
92 protected:
93
94 PrivatePartType* m_private_part;
95
96 Array2View<DataType> m_view;
97};
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102} // End namespace Arcane
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107#endif
Interface of a variable.
Definition IVariable.h:40
MeshVariableRef(const VariableBuildInfo &vb)
Constructs a reference linked to the module.
Integer arraySize() const
If the variable is an array, returns its dimension, otherwise returns 0.
void updateFromInternal()
Updates from the internal part.
Parameters necessary for building a variable.
Information characterizing a variable.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.