preCICE v3.1.2
Loading...
Searching...
No Matches
Tooling.cpp
Go to the documentation of this file.
1#include "precice/Tooling.hpp"
2
3#include "fmt/color.h"
5#include "precice/impl/versions.hpp"
6#include "utils/Parallel.hpp"
7#include "utils/Petsc.hpp"
8#include "utils/fmt.hpp"
9#include "xml/Printer.hpp"
10
11namespace precice {
12
13namespace tooling {
14
16{
18 switch (reftype) {
21 return;
24 return;
26 out << "<!-- generated with preCICE " PRECICE_VERSION " -->\n";
28 return;
29 }
30}
31
32void checkConfiguration(const std::string &filename, const std::string &participant, int size)
33{
36
37 // Console output
38 config.format = "precice-tools: %ColorizedSeverity%%Message%";
39 config.filter = "%Severity% >= info";
40 config.type = "stream";
41 config.output = "stdout";
42
43 return config;
44 }()});
45
46 // Lock the logging configuration to prevent the parser from changing it
48
49 fmt::print("Checking {} for syntax and basic setup issues...\n", filename);
52 const auto wasInitialized = utils::Parallel::isMPIInitialized();
53 if (!wasInitialized) {
55 }
57 participant,
58 0,
59 size};
60 xml::configure(config.getXMLTag(), context, filename);
61 fmt::print(fmt::emphasis::bold | fg(fmt::color::green), "No major issues detected\n", filename);
62 if (!wasInitialized) {
65 }
66}
67
68} // namespace tooling
69
71{
72 return {precice::versionInformation};
73}
74
75} // namespace precice
std::ostream & out
Main class for preCICE XML configuration tree.
xml::XMLTag & getXMLTag()
Returns root xml tag to start the automatic configuration process.
static bool isMPIInitialized()
Return true if MPI is initialized.
Definition Parallel.cpp:179
static void finalizeTestingMPI()
Unconditionally finalizes MPI environment.
Definition Parallel.cpp:261
static void initializeTestingMPI(int *argc, char ***argv)
Definition Parallel.cpp:249
static void finalize()
Finalizes Petsc environment.
Definition Petsc.cpp:98
void setupLogging(LoggingConfiguration configs, bool enabled)
Configures the logging from a LoggingConfiguration.
void setMPIRank(int const rank)
void printConfigReference(std::ostream &out, ConfigReferenceType reftype)
Generates a configuration reference.
Definition Tooling.cpp:15
void checkConfiguration(const std::string &filename, const std::string &participant, int size)
Checks a given configuration.
Definition Tooling.cpp:32
@ MD
Markdown version used for the website.
void toMarkdown(std::ostream &out, const XMLTag &tag)
Prints the Markdown reference for the given tag.
Definition Printer.cpp:458
void toDTD(std::ostream &out, const XMLTag &tag)
Prints the DTD reference for the given tag.
Definition Printer.cpp:463
void toDocumentation(std::ostream &out, const XMLTag &tag)
Prints the XML reference for the given tag.
Definition Printer.cpp:468
void configure(XMLTag &tag, const precice::xml::ConfigurationContext &context, std::string_view configurationFilename)
Configures the given configuration from file configurationFilename.
Definition XMLTag.cpp:395
Main namespace of the precice library.
std::string getVersionInformation()
Returns information on the version of preCICE.
Definition Tooling.cpp:70
Holds the configuration for one logging backend (sink) and takes care of default values.
Tightly coupled to the parameters of Participant()
Definition XMLTag.hpp:24