Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ArcaneCeaVerifierModule.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* ArcaneVerifierModule.cc (C) 2000-2024 */
9/* */
10/* Module de vérification. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/PlatformUtils.h"
15#include "arcane/utils/ScopedPtr.h"
16
17#include "arcane/core/EntryPoint.h"
18#include "arcane/core/ISubDomain.h"
19#include "arcane/core/ModuleFactory.h"
20#include "arcane/core/IVerifierService.h"
21#include "arcane/core/ServiceUtils.h"
22#include "arcane/core/IVariableMng.h"
23#include "arcane/core/IParallelMng.h"
24#include "arcane/core/IMesh.h"
25#include "arcane/core/IItemFamily.h"
26#include "arcane/core/ITimeLoopMng.h"
27#include "arcane/core/ServiceBuilder.h"
28#include "arcane/core/ObserverPool.h"
29#include "arcane/core/ICheckpointMng.h"
30#include "arcane/core/MeshVisitor.h"
31#include "arcane/core/IDirectory.h"
32
33#include "arcane/cea/ArcaneCeaVerifier_axl.h"
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38namespace Arcane
39{
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
48{
49 public:
50
51 explicit ArcaneVerifierModule(const ModuleBuildInfo& mb);
52
53 public:
54
55 VersionInfo versionInfo() const override { return VersionInfo(0,0,1); }
56
57 public:
58
59 void onExit() override;
60 void onInit() override;
61
62 private:
63
64 ObserverPool m_observers;
65
66 private:
67
68 void _checkSortedGroups();
69};
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
73
74ArcaneVerifierModule::
75ArcaneVerifierModule(const ModuleBuildInfo& mb)
76: ArcaneArcaneCeaVerifierObject(mb)
77{
78}
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
83void ArcaneVerifierModule::
84onInit()
85{
86 if (options()->trace.size()!=0)
87 this->pwarning() << "The option 'trace' is no longer used and should be removed";
88
89 if (!platform::getEnvironmentVariable("ARCANE_VERIFY_SORTEDGROUP").null()){
90 info() << "Add observer to check sorted groups before checkpoint";
91 // Ajoute un observer signalant les groupes non triés.
92 m_observers.addObserver(this,
93 &ArcaneVerifierModule::_checkSortedGroups,
94 subDomain()->checkpointMng()->writeObservable());
95 }
96}
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101void ArcaneVerifierModule::
102_checkSortedGroups()
103{
104 // Affiche la liste des groupes non triés.
105 Integer nb_sorted_group = 0;
106 Integer nb_group = 0;
107 auto check_sorted_func = [&](ItemGroup& g)
108 {
109 ++nb_group;
110 if (g.checkIsSorted())
111 ++nb_sorted_group;
112 else
113 info() << "VerifierModule: group not sorted name=" << g.name();
114 };
115 meshvisitor::visitGroups(this->mesh(),check_sorted_func);
116 info() << "VerifierModule: nb_unsorted_group=" << (nb_group-nb_sorted_group)
117 << "/" << nb_group;
118}
119
120/*---------------------------------------------------------------------------*/
121/*---------------------------------------------------------------------------*/
122
124onExit()
125{
126 if (!options()->verify())
127 return;
128 if (!platform::getEnvironmentVariable("ARCANE_NO_VERIFY").null())
129 return;
130
132 bool is_parallel = pm->isParallel();
133
134 Ref<IVerifierService> verifier_service;
135
136 {
138
139 String verifier_service_name = options()->verifierServiceName();
140 // Autorise pour test une variable d'environnement pour surcharger le service
141 String env_service_name = platform::getEnvironmentVariable("ARCANE_VERIFIER_SERVICE");
142 if (!env_service_name.null())
143 verifier_service_name = env_service_name;
144 info() << "Verification Module using service=" << verifier_service_name;
145 verifier_service = sf.createReference(verifier_service_name);
146 }
147
148 bool compare_from_sequential = options()->compareParallelSequential();
149 if (!is_parallel)
150 compare_from_sequential = false;
151
152 String result_file_name = options()->resultFile();
153 String reference_file_name = options()->referenceFile();
154
155 if (options()->filesInOutputDir()) {
156 if (result_file_name.empty()) {
157 result_file_name = subDomain()->exportDirectory().file("compare.xml");
158 }
159 else {
160 result_file_name = subDomain()->exportDirectory().file(result_file_name);
161 }
162
163 if (reference_file_name.empty()) {
164 reference_file_name = subDomain()->exportDirectory().file("check");
165 }
166 else {
167 reference_file_name = subDomain()->exportDirectory().file(reference_file_name);
168 }
169 }
170 else {
171 if (result_file_name.empty()) {
172 result_file_name = "compare.xml";
173 }
174
175 if (reference_file_name.empty()) {
176 reference_file_name = "check";
177 }
178 }
179
180 verifier_service->setResultFileName(result_file_name);
181
182 info() << "Verification check is_parallel?=" << is_parallel << " compare_from_sequential?=" << compare_from_sequential;
183 verifier_service->setFileName(reference_file_name);
184
185 if (options()->generate()){
186 info() << "Writing check file '" << reference_file_name << "'";
187 verifier_service->writeReferenceFile();
188 }
189 else{
190 info() << "Comparing reference file '" << reference_file_name << "'";
191 verifier_service->doVerifFromReferenceFile(compare_from_sequential,false);
192 }
193}
194
195/*---------------------------------------------------------------------------*/
196/*---------------------------------------------------------------------------*/
197
198ARCANE_REGISTER_MODULE_ARCANECEAVERIFIER(ArcaneVerifierModule);
199
200/*---------------------------------------------------------------------------*/
201/*---------------------------------------------------------------------------*/
202
203} // End namespace Arcane
204
205/*---------------------------------------------------------------------------*/
206/*---------------------------------------------------------------------------*/
207
ISubDomain * subDomain() const override
Sous-domaine associé au module.
Generation de la classe de base du Module.
CaseOptionsArcaneCeaVerifier * options() const
Options du jeu de données du module.
void onExit() override
points d'entrée
VersionInfo versionInfo() const override
Version du module.
virtual String file(const String &file_name) const =0
Retourne le chemin complet du fichier file_name dans le répertoire.
Interface du gestionnaire de parallélisme pour un sous-domaine.
virtual bool isParallel() const =0
Retourne true si l'exécution est parallèle.
virtual IParallelMng * parallelMng()=0
Retourne le gestionnaire de parallélisme.
virtual const IDirectory & exportDirectory() const =0
Répertoire de base des exportations.
Informations pour construire un module.
Liste d'observateurs.
void addObserver(T *obj, void(T::*func)(const IObservable &), IObservable *oba)
Ajoute un observateur.
Classe utilitaire pour instantier un service d'une interface donnée.
Ref< InterfaceType > createReference(const String &name, eServiceBuilderProperties properties=SB_None)
Créé une instance implémentant l'interface InterfaceType.
Informations sur une version.
Definition VersionInfo.h:46
Référence à une instance.
Chaîne de caractères unicode.
bool empty() const
Vrai si la chaîne est vide (nulle ou "")
Definition String.cc:315
bool null() const
Retourne true si la chaîne est nulle.
Definition String.cc:304
TraceMessage pwarning() const
TraceMessage info() const
Flot pour un message d'information.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.