Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
VerifierService.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/* VerifierService.h (C) 2000-2025 */
9/* */
10/* Base class for the variable verification service. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_VERIFIERSERVICE_H
13#define ARCANE_CORE_VERIFIERSERVICE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/String.h"
18
20#include "arcane/core/AbstractService.h"
21#include "arcane/core/IVerifierService.h"
22#include "arcane/core/VariableComparer.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
34class IDataReader;
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39/*!
40 * \ingroup StandardService
41 * \brief Base class for the data verification service
42 * between two runs.
43 */
44class ARCANE_CORE_EXPORT VerifierService
45: public AbstractService
46, public IVerifierService
47{
48 private:
49
50 struct DiffInfo
51 {
52 public:
53
54 DiffInfo()
55 : m_variable_name()
56 , m_nb_diff(0)
57 {}
58 DiffInfo(const String& var_name, Int64 nb_diff)
59 : m_variable_name(var_name)
60 , m_nb_diff(nb_diff)
61 {}
62
63 public:
64
65 String m_variable_name;
66 Int64 m_nb_diff;
67 };
68
69 public:
70
71 explicit VerifierService(const ServiceBuildInfo& sbi);
72
73 public:
74
75 IBase* serviceParent() const override;
76 IServiceInfo* serviceInfo() const override { return m_service_info; }
77 IService* serviceInterface() override { return this; }
78
79 public:
80
81 void setFileName(const String& file_name) override { m_file_name = file_name; }
82 String fileName() const override { return m_file_name; }
83
84 public:
85
86 void setResultFileName(const String& file_name) override { m_result_file_name = file_name; }
87 String resultfileName() const override { return m_result_file_name; }
88
89 //! Desired comparison type
90 void setCompareMode(eCompareMode v) override { m_compare_mode = v; }
91 eCompareMode compareMode() const override { return m_compare_mode; }
92
93 void setSubDir(const String& sub_dir) override { m_sub_dir = sub_dir; }
94 String subDir() const override { return m_sub_dir; }
95
97 {
98 m_compute_diff_method = v;
99 }
100 eVariableComparerComputeDifferenceMethod computeDifferenceMethod() const override
101 {
102 return m_compute_diff_method;
103 }
104
105 protected:
106
107 virtual void _doVerif(IDataReader* reader, const VariableCollection& variables, bool compare_ghost);
108 //! Fills the list of variables that need to be reread in \a variables
109 virtual void _getVariables(VariableList variables, bool parallel_sequential);
110
111 public:
112
113 ISubDomain* subDomain() { return m_sub_domain; }
114
115 protected:
116 private:
117
118 ISubDomain* m_sub_domain = nullptr;
119 IServiceInfo* m_service_info = nullptr;
120 String m_file_name;
121 String m_result_file_name;
122 String m_sub_dir;
123 eCompareMode m_compare_mode = eCompareMode::Values;
124 eVariableComparerComputeDifferenceMethod m_compute_diff_method = eVariableComparerComputeDifferenceMethod::Relative;
125
126 private:
127
128 template <typename ReaderType> void
129 _doVerif2(ReaderType reader, const VariableList& variables, bool compare_ghost);
130};
131
132/*---------------------------------------------------------------------------*/
133/*---------------------------------------------------------------------------*/
134
135} // End namespace Arcane
136
137/*---------------------------------------------------------------------------*/
138/*---------------------------------------------------------------------------*/
139
140#endif
Declarations of Arcane's general types.
AbstractService(const ServiceBuildInfo &)
Constructor from a ServiceBuildInfo.
Interface of the base class for main arcane objects.
Definition IBase.h:32
Interface for reading variable data.
Definition IDataReader.h:35
Interface for service or module information.
Interface of a service.
Definition IService.h:40
Interface of the data verification service between two executions.
Structure containing the information to create a service.
IBase * serviceParent() const override
Access to the base interface of main Arcane objects.
String fileName() const override
Name of the file containing the reference values.
void setComputeDifferenceMethod(eVariableComparerComputeDifferenceMethod v) override
Method to use for calculating the difference between two values.
IService * serviceInterface() override
Returns the low-level IService interface of the service.
void setFileName(const String &file_name) override
Sets the name of the file containing the reference values.
void setCompareMode(eCompareMode v) override
Desired comparison type.
void setSubDir(const String &sub_dir) override
Sets the name of the subdirectory containing the reference values.
IServiceInfo * serviceInfo() const override
Access to service information. See IServiceInfo for details.
void setResultFileName(const String &file_name) override
Name of the file containing the results.
String subDir() const override
Name of the file containing the reference values.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
eVariableComparerComputeDifferenceMethod
Method used to calculate the difference between two values v1 and v2.