Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
VariableDiff.cc
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.cc (C) 2000-2023 */
9/* */
10/* Gestion des différences entre les variables */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/VariableDiff.h"
15
16#include "arcane/utils/OStringStream.h"
17#include "arcane/utils/ITraceMng.h"
18
19#include "arcane/core/IVariable.h"
20#include "arcane/core/IParallelMng.h"
21
22#include <algorithm>
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane
28{
29
30template <typename DataType> void VariableDiff<DataType>::DiffPrinter::
31sort(ArrayView<DiffInfo> diffs_info)
32{
33 if constexpr (std::is_same<TrueType, typename VarDataTypeTraits::IsNumeric>::value) {
34 std::sort(std::begin(diffs_info), std::end(diffs_info));
35 }
36 else
37 ARCANE_UNUSED(diffs_info);
38}
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
42
43template <typename DataType> void VariableDiff<DataType>::DiffPrinter::
44dump(ConstArrayView<DiffInfo> diffs_info, IVariable* var, IParallelMng* pm, int max_print)
45{
46 ITraceMng* msg = pm->traceMng();
47 Int32 sid = pm->commRank();
48 const String& var_name = var->name();
49 Integer nb_diff = diffs_info.size();
50 Integer nb_print = nb_diff;
51 if (max_print >= 0 && nb_diff > static_cast<Integer>(max_print))
52 nb_print = max_print;
53 OStringStream ostr;
54 ostr().precision(FloatInfo<Real>::maxDigit());
55 ostr() << nb_diff << " entities having different values for the variable "
56 << var_name << '\n';
57 for (Integer i = 0; i < nb_print; ++i) {
58 const DiffInfo& di = diffs_info[i];
59 if (di.m_unique_id != NULL_ITEM_UNIQUE_ID) {
60 // Il s'agit d'une entité
61 char type = di.m_is_own ? 'O' : 'G';
62 ostr() << "VDIFF: Variable '" << var_name << "'"
63 << " (" << type << ")"
64 << " uid=" << di.m_unique_id
65 << " lid=" << di.m_local_id;
66 if (di.m_sub_index != NULL_ITEM_ID)
67 ostr() << " [" << di.m_sub_index << "]";
68 ostr() << " val: " << di.m_current
69 << " ref: " << di.m_ref << " rdiff: " << di.m_diff << '\n';
70 }
71 else {
72 // Il s'agit de l'indice d'une variable tableau
73 ostr() << "VDIFF: Variable '" << var_name << "'"
74 << " index=" << di.m_local_id;
75 if (di.m_sub_index != NULL_ITEM_ID)
76 ostr() << " [" << di.m_sub_index << "]";
77 ostr() << " val: " << di.m_current
78 << " ref: " << di.m_ref << " rdiff: " << di.m_diff << '\n';
79 }
80 }
81 msg->pinfo() << "Processor " << sid << " : " << nb_diff
82 << " values are different on the variable "
83 << var_name << ":\n"
84 << ostr.str();
85}
86
87/*---------------------------------------------------------------------------*/
88/*---------------------------------------------------------------------------*/
89
90template class VariableDiff<Byte>::DiffPrinter;
91template class VariableDiff<Real>::DiffPrinter;
92template class VariableDiff<Int16>::DiffPrinter;
93template class VariableDiff<Int32>::DiffPrinter;
94template class VariableDiff<Int64>::DiffPrinter;
95template class VariableDiff<Real2>::DiffPrinter;
96template class VariableDiff<Real2x2>::DiffPrinter;
97template class VariableDiff<Real3>::DiffPrinter;
98template class VariableDiff<Real3x3>::DiffPrinter;
99template class VariableDiff<String>::DiffPrinter;
100
101/*---------------------------------------------------------------------------*/
102/*---------------------------------------------------------------------------*/
103
104} // End namespace Arcane
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.