Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Array2Variable.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/* Array2Variable.h (C) 2000-2025 */
9/* */
10/* 2D array variable. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ARRAY2VARIABLE_H
13#define ARCANE_CORE_ARRAY2VARIABLE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array2.h"
18
19#include "arcane/core/Variable.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30/*!
31 * \internal
32 * \brief Variable on a 2D array.
33 */
34template <class T>
36: public Variable
37{
38 public:
39
40 using ValueType = Array2<T>;
41 using ValueDataType = IArray2DataT<T>;
42 using ThatClass = Array2VariableT<T>;
43 using BaseClass = Variable;
44
45 protected:
46
47 //! Constructs a variable based on the reference \a v
49
50 public:
51
52 static ARCANE_CORE_EXPORT ThatClass* getReference(IVariable* var);
53 static ARCANE_CORE_EXPORT ThatClass* getReference(const VariableBuildInfo& v, const VariableInfo& vi);
54
55 public:
56
57 void synchronize() override;
58 void synchronize(Int32ConstArrayView local_ids) override;
59 Real allocatedMemory() const override;
60 Integer nbElement() const override { return m_data->view().totalNbElement(); }
61 ARCCORE_DEPRECATED_2021("Use valueView() instead")
62 virtual ValueType& value();
63 ConstArray2View<T> constValueView() const { return m_data->view(); }
64 ConstArray2View<T> valueView() const { return m_data->view(); }
65 Array2View<T> valueView() { return m_data->view(); }
66 void shrinkMemory() override;
67 void copyItemsValues(Int32ConstArrayView source, Int32ConstArrayView destination) override;
69 Int32ConstArrayView second_source,
70 Int32ConstArrayView destination) override;
71 void compact(Int32ConstArrayView old_to_new_ids) override;
72 void print(std::ostream& o) const override;
73 void setIsSynchronized() override;
74 void setIsSynchronized(const ItemGroup& item_group) override;
75 IData* data() override { return m_data; }
76 const IData* data() const override { return m_data; }
77
78 public:
79
80 ARCANE_CORE_EXPORT void directResize(Integer dim1);
81 ARCANE_CORE_EXPORT void directResize(Integer dim1, Integer dim2);
82 ARCANE_CORE_EXPORT void directResizeAndReshape(const ArrayShape& shape);
83 ARCANE_CORE_EXPORT void swapValues(ThatClass& rhs);
84 ARCANE_CORE_EXPORT void fillShape(ArrayShape& shape);
85 ValueDataType* trueData() { return m_data; }
86
87 protected:
88
89 void _internalResize(const VariableResizeArgs& resize_args) override;
91
92 private:
93
94 ValueDataType* m_data = nullptr;
95};
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99
100} // End namespace Arcane
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
104
105#endif
VariableComparerResults _compareVariable(const VariableComparerArgs &compare_args) final
Comparison of values between variables.
void compact(Int32ConstArrayView old_to_new_ids) override
Compresses the variable's values.
void setIsSynchronized() override
Indicates that the variable is synchronized.
Array2VariableT(const VariableBuildInfo &v, const VariableInfo &vi)
Constructs a variable based on the reference v.
Integer nbElement() const override
Number of elements of the variable.
IData * data() override
Data associated with 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...
void copyItemsValues(Int32ConstArrayView source, Int32ConstArrayView destination) override
Copies the values of entities numbered source into entities numbered destination.
void synchronize() override
Synchronizes the variable.
const IData * data() const override
Data associated with the variable.
Real allocatedMemory() const override
Memory size (in Bytes) used by the variable.
void setIsSynchronized(const ItemGroup &item_group) override
Indicates that the variable is synchronized on the group item_group.
void print(std::ostream &o) const override
Prints the variable's values to the stream o.
void synchronize(Int32ConstArrayView local_ids) override
Synchronizes the variable on a list of entities.
void shrinkMemory() override
Frees any additional memory allocated for the data.
Class representing a classic 2D array.
Array shape.
Definition ArrayShape.h:42
virtual ConstArray2View< DataType > view() const =0
Constant view on the data.
Interface of a data item.
Definition IData.h:34
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.
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.