Arcane  v3.16.2.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
VariableDiff.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* Gestion des différences entre les 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/*!
32 * \internal
33 *
34 * \brief Classe de base pour les comparaisons de valeurs entre deux variables.
35 */
36template <typename DataType>
38{
39 public:
40
41 using VarDataTypeTraits = VariableDataTypeTraitsT<DataType>;
42 static constexpr bool IsNumeric = std::is_same_v<typename VarDataTypeTraits::IsNumeric, TrueType>;
43
44 public:
45
46 class DiffInfo
47 {
48 public:
49
50 using VarDataTypeTraits = VariableDataTypeTraitsT<DataType>;
51
52 public:
53
54 DiffInfo() = default;
55 DiffInfo(const DataType& current, const DataType& ref, const DataType& diff,
56 Item item, Integer sub_index)
57 : m_current(current)
58 , m_ref(ref)
59 , m_diff(diff)
60 , m_sub_index(sub_index)
61 , m_is_own(item.isOwn())
62 , m_local_id(item.localId())
63 , m_unique_id(item.uniqueId())
64 {}
65 DiffInfo(const DataType& current, const DataType& ref, const DataType& diff,
66 Int32 index, Integer sub_index)
67 : m_current(current)
68 , m_ref(ref)
69 , m_diff(diff)
70 , m_sub_index(sub_index)
71 , m_is_own(false)
72 , m_local_id(index)
73 , m_unique_id(NULL_ITEM_UNIQUE_ID)
74 {}
75
76 public:
77
78 DataType m_current = {};
79 DataType m_ref = {};
80 DataType m_diff = {};
81 Integer m_sub_index = NULL_ITEM_ID;
82 bool m_is_own = false;
83 Int32 m_local_id = NULL_ITEM_LOCAL_ID;
84 Int64 m_unique_id = NULL_ITEM_UNIQUE_ID;
85
86 public:
87
88 bool operator<(const DiffInfo& t2) const
89 {
90 return VarDataTypeTraits::normeMax(m_diff) > VarDataTypeTraits::normeMax(t2.m_diff);
91 }
92 };
93
94 UniqueArray<DiffInfo> m_diffs_info;
95
96 public:
97
98 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
99 void sort(TrueType)
100 {
101 _sort();
102 }
103
104 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
105 void sort(FalseType)
106 {
107 }
108
109 protected:
110
111 void _sortAndDump(IVariable* var, IParallelMng* pm, const VariableComparerArgs& compare_args)
112 {
113 _sort();
114 dump(var, pm, compare_args);
115 }
116
117 void dump(IVariable* var, IParallelMng* pm, const VariableComparerArgs& compare_args)
118 {
119 DiffPrinter::dump(m_diffs_info, var, pm, compare_args);
120 }
121 void _sort()
122 {
123 DiffPrinter::sort(m_diffs_info);
124 }
125
126 private:
127
128 class DiffPrinter
129 {
130 public:
131
132 ARCANE_CORE_EXPORT static void
133 dump(ConstArrayView<DiffInfo> diff_infos, IVariable* var, IParallelMng* pm,
134 const VariableComparerArgs& compare_args);
135 ARCANE_CORE_EXPORT static void sort(ArrayView<DiffInfo> diff_infos);
136 };
137};
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
142} // namespace Arcane
143
144/*---------------------------------------------------------------------------*/
145/*---------------------------------------------------------------------------*/
146
147#endif
Interface du gestionnaire de parallélisme pour un sous-domaine.
Classe de base d'un élément de maillage.
Definition Item.h:83
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
Definition Item.h:219
bool isOwn() const
true si l'entité est appartient au sous-domaine
Definition Item.h:253
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
Definition Item.h:225
Vecteur 1D de données avec sémantique par valeur (style STL).
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
std::int32_t Int32
Type entier signé sur 32 bits.