Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
VariableScalar.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/* VariableScalar.h (C) 2000-2025 */
9/* */
10/* Scalar variable. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_VARIABLESCALAR_H
13#define ARCANE_CORE_VARIABLESCALAR_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/Variable.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*!
29 * \internal
30 * \brief Scalar variable.
31 */
32template <class T>
34: public Variable
35{
36 public:
37
38 typedef T ValueType;
39 typedef IScalarDataT<T> ValueDataType;
40 typedef VariableScalarT<T> ThatClass;
41 typedef Variable BaseClass;
42
43 protected:
44
45 //! Constructs a variable based on the reference \a v
47
48 public:
49
50 static ARCANE_CORE_EXPORT ThatClass* getReference(const VariableBuildInfo& v, const VariableInfo& vi);
51 static ARCANE_CORE_EXPORT ThatClass* getReference(IVariable* var);
52
53 public:
54
55 void synchronize() override;
56 void synchronize(Int32ConstArrayView local_ids) override;
57 Real allocatedMemory() const override;
58 Integer nbElement() const override { return 1; }
59 ValueType& value() { return m_value->value(); }
60 void shrinkMemory() override {}
61 void print(std::ostream& o) const override;
62 IData* data() override { return m_value; }
63 const IData* data() const override { return m_value; }
64
65 public:
66
67 void copyItemsValues(Int32ConstArrayView source, Int32ConstArrayView destination) override;
69 Int32ConstArrayView second_source,
70 Int32ConstArrayView destination) override;
71 void compact(Int32ConstArrayView new_to_old_ids) override;
72 void setIsSynchronized() override;
73 void setIsSynchronized(const ItemGroup& item_group) override;
74
75 public:
76
77 ARCANE_CORE_EXPORT void swapValues(ThatClass& rhs);
78
79 protected:
80
81 void _internalResize(const VariableResizeArgs& resize_args) override
82 {
83 ARCANE_UNUSED(resize_args);
84 }
86
87 private:
88
89 ValueDataType* m_value;
90};
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95} // End namespace Arcane
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99
100#endif
Interface of a data item.
Definition IData.h:34
virtual DataType & value()=0
Data value.
Interface of a variable.
Definition IVariable.h:40
Mesh entity group.
Definition ItemGroup.h:51
Parameters necessary for building a variable.
Arguments for VariableComparer methods.
Results of a comparison operation.
Information characterizing a variable.
IData * data() override
Data associated with the variable.
void copyItemsValues(Int32ConstArrayView source, Int32ConstArrayView destination) override
Copies the values of entities numbered source into entities numbered destination.
void shrinkMemory() override
Frees any additional memory allocated for the data.
VariableScalarT(const VariableBuildInfo &v, const VariableInfo &vi)
Constructs a variable based on the reference v.
void setIsSynchronized(const ItemGroup &item_group) override
Indicates that the variable is synchronized on the group item_group.
void setIsSynchronized() override
Indicates that the variable is synchronized.
void synchronize() override
Synchronizes the variable.
Integer nbElement() const override
Number of elements of the variable.
void copyItemsMeanValues(Int32ConstArrayView first_source, Int32ConstArrayView second_source, Int32ConstArrayView destination) override
Copies the mean values of entities numbered first_source and second_source into entities numbered des...
VariableComparerResults _compareVariable(const VariableComparerArgs &compare_args) final
Comparison of values between variables.
void print(std::ostream &o) const override
Prints the variable's values to the stream o.
void compact(Int32ConstArrayView new_to_old_ids) override
Compresses the variable's values.
Real allocatedMemory() const override
Memory size (in Bytes) used by the variable.
void synchronize(Int32ConstArrayView local_ids) override
Synchronizes the variable on a list of entities.
const IData * data() const override
Data associated with the variable.
Variable(const VariableBuildInfo &v, const VariableInfo &vi)
Creates a variable linked to the reference v.
Definition Variable.cc:344
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
double Real
Type representing a real number.