Arcane  v3.14.10.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-2023 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-2023 */
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
43 public:
44
46 {
47 public:
48
49 using VarDataTypeTraits = VariableDataTypeTraitsT<DataType>;
50
51 public:
52
53 DiffInfo() = default;
54 DiffInfo(const DataType& current, const DataType& ref, const DataType& diff,
55 Item item, Integer sub_index)
56 : m_current(current)
57 , m_ref(ref)
58 , m_diff(diff)
59 , m_sub_index(sub_index)
60 , m_is_own(item.isOwn())
61 , m_local_id(item.localId())
62 , m_unique_id(item.uniqueId())
63 {}
64 DiffInfo(const DataType& current, const DataType& ref, const DataType& diff,
65 Int32 index, Integer sub_index)
66 : m_current(current)
67 , m_ref(ref)
68 , m_diff(diff)
69 , m_sub_index(sub_index)
70 , m_is_own(false)
71 , m_local_id(index)
72 , m_unique_id(NULL_ITEM_UNIQUE_ID)
73 {}
74
75 public:
76
77 DataType m_current = {};
78 DataType m_ref = {};
79 DataType m_diff = {};
80 Integer m_sub_index = NULL_ITEM_ID;
81 bool m_is_own = false;
82 Int32 m_local_id = NULL_ITEM_LOCAL_ID;
83 Int64 m_unique_id = NULL_ITEM_UNIQUE_ID;
84
85 public:
86
87 bool operator<(const DiffInfo& t2) const
88 {
89 return VarDataTypeTraits::normeMax(m_diff) > VarDataTypeTraits::normeMax(t2.m_diff);
90 }
91 };
92
93 UniqueArray<DiffInfo> m_diffs_info;
94
95 public:
96
97 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
98 void sort(TrueType)
99 {
100 _sort();
101 }
102
103 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
104 void sort(FalseType)
105 {
106 }
107
108 protected:
109
110 void _sortAndDump(IVariable* var, IParallelMng* pm, int max_print)
111 {
112 _sort();
113 dump(var, pm, max_print);
114 }
115
116 void dump(IVariable* var, IParallelMng* pm, int max_print)
117 {
118 DiffPrinter::dump(m_diffs_info, var, pm, max_print);
119 }
120 void _sort()
121 {
122 DiffPrinter::sort(m_diffs_info);
123 }
124
125 private:
126
127 class DiffPrinter
128 {
129 public:
130
131 ARCANE_CORE_EXPORT static void dump(ConstArrayView<DiffInfo> diff_infos,
132 IVariable* var, IParallelMng* pm, int max_print);
133 ARCANE_CORE_EXPORT static void sort(ArrayView<DiffInfo> diff_infos);
134 };
135};
136
137/*---------------------------------------------------------------------------*/
138/*---------------------------------------------------------------------------*/
139
140} // namespace Arcane
141
142/*---------------------------------------------------------------------------*/
143/*---------------------------------------------------------------------------*/
144
145#endif
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:210
bool isOwn() const
true si l'entité est appartient au sous-domaine
Definition Item.h:244
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
Definition Item.h:216
Vecteur 1D de données avec sémantique par valeur (style STL).
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-