From cb14b1e690fba922ff11bc4a2a4a7260858612c3 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 1 Feb 2023 15:42:04 +0100 Subject: [PATCH] cosmetics --- opm/simulators/utils/ParallelFileMerger.cpp | 53 ++++++++------------- opm/simulators/utils/ParallelFileMerger.hpp | 9 ++-- 2 files changed, 25 insertions(+), 37 deletions(-) diff --git a/opm/simulators/utils/ParallelFileMerger.cpp b/opm/simulators/utils/ParallelFileMerger.cpp index 43dd9b917..862d8db75 100644 --- a/opm/simulators/utils/ParallelFileMerger.cpp +++ b/opm/simulators/utils/ParallelFileMerger.cpp @@ -26,21 +26,18 @@ #include #include -namespace Opm -{ -namespace detail -{ +namespace Opm { +namespace detail { ParallelFileMerger::ParallelFileMerger(const fs::path& output_dir, const std::string& deckname, bool show_fallout) - : debugFileRegex_(deckname+"\\.\\d+\\.DBG"), - logFileRegex_(deckname+"\\.\\d+\\.PRT"), - fileWarningRegex_(deckname+"\\.(\\d+)\\.[^.]+"), - show_fallout_(show_fallout) + : debugFileRegex_(deckname+"\\.\\d+\\.DBG") + , logFileRegex_(deckname+"\\.\\d+\\.PRT") + , fileWarningRegex_(deckname+"\\.(\\d+)\\.[^.]+") + , show_fallout_(show_fallout) { - if ( show_fallout_ ) - { + if (show_fallout_) { auto debugPath = output_dir; debugPath /= (deckname + ".DBG"); debugStream_ = std::make_unique(debugPath, @@ -57,35 +54,28 @@ void ParallelFileMerger::operator()(const fs::path& file) std::smatch matches; std::string filename = file.filename().native(); - if ( std::regex_match(filename, matches, fileWarningRegex_) ) - { + if (std::regex_match(filename, matches, fileWarningRegex_)) { std::string rank = std::regex_replace(filename, fileWarningRegex_, "$1"); - if( std::regex_match(filename, logFileRegex_) ) - { - if ( show_fallout_ ){ + if (std::regex_match(filename, logFileRegex_)) { + if (show_fallout_) { appendFile(*logStream_, file, rank); - }else{ + } else { fs::remove(file); } - } - else - { - if (std::regex_match(filename, debugFileRegex_) ) - { - if ( show_fallout_ ){ + } else { + if (std::regex_match(filename, debugFileRegex_)) { + if (show_fallout_) { appendFile(*debugStream_, file, rank); - }else{ + } else { fs::remove(file); } - } - else - { - if ( show_fallout_ ){ + } else { + if (show_fallout_) { std::cerr << "WARNING: Unrecognized file with name " - << filename - << " that might stem from a parallel run." - << std::endl; + << filename + << " that might stem from a parallel run." + << std::endl; } } } @@ -94,8 +84,7 @@ void ParallelFileMerger::operator()(const fs::path& file) void ParallelFileMerger::appendFile(std::ofstream& of, const fs::path& file, const std::string& rank) { - if( fs::file_size(file) ) - { + if (fs::file_size(file)) { std::cerr << "WARNING: There has been logging to file " << file.string() <<" by process " << rank << std::endl; diff --git a/opm/simulators/utils/ParallelFileMerger.hpp b/opm/simulators/utils/ParallelFileMerger.hpp index 05bfbf377..bf18c6d2b 100644 --- a/opm/simulators/utils/ParallelFileMerger.hpp +++ b/opm/simulators/utils/ParallelFileMerger.hpp @@ -27,11 +27,8 @@ #include #include - -namespace Opm -{ -namespace detail -{ +namespace Opm { +namespace detail { namespace fs = ::std::filesystem; @@ -73,6 +70,8 @@ private: /// \brief Whether to show any logging fallout bool show_fallout_; }; + } // end namespace detail } // end namespace Opm + #endif // end header guard