Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
VariableDiff.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/* VariableDiff.h (C) 2000-2025 */
9/* */
10/* Management of differences between variables */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_VARIABLEDIFF_H
13#define ARCANE_CORE_VARIABLEDIFF_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array.h"
18
19#include "arcane/core/VariableDataTypeTraits.h"
20#include "arcane/core/Item.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27class IParallelMng;
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
37template <typename DataType>
39{
40 public:
41
42 using VarDataTypeTraits = VariableDataTypeTraitsT<DataType>;
43 static constexpr bool IsNumeric = std::is_same_v<typename VarDataTypeTraits::IsNumeric, TrueType>;
44
45 public:
46
47 class DiffInfo
48 {
49 public:
50
51 using VarDataTypeTraits = VariableDataTypeTraitsT<DataType>;
52
53 public:
54
55 DiffInfo() = default;
56 DiffInfo(const DataType& current, const DataType& ref, const DataType& diff,
57 Item item, Integer sub_index)
58 : m_current(current)
59 , m_ref(ref)
60 , m_diff(diff)
61 , m_sub_index(sub_index)
62 , m_is_own(item.isOwn())
63 , m_local_id(item.localId())
64 , m_unique_id(item.uniqueId())
65 {}
66 DiffInfo(const DataType& current, const DataType& ref, const DataType& diff,
67 Int32 index, Integer sub_index)
68 : m_current(current)
69 , m_ref(ref)
70 , m_diff(diff)
71 , m_sub_index(sub_index)
72 , m_is_own(false)
73 , m_local_id(index)
74 , m_unique_id(NULL_ITEM_UNIQUE_ID)
75 {}
76
77 public:
78
79 DataType m_current = {};
80 DataType m_ref = {};
81 DataType m_diff = {};
82 Integer m_sub_index = NULL_ITEM_ID;
83 bool m_is_own = false;
84 Int32 m_local_id = NULL_ITEM_LOCAL_ID;
85 Int64 m_unique_id = NULL_ITEM_UNIQUE_ID;
86
87 public:
88
89 bool operator<(const DiffInfo& t2) const
90 {
91 return VarDataTypeTraits::normeMax(m_diff) > VarDataTypeTraits::normeMax(t2.m_diff);
92 }
93 };
94
95 UniqueArray<DiffInfo> m_diffs_info;
96
97 public:
98
99 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
100 void sort(TrueType)
101 {
102 _sort();
103 }
104
105 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
106 void sort(FalseType)
107 {
108 }
109
110 protected:
111
112 void _sortAndDump(IVariable* var, IParallelMng* pm, const VariableComparerArgs& compare_args)
113 {
114 _sort();
115 dump(var, pm, compare_args);
116 }
117
118 void dump(IVariable* var, IParallelMng* pm, const VariableComparerArgs& compare_args)
119 {
120 DiffPrinter::dump(m_diffs_info, var, pm, compare_args);
121 }
122 void _sort()
123 {
124 DiffPrinter::sort(m_diffs_info);
125 }
126
127 private:
128
130 {
131 public:
132
133 ARCANE_CORE_EXPORT static void
134 dump(ConstArrayView<DiffInfo> diff_infos, IVariable* var, IParallelMng* pm,
135 const VariableComparerArgs& compare_args);
136 ARCANE_CORE_EXPORT static void sort(ArrayView<DiffInfo> diff_infos);
137 };
138};
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
143} // namespace Arcane
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
147
148#endif
Modifiable view of an array of type T.
Constant view of an array of type T.
Interface of the parallelism manager for a subdomain.
Interface of a variable.
Definition IVariable.h:40
Base class for a mesh element.
Definition Item.h:84
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
Definition Item.h:233
ItemUniqueId uniqueId() const
Unique identifier across all domains.
Definition Item.h:239
constexpr bool isOwn() const
true if the entity belongs to the subdomain
Definition Item.h:267
1D data vector with value semantics (STL style).
Arguments for VariableComparer methods.
Template class for information about a variable type.
Base class for value comparisons between two variables.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.
Structure equivalent to the boolean value true.
Structure equivalent to the boolean value true.