Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
PrivateVariableScalar.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/* PrivateVariableScalar.h (C) 2000-2025 */
9/* */
10/* Class managing a variable on a mesh entity. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_PRIVATEVARIABLESCALAR_H
13#define ARCANE_CORE_PRIVATEVARIABLESCALAR_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/MeshVariableRef.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*!
29 * \ingroup Variable
30 * \brief Class for factoring scalar variables on mesh entities.
31 */
32template <typename DataType>
34: public MeshVariableRef
35{
36 protected:
37
38 typedef DataType& DataTypeReturnReference;
39 typedef VariableArrayT<DataType> PrivatePartType;
40
41 protected:
42
43 //! Constructs a reference linked to the \a module
44 ARCANE_CORE_EXPORT PrivateVariableScalarT(const VariableBuildInfo& vb, const VariableInfo& vi);
45
46 protected:
47
48 ARCANE_CORE_EXPORT PrivateVariableScalarT(const PrivateVariableScalarT& rhs);
49 ARCANE_CORE_EXPORT PrivateVariableScalarT(IVariable* var);
50 ARCANE_CORE_EXPORT PrivateVariableScalarT();
51
52 ARCANE_CORE_EXPORT void operator=(const PrivateVariableScalarT& rhs);
53
54 public:
55
56 ArrayView<DataType> asArray() { return m_view; }
57 ConstArrayView<DataType> asArray() const { return m_view; }
58 Integer arraySize() const { return 0; }
59
60 ARCANE_CORE_EXPORT void updateFromInternal();
61
62 ARCANE_CORE_EXPORT ItemGroup itemGroup() const;
63
64 public:
65
66 SmallSpan<DataType> _internalSpan() { return m_view; }
67 SmallSpan<const DataType> _internalSpan() const { return m_view; }
68 SmallSpan<const DataType> _internalConstSpan() const { return m_view; }
69
70 protected:
71
72 void _internalInit() { MeshVariableRef::_internalInit(m_private_part); }
73
74 protected:
75
76 const DataType& _value(Integer local_id) const { return m_view[local_id]; }
77 DataTypeReturnReference _value(Integer local_id) { return m_view[local_id]; }
78
79 const DataType& _putValue(Integer index, const DataType& v)
80 {
81 return (_value(index) = v);
82 }
83
84 protected:
85
86 PrivatePartType* m_private_part = nullptr;
87
88 ArrayView<DataType> m_view;
89
90 IMemoryAccessTrace* m_memory_trace = nullptr;
91};
92
93/*---------------------------------------------------------------------------*/
94/*---------------------------------------------------------------------------*/
95
96} // End namespace Arcane
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101#endif
Modifiable view of an array of type T.
Constant view of an array of type T.
Interface of a variable.
Definition IVariable.h:40
Mesh entity group.
Definition ItemGroup.h:51
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.
PrivateVariableScalarT(const VariableBuildInfo &vb, const VariableInfo &vi)
Constructs a reference linked to the module.
View of an array of elements of type T.
Definition Span.h:805
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.