Defaults for IOConfig; add string constructor

Brings back the Deck-less constructor for IOConfig, but leveraged by
default values for most members.
This commit is contained in:
Jørgen Kvalsvik
2016-05-24 16:05:39 +02:00
parent f79f40802a
commit 469f33c575
2 changed files with 36 additions and 23 deletions

View File

@@ -39,10 +39,33 @@
namespace Opm {
namespace {
const char* default_dir = ".";
inline std::string basename( const std::string& path ) {
return boost::filesystem::path( path ).stem().string();
}
inline std::string outputdir( const std::string& path ) {
auto dir = boost::filesystem::path( path ).parent_path().string();
if( dir.empty() ) return default_dir;
return dir;
}
}
IOConfig::IOConfig( const Deck& deck ) :
IOConfig( GRIDSection( deck ), RUNSPECSection( deck ), deck.getDataFile() )
{}
IOConfig::IOConfig( const std::string& input_path ) :
m_deck_filename( input_path ),
m_output_dir( outputdir( input_path ) ),
m_base_name( basename( input_path ) )
{}
static inline bool write_egrid_file( const GRIDSection& grid ) {
if( grid.hasKeyword( "NOGGF" ) ) return false;
if( !grid.hasKeyword( "GRIDFILE" ) ) return true;
@@ -73,25 +96,14 @@ namespace Opm {
const std::string& input_path ) :
m_write_INIT_file( grid.hasKeyword( "INIT" ) ),
m_write_EGRID_file( write_egrid_file( grid ) ),
m_write_initial_RST_file(false),
m_UNIFIN( runspec.hasKeyword( "UNIFIN" ) ),
m_UNIFOUT( runspec.hasKeyword( "UNIFOUT" ) ),
m_FMTIN( runspec.hasKeyword( "FMTIN" ) ),
m_FMTOUT( runspec.hasKeyword( "FMTOUT" ) ),
m_ignore_RPTSCHED_RESTART(false),
m_deck_filename( input_path ),
m_output_enabled(true)
{
m_output_dir = ".";
m_base_name = "";
if (!input_path.empty()) {
boost::filesystem::path path( this->m_deck_filename );
m_base_name = path.stem().string();
m_output_dir = path.parent_path().string();
if (m_output_dir == "")
m_output_dir = ".";
}
}
m_output_dir( outputdir( input_path ) ),
m_base_name( basename( input_path ) )
{}
bool IOConfig::getWriteEGRIDFile() const {
return m_write_EGRID_file;

View File

@@ -121,6 +121,7 @@ namespace Opm {
IOConfig() = default;
explicit IOConfig( const Deck& );
explicit IOConfig( const std::string& input_path );
int getFirstRestartStep() const;
int getFirstRFTStep() const;
@@ -182,18 +183,18 @@ namespace Opm {
std::shared_ptr< const TimeMap > m_timemap;
bool m_write_INIT_file;
bool m_write_EGRID_file;
bool m_write_initial_RST_file;
bool m_UNIFIN;
bool m_UNIFOUT;
bool m_FMTIN;
bool m_FMTOUT;
bool m_ignore_RPTSCHED_RESTART;
bool m_write_INIT_file = false;
bool m_write_EGRID_file = true;
bool m_write_initial_RST_file = false;
bool m_UNIFIN = false;
bool m_UNIFOUT = false;
bool m_FMTIN = false;
bool m_FMTOUT = false;
bool m_ignore_RPTSCHED_RESTART = false;
int m_first_restart_step;
int m_first_rft_step;
std::string m_deck_filename;
bool m_output_enabled;
bool m_output_enabled = true;
std::string m_output_dir;
std::string m_base_name;