Merge pull request #784 from kjellkongsvik/clean_EclipseWriter
Clean eclipse writer
This commit is contained in:
@@ -120,9 +120,17 @@ namespace Opm {
|
||||
DeckView( limits.first, limits.second )
|
||||
{}
|
||||
|
||||
Deck::Deck() : Deck( std::vector< DeckKeyword >() ) {}
|
||||
Deck::Deck( std::vector< DeckKeyword >&& x ) : DeckView( x.begin(), x.end() ),
|
||||
keywordList( std::move( x ) ) {}
|
||||
Deck::Deck() :
|
||||
Deck( std::vector< DeckKeyword >() )
|
||||
{
|
||||
m_dataFile = "";
|
||||
}
|
||||
|
||||
Deck::Deck( std::vector< DeckKeyword >&& x ) :
|
||||
DeckView( x.begin(), x.end() ),
|
||||
keywordList( std::move( x ) ),
|
||||
m_dataFile("")
|
||||
{}
|
||||
|
||||
void Deck::addKeyword( DeckKeyword&& keyword ) {
|
||||
this->keywordList.push_back( std::move( keyword ) );
|
||||
@@ -187,4 +195,12 @@ namespace Opm {
|
||||
this->activeUnits = std::unique_ptr< UnitSystem >( UnitSystem::newMETRIC() );
|
||||
}
|
||||
|
||||
const std::string Deck::getDataFile() const {
|
||||
return m_dataFile;
|
||||
}
|
||||
|
||||
void Deck::setDataFile(const std::string& dataFile) {
|
||||
m_dataFile = dataFile;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
#include <opm/parser/eclipse/Parser/MessageContainer.hpp>
|
||||
@@ -128,17 +130,22 @@ namespace Opm {
|
||||
const UnitSystem& getDefaultUnitSystem() const;
|
||||
const UnitSystem& getActiveUnitSystem() const;
|
||||
|
||||
const std::string getDataFile() const;
|
||||
void setDataFile(const std::string& dataFile);
|
||||
|
||||
private:
|
||||
Deck( std::vector< DeckKeyword >&& );
|
||||
|
||||
void initUnitSystem() const;
|
||||
|
||||
|
||||
std::vector< DeckKeyword > keywordList;
|
||||
mutable MessageContainer m_messageContainer;
|
||||
|
||||
mutable std::unique_ptr< UnitSystem > activeUnits;
|
||||
mutable std::unique_ptr< UnitSystem > defaultUnits;
|
||||
|
||||
std::string m_dataFile;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Deck> DeckPtr;
|
||||
|
||||
@@ -153,3 +153,11 @@ BOOST_AUTO_TEST_CASE(keywordList_getbyindex_correctkeywordreturned) {
|
||||
BOOST_CHECK_EQUAL("TRULSX", deck.getKeyword(2).name());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(set_and_get_data_file) {
|
||||
Deck deck;
|
||||
BOOST_CHECK_EQUAL("", deck.getDataFile());
|
||||
std::string file("/path/to/file.DATA");
|
||||
deck.setDataFile( file );
|
||||
BOOST_CHECK_EQUAL(file, deck.getDataFile());
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,9 @@ namespace Opm {
|
||||
}
|
||||
|
||||
void EclipseState::initIOConfig(DeckConstPtr deck) {
|
||||
m_ioConfig = std::make_shared<IOConfig>();
|
||||
std::string dataFile = deck->getDataFile();
|
||||
|
||||
m_ioConfig = std::make_shared<IOConfig>(dataFile);
|
||||
if (Section::hasGRID(*deck)) {
|
||||
std::shared_ptr<const GRIDSection> gridSection = std::make_shared<const GRIDSection>(*deck);
|
||||
m_ioConfig->handleGridSection(gridSection);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
@@ -46,8 +47,17 @@ namespace Opm {
|
||||
m_UNIFOUT(false),
|
||||
m_FMTIN(false),
|
||||
m_FMTOUT(false),
|
||||
m_eclipse_input_path(input_path),
|
||||
m_ignore_RPTSCHED_RESTART(false){
|
||||
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( input_path );
|
||||
m_base_name = path.stem().string();
|
||||
m_output_dir = path.parent_path().string();
|
||||
}
|
||||
}
|
||||
|
||||
bool IOConfig::getWriteEGRIDFile() const {
|
||||
@@ -346,12 +356,6 @@ namespace Opm {
|
||||
return m_FMTOUT;
|
||||
}
|
||||
|
||||
|
||||
const std::string& IOConfig::getEclipseInputPath() const {
|
||||
return m_eclipse_input_path;
|
||||
}
|
||||
|
||||
|
||||
void IOConfig::setWriteInitialRestartFile(bool writeInitialRestartFile) {
|
||||
m_write_initial_RST_file = writeInitialRestartFile;
|
||||
}
|
||||
@@ -445,4 +449,24 @@ namespace Opm {
|
||||
return m_first_rft_step;
|
||||
}
|
||||
|
||||
bool IOConfig::getOutputEnabled(){
|
||||
return m_output_enabled;
|
||||
}
|
||||
|
||||
void IOConfig::setOutputEnabled(bool enabled){
|
||||
m_output_enabled = enabled;
|
||||
}
|
||||
|
||||
std::string IOConfig::getOutputDir() {
|
||||
return m_output_dir;
|
||||
}
|
||||
|
||||
void IOConfig::setOutputDir(const std::string& outputDir) {
|
||||
m_output_dir = outputDir;
|
||||
}
|
||||
|
||||
std::string IOConfig::getBaseName() {
|
||||
return m_base_name;
|
||||
}
|
||||
|
||||
} //namespace Opm
|
||||
|
||||
@@ -158,6 +158,13 @@ namespace Opm {
|
||||
|
||||
std::string getRestartFileName(const std::string& restart_base, int report_step, bool output) const;
|
||||
|
||||
bool getOutputEnabled();
|
||||
void setOutputEnabled(bool enabled);
|
||||
|
||||
std::string getOutputDir();
|
||||
void setOutputDir(const std::string& outputDir);
|
||||
|
||||
std::string getBaseName();
|
||||
|
||||
private:
|
||||
|
||||
@@ -178,11 +185,13 @@ namespace Opm {
|
||||
bool m_UNIFOUT;
|
||||
bool m_FMTIN;
|
||||
bool m_FMTOUT;
|
||||
std::string m_eclipse_input_path;
|
||||
bool m_ignore_RPTSCHED_RESTART;
|
||||
int m_first_restart_step;
|
||||
int m_first_rft_step;
|
||||
|
||||
std::string m_deck_filename;
|
||||
bool m_output_enabled;
|
||||
std::string m_output_dir;
|
||||
std::string m_base_name;
|
||||
|
||||
struct restartConfig {
|
||||
/*
|
||||
|
||||
@@ -460,6 +460,24 @@ BOOST_AUTO_TEST_CASE(IOConfigTest) {
|
||||
ioConfigPtr4->handleRunspecSection(runspecSection4);
|
||||
|
||||
BOOST_CHECK_EQUAL(false, ioConfigPtr4->getWriteEGRIDFile());
|
||||
|
||||
IOConfigPtr ioConfigPtr5;
|
||||
BOOST_CHECK_NO_THROW(ioConfigPtr5 = std::make_shared<IOConfig>());
|
||||
BOOST_CHECK_EQUAL("", ioConfigPtr5->getBaseName());
|
||||
|
||||
std::string testString = "testString.DATA";
|
||||
IOConfigPtr ioConfigPtr6 = std::make_shared<IOConfig>(testString);
|
||||
std::string output_dir6 = ".";
|
||||
ioConfigPtr6->setOutputDir(output_dir6);
|
||||
BOOST_CHECK_EQUAL("testString", ioConfigPtr6->getBaseName());
|
||||
|
||||
std::string absTestPath = "/path/to/testString.DATA";
|
||||
IOConfigPtr ioConfigPtr7 = std::make_shared<IOConfig>(absTestPath);
|
||||
std::string output_dir7 = "/path/to";
|
||||
ioConfigPtr7->setOutputDir(output_dir7);
|
||||
BOOST_CHECK_EQUAL(output_dir7, ioConfigPtr7->getOutputDir());
|
||||
BOOST_CHECK_EQUAL("testString", ioConfigPtr7->getBaseName());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE( CheckUnsoppertedInSCHEDULE ) {
|
||||
|
||||
auto deck = parser.parseString( deckString , parseContext );
|
||||
std::shared_ptr<EclipseGrid> grid = std::make_shared<EclipseGrid>( deck );
|
||||
std::shared_ptr<IOConfig> ioconfig = std::make_shared<IOConfig>( "path" );
|
||||
std::shared_ptr<IOConfig> ioconfig = std::make_shared<IOConfig>();
|
||||
|
||||
parseContext.update( ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER , InputError::IGNORE );
|
||||
{
|
||||
|
||||
@@ -117,6 +117,8 @@ namespace Opm {
|
||||
|
||||
void openRootFile( const boost::filesystem::path& inputFile) {
|
||||
openFile( inputFile );
|
||||
deck->setDataFile(dataFile.string());
|
||||
|
||||
const boost::filesystem::path& inputFileCanonical = boost::filesystem::canonical(inputFile);
|
||||
rootPath = inputFileCanonical.parent_path();
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE( CheckUnsupportedInSCHEDULE ) {
|
||||
auto deckSupported = parser.parseString( deckStringSupported , parseContext );
|
||||
auto deckUnSupported = parser.parseString( deckStringUnSupported , parseContext );
|
||||
std::shared_ptr<EclipseGrid> grid = std::make_shared<EclipseGrid>( deckSupported );
|
||||
std::shared_ptr<IOConfig> ioconfig = std::make_shared<IOConfig>( "path" );
|
||||
std::shared_ptr<IOConfig> ioconfig = std::make_shared<IOConfig>();
|
||||
|
||||
parseContext.update( ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER , InputError::IGNORE );
|
||||
BOOST_CHECK_NO_THROW( Schedule( parseContext , grid , deckSupported , ioconfig ));
|
||||
@@ -203,7 +203,7 @@ BOOST_AUTO_TEST_CASE(TestCOMPORD) {
|
||||
auto deck = parser.parseString( deckString , parseContext );
|
||||
|
||||
std::shared_ptr<EclipseGrid> grid = std::make_shared<EclipseGrid>( deck );
|
||||
std::shared_ptr<IOConfig> ioconfig = std::make_shared<IOConfig>( "path" );
|
||||
std::shared_ptr<IOConfig> ioconfig = std::make_shared<IOConfig>();
|
||||
|
||||
parseContext.update( ParseContext::UNSUPPORTED_COMPORD_TYPE , InputError::IGNORE);
|
||||
BOOST_CHECK_NO_THROW( Schedule( parseContext , grid , deck , ioconfig ));
|
||||
|
||||
Reference in New Issue
Block a user