Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
VariableComparer.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/* VariableComparer.h (C) 2000-2025 */
9/* */
10/* Class to perform comparisons between variables. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_VARIABLECOMPARER_H
13#define ARCANE_CORE_VARIABLECOMPARER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
40
53
54/*---------------------------------------------------------------------------*/
55/*---------------------------------------------------------------------------*/
56
60class ARCANE_CORE_EXPORT VariableComparerArgs
61{
62 public:
63
70 void setMaxPrint(Int32 v) { m_max_print = v; }
71 Int32 maxPrint() const { return m_max_print; }
72
82 void setCompareGhost(bool v) { m_is_compare_ghost = v; }
83 bool isCompareGhost() const { return m_is_compare_ghost; }
84
85 void setDataReader(IDataReader* v) { m_data_reader = v; }
86 IDataReader* dataReader() const { return m_data_reader; }
87
88 void setCompareMode(eVariableComparerCompareMode v) { m_compare_mode = v; }
89 eVariableComparerCompareMode compareMode() const { return m_compare_mode; }
90
91 void setComputeDifferenceMethod(eVariableComparerComputeDifferenceMethod v) { m_compute_difference_method = v; }
92 eVariableComparerComputeDifferenceMethod computeDifferenceMethod() const { return m_compute_difference_method; }
93
94 private:
95
96 Int32 m_max_print = 0;
97 bool m_is_compare_ghost = false;
98 IDataReader* m_data_reader = nullptr;
99 eVariableComparerCompareMode m_compare_mode = eVariableComparerCompareMode::Same;
100 eVariableComparerComputeDifferenceMethod m_compute_difference_method = eVariableComparerComputeDifferenceMethod::Relative;
101};
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
109class ARCANE_CORE_EXPORT VariableComparerResults
110{
111 public:
112
113 VariableComparerResults() = default;
114 explicit VariableComparerResults(Int32 nb_diff)
115 : m_nb_diff(nb_diff)
116 {}
117
118 public:
119
120 void setNbDifference(Int32 v) { m_nb_diff = v; }
121 Int32 nbDifference() const { return m_nb_diff; }
122
123 public:
124
125 Int32 m_nb_diff = 0;
126};
127
128/*---------------------------------------------------------------------------*/
129/*---------------------------------------------------------------------------*/
130
144class ARCANE_CORE_EXPORT VariableComparer
145{
146 public:
147
148 VariableComparer() = default;
149
150 public:
151
167
189
190 public:
191
209
210 public:
211
214};
215
216/*---------------------------------------------------------------------------*/
217/*---------------------------------------------------------------------------*/
218
219} // namespace Arcane
220
221/*---------------------------------------------------------------------------*/
222/*---------------------------------------------------------------------------*/
223
224#endif
Declarations of Arcane's general types.
Interface for reading variable data.
Definition IDataReader.h:35
Interface of a variable.
Definition IVariable.h:40
Arguments for VariableComparer methods.
void setMaxPrint(Int32 v)
Sets the number of errors to display in the listing.
void setCompareGhost(bool v)
Indicates on which entities the comparison is performed.
Results of a comparison operation.
VariableComparerArgs buildForCheckIfSameOnAllReplica()
Creates a comparison to verify that a variable is identical on all replicas.
VariableComparerResults apply(IVariable *var, const VariableComparerArgs &compare_args)
Applies the comparison compare_args to the variable var.
VariableComparerArgs buildForCheckIfSame(IDataReader *data_reader)
Creates a comparison to verify that a variable is identical to a reference value.
VariableComparerArgs buildForCheckIfSync()
Creates a comparison to verify that a variable is synchronized.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
eVariableComparerComputeDifferenceMethod
Method used to calculate the difference between two values v1 and v2.
eVariableComparerCompareMode
Comparison method to use.
@ SameOnAllReplica
Checks that the variable values are the same on all replicas.
@ Same
Compares with a reference.
@ Sync
Checks that the variable is synchronized.
std::int32_t Int32
Signed integer type of 32 bits.