remove ParseContext.

This commit is contained in:
Liu Ming
2016-05-11 10:07:32 +08:00
committed by Joakim Hove
parent 14c33394f4
commit ca085fa6a2
7 changed files with 25 additions and 38 deletions

View File

@@ -73,7 +73,7 @@ namespace Opm {
m_inputGrid( std::make_shared<EclipseGrid>(deck, nullptr) ),
m_eclipseProperties( deck, m_tables, *m_inputGrid ),
m_schedule( std::make_shared<Schedule>( m_parseContext, m_inputGrid, deck, m_ioConfig ) ),
m_simulationConfig( std::make_shared<SimulationConfig>( m_parseContext, deck, m_eclipseProperties ) ),
m_simulationConfig( std::make_shared<SimulationConfig>( deck, m_eclipseProperties ) ),
m_summaryConfig( deck, *m_schedule, m_eclipseProperties, m_inputGrid->getNXYZ() ),
m_nnc( deck, m_inputGrid ),
m_deckUnitSystem( deck.getActiveUnitSystem() )

View File

@@ -46,8 +46,7 @@
namespace Opm {
SimulationConfig::SimulationConfig(const ParseContext& parseContext,
const Deck& deck,
SimulationConfig::SimulationConfig(const Deck& deck,
const Eclipse3DProperties& eclipseProperties) :
m_useCPR(false),
m_DISGAS(false),
@@ -70,14 +69,13 @@ namespace Opm {
}
}
initThresholdPressure(parseContext , deck, eclipseProperties);
initThresholdPressure(deck, eclipseProperties);
}
void SimulationConfig::initThresholdPressure(const ParseContext& parseContext,
const Deck& deck,
void SimulationConfig::initThresholdPressure(const Deck& deck,
const Eclipse3DProperties& eclipseProperties) {
m_ThresholdPressure = std::make_shared<const ThresholdPressure>(parseContext , deck, eclipseProperties);
m_ThresholdPressure = std::make_shared<const ThresholdPressure>(deck, eclipseProperties);
}

View File

@@ -26,14 +26,12 @@
namespace Opm {
class ThresholdPressure;
class ParseContext;
class SimulationConfig {
public:
SimulationConfig(const ParseContext& parseContext,
const Deck& deck,
SimulationConfig(const Deck& deck,
const Eclipse3DProperties& gridProperties);
std::shared_ptr<const ThresholdPressure> getThresholdPressure() const;
@@ -44,8 +42,7 @@ namespace Opm {
private:
void initThresholdPressure(const ParseContext& parseContext,
const Deck& deck,
void initThresholdPressure(const Deck& deck,
const Eclipse3DProperties& gridProperties);
std::shared_ptr< const ThresholdPressure > m_ThresholdPressure;

View File

@@ -21,7 +21,6 @@
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/E.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/R.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/T.hpp>
@@ -29,16 +28,14 @@
namespace Opm {
ThresholdPressure::ThresholdPressure(const ParseContext& parseContext,
const Deck& deck,
const Eclipse3DProperties& eclipseProperties) :
m_parseContext( parseContext )
ThresholdPressure::ThresholdPressure(const Deck& deck,
const Eclipse3DProperties& eclipseProperties)
{
if (Section::hasRUNSPEC( deck ) && Section::hasSOLUTION( deck )) {
std::shared_ptr<const RUNSPECSection> runspecSection = std::make_shared<const RUNSPECSection>( deck );
std::shared_ptr<const SOLUTIONSection> solutionSection = std::make_shared<const SOLUTIONSection>( deck );
initThresholdPressure( parseContext, runspecSection, solutionSection, eclipseProperties );
initThresholdPressure( runspecSection, solutionSection, eclipseProperties );
}
}
@@ -66,8 +63,7 @@ namespace Opm {
}
void ThresholdPressure::initThresholdPressure(const ParseContext& /* parseContext */,
std::shared_ptr<const RUNSPECSection> runspecSection,
void ThresholdPressure::initThresholdPressure(std::shared_ptr<const RUNSPECSection> runspecSection,
std::shared_ptr<const SOLUTIONSection> solutionSection,
const Eclipse3DProperties& eclipseProperties) {
@@ -164,7 +160,7 @@ namespace Opm {
return value;
else {
std::string msg = "The THPRES value for regions " + std::to_string(r1) + " and " + std::to_string(r2) + " has not been initialized. Using 0.0";
m_parseContext.handleError(ParseContext::INTERNAL_ERROR_UNINITIALIZED_THPRES, msg);
throw std::invalid_argument(msg);
return 0;
}
}

View File

@@ -29,7 +29,6 @@ namespace Opm {
class Deck;
class ParseContext;
class RUNSPECSection;
class SOLUTIONSection;
@@ -37,8 +36,7 @@ namespace Opm {
public:
ThresholdPressure(const ParseContext& parseContext,
const Deck& deck,
ThresholdPressure(const Deck& deck,
const Eclipse3DProperties& eclipseProperties);
@@ -69,8 +67,7 @@ namespace Opm {
double getThresholdPressure(int r1 , int r2) const;
size_t size() const;
private:
void initThresholdPressure(const ParseContext& parseContext,
std::shared_ptr<const RUNSPECSection> runspecSection,
void initThresholdPressure(std::shared_ptr<const RUNSPECSection> runspecSection,
std::shared_ptr<const SOLUTIONSection> solutionSection,
const Eclipse3DProperties& eclipseProperties);
@@ -81,7 +78,6 @@ namespace Opm {
std::vector<std::pair<bool,double>> m_thresholdPressureTable;
std::map<std::pair<int,int> , std::pair<bool , double> > m_pressureTable;
const ParseContext& m_parseContext;
};

View File

@@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(SimulationConfigGetThresholdPressureTableTest) {
Eclipse3DProperties ep(*deck, tm, eg);
SimulationConfigConstPtr simulationConfigPtr;
BOOST_CHECK_NO_THROW(simulationConfigPtr = std::make_shared
<const SimulationConfig>(parseContext , *deck, ep));
<const SimulationConfig>(*deck, ep));
}
@@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE(SimulationConfigNOTHPRES) {
TableManager tm(*deck);
EclipseGrid eg(10, 3, 4);
Eclipse3DProperties ep(*deck, tm, eg);
SimulationConfig simulationConfig(parseContext , *deck, ep);
SimulationConfig simulationConfig(*deck, ep);
BOOST_CHECK( !simulationConfig.hasThresholdPressure() );
}
@@ -139,18 +139,18 @@ BOOST_AUTO_TEST_CASE(SimulationConfigCPRNotUsed) {
TableManager tm(*deck);
EclipseGrid eg(10, 3, 4);
Eclipse3DProperties ep(*deck, tm, eg);
SimulationConfig simulationConfig(parseContext , *deck, ep);
SimulationConfig simulationConfig(*deck, ep);
BOOST_CHECK( ! simulationConfig.useCPR());
}
BOOST_AUTO_TEST_CASE(SimulationConfigCPRUsed) {
ParseContext parseContext;
ParseContext parseContext;
DeckPtr deck = createDeck(parseContext, inputStr_cpr);
TableManager tm(*deck);
EclipseGrid eg(10, 3, 4);
Eclipse3DProperties ep(*deck, tm, eg);
SUMMARYSection summary(*deck);
SimulationConfig simulationConfig(parseContext , *deck, ep);
SimulationConfig simulationConfig(*deck, ep);
BOOST_CHECK( simulationConfig.useCPR() );
BOOST_CHECK( ! summary.hasKeyword("CPR") );
}
@@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE(SimulationConfigCPRInSUMMARYSection) {
EclipseGrid eg(10, 3, 4);
Eclipse3DProperties ep(*deck, tm, eg);
SUMMARYSection summary(*deck);
SimulationConfig simulationConfig(parseContext , *deck, ep);
SimulationConfig simulationConfig(*deck, ep);
BOOST_CHECK( ! simulationConfig.useCPR());
BOOST_CHECK( summary.hasKeyword("CPR"));
}
@@ -176,7 +176,7 @@ BOOST_AUTO_TEST_CASE(SimulationConfigCPRBoth) {
EclipseGrid eg(10, 3, 4);
Eclipse3DProperties ep(*deck, tm, eg);
SUMMARYSection summary(*deck);
SimulationConfig simulationConfig(parseContext , *deck, ep);
SimulationConfig simulationConfig(*deck, ep);
BOOST_CHECK( simulationConfig.useCPR());
BOOST_CHECK( summary.hasKeyword("CPR"));
@@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(SimulationConfig_VAPOIL_DISGAS) {
TableManager tm(*deck);
EclipseGrid eg(10, 3, 4);
Eclipse3DProperties ep(*deck, tm, eg);
SimulationConfig simulationConfig(parseContext , *deck, ep);
SimulationConfig simulationConfig(*deck, ep);
BOOST_CHECK_EQUAL( false , simulationConfig.hasDISGAS());
BOOST_CHECK_EQUAL( false , simulationConfig.hasVAPOIL());
@@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(SimulationConfig_VAPOIL_DISGAS) {
TableManager tm_vd(*deck_vd);
EclipseGrid eg_vd(10, 3, 4);
Eclipse3DProperties ep_vd(*deck_vd, tm, eg);
SimulationConfig simulationConfig_vd(parseContext , *deck_vd, ep_vd);
SimulationConfig simulationConfig_vd(*deck_vd, ep_vd);
BOOST_CHECK_EQUAL( true , simulationConfig_vd.hasDISGAS());
BOOST_CHECK_EQUAL( true , simulationConfig_vd.hasVAPOIL());
}

View File

@@ -194,7 +194,7 @@ struct Setup
tablemanager(*deck),
grid(10, 3, 4),
props(*deck, tablemanager, grid),
threshPres(parseContext, *deck, props)
threshPres(*deck, props)
{
}
explicit Setup(const std::string& input, ParseContext& parseContextArg) :
@@ -203,7 +203,7 @@ struct Setup
tablemanager(*deck),
grid(10, 3, 4),
props(*deck, tablemanager, grid),
threshPres(parseContextArg, *deck, props)
threshPres(*deck, props)
{
}