mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-22 17:26:27 -06:00
Merge pull request #616 from jokva/accept-filename-without-DATA
Flow accepts base name for input Deck
This commit is contained in:
commit
543c1655b9
@ -94,6 +94,7 @@
|
||||
#include <vector>
|
||||
#include <numeric>
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
|
||||
@ -101,6 +102,33 @@
|
||||
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 );
|
||||
}
|
||||
|
||||
/// This class encapsulates the setup and running of
|
||||
/// a simulator based on an input deck.
|
||||
template <class Implementation, class Grid, class Simulator>
|
||||
@ -259,10 +287,6 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Read parameters, see if a deck was specified on the command line, and if
|
||||
// it was, insert it into parameters.
|
||||
// Writes to:
|
||||
@ -282,7 +306,8 @@ namespace Opm
|
||||
std::cerr << "You can only specify a single input deck on the command line.\n";
|
||||
return false;
|
||||
} else {
|
||||
param_.insertParameter("deck_filename", param_.unhandledArguments()[0]);
|
||||
const auto casename = simulationCaseName( param_.unhandledArguments()[ 0 ] );
|
||||
param_.insertParameter("deck_filename", casename.string() );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user