Main.hpp: Adjust Whitespace

In preparation of refactoring 'dispatchDynamic_<>()'
This commit is contained in:
Bård Skaflestad
2021-10-07 15:09:54 +02:00
parent ed73f1b326
commit 3455dbdac9

View File

@@ -65,8 +65,14 @@
#include <opm/simulators/utils/ParallelEclipseState.hpp> #include <opm/simulators/utils/ParallelEclipseState.hpp>
#endif #endif
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include <utility>
namespace Opm::Properties { namespace Opm::Properties {
@@ -88,6 +94,7 @@ namespace Opm {
std::shared_ptr<SummaryConfig> summaryConfig) std::shared_ptr<SummaryConfig> summaryConfig)
{ {
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>; using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalDeck(deck); Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(eclState); Vanguard::setExternalEclState(eclState);
Vanguard::setExternalSchedule(schedule); Vanguard::setExternalSchedule(schedule);
@@ -133,10 +140,9 @@ namespace Opm
initMPI(); initMPI();
} }
// This constructor can be called from Python when Python has already // This constructor can be called from Python when Python has
// parsed a deck // already parsed a deck
Main( Main(std::shared_ptr<Deck> deck,
std::shared_ptr<Deck> deck,
std::shared_ptr<EclipseState> eclipseState, std::shared_ptr<EclipseState> eclipseState,
std::shared_ptr<Schedule> schedule, std::shared_ptr<Schedule> schedule,
std::shared_ptr<SummaryConfig> summaryConfig) std::shared_ptr<SummaryConfig> summaryConfig)
@@ -215,9 +221,10 @@ namespace Opm
int exitCode = EXIT_SUCCESS; int exitCode = EXIT_SUCCESS;
if (isSimulationRank_) { if (isSimulationRank_) {
if (initialize_<Properties::TTag::FlowEarlyBird>(exitCode)) { if (initialize_<Properties::TTag::FlowEarlyBird>(exitCode)) {
return dispatchDynamic_(); return this->dispatchDynamic_();
} }
} }
return exitCode; return exitCode;
} }
@@ -227,9 +234,10 @@ namespace Opm
int exitCode = EXIT_SUCCESS; int exitCode = EXIT_SUCCESS;
if (isSimulationRank_) { if (isSimulationRank_) {
if (initialize_<TypeTag>(exitCode)) { if (initialize_<TypeTag>(exitCode)) {
return dispatchStatic_<TypeTag>(); return this->dispatchStatic_<TypeTag>();
} }
} }
return exitCode; return exitCode;
} }
@@ -393,8 +401,10 @@ namespace Opm
/// \brief Initialize /// \brief Initialize
/// \param exitCode The exitCode of the program. /// \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 <class TypeTagEarlyBird> template <class TypeTagEarlyBird>
bool initialize_(int& exitCode) bool initialize_(int& exitCode)
{ {
@@ -524,34 +534,34 @@ namespace Opm
return true; return true;
} }
filesystem::path simulationCaseName_( const std::string& casename ) { filesystem::path simulationCaseName_(const std::string& casename)
{
namespace fs = ::Opm::filesystem; namespace fs = ::Opm::filesystem;
const auto exists = []( const fs::path& f ) -> bool { auto exists = [](const fs::path& f)
if( !fs::exists( f ) ) return false; {
return (fs::exists(f) && fs::is_regular_file(f))
if( fs::is_regular_file( f ) ) return true; || (fs::is_symlink(f) &&
fs::is_regular_file(fs::read_symlink(f)));
return 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; return simcase;
} }
for( const auto& ext : { std::string("data"), std::string("DATA") } ) { for (const auto& ext : { std::string("DATA"), std::string("data") }) {
if (exists(simcase.replace_extension(ext))) { if (exists(simcase.replace_extension(ext))) {
return simcase; 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 // This function is an extreme special case, if the program has been invoked
// *exactly* as: // *exactly* as:
// //