Merge pull request #1532 from joakim-hove/uda-value-dim-constructor
Uda value dim constructor
This commit is contained in:
@@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(GetSIWithoutDimensionThrows) {
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(GetSISingleDimensionCorrect) {
|
||||
Dimension dim{ "Length" , 100 };
|
||||
Dimension dim{ 100 };
|
||||
DeckItem item( "HEI", double(), { dim }, { dim } );
|
||||
|
||||
item.push_back(1.0 , 100 );
|
||||
@@ -305,8 +305,8 @@ BOOST_AUTO_TEST_CASE(GetSISingleDimensionCorrect) {
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(GetSISingleDefault) {
|
||||
Dimension dim{ "Length" , 1 };
|
||||
Dimension defaultDim{ "Length" , 100 };
|
||||
Dimension dim{ 1 };
|
||||
Dimension defaultDim{ 100 };
|
||||
DeckItem item( "HEI", double() , {dim}, {defaultDim});
|
||||
|
||||
item.push_backDefault( 1.0 );
|
||||
@@ -315,11 +315,11 @@ BOOST_AUTO_TEST_CASE(GetSISingleDefault) {
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(GetSIMultipleDim) {
|
||||
Dimension dim1{ "Length" , 2 };
|
||||
Dimension dim2{ "Length" , 4 };
|
||||
Dimension dim3{ "Length" , 8 };
|
||||
Dimension dim4{ "Length" ,16 };
|
||||
Dimension defaultDim{ "Length" , 100 };
|
||||
Dimension dim1{ 2 };
|
||||
Dimension dim2{ 4 };
|
||||
Dimension dim3{ 8 };
|
||||
Dimension dim4{ 16 };
|
||||
Dimension defaultDim{ 100 };
|
||||
DeckItem item( "HEI", double(), {dim1, dim2, dim3, dim4}, {defaultDim, defaultDim, defaultDim, defaultDim} );
|
||||
|
||||
item.push_back( 1.0, 16 );
|
||||
|
||||
@@ -1217,10 +1217,10 @@ BOOST_AUTO_TEST_CASE(UDA_VALUE) {
|
||||
BOOST_CHECK(!value0.is<std::string>());
|
||||
BOOST_CHECK_EQUAL( value0.get<double>(), 0);
|
||||
BOOST_CHECK_THROW( value0.get<std::string>(), std::invalid_argument);
|
||||
value0.reset( 10 );
|
||||
value0 = 10;
|
||||
BOOST_CHECK_EQUAL( value0.get<double>(), 10);
|
||||
BOOST_CHECK_THROW( value0.get<std::string>(), std::invalid_argument);
|
||||
value0.reset( "STRING" );
|
||||
value0 = "STRING";
|
||||
BOOST_CHECK_EQUAL( value0.get<std::string>(), std::string("STRING"));
|
||||
BOOST_CHECK_THROW( value0.get<double>(), std::invalid_argument);
|
||||
|
||||
@@ -1248,8 +1248,8 @@ BOOST_AUTO_TEST_CASE(UDA_VALUE) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UDA_VALUE_DIM) {
|
||||
UDAValue value0(1);
|
||||
Dimension dim("DUMMY", 10);
|
||||
UDAValue value1(value0, dim);
|
||||
Dimension dim(10);
|
||||
UDAValue value1(1, dim);
|
||||
|
||||
BOOST_CHECK_EQUAL( value0.get<double>(), 1);
|
||||
BOOST_CHECK_EQUAL( value0.getSI(), 1);
|
||||
|
||||
@@ -37,27 +37,10 @@ BOOST_AUTO_TEST_CASE(DefDim) {
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateDimension) {
|
||||
Dimension length("Length" , 1);
|
||||
BOOST_CHECK_EQUAL("Length" , length.getName());
|
||||
Dimension length(1);
|
||||
BOOST_CHECK_EQUAL(1 , length.getSIScaling());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(makeComposite) {
|
||||
auto composite = Dimension::newComposite("Length*Length*Length/Time" , 100);
|
||||
BOOST_CHECK_EQUAL("Length*Length*Length/Time" , composite.getName());
|
||||
BOOST_CHECK_EQUAL(100 , composite.getSIScaling());
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateDimensionInvalidNameThrows) {
|
||||
BOOST_CHECK_THROW(Dimension(" " , 1) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW(Dimension(".LX" , 1) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW(Dimension("*" , 1) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW(Dimension("/" , 1) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW(Dimension("2" , 1) , std::invalid_argument);
|
||||
BOOST_CHECK_NO_THROW(Dimension("1" , 1));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateUnitSystem) {
|
||||
UnitSystem system(UnitSystem::UnitType::UNIT_TYPE_METRIC);
|
||||
@@ -112,7 +95,6 @@ BOOST_AUTO_TEST_CASE(UnitSystemParseInvalidThrows) {
|
||||
system.addDimension("Time" , 9.0 );
|
||||
|
||||
auto volumePerTime = system.parse( "Length*Length*Length/Time" );
|
||||
BOOST_CHECK_EQUAL("Length*Length*Length/Time" , volumePerTime.getName() );
|
||||
BOOST_CHECK_EQUAL(3.0 , volumePerTime.getSIScaling());
|
||||
}
|
||||
|
||||
@@ -123,6 +105,7 @@ static void checkSystemHasRequiredDimensions( const UnitSystem& system) {
|
||||
BOOST_CHECK( system.hasDimension("Length"));
|
||||
BOOST_CHECK( system.hasDimension("Mass"));
|
||||
BOOST_CHECK( system.hasDimension("Time"));
|
||||
|
||||
BOOST_CHECK( system.hasDimension("Permeability"));
|
||||
BOOST_CHECK( system.hasDimension("Pressure"));
|
||||
BOOST_CHECK( system.hasDimension("Temperature"));
|
||||
@@ -174,14 +157,12 @@ BOOST_AUTO_TEST_CASE(CreateInputSystem) {
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DimensionEqual) {
|
||||
Dimension d1("Length" , 1);
|
||||
Dimension d2("Length" , 1);
|
||||
Dimension d3("Time" , 1);
|
||||
Dimension d4("Length" , 2);
|
||||
Dimension d1(1);
|
||||
Dimension d2(1);
|
||||
Dimension d4(2);
|
||||
|
||||
BOOST_CHECK_EQUAL( true , d1.equal(d1) );
|
||||
BOOST_CHECK_EQUAL( true , d1.equal(d2) );
|
||||
BOOST_CHECK_EQUAL( false , d1.equal(d3) );
|
||||
BOOST_CHECK_EQUAL( false , d1.equal(d4) );
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
|
||||
|
||||
/* Set a surface injection rate => Well becomes an Injector */
|
||||
auto injectionProps1 = std::make_shared<Opm::Well::WellInjectionProperties>(well.getInjectionProperties());
|
||||
injectionProps1->surfaceInjectionRate.reset(100);
|
||||
injectionProps1->surfaceInjectionRate = 100;
|
||||
well.updateInjection(injectionProps1);
|
||||
BOOST_CHECK_EQUAL( true , well.isInjector());
|
||||
BOOST_CHECK_EQUAL( false , well.isProducer());
|
||||
@@ -224,7 +224,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
|
||||
|
||||
/* Set a reservoir injection rate => Well becomes an Injector */
|
||||
auto injectionProps2 = std::make_shared<Opm::Well::WellInjectionProperties>(well.getInjectionProperties());
|
||||
injectionProps2->reservoirInjectionRate.reset(200);
|
||||
injectionProps2->reservoirInjectionRate = 200;
|
||||
well.updateInjection(injectionProps2);
|
||||
BOOST_CHECK_EQUAL( false , well.isProducer());
|
||||
BOOST_CHECK_EQUAL( 200 , well.getInjectionProperties().reservoirInjectionRate.get<double>());
|
||||
@@ -238,9 +238,9 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
|
||||
well.updateInjection(injectionProps3);
|
||||
|
||||
auto properties = std::make_shared<Opm::Well::WellProductionProperties>( well.getProductionProperties() );
|
||||
properties->OilRate.reset(100);
|
||||
properties->GasRate.reset(200);
|
||||
properties->WaterRate.reset(300);
|
||||
properties->OilRate = 100;
|
||||
properties->GasRate = 200;
|
||||
properties->WaterRate = 300;
|
||||
well.updateProduction(properties);
|
||||
|
||||
BOOST_CHECK_EQUAL( false , well.isInjector());
|
||||
@@ -277,14 +277,14 @@ BOOST_AUTO_TEST_CASE(XHPLimitDefault) {
|
||||
|
||||
|
||||
auto productionProps = std::make_shared<Opm::Well::WellProductionProperties>(well.getProductionProperties());
|
||||
productionProps->BHPTarget.reset(100);
|
||||
productionProps->BHPTarget = 100;
|
||||
productionProps->addProductionControl(Opm::Well::ProducerCMode::BHP);
|
||||
well.updateProduction(productionProps);
|
||||
BOOST_CHECK_EQUAL( 100 , well.getProductionProperties().BHPTarget.get<double>());
|
||||
BOOST_CHECK_EQUAL( true, well.getProductionProperties().hasProductionControl( Opm::Well::ProducerCMode::BHP ));
|
||||
|
||||
auto injProps = std::make_shared<Opm::Well::WellInjectionProperties>(well.getInjectionProperties());
|
||||
injProps->THPTarget.reset(200);
|
||||
injProps->THPTarget = 200;
|
||||
well.updateInjection(injProps);
|
||||
BOOST_CHECK_EQUAL( 200 , well.getInjectionProperties().THPTarget.get<double>());
|
||||
BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well::InjectorCMode::THP ));
|
||||
@@ -318,26 +318,26 @@ BOOST_AUTO_TEST_CASE(WellHaveProductionControlLimit) {
|
||||
BOOST_CHECK( !well.getProductionProperties().hasProductionControl( Opm::Well::ProducerCMode::RESV ));
|
||||
|
||||
auto properties1 = std::make_shared<Opm::Well::WellProductionProperties>(well.getProductionProperties());
|
||||
properties1->OilRate.reset(100);
|
||||
properties1->OilRate = 100;
|
||||
properties1->addProductionControl(Opm::Well::ProducerCMode::ORAT);
|
||||
well.updateProduction(properties1);
|
||||
BOOST_CHECK( well.getProductionProperties().hasProductionControl( Opm::Well::ProducerCMode::ORAT ));
|
||||
BOOST_CHECK( !well.getProductionProperties().hasProductionControl( Opm::Well::ProducerCMode::RESV ));
|
||||
|
||||
auto properties2 = std::make_shared<Opm::Well::WellProductionProperties>(well.getProductionProperties());
|
||||
properties2->ResVRate.reset( 100 );
|
||||
properties2->ResVRate = 100;
|
||||
properties2->addProductionControl(Opm::Well::ProducerCMode::RESV);
|
||||
well.updateProduction(properties2);
|
||||
BOOST_CHECK( well.getProductionProperties().hasProductionControl( Opm::Well::ProducerCMode::RESV ));
|
||||
|
||||
auto properties3 = std::make_shared<Opm::Well::WellProductionProperties>(well.getProductionProperties());
|
||||
properties3->OilRate.reset(100);
|
||||
properties3->WaterRate.reset(100);
|
||||
properties3->GasRate.reset(100);
|
||||
properties3->LiquidRate.reset(100);
|
||||
properties3->ResVRate.reset(100);
|
||||
properties3->BHPTarget.reset(100);
|
||||
properties3->THPTarget.reset(100);
|
||||
properties3->OilRate = 100;
|
||||
properties3->WaterRate = 100;
|
||||
properties3->GasRate = 100;
|
||||
properties3->LiquidRate = 100;
|
||||
properties3->ResVRate = 100;
|
||||
properties3->BHPTarget = 100;
|
||||
properties3->THPTarget = 100;
|
||||
properties3->addProductionControl(Opm::Well::ProducerCMode::ORAT);
|
||||
properties3->addProductionControl(Opm::Well::ProducerCMode::LRAT);
|
||||
properties3->addProductionControl(Opm::Well::ProducerCMode::BHP);
|
||||
@@ -364,22 +364,22 @@ BOOST_AUTO_TEST_CASE(WellHaveInjectionControlLimit) {
|
||||
BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well::InjectorCMode::RESV ));
|
||||
|
||||
auto injProps1 = std::make_shared<Opm::Well::WellInjectionProperties>(well.getInjectionProperties());
|
||||
injProps1->surfaceInjectionRate.reset(100);
|
||||
injProps1->surfaceInjectionRate = 100;
|
||||
injProps1->addInjectionControl(Opm::Well::InjectorCMode::RATE);
|
||||
well.updateInjection(injProps1);
|
||||
BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well::InjectorCMode::RATE ));
|
||||
BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well::InjectorCMode::RESV ));
|
||||
|
||||
auto injProps2 = std::make_shared<Opm::Well::WellInjectionProperties>(well.getInjectionProperties());
|
||||
injProps2->reservoirInjectionRate.reset(100);
|
||||
injProps2->reservoirInjectionRate = 100;
|
||||
injProps2->addInjectionControl(Opm::Well::InjectorCMode::RESV);
|
||||
well.updateInjection(injProps2);
|
||||
BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well::InjectorCMode::RESV ));
|
||||
|
||||
auto injProps3 = std::make_shared<Opm::Well::WellInjectionProperties>(well.getInjectionProperties());
|
||||
injProps3->BHPTarget.reset(100);
|
||||
injProps3->BHPTarget = 100;
|
||||
injProps3->addInjectionControl(Opm::Well::InjectorCMode::BHP);
|
||||
injProps3->THPTarget.reset(100);
|
||||
injProps3->THPTarget = 100;
|
||||
injProps3->addInjectionControl(Opm::Well::InjectorCMode::THP);
|
||||
well.updateInjection(injProps3);
|
||||
|
||||
@@ -493,10 +493,10 @@ namespace {
|
||||
|
||||
Opm::Well::WellProductionProperties properties(const std::string& input) {
|
||||
Opm::Parser parser;
|
||||
|
||||
Opm::UnitSystem unit_system(Opm::UnitSystem::UnitType::UNIT_TYPE_METRIC);
|
||||
auto deck = parser.parseString(input);
|
||||
const auto& record = deck.getKeyword("WCONHIST").getRecord(0);
|
||||
Opm::Well::WellProductionProperties hist("W");
|
||||
Opm::Well::WellProductionProperties hist(unit_system, "W");
|
||||
hist.handleWCONHIST(record);
|
||||
|
||||
|
||||
@@ -542,14 +542,14 @@ namespace {
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
Opm::UnitSystem unit_system(Opm::UnitSystem::UnitType::UNIT_TYPE_METRIC);
|
||||
Opm::Well::WellProductionProperties properties(const std::string& input)
|
||||
{
|
||||
Opm::Parser parser;
|
||||
auto deck = parser.parseString(input);
|
||||
const auto& kwd = deck.getKeyword("WCONPROD");
|
||||
const auto& record = kwd.getRecord(0);
|
||||
Opm::Well::WellProductionProperties pred("W");
|
||||
Opm::Well::WellProductionProperties pred(unit_system, "W");
|
||||
pred.handleWCONPROD("WELL", record);
|
||||
|
||||
return pred;
|
||||
@@ -767,8 +767,9 @@ BOOST_AUTO_TEST_CASE(BHP_CMODE)
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CMODE_DEFAULT) {
|
||||
const Opm::Well::WellProductionProperties Pproperties("W");
|
||||
const Opm::Well::WellInjectionProperties Iproperties("W");
|
||||
auto unit_system = UnitSystem::newMETRIC();
|
||||
const Opm::Well::WellProductionProperties Pproperties(unit_system, "W");
|
||||
const Opm::Well::WellInjectionProperties Iproperties(unit_system, "W");
|
||||
|
||||
BOOST_CHECK( Pproperties.controlMode == Opm::Well::ProducerCMode::CMODE_UNDEFINED );
|
||||
BOOST_CHECK( Iproperties.controlMode == Opm::Well::InjectorCMode::CMODE_UNDEFINED );
|
||||
@@ -778,8 +779,9 @@ BOOST_AUTO_TEST_CASE(CMODE_DEFAULT) {
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(WELL_CONTROLS) {
|
||||
Opm::Well well("WELL", "GROUP", 0, 0, 0, 0, 1000, Opm::Phase::OIL, Opm::Well::ProducerCMode::CMODE_UNDEFINED, Opm::Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0, 1.0, false, false);
|
||||
Opm::Well::WellProductionProperties prod("OP1");
|
||||
auto unit_system = UnitSystem::newMETRIC();
|
||||
Opm::Well well("WELL", "GROUP", 0, 0, 0, 0, 1000, Opm::Phase::OIL, Opm::Well::ProducerCMode::CMODE_UNDEFINED, Opm::Connection::Order::DEPTH, unit_system, 0, 1.0, false, false);
|
||||
Opm::Well::WellProductionProperties prod(unit_system, "OP1");
|
||||
Opm::SummaryState st(std::chrono::system_clock::now());
|
||||
well.productionControls(st);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user