Make EclipseGrid no longer use shared_ptr

This commit is contained in:
Jørgen Kvalsvik
2016-10-10 14:09:24 +02:00
parent fcc93085ee
commit 1906bf4d16
23 changed files with 148 additions and 166 deletions

View File

@@ -626,24 +626,24 @@ bool parseState( ParserState& parserState, const Parser& parser ) {
return parse(*deck, context);
}
std::shared_ptr<const EclipseGrid> Parser::parseGrid(const std::string &filename, const ParseContext& context) {
EclipseGrid Parser::parseGrid(const std::string &filename, const ParseContext& context) {
if (context.hasKey(ParseContext::PARSE_MISSING_SECTIONS))
return std::make_shared<const EclipseGrid>(filename);
return EclipseGrid{ filename };
return parse(filename, context).getInputGrid();
}
std::shared_ptr<const EclipseGrid> Parser::parseGrid(const Deck& deck, const ParseContext& context)
EclipseGrid Parser::parseGrid(const Deck& deck, const ParseContext& context)
{
if (context.hasKey(ParseContext::PARSE_MISSING_SECTIONS))
return std::make_shared<const EclipseGrid>(deck);
return EclipseGrid{ deck };
return parse(deck, context).getInputGrid();
}
std::shared_ptr<const EclipseGrid> Parser::parseGridData(const std::string &data, const ParseContext& context) {
EclipseGrid Parser::parseGridData(const std::string &data, const ParseContext& context) {
Parser parser;
auto deck = parser.parseString(data, context);
if (context.hasKey(ParseContext::PARSE_MISSING_SECTIONS)) {
return std::make_shared<const EclipseGrid>(deck);
return EclipseGrid{ *deck };
}
return parse(*deck, context).getInputGrid();
}

View File

@@ -101,19 +101,19 @@ namespace Opm {
/// Parses the deck specified in filename. If context contains ParseContext::PARSE_PARTIAL_DECK,
/// we construct only a lean grid, otherwise, we construct a full EclipseState and return the
/// fully constructed InputGrid
static std::shared_ptr<const EclipseGrid> parseGrid(const std::string &filename,
static EclipseGrid parseGrid(const std::string &filename,
const ParseContext& context = ParseContext());
/// Parses the provided deck. If context contains ParseContext::PARSE_PARTIAL_DECK,
/// we construct only a lean grid, otherwise, we construct a full EclipseState and return the
/// fully constructed InputGrid
static std::shared_ptr<const EclipseGrid> parseGrid(const Deck& deck,
static EclipseGrid parseGrid(const Deck& deck,
const ParseContext& context = ParseContext());
/// Parses the provided deck string. If context contains ParseContext::PARSE_PARTIAL_DECK,
/// we construct only a lean grid, otherwise, we construct a full EclipseState and return the
/// fully constructed InputGrid
static std::shared_ptr<const EclipseGrid> parseGridData(const std::string &data,
static EclipseGrid parseGridData(const std::string &data,
const ParseContext& context = ParseContext());
private:

View File

@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE( CheckUnsupportedInSCHEDULE ) {
auto deckSupported = parser.parseString( deckStringSupported , parseContext );
auto deckUnSupported = parser.parseString( deckStringUnSupported , parseContext );
EclipseGrid grid( deckSupported );
EclipseGrid grid( *deckSupported );
parseContext.update( ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER , InputError::IGNORE );
BOOST_CHECK_NO_THROW( Schedule( parseContext , grid , deckSupported ));
@@ -262,7 +262,7 @@ BOOST_AUTO_TEST_CASE(TestCOMPORD) {
Parser parser(true);
auto deck = parser.parseString( deckString , parseContext );
EclipseGrid grid( deck );
EclipseGrid grid( *deck );
parseContext.update( ParseContext::UNSUPPORTED_COMPORD_TYPE , InputError::IGNORE);
BOOST_CHECK_NO_THROW( Schedule( parseContext , grid , deck ));