mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Move helpers to the detail namespace, layout changes.
The helpers were moved to the bottom of the file for clarity. Misc. layout and whitespace changes, also fix two minor errors in comments.
This commit is contained in:
parent
8ea71e2f15
commit
34bc69c257
@ -103,56 +103,18 @@
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
boost::filesystem::path simulationCaseName( const std::string& casename ) {
|
||||
namespace fs = boost::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 simcase = fs::path( casename );
|
||||
|
||||
if( exists( simcase ) ) {
|
||||
return simcase;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int64_t convertMessageType(const Message::type& mtype)
|
||||
namespace detail
|
||||
{
|
||||
switch (mtype) {
|
||||
case Message::type::Debug:
|
||||
return Log::MessageType::Debug;
|
||||
case Message::type::Info:
|
||||
return Log::MessageType::Info;
|
||||
case Message::type::Warning:
|
||||
return Log::MessageType::Warning;
|
||||
case Message::type::Error:
|
||||
return Log::MessageType::Error;
|
||||
case Message::type::Problem:
|
||||
return Log::MessageType::Problem;
|
||||
case Message::type::Bug:
|
||||
return Log::MessageType::Bug;
|
||||
}
|
||||
throw std::logic_error("Invalid messages type!\n");
|
||||
boost::filesystem::path simulationCaseName( const std::string& casename );
|
||||
int64_t convertMessageType(const Message::type& mtype);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// This class encapsulates the setup and running of
|
||||
/// a simulator based on an input deck.
|
||||
template <class Implementation, class Grid, class Simulator>
|
||||
@ -331,7 +293,7 @@ namespace Opm
|
||||
std::cerr << "You can only specify a single input deck on the command line.\n";
|
||||
return false;
|
||||
} else {
|
||||
const auto casename = simulationCaseName( param_.unhandledArguments()[ 0 ] );
|
||||
const auto casename = detail::simulationCaseName( param_.unhandledArguments()[ 0 ] );
|
||||
param_.insertParameter("deck_filename", casename.string() );
|
||||
}
|
||||
}
|
||||
@ -598,11 +560,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
|
||||
// extract messages from parser
|
||||
// Write to:
|
||||
// logFile_
|
||||
|
||||
// Extract messages from parser.
|
||||
// Writes to:
|
||||
// OpmLog singleton.
|
||||
void extractMessages()
|
||||
{
|
||||
auto extractMessage = [](const Message& msg) {
|
||||
@ -629,9 +589,10 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
// run diagnostics
|
||||
|
||||
// Run diagnostics.
|
||||
// Writes to:
|
||||
// logFile_
|
||||
// OpmLog singleton.
|
||||
void runDiagnostics()
|
||||
{
|
||||
// Run relperm diagnostics
|
||||
@ -796,6 +757,67 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
boost::filesystem::path simulationCaseName( const std::string& casename ) {
|
||||
namespace fs = boost::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 simcase = fs::path( casename );
|
||||
|
||||
if( exists( simcase ) ) {
|
||||
return simcase;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int64_t convertMessageType(const Message::type& mtype)
|
||||
{
|
||||
switch (mtype) {
|
||||
case Message::type::Debug:
|
||||
return Log::MessageType::Debug;
|
||||
case Message::type::Info:
|
||||
return Log::MessageType::Info;
|
||||
case Message::type::Warning:
|
||||
return Log::MessageType::Warning;
|
||||
case Message::type::Error:
|
||||
return Log::MessageType::Error;
|
||||
case Message::type::Problem:
|
||||
return Log::MessageType::Problem;
|
||||
case Message::type::Bug:
|
||||
return Log::MessageType::Bug;
|
||||
}
|
||||
throw std::logic_error("Invalid messages type!\n");
|
||||
}
|
||||
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_FLOWMAIN_HEADER_INCLUDED
|
||||
|
Loading…
Reference in New Issue
Block a user