From 3455dbdac9a7811bbae0aeb45e426a471f73c681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Thu, 7 Oct 2021 15:09:54 +0200 Subject: [PATCH] Main.hpp: Adjust Whitespace In preparation of refactoring 'dispatchDynamic_<>()' --- opm/simulators/flow/Main.hpp | 100 +++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 45 deletions(-) diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index 6660ae3f6..b16f0fd59 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -65,8 +65,14 @@ #include #endif +#include +#include +#include +#include +#include #include #include +#include namespace Opm::Properties { @@ -81,30 +87,31 @@ struct FlowEarlyBird { } // namespace Opm::Properties namespace Opm { - template - void flowEbosSetDeck(std::shared_ptr deck, - std::shared_ptr eclState, - std::shared_ptr schedule, - std::shared_ptr summaryConfig) - { - using Vanguard = GetPropType; - Vanguard::setExternalDeck(deck); - Vanguard::setExternalEclState(eclState); - Vanguard::setExternalSchedule(schedule); - Vanguard::setExternalSummaryConfig(summaryConfig); - } + template + void flowEbosSetDeck(std::shared_ptr deck, + std::shared_ptr eclState, + std::shared_ptr schedule, + std::shared_ptr summaryConfig) + { + using Vanguard = GetPropType; -// ----------------- Main program ----------------- - template - int flowEbosMain(int argc, char** argv, bool outputCout, bool outputFiles) - { - // we always want to use the default locale, and thus spare us the trouble - // with incorrect locale settings. - resetLocale(); + Vanguard::setExternalDeck(deck); + Vanguard::setExternalEclState(eclState); + Vanguard::setExternalSchedule(schedule); + Vanguard::setExternalSummaryConfig(summaryConfig); + } - FlowMainEbos mainfunc(argc, argv, outputCout, outputFiles); - return mainfunc.execute(); - } + // ----------------- Main program ----------------- + template + int flowEbosMain(int argc, char** argv, bool outputCout, bool outputFiles) + { + // we always want to use the default locale, and thus spare us the trouble + // with incorrect locale settings. + resetLocale(); + + FlowMainEbos mainfunc(argc, argv, outputCout, outputFiles); + return mainfunc.execute(); + } } @@ -127,16 +134,15 @@ namespace Opm Main(int argc, char** argv) : argc_(argc), argv_(argv) { initMPI(); } // This constructor can be called from Python - Main(const std::string &filename) + Main(const std::string& filename) { setArgvArgc_(filename); initMPI(); } - // This constructor can be called from Python when Python has already - // parsed a deck - Main( - std::shared_ptr deck, + // This constructor can be called from Python when Python has + // already parsed a deck + Main(std::shared_ptr deck, std::shared_ptr eclipseState, std::shared_ptr schedule, std::shared_ptr summaryConfig) @@ -215,9 +221,10 @@ namespace Opm int exitCode = EXIT_SUCCESS; if (isSimulationRank_) { if (initialize_(exitCode)) { - return dispatchDynamic_(); + return this->dispatchDynamic_(); } } + return exitCode; } @@ -227,9 +234,10 @@ namespace Opm int exitCode = EXIT_SUCCESS; if (isSimulationRank_) { if (initialize_(exitCode)) { - return dispatchStatic_(); + return this->dispatchStatic_(); } } + return exitCode; } @@ -393,8 +401,10 @@ namespace Opm /// \brief Initialize /// \param exitCode The exitCode of the program. - /// \return Whether to actually run the simulator. I.e. true if parsing of command line - /// was successful and no --help, --print-properties, or --print-parameters have been found. + /// + /// \return Whether to actually run the simulator. I.e. true if + /// parsing of command line was successful and no --help, + /// --print-properties, or --print-parameters have been found. template bool initialize_(int& exitCode) { @@ -524,34 +534,34 @@ namespace Opm return true; } - filesystem::path simulationCaseName_( const std::string& casename ) { + filesystem::path simulationCaseName_(const std::string& casename) + { namespace fs = ::Opm::filesystem; - const auto exists = []( const fs::path& f ) -> bool { - if( !fs::exists( f ) ) return false; - - if( fs::is_regular_file( f ) ) return true; - - return fs::is_symlink( f ) - && fs::is_regular_file( fs::read_symlink( f ) ); + auto exists = [](const fs::path& f) + { + return (fs::exists(f) && fs::is_regular_file(f)) + || (fs::is_symlink(f) && + fs::is_regular_file(fs::read_symlink(f))); }; - auto simcase = fs::path( casename ); + auto simcase = fs::path { casename }; - if( exists( simcase ) ) { + if (exists(simcase)) { return simcase; } - for( const auto& ext : { std::string("data"), std::string("DATA") } ) { - if( exists( simcase.replace_extension( ext ) ) ) { + for (const auto& ext : { std::string("DATA"), std::string("data") }) { + if (exists(simcase.replace_extension(ext))) { return simcase; } } - throw std::invalid_argument( "Cannot find input case " + casename ); + throw std::invalid_argument { + "Cannot find input case '" + casename + '\'' + }; } - // This function is an extreme special case, if the program has been invoked // *exactly* as: //