From dcd45ba397aaa2b4dae8953ac161df78c5246aee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Gr=C3=B8n=C3=A5s=20Drange?= Date: Tue, 19 Apr 2016 15:20:34 +0200 Subject: [PATCH 01/69] Fixed major indentation issue---whole file indented arbitrarily --- tests/test_wellsmanager.cpp | 458 +++++++++++++++++------------------- 1 file changed, 220 insertions(+), 238 deletions(-) diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index da5995f20..8b97cc100 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -29,273 +29,255 @@ #include #include - #include - #include +#include +#include - #include - #include - #include +#include +#include +#include - #include +#include +void wells_static_check(const Wells* wells) { + BOOST_CHECK_EQUAL(2, wells->number_of_wells); + BOOST_CHECK_EQUAL(3, wells->number_of_phases); - void wells_static_check(const Wells* wells) { - BOOST_CHECK_EQUAL(2 , wells->number_of_wells); - BOOST_CHECK_EQUAL(3 , wells->number_of_phases); + BOOST_CHECK_EQUAL("INJ1", wells->name[0]); + BOOST_CHECK_EQUAL("PROD1", wells->name[1]); - BOOST_CHECK_EQUAL("INJ1" , wells->name[0]); - BOOST_CHECK_EQUAL("PROD1" , wells->name[1]); + /* The mapping from well number into the wells->WI and wells->well_cells arrays. */ + BOOST_CHECK_EQUAL(0, wells->well_connpos[0]); + BOOST_CHECK_EQUAL(1, wells->well_connpos[1]); + BOOST_CHECK_EQUAL(2, wells->well_connpos[2]); - /* The mapping from well number into the wells->WI and wells->well_cells arrays. */ - BOOST_CHECK_EQUAL(0 , wells->well_connpos[0]); - BOOST_CHECK_EQUAL(1 , wells->well_connpos[1]); - BOOST_CHECK_EQUAL(2 , wells->well_connpos[2]); + /* Connection factor */ + BOOST_CHECK_CLOSE(1.2279166666666664e-12, wells->WI[0], 0.001); + BOOST_CHECK_CLOSE(1.2279166666666664e-12, wells->WI[1], 0.001); - /* Connection factor */ - BOOST_CHECK_CLOSE(1.2279166666666664e-12 , wells->WI[0] , 0.001); - BOOST_CHECK_CLOSE(1.2279166666666664e-12 , wells->WI[1] , 0.001); + /* Completed cells */ + BOOST_CHECK_EQUAL(0, wells->well_cells[0]); + BOOST_CHECK_EQUAL(9 + 2 * 10 + 2 * 10 * 10, wells->well_cells[1]); +} - /* Completed cells */ - BOOST_CHECK_EQUAL(0 , wells->well_cells[0]); - BOOST_CHECK_EQUAL(9 + 2*10 + 2*10*10 , wells->well_cells[1]); +/* + The number of controls is determined by looking at which elements + have been given explicit - non-default - values in the WCONxxxx + keyword. Is that at all interesting? + */ + +void check_controls_epoch0(struct WellControls ** ctrls) { + // The injector + { + const struct WellControls * ctrls0 = ctrls[0]; + BOOST_CHECK_EQUAL(3, well_controls_get_num(ctrls0)); // The number of controls for the injector == 3?? + + BOOST_CHECK_EQUAL(SURFACE_RATE, well_controls_iget_type(ctrls0, 0)); + BOOST_CHECK_EQUAL(RESERVOIR_RATE, well_controls_iget_type(ctrls0, 1)); + BOOST_CHECK_EQUAL(BHP, well_controls_iget_type(ctrls0, 2)); + + // The different targets + BOOST_CHECK_EQUAL(100.0 / 86400, well_controls_iget_target(ctrls0, 0)); + BOOST_CHECK_EQUAL(200.0 / 86400, well_controls_iget_target(ctrls0, 1)); + BOOST_CHECK_EQUAL(400 * 100000, well_controls_iget_target(ctrls0, 2)); + + // Which control is active + BOOST_CHECK_EQUAL(0, well_controls_get_current(ctrls0)); + + // The phase distribution in the active target + { + const double * distr = well_controls_iget_distr(ctrls0, 0); + BOOST_CHECK_EQUAL(0, distr[0]); // Water + BOOST_CHECK_EQUAL(0, distr[1]); // Oil + BOOST_CHECK_EQUAL(1, distr[2]); // Gas } + } + // The producer + { + const struct WellControls * ctrls1 = ctrls[1]; + BOOST_CHECK_EQUAL(2, well_controls_get_num(ctrls1)); // The number of controls for the producer == 2?? + BOOST_CHECK_EQUAL(SURFACE_RATE, well_controls_iget_type(ctrls1, 0)); + BOOST_CHECK_EQUAL(BHP, well_controls_iget_type(ctrls1, 1)); - /* - The number of controls is determined by looking at which elements - have been given explicit - non-default - values in the WCONxxxx - keyword. Is that at all interesting? - */ + // The different targets + BOOST_CHECK_EQUAL(-20000.0 / 86400, well_controls_iget_target(ctrls1, 0)); + BOOST_CHECK_EQUAL(1000 * 100000, well_controls_iget_target(ctrls1, 1)); + // Which control is active + BOOST_CHECK_EQUAL(0, well_controls_get_current(ctrls1)); - void check_controls_epoch0( struct WellControls ** ctrls) { - // The injector - { - const struct WellControls * ctrls0 = ctrls[0]; - BOOST_CHECK_EQUAL( 3 , well_controls_get_num(ctrls0)); // The number of controls for the injector == 3?? - - BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls0 , 0) ); - BOOST_CHECK_EQUAL( RESERVOIR_RATE , well_controls_iget_type(ctrls0 , 1) ); - BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls0 , 2) ); - - // The different targets - BOOST_CHECK_EQUAL( 100.0 / 86400 , well_controls_iget_target(ctrls0,0)); - BOOST_CHECK_EQUAL( 200.0 / 86400 , well_controls_iget_target(ctrls0,1)); - BOOST_CHECK_EQUAL( 400 * 100000 , well_controls_iget_target(ctrls0,2)); - - // Which control is active - BOOST_CHECK_EQUAL( 0 , well_controls_get_current(ctrls0) ); - - // The phase distribution in the active target - { - const double * distr = well_controls_iget_distr( ctrls0 , 0 ); - BOOST_CHECK_EQUAL( 0 , distr[0] ); // Water - BOOST_CHECK_EQUAL( 0 , distr[1] ); // Oil - BOOST_CHECK_EQUAL( 1 , distr[2] ); // Gas - } - } - - // The producer - { - const struct WellControls * ctrls1 = ctrls[1]; - BOOST_CHECK_EQUAL( 2 , well_controls_get_num( ctrls1 )); // The number of controls for the producer == 2?? - BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls1 , 0) ); - BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls1 , 1) ); - - // The different targets - BOOST_CHECK_EQUAL( -20000.0 / 86400 , well_controls_iget_target(ctrls1,0)); - BOOST_CHECK_EQUAL( 1000 * 100000 , well_controls_iget_target(ctrls1,1)); - - // Which control is active - BOOST_CHECK_EQUAL( 0 , well_controls_get_current(ctrls1)); - - // The phase distribution in the active target - { - const double * distr = well_controls_iget_distr( ctrls1 , 0 ); - BOOST_CHECK_EQUAL( 0 , distr[0] ); // Water - BOOST_CHECK_EQUAL( 1 , distr[1] ); // Oil - BOOST_CHECK_EQUAL( 0 , distr[2] ); // Gas - } - } + // The phase distribution in the active target + { + const double * distr = well_controls_iget_distr(ctrls1, 0); + BOOST_CHECK_EQUAL(0, distr[0]); // Water + BOOST_CHECK_EQUAL(1, distr[1]); // Oil + BOOST_CHECK_EQUAL(0, distr[2]); // Gas } + } +} +void check_controls_epoch1(struct WellControls ** ctrls) { + // The injector + { + const struct WellControls * ctrls0 = ctrls[0]; + BOOST_CHECK_EQUAL(3, well_controls_get_num(ctrls0)); // The number of controls for the injector == 3?? + BOOST_CHECK_EQUAL(SURFACE_RATE, well_controls_iget_type(ctrls0, 0)); + BOOST_CHECK_EQUAL(RESERVOIR_RATE, well_controls_iget_type(ctrls0, 1)); + BOOST_CHECK_EQUAL(BHP, well_controls_iget_type(ctrls0, 2)); + // The different targets + BOOST_CHECK_CLOSE(10.0 / 86400, well_controls_iget_target(ctrls0, 0), 0.001); + BOOST_CHECK_CLOSE(20.0 / 86400, well_controls_iget_target(ctrls0, 1), 0.001); + BOOST_CHECK_CLOSE(40 * 100000, well_controls_iget_target(ctrls0, 2), 0.001); - void check_controls_epoch1( struct WellControls ** ctrls) { - // The injector - { - const struct WellControls * ctrls0 = ctrls[0]; - BOOST_CHECK_EQUAL( 3 , well_controls_get_num(ctrls0)); // The number of controls for the injector == 3?? + // Which control is active + BOOST_CHECK_EQUAL(1, well_controls_get_current(ctrls0)); - BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls0 , 0 )); - BOOST_CHECK_EQUAL( RESERVOIR_RATE , well_controls_iget_type(ctrls0 , 1 )); - BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls0 , 2 )); - - // The different targets - BOOST_CHECK_CLOSE( 10.0 / 86400 , well_controls_iget_target(ctrls0 , 0) , 0.001); - BOOST_CHECK_CLOSE( 20.0 / 86400 , well_controls_iget_target(ctrls0 , 1) , 0.001); - BOOST_CHECK_CLOSE( 40 * 100000 , well_controls_iget_target(ctrls0 , 2) , 0.001); - - // Which control is active - BOOST_CHECK_EQUAL( 1 , well_controls_get_current(ctrls0)); - - { - const double * distr = well_controls_iget_distr( ctrls0 , 1 ); - BOOST_CHECK_EQUAL( 1 , distr[0] ); // Water - BOOST_CHECK_EQUAL( 0 , distr[1] ); // Oil - BOOST_CHECK_EQUAL( 0 , distr[2] ); // Gas - } - } - - // The producer - { - const struct WellControls * ctrls1 = ctrls[1]; - BOOST_CHECK_EQUAL( 3 , well_controls_get_num(ctrls1)); // The number of controls for the producer - now 3. - BOOST_CHECK_EQUAL( SURFACE_RATE , well_controls_iget_type(ctrls1 , 0) ); - BOOST_CHECK_EQUAL( RESERVOIR_RATE , well_controls_iget_type(ctrls1 , 1) ); - BOOST_CHECK_EQUAL( BHP , well_controls_iget_type(ctrls1 , 2) ); - - // The different targets - BOOST_CHECK_CLOSE( -999.0 / 86400 , well_controls_iget_target(ctrls1 , 0), 0.001); - BOOST_CHECK_CLOSE( -123.0 / 86400 , well_controls_iget_target(ctrls1 , 1), 0.001); - BOOST_CHECK_CLOSE( 100 * 100000 , well_controls_iget_target(ctrls1 , 2), 0.001); - - // Which control is active - BOOST_CHECK_EQUAL( 1 , well_controls_get_current(ctrls1) ); - - { - const double * distr = well_controls_iget_distr( ctrls1 , 1 ); - BOOST_CHECK_EQUAL( 1 , distr[0] ); // Water - BOOST_CHECK_EQUAL( 1 , distr[1] ); // Oil - BOOST_CHECK_EQUAL( 1 , distr[2] ); // Gas - } - } + { + const double * distr = well_controls_iget_distr(ctrls0, 1); + BOOST_CHECK_EQUAL(1, distr[0]); // Water + BOOST_CHECK_EQUAL(0, distr[1]); // Oil + BOOST_CHECK_EQUAL(0, distr[2]); // Gas } + } + // The producer + { + const struct WellControls * ctrls1 = ctrls[1]; + BOOST_CHECK_EQUAL(3, well_controls_get_num(ctrls1)); // The number of controls for the producer - now 3. + BOOST_CHECK_EQUAL(SURFACE_RATE, well_controls_iget_type(ctrls1, 0)); + BOOST_CHECK_EQUAL(RESERVOIR_RATE, well_controls_iget_type(ctrls1, 1)); + BOOST_CHECK_EQUAL(BHP, well_controls_iget_type(ctrls1, 2)); - void check_controls_epoch3( struct WellControls ** ctrls) { - // The new producer - const struct WellControls * ctrls1 = ctrls[1]; - // Note: controls include default (1 atm) BHP control. - BOOST_CHECK_EQUAL( 6 , well_controls_get_num(ctrls1)); + // The different targets + BOOST_CHECK_CLOSE(-999.0 / 86400, well_controls_iget_target(ctrls1, 0), 0.001); + BOOST_CHECK_CLOSE(-123.0 / 86400, well_controls_iget_target(ctrls1, 1), 0.001); + BOOST_CHECK_CLOSE(100 * 100000, well_controls_iget_target(ctrls1, 2), 0.001); + + // Which control is active + BOOST_CHECK_EQUAL(1, well_controls_get_current(ctrls1)); + + { + const double * distr = well_controls_iget_distr(ctrls1, 1); + BOOST_CHECK_EQUAL(1, distr[0]); // Water + BOOST_CHECK_EQUAL(1, distr[1]); // Oil + BOOST_CHECK_EQUAL(1, distr[2]); // Gas } + } +} +void check_controls_epoch3(struct WellControls ** ctrls) { + // The new producer + const struct WellControls * ctrls1 = ctrls[1]; + // Note: controls include default (1 atm) BHP control. + BOOST_CHECK_EQUAL(6, well_controls_get_num(ctrls1)); +} +BOOST_AUTO_TEST_CASE(New_Constructor_Works) { + const std::string filename = "wells_manager_data.data"; + Opm::ParserPtr parser(new Opm::Parser()); + Opm::ParseContext parseContext; + Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); - BOOST_AUTO_TEST_CASE(New_Constructor_Works) { - - const std::string filename = "wells_manager_data.data"; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::ParseContext parseContext; - Opm::DeckConstPtr deck(parser->parseFile(filename , parseContext)); - - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); - Opm::GridManager gridManager(deck); - - { - Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid(), NULL); - wells_static_check( wellsManager.c_wells() ); - check_controls_epoch0( wellsManager.c_wells()->ctrls ); - } - - { - Opm::WellsManager wellsManager(eclipseState, 1, *gridManager.c_grid(), NULL); - wells_static_check( wellsManager.c_wells() ); - check_controls_epoch1( wellsManager.c_wells()->ctrls ); - } - - - { - Opm::WellsManager wellsManager(eclipseState, 3, *gridManager.c_grid(), NULL); - const Wells* wells = wellsManager.c_wells(); - - // There is 3 wells in total in the deck at the 3rd schedule step. - // PROD1 is shut and should therefore not be counted. - // The new well is therefore the secound well. - BOOST_CHECK_EQUAL(2 , wells->number_of_wells); - BOOST_CHECK_EQUAL( wells->name[0] , "INJ1"); - BOOST_CHECK_EQUAL( wells->name[1] , "NEW"); - - check_controls_epoch3( wellsManager.c_wells()->ctrls ); - } - - } - - - - BOOST_AUTO_TEST_CASE(WellsEqual) { - const std::string filename = "wells_manager_data.data"; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::ParseContext parseContext; - Opm::DeckConstPtr deck(parser->parseFile(filename , parseContext)); - - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); - Opm::GridManager gridManager(deck); - - Opm::WellsManager wellsManager0(eclipseState , 0 , *gridManager.c_grid(), NULL); - Opm::WellsManager wellsManager1(eclipseState , 1 , *gridManager.c_grid(), NULL); - - BOOST_CHECK( wells_equal( wellsManager0.c_wells() , wellsManager0.c_wells(),false) ); - BOOST_CHECK( !wells_equal( wellsManager0.c_wells() , wellsManager1.c_wells(),false) ); - } - - - BOOST_AUTO_TEST_CASE(ControlsEqual) { - const std::string filename = "wells_manager_data.data"; - Opm::ParseContext parseContext; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr deck(parser->parseFile(filename , parseContext)); - - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); - Opm::GridManager gridManager(deck); - - Opm::WellsManager wellsManager0(eclipseState , 0 , *gridManager.c_grid(), NULL); - Opm::WellsManager wellsManager1(eclipseState , 1 , *gridManager.c_grid(), NULL); - - BOOST_CHECK( well_controls_equal( wellsManager0.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[0] , false)); - BOOST_CHECK( well_controls_equal( wellsManager0.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[1] , false)); - BOOST_CHECK( well_controls_equal( wellsManager1.c_wells()->ctrls[0] , wellsManager1.c_wells()->ctrls[0] , false)); - BOOST_CHECK( well_controls_equal( wellsManager1.c_wells()->ctrls[1] , wellsManager1.c_wells()->ctrls[1] , false)); - - BOOST_CHECK( !well_controls_equal( wellsManager0.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[1] , false)); - BOOST_CHECK( !well_controls_equal( wellsManager0.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[0] , false)); - BOOST_CHECK( !well_controls_equal( wellsManager1.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[0] , false)); - BOOST_CHECK( !well_controls_equal( wellsManager1.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[1] , false)); - } - - - - BOOST_AUTO_TEST_CASE(WellShutOK) { - const std::string filename = "wells_manager_data.data"; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::ParseContext parseContext; - Opm::DeckConstPtr deck(parser->parseFile(filename , parseContext)); - - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); - Opm::GridManager gridManager(deck); - - Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL); - - // Shut wells are not added to the deck. i.e number of wells should be 2-1 - BOOST_CHECK( wellsManager2.c_wells()->number_of_wells == 1); - - //BOOST_CHECK_NO_THROW( Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL)); - } - - - - BOOST_AUTO_TEST_CASE(WellSTOPOK) { - const std::string filename = "wells_manager_data_wellSTOP.data"; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::ParseContext parseContext; - Opm::DeckConstPtr deck(parser->parseFile(filename , parseContext)); - - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); Opm::GridManager gridManager(deck); - Opm::WellsManager wellsManager(eclipseState , 0 , *gridManager.c_grid(), NULL); + { + Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid(), NULL); + wells_static_check(wellsManager.c_wells()); + check_controls_epoch0(wellsManager.c_wells()->ctrls); + } + + { + Opm::WellsManager wellsManager(eclipseState, 1, *gridManager.c_grid(), NULL); + wells_static_check(wellsManager.c_wells()); + check_controls_epoch1(wellsManager.c_wells()->ctrls); + } + + { + Opm::WellsManager wellsManager(eclipseState, 3, *gridManager.c_grid(), NULL); + const Wells* wells = wellsManager.c_wells(); + + // There is 3 wells in total in the deck at the 3rd schedule step. + // PROD1 is shut and should therefore not be counted. + // The new well is therefore the secound well. + BOOST_CHECK_EQUAL(2, wells->number_of_wells); + BOOST_CHECK_EQUAL(wells->name[0], "INJ1"); + BOOST_CHECK_EQUAL(wells->name[1], "NEW"); + + check_controls_epoch3(wellsManager.c_wells()->ctrls); + } + +} + +BOOST_AUTO_TEST_CASE(WellsEqual) { + const std::string filename = "wells_manager_data.data"; + Opm::ParserPtr parser(new Opm::Parser()); + Opm::ParseContext parseContext; + Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); + + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); + Opm::GridManager gridManager(deck); + + Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid(), NULL); + Opm::WellsManager wellsManager1(eclipseState, 1, *gridManager.c_grid(), NULL); + + BOOST_CHECK(wells_equal( wellsManager0.c_wells() , wellsManager0.c_wells(),false)); + BOOST_CHECK(!wells_equal( wellsManager0.c_wells() , wellsManager1.c_wells(),false)); +} + +BOOST_AUTO_TEST_CASE(ControlsEqual) { + const std::string filename = "wells_manager_data.data"; + Opm::ParseContext parseContext; + Opm::ParserPtr parser(new Opm::Parser()); + Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); + + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); + Opm::GridManager gridManager(deck); + + Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid(), NULL); + Opm::WellsManager wellsManager1(eclipseState, 1, *gridManager.c_grid(), NULL); + + BOOST_CHECK(well_controls_equal( wellsManager0.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[0] , false)); + BOOST_CHECK(well_controls_equal( wellsManager0.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[1] , false)); + BOOST_CHECK(well_controls_equal( wellsManager1.c_wells()->ctrls[0] , wellsManager1.c_wells()->ctrls[0] , false)); + BOOST_CHECK(well_controls_equal( wellsManager1.c_wells()->ctrls[1] , wellsManager1.c_wells()->ctrls[1] , false)); + + BOOST_CHECK(!well_controls_equal( wellsManager0.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[1] , false)); + BOOST_CHECK(!well_controls_equal( wellsManager0.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[0] , false)); + BOOST_CHECK(!well_controls_equal( wellsManager1.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[0] , false)); + BOOST_CHECK(!well_controls_equal( wellsManager1.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[1] , false)); +} + +BOOST_AUTO_TEST_CASE(WellShutOK) { + const std::string filename = "wells_manager_data.data"; + Opm::ParserPtr parser(new Opm::Parser()); + Opm::ParseContext parseContext; + Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); + + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); + Opm::GridManager gridManager(deck); + + Opm::WellsManager wellsManager2(eclipseState, 2, *gridManager.c_grid(), NULL); + + // Shut wells are not added to the deck. i.e number of wells should be 2-1 + BOOST_CHECK(wellsManager2.c_wells()->number_of_wells == 1); + + //BOOST_CHECK_NO_THROW( Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL)); +} + +BOOST_AUTO_TEST_CASE(WellSTOPOK) { + const std::string filename = "wells_manager_data_wellSTOP.data"; + Opm::ParserPtr parser(new Opm::Parser()); + Opm::ParseContext parseContext; + Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); + + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); + Opm::GridManager gridManager(deck); + + Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid(), NULL); const Wells* wells = wellsManager.c_wells(); const struct WellControls* ctrls0 = wells->ctrls[0]; From 75936c1d9ccaec836ad679542588139d4789d1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Gr=C3=B8n=C3=A5s=20Drange?= Date: Tue, 19 Apr 2016 17:00:01 +0200 Subject: [PATCH 02/69] Using getInputGrid API from Parser, changed GridManager to no longer accept Deck in constructor --- examples/compute_initial_state.cpp | 2 +- examples/diagnose_relperm.cpp | 2 +- opm/core/wells/WellsManager_impl.hpp | 2 +- tests/test_blackoilstate.cpp | 28 +++++++++++++++++++++++----- tests/test_pinchprocessor.cpp | 2 +- tests/test_relpermdiagnostics.cpp | 2 +- tests/test_stoppedwells.cpp | 2 +- tests/test_wellsmanager.cpp | 10 +++++----- 8 files changed, 34 insertions(+), 16 deletions(-) diff --git a/examples/compute_initial_state.cpp b/examples/compute_initial_state.cpp index a88638f02..a2b8c2ed8 100644 --- a/examples/compute_initial_state.cpp +++ b/examples/compute_initial_state.cpp @@ -90,7 +90,7 @@ try Opm::DeckConstPtr deck = parser->parseFile(deck_filename , parseContext); Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); const double grav = param.getDefault("gravity", unit::gravity); - GridManager gm(deck); + GridManager gm(eclipseState->getInputGrid()); const UnstructuredGrid& grid = *gm.c_grid(); BlackoilPropertiesFromDeck props(deck, eclipseState, grid, param); warnIfUnusedParams(param); diff --git a/examples/diagnose_relperm.cpp b/examples/diagnose_relperm.cpp index 862fb96d7..6de6a9489 100644 --- a/examples/diagnose_relperm.cpp +++ b/examples/diagnose_relperm.cpp @@ -78,7 +78,7 @@ try Opm::DeckConstPtr deck(parser->parseFile(eclipseFilename, parseContext)); eclState.reset(new EclipseState(deck, parseContext)); - GridManager gm(deck); + GridManager gm(eclState->getInputGrid()); const UnstructuredGrid& grid = *gm.c_grid(); using boost::filesystem::path; path fpath(eclipseFilename); diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 1f44443a0..9d9190313 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -390,7 +390,7 @@ WellsManager::init(const Opm::EclipseStateConstPtr eclipseState, DoubleArray ntg_glob(eclipseState, "NTG", 1.0); NTGArray ntg(ntg_glob, global_cell); - EclipseGridConstPtr eclGrid = eclipseState->getEclipseGrid(); + EclipseGridConstPtr eclGrid = eclipseState->getInputGrid(); // use cell thickness (dz) from eclGrid // dz overwrites values calculated by WellDetails::getCubeDim diff --git a/tests/test_blackoilstate.cpp b/tests/test_blackoilstate.cpp index 0cff885a9..b1942dbb0 100644 --- a/tests/test_blackoilstate.cpp +++ b/tests/test_blackoilstate.cpp @@ -28,6 +28,13 @@ using namespace Opm; using namespace std; +// ACTNUM 1 998*2 3 +std::vector get_testBlackoilStateActnum() { + std::vector actnum(10 * 10 * 10, 2); + actnum.front() = 1; + actnum.back() = 3; + return actnum; +} BOOST_AUTO_TEST_CASE(EqualsDifferentDeckReturnFalse) { @@ -35,12 +42,20 @@ BOOST_AUTO_TEST_CASE(EqualsDifferentDeckReturnFalse) { const string filename1 = "testBlackoilState1.DATA"; const string filename2 = "testBlackoilState2.DATA"; Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr deck1(parser->parseFile(filename1, parseContext)); - Opm::DeckConstPtr deck2(parser->parseFile(filename2, parseContext)); - GridManager gridManager1(deck1); + Opm::DeckConstPtr deck1(parser->parseFile(filename1, parseContext)); + auto eg1 = std::make_shared(deck1); + std::vector actnum = get_testBlackoilStateActnum(); + eg1->resetACTNUM(actnum.data()); + + + Opm::DeckConstPtr deck2(parser->parseFile(filename2, parseContext)); + auto eg2 = std::make_shared(deck2); + + GridManager gridManager1(eg1); const UnstructuredGrid& grid1 = *gridManager1.c_grid(); - GridManager gridManager2(deck2); + + GridManager gridManager2(eg2); const UnstructuredGrid& grid2 = *gridManager2.c_grid(); BlackoilState state1( UgGridHelpers::numCells( grid1 ) , UgGridHelpers::numFaces( grid1 ) , 3); @@ -58,8 +73,11 @@ BOOST_AUTO_TEST_CASE(EqualsNumericalDifferenceReturnFalse) { Opm::ParseContext parseContext; Opm::ParserPtr parser(new Opm::Parser()); Opm::DeckConstPtr deck(parser->parseFile(filename , parseContext)); + auto eg = std::make_shared(deck); + std::vector actnum = get_testBlackoilStateActnum(); + eg->resetACTNUM(actnum.data()); - GridManager gridManager(deck); + GridManager gridManager(eg); const UnstructuredGrid& grid = *gridManager.c_grid(); BlackoilState state1( UgGridHelpers::numCells( grid ) , UgGridHelpers::numFaces( grid ) , 3); diff --git a/tests/test_pinchprocessor.cpp b/tests/test_pinchprocessor.cpp index 6a2711a5d..cba80906e 100644 --- a/tests/test_pinchprocessor.cpp +++ b/tests/test_pinchprocessor.cpp @@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE(Processing) Opm::DeckConstPtr deck = parser->parseFile(filename, parseContext); std::shared_ptr eclstate (new Opm::EclipseState(deck, parseContext)); const auto& porv = eclstate->get3DProperties().getDoubleGridProperty("PORV").getData(); - EclipseGridConstPtr eclgrid = eclstate->getEclipseGrid(); + EclipseGridConstPtr eclgrid = eclstate->getInputGrid(); BOOST_CHECK_EQUAL(eclgrid->getMinpvMode(), MinpvMode::EclSTD); diff --git a/tests/test_relpermdiagnostics.cpp b/tests/test_relpermdiagnostics.cpp index 65862ae3d..ae9c285e3 100644 --- a/tests/test_relpermdiagnostics.cpp +++ b/tests/test_relpermdiagnostics.cpp @@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(diagnosis) Opm::DeckConstPtr deck(parser->parseFile("../tests/relpermDiagnostics.DATA", parseContext)); eclState.reset(new EclipseState(deck, parseContext)); - GridManager gm(deck); + GridManager gm(eclState->getInputGrid()); const UnstructuredGrid& grid = *gm.c_grid(); std::string logFile = "LOGFILE.txt"; std::shared_ptr prtLog = std::make_shared(logFile, Log::DefaultMessageTypes); diff --git a/tests/test_stoppedwells.cpp b/tests/test_stoppedwells.cpp index 213e59857..b67a148d2 100644 --- a/tests/test_stoppedwells.cpp +++ b/tests/test_stoppedwells.cpp @@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells) Opm::DeckConstPtr deck(parser->parseFile(filename , parseContext)); Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); - Opm::GridManager gridManager(deck); + Opm::GridManager gridManager(eclipseState->getInputGrid()); double target_surfacerate_inj; double target_surfacerate_prod; diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index 8b97cc100..2d2587405 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -182,7 +182,7 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works) { Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); - Opm::GridManager gridManager(deck); + Opm::GridManager gridManager(eclipseState->getInputGrid()); { Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid(), NULL); @@ -219,7 +219,7 @@ BOOST_AUTO_TEST_CASE(WellsEqual) { Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); - Opm::GridManager gridManager(deck); + Opm::GridManager gridManager(eclipseState->getInputGrid()); Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid(), NULL); Opm::WellsManager wellsManager1(eclipseState, 1, *gridManager.c_grid(), NULL); @@ -235,7 +235,7 @@ BOOST_AUTO_TEST_CASE(ControlsEqual) { Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); - Opm::GridManager gridManager(deck); + Opm::GridManager gridManager(eclipseState->getInputGrid()); Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid(), NULL); Opm::WellsManager wellsManager1(eclipseState, 1, *gridManager.c_grid(), NULL); @@ -258,7 +258,7 @@ BOOST_AUTO_TEST_CASE(WellShutOK) { Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); - Opm::GridManager gridManager(deck); + Opm::GridManager gridManager(eclipseState->getInputGrid()); Opm::WellsManager wellsManager2(eclipseState, 2, *gridManager.c_grid(), NULL); @@ -275,7 +275,7 @@ BOOST_AUTO_TEST_CASE(WellSTOPOK) { Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); - Opm::GridManager gridManager(deck); + Opm::GridManager gridManager(eclipseState->getInputGrid()); Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid(), NULL); From dcf9c6a06788bb2d05fdbf2f200e08a1055a507d Mon Sep 17 00:00:00 2001 From: babrodtk Date: Wed, 20 Apr 2016 18:03:47 +0200 Subject: [PATCH 03/69] Checkpoint --- opm/core/props/phaseUsageFromDeck.hpp | 10 ++++++++-- opm/core/simulator/initState_impl.hpp | 11 +++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/opm/core/props/phaseUsageFromDeck.hpp b/opm/core/props/phaseUsageFromDeck.hpp index 8feefd1f0..c7890ebd3 100644 --- a/opm/core/props/phaseUsageFromDeck.hpp +++ b/opm/core/props/phaseUsageFromDeck.hpp @@ -88,8 +88,14 @@ namespace Opm } pu.num_phases = 0; for (int i = 0; i < BlackoilPhases::MaxNumPhases; ++i) { - pu.phase_pos[i] = pu.num_phases; - pu.num_phases += pu.phase_used[i]; + if (pu.phase_used[i]) { + pu.phase_pos[i] = pu.num_phases; + pu.num_phases += 1; + } + else { + //Set to ridiculous value on purpose: should never be used + pu.phase_pos[i] = -1; + } } // Only 2 or 3 phase systems handled. diff --git a/opm/core/simulator/initState_impl.hpp b/opm/core/simulator/initState_impl.hpp index 8e8fc24f9..38cfe9ba0 100644 --- a/opm/core/simulator/initState_impl.hpp +++ b/opm/core/simulator/initState_impl.hpp @@ -741,7 +741,7 @@ namespace Opm } /// Initialize surface volume from pressure and saturation by z = As. - /// Here saturation is used as an intial guess for z in the + /// Here saturation is used as an initial guess for z in the /// computation of A. template void initBlackoilSurfvol(const UnstructuredGrid& grid, @@ -801,9 +801,9 @@ namespace Opm State& state) { - if (props.numPhases() != 3) { - OPM_THROW(std::runtime_error, "initBlackoilSurfvol() is only supported in three-phase simulations."); - } + //if (props.numPhases() != 3) { + // OPM_THROW(std::runtime_error, "initBlackoilSurfvol() is only supported in three-phase simulations."); + //} const std::vector& rs = state.gasoilratio(); const std::vector& rv = state.rv(); @@ -828,6 +828,8 @@ namespace Opm std::vector capPressures(number_of_cells*np); props.capPress(number_of_cells,&state.saturation()[0],&allcells[0],&capPressures[0],NULL); + /* + * FIXME: This never used? std::vector Pw(number_of_cells); std::vector Pg(number_of_cells); @@ -835,6 +837,7 @@ namespace Opm Pw[c] = state.pressure()[c] + capPressures[c*np + BlackoilPhases::Aqua]; Pg[c] = state.pressure()[c] + capPressures[c*np + BlackoilPhases::Vapour]; } + */ double z_tmp; From eabb2e1f6440b7c1fcc8dcbfdff9408fdd3878b7 Mon Sep 17 00:00:00 2001 From: babrodtk Date: Thu, 21 Apr 2016 16:17:54 +0200 Subject: [PATCH 04/69] Runs first iterations of two-phase test case plausibly --- opm/core/props/BlackoilPropertiesFromDeck.cpp | 4 ++-- opm/core/props/phaseUsageFromDeck.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/opm/core/props/BlackoilPropertiesFromDeck.cpp b/opm/core/props/BlackoilPropertiesFromDeck.cpp index 0795d3f27..97d0a6e65 100644 --- a/opm/core/props/BlackoilPropertiesFromDeck.cpp +++ b/opm/core/props/BlackoilPropertiesFromDeck.cpp @@ -322,8 +322,8 @@ namespace Opm this->compute_R_(n, p, T, z, cells, &R_[0]); } const auto& pu = phaseUsage(); - bool oil_and_gas = pu.phase_pos[BlackoilPhases::Liquid] && - pu.phase_pos[BlackoilPhases::Vapour]; + bool oil_and_gas = pu.phase_used[BlackoilPhases::Liquid] && + pu.phase_used[BlackoilPhases::Vapour]; const int o = pu.phase_pos[BlackoilPhases::Liquid]; const int g = pu.phase_pos[BlackoilPhases::Vapour]; diff --git a/opm/core/props/phaseUsageFromDeck.hpp b/opm/core/props/phaseUsageFromDeck.hpp index c7890ebd3..88571e452 100644 --- a/opm/core/props/phaseUsageFromDeck.hpp +++ b/opm/core/props/phaseUsageFromDeck.hpp @@ -94,7 +94,7 @@ namespace Opm } else { //Set to ridiculous value on purpose: should never be used - pu.phase_pos[i] = -1; + pu.phase_pos[i] = 2000000000; } } From cae4d39a86c0e495b56f719e8cf4acc2a82a7a02 Mon Sep 17 00:00:00 2001 From: babrodtk Date: Fri, 22 Apr 2016 08:16:39 +0200 Subject: [PATCH 05/69] Code cleanup --- opm/core/simulator/initState_impl.hpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/opm/core/simulator/initState_impl.hpp b/opm/core/simulator/initState_impl.hpp index 38cfe9ba0..910262a2a 100644 --- a/opm/core/simulator/initState_impl.hpp +++ b/opm/core/simulator/initState_impl.hpp @@ -800,10 +800,6 @@ namespace Opm const Props& props, State& state) { - - //if (props.numPhases() != 3) { - // OPM_THROW(std::runtime_error, "initBlackoilSurfvol() is only supported in three-phase simulations."); - //} const std::vector& rs = state.gasoilratio(); const std::vector& rv = state.rv(); @@ -828,18 +824,6 @@ namespace Opm std::vector capPressures(number_of_cells*np); props.capPress(number_of_cells,&state.saturation()[0],&allcells[0],&capPressures[0],NULL); - /* - * FIXME: This never used? - std::vector Pw(number_of_cells); - std::vector Pg(number_of_cells); - - for (int c = 0; c < number_of_cells; ++c){ - Pw[c] = state.pressure()[c] + capPressures[c*np + BlackoilPhases::Aqua]; - Pg[c] = state.pressure()[c] + capPressures[c*np + BlackoilPhases::Vapour]; - } - */ - - double z_tmp; // Water phase From 9f9948434737c73dd940d503fb3ec8fbb676655c Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 6 May 2016 21:40:33 +0200 Subject: [PATCH 06/69] Prevent dereferencing the end iterator. This happened for empty regions and surfaced when compiling with "-D_GLIBCXX_DEBUG -DDEBUG -DGLIBCXX_FORCE_NEW". --- opm/core/simulator/initStateEquil.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/opm/core/simulator/initStateEquil.hpp b/opm/core/simulator/initStateEquil.hpp index 2e539ea49..2b4b02b1f 100644 --- a/opm/core/simulator/initStateEquil.hpp +++ b/opm/core/simulator/initStateEquil.hpp @@ -264,6 +264,11 @@ namespace Opm if (deck->hasKeyword("DISGAS")) { const TableContainer& rsvdTables = tables.getRsvdTables(); for (size_t i = 0; i < rec.size(); ++i) { + if (eqlmap.cells(i).empty()) + { + rs_func_.push_back(std::shared_ptr()); + continue; + } const int cell = *(eqlmap.cells(i).begin()); if (!rec[i].liveOilInitConstantRs()) { if (rsvdTables.size() <= 0 ) { @@ -297,6 +302,11 @@ namespace Opm if (deck->hasKeyword("VAPOIL")) { const TableContainer& rvvdTables = tables.getRvvdTables(); for (size_t i = 0; i < rec.size(); ++i) { + if (eqlmap.cells(i).empty()) + { + rv_func_.push_back(std::shared_ptr()); + continue; + } const int cell = *(eqlmap.cells(i).begin()); if (!rec[i].wetGasInitConstantRv()) { if (rvvdTables.size() <= 0) { @@ -381,6 +391,10 @@ namespace Opm { for (const auto& r : reg.activeRegions()) { const auto& cells = reg.cells(r); + if (cells.empty()) + { + continue; + } const int repcell = *cells.begin(); const RhoCalc calc(props, repcell); From 363b9a3795449ee192bd681f73a3c1484ed06355 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Tue, 10 May 2016 14:01:15 +0800 Subject: [PATCH 07/69] unify the format. --- opm/core/props/satfunc/RelpermDiagnostics.cpp | 106 +++++++++--------- .../props/satfunc/RelpermDiagnostics_impl.hpp | 20 ++-- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/opm/core/props/satfunc/RelpermDiagnostics.cpp b/opm/core/props/satfunc/RelpermDiagnostics.cpp index 5cf71b59a..9efffa52e 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.cpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.cpp @@ -107,14 +107,14 @@ namespace Opm{ bool family2 = ((!swfnTables.empty() && !sgfnTables.empty()) || !sgwfnTables.empty()) && (!sof3Tables.empty() || !sof2Tables.empty()); if (family1 && family2) { - const std::string msg = "-- Error: Saturation families should not be mixed.\n Use either SGOF and SWOF or SGFN, SWFN and SOF3."; + const std::string msg = "Error: Saturation families should not be mixed.\n Use either SGOF and SWOF or SGFN, SWFN and SOF3."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (!family1 && !family2) { - const std::string msg = "-- Error, Saturations function must be specified using either \n \ + const std::string msg = "Error, Saturations function must be specified using either \n \ family 1 or family 2 keywords \n \ Use either SGOF and SWOF or SGFN, SWFN and SOF3."; messages_.push_back(msg); @@ -217,7 +217,7 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { - const std::string msg = "-- Error: In SWOF table SATNUM = "+ regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "Error: In SWOF table SATNUM = "+ regionIdx + ", saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -225,13 +225,13 @@ namespace Opm{ //TODO check endpoint sw.back() == 1. - Sor. //Check krw column. if (krw.front() != 0.0) { - const std::string msg = "-- Error: In SWOF table SATNUM = " + regionIdx + ", first value of krw should be 0."; + const std::string msg = "Error: In SWOF table SATNUM = " + regionIdx + ", first value of krw should be 0."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krw.front() < 0.0 || krw.back() > 1.0) { - const std::string msg = "-- Error: In SWOF table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; + const std::string msg = "Error: In SWOF table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -239,7 +239,7 @@ namespace Opm{ ///Check krow column. if (krow.front() > 1.0 || krow.back() < 0.0) { - const std::string msg = "-- Error: In SWOF table SATNUM = "+ regionIdx + ", krow should be in range [0, 1]."; + const std::string msg = "Error: In SWOF table SATNUM = "+ regionIdx + ", krow should be in range [0, 1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -260,13 +260,13 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. if (sg.front() < 0.0 || sg.back() > 1.0) { - const std::string msg = "-- Error: In SGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (sg.front() != 0.0) { - const std::string msg = "-- Error: In SGOF table SATNUM = " + regionIdx + ", first value of sg should be 0."; + const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", first value of sg should be 0."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -274,13 +274,13 @@ namespace Opm{ //TODO check endpoint sw.back() == 1. - Sor. //Check krw column. if (krg.front() != 0.0) { - const std::string msg = "-- Error: In SGOF table SATNUM = " + regionIdx + ", first value of krg should be 0."; + const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", first value of krg should be 0."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krg.front() < 0.0 || krg.back() > 1.0) { - const std::string msg = "-- Error: In SGOF table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; + const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -288,7 +288,7 @@ namespace Opm{ //Check krow column. if (krog.front() > 1.0 || krog.back() < 0.0) { - const std::string msg = "-- Error: In SGOF table SATNUM = " + regionIdx + ", krog should be in range [0, 1]."; + const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", krog should be in range [0, 1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -306,33 +306,33 @@ namespace Opm{ //Check sl column. //TODO first value means sl = swco + sor if (sl.front() < 0.0 || sl.back() > 1.0) { - const std::string msg = "-- Error: In SLGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (sl.back() != 1.0) { - const std::string msg = "-- Error: In SLGOF table SATNUM = " + regionIdx + ", last value of sl should be 1."; + const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", last value of sl should be 1."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krg.front() > 1.0 || krg.back() < 0) { - const std::string msg = "-- Error: In SLGOF table SATNUM = " + regionIdx + ", krg shoule be in range [0, 1]."; + const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", krg shoule be in range [0, 1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krg.back() != 0.0) { - const std::string msg = "-- Error: In SLGOF table SATNUM = " + regionIdx + ", last value of krg hould be 0."; + const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", last value of krg hould be 0."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krog.front() < 0.0 || krog.back() > 1.0) { - const std::string msg = "-- Error: In SLGOF table SATNUM = " + regionIdx + ", krog shoule be in range [0, 1]."; + const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", krog shoule be in range [0, 1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -351,7 +351,7 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { - const std::string msg = "-- Error: In SWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -359,14 +359,14 @@ namespace Opm{ //Check krw column. if (krw.front() < 0.0 || krw.back() > 1.0) { - const std::string msg = "-- Error: In SWFN table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; + const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krw.front() != 0.0) { - const std::string msg = "-- Error: In SWFN table SATNUM = " + regionIdx + ", first value of krw should be 0."; + const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", first value of krw should be 0."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -385,7 +385,7 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sg column. if (sg.front() < 0.0 || sg.back() > 1.0) { - const std::string msg = "-- Error: In SGFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -393,13 +393,13 @@ namespace Opm{ //Check krg column. if (krg.front() < 0.0 || krg.back() > 1.0) { - const std::string msg = "-- Error: In SGFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; + const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krg.front() != 0.0) { - const std::string msg = "-- Error: In SGFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; + const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -420,7 +420,7 @@ namespace Opm{ //Check so column. //TODO: The max so = 1 - Swco if (so.front() < 0.0 || so.back() > 1.0) { - const std::string msg = "-- Error: In SOF3 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -428,13 +428,13 @@ namespace Opm{ //Check krow column. if (krow.front() < 0.0 || krow.back() > 1.0) { - const std::string msg = "-- Error: In SOF3 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; + const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krow.front() != 0.0) { - const std::string msg = "-- Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krow should be 0."; + const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krow should be 0."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -442,21 +442,21 @@ namespace Opm{ //Check krog column. if (krog.front() < 0.0 || krog.back() > 1.0) { - const std::string msg = "-- Error: In SOF3 table SATNUM = " + regionIdx + ", krog should be in range [0,1]."; + const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", krog should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krog.front() != 0.0) { - const std::string msg = "-- Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krog should be 0."; + const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krog should be 0."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krog.back() != krow.back()) { - const std::string msg = "-- Error: In SOF3 table SATNUM = " + regionIdx + ", max value of krog and krow should be the same."; + const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", max value of krog and krow should be the same."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -476,7 +476,7 @@ namespace Opm{ //Check so column. //TODO: The max so = 1 - Swco if (so.front() < 0.0 || so.back() > 1.0) { - const std::string msg = "-- Error: In SOF2 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -484,13 +484,13 @@ namespace Opm{ //Check krow column. if (kro.front() < 0.0 || kro.back() > 1.0) { - const std::string msg = "-- Error: In SOF2 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; + const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (kro.front() != 0.0) { - const std::string msg = "-- Error: In SOF2 table SATNUM = " + regionIdx + ", first value of krow should be 0."; + const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", first value of krow should be 0."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -510,7 +510,7 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sg column. if (sg.front() < 0.0 || sg.back() > 1.0) { - const std::string msg = "-- Error: In SGWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -518,13 +518,13 @@ namespace Opm{ //Check krg column. if (krg.front() < 0.0 || krg.back() > 1.0) { - const std::string msg = "-- Error: In SGWFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; + const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krg.front() != 0.0) { - const std::string msg = "-- Error: In SGWFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; + const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -533,13 +533,13 @@ namespace Opm{ //Check krgw column. //TODO check saturation sw = 1. - sg if (krgw.front() > 1.0 || krgw.back() < 0.0) { - const std::string msg = "-- Error: In SGWFN table SATNUM = " + regionIdx + ", krgw should be in range [0,1]."; + const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", krgw should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krgw.back() != 0.0) { - const std::string msg = "-- Error: In SGWFN table SATNUM = " + regionIdx + ", last value of krgw should be 0."; + const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", last value of krgw should be 0."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -556,7 +556,7 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { - const std::string msg = "-- Error: In SGCWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "Error: In SGCWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -564,7 +564,7 @@ namespace Opm{ //Check critical gas column. if (sgc.front() < 0.0 || sgc.back() > 1.0) { - const std::string msg = "-- Error: In SGCWMIS table SATNUM = " + regionIdx + ", critical gas saturation should be in range [0,1]."; + const std::string msg = "Error: In SGCWMIS table SATNUM = " + regionIdx + ", critical gas saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -583,7 +583,7 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { - const std::string msg = "-- Error: In SORWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "Error: In SORWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -591,7 +591,7 @@ namespace Opm{ //Check critical oil column. if (sor.front() < 0.0 || sor.back() > 1.0) { - const std::string msg = "-- Error: In SORWMIS table SATNUM = " + regionIdx + ", critical oil saturation should be in range [0,1]."; + const std::string msg = "Error: In SORWMIS table SATNUM = " + regionIdx + ", critical oil saturation should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -610,7 +610,7 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check phase fraction column. if (frac.front() < 0.0 || frac.back() > 1.0) { - const std::string msg = "-- Error: In SSFN table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; + const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -618,7 +618,7 @@ namespace Opm{ //Check gas relperm multiplier column. if (krgm.front() < 0.0 || krgm.back() > 1.0) { - const std::string msg = "-- Error: In SSFN table SATNUM = " + regionIdx + ", gas relative permeability multiplier should be in range [0,1]."; + const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", gas relative permeability multiplier should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -626,7 +626,7 @@ namespace Opm{ //Check solvent relperm multiplier column. if (krsm.front() < 0.0 || krsm.back() > 1.0) { - const std::string msg = "-- Error: In SSFN table SATNUM = " + regionIdx + ", solvent relative permeability multiplier should be in range [0,1]."; + const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", solvent relative permeability multiplier should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -647,7 +647,7 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check phase fraction column. if (frac.front() < 0.0 || frac.back() > 1.0) { - const std::string msg = "-- Error: In MISC table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; + const std::string msg = "Error: In MISC table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -655,7 +655,7 @@ namespace Opm{ //Check miscibility column. if (misc.front() < 0.0 || misc.back() > 1.0) { - const std::string msg = "-- Error: In MISC table SATNUM = " + regionIdx + ", miscibility should be in range [0,1]."; + const std::string msg = "Error: In MISC table SATNUM = " + regionIdx + ", miscibility should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -676,7 +676,7 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check phase fraction column. if (frac.front() < 0.0 || frac.back() > 1.0) { - const std::string msg = "-- Error: In MSFN table SATNUM = " + regionIdx + ", total gas fraction should be in range [0,1]."; + const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", total gas fraction should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -684,7 +684,7 @@ namespace Opm{ //Check gas_solvent relperm multiplier column. if (krgsm.front() < 0.0 || krgsm.back() > 1.0) { - const std::string msg = "-- Error: In MSFN table SATNUM = " + regionIdx + ", gas+solvent relative permeability multiplier should be in range [0,1]."; + const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", gas+solvent relative permeability multiplier should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -692,7 +692,7 @@ namespace Opm{ //Check oil relperm multiplier column. if (krom.front() > 1.0 || krom.back() < 0.0) { - const std::string msg = "-- Error: In MSFN table SATNUM = " + regionIdx + ", oil relative permeability multiplier should be in range [0,1]."; + const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", oil relative permeability multiplier should be in range [0,1]."; messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; @@ -722,13 +722,13 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx + 1); ///Consistency check. if (unscaledEpsInfo_[satnumIdx].Sgu > (1. - unscaledEpsInfo_[satnumIdx].Swl)) { - const std::string msg = "-- Warning: In saturation table SATNUM = " + regionIdx + ", Sgmax should not exceed 1-Swco."; + const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sgmax should not exceed 1-Swco."; messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; } if (unscaledEpsInfo_[satnumIdx].Sgl > (1. - unscaledEpsInfo_[satnumIdx].Swu)) { - const std::string msg = "-- Warning: In saturation table SATNUM = " + regionIdx + ", Sgco should not exceed 1-Swmax."; + const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sgco should not exceed 1-Swmax."; messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; @@ -762,7 +762,7 @@ namespace Opm{ krog_value = table.evaluate("KROG" , Sou); } if (krow_value != krog_value) { - const std::string msg = "-- Warning: In saturation table SATNUM = " + regionIdx + ", Krow(Somax) should be equal to Krog(Somax)."; + const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Krow(Somax) should be equal to Krog(Somax)."; messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; @@ -771,13 +771,13 @@ namespace Opm{ //Krw(Sw=0)=Krg(Sg=0)=Krow(So=0)=Krog(So=0)=0. //Mobile fluid requirements if (((unscaledEpsInfo_[satnumIdx].Sowcr + unscaledEpsInfo_[satnumIdx].Swcr)-1) >= 0) { - const std::string msg = "-- Warning: In saturation table SATNUM = " + regionIdx + ", Sowcr + Swcr should be less than 1."; + const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sowcr + Swcr should be less than 1."; messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; } if (((unscaledEpsInfo_[satnumIdx].Sogcr + unscaledEpsInfo_[satnumIdx].Sgcr + unscaledEpsInfo_[satnumIdx].Swl) - 1 ) > 0) { - const std::string msg = "-- Warning: In saturation table SATNUM = " + regionIdx + ", Sogcr + Sgcr + Swco should be less than 1."; + const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sogcr + Sgcr + Swco should be less than 1."; messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; diff --git a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp index 869e8cbb5..118666d99 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -56,7 +56,7 @@ namespace Opm { std::cout << x << std::endl; limits++; } else { - std::cout << "\nMore inconsistencies exist. Check saturation function input and LOGFILE!" << std::endl; + std::cout << "\nMore inconsistencies exist. Check saturation function input and .SATFUNCLOG file!" << std::endl; break; } } @@ -98,7 +98,7 @@ namespace Opm { // SGU <= 1.0 - SWL if (scaledEpsInfo_[c].Sgu > (1.0 - scaledEpsInfo_[c].Swl)) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGU exceed 1.0 - SWL"; + const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGU exceed 1.0 - SWL"; scaled_messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; @@ -106,7 +106,7 @@ namespace Opm { // SGL <= 1.0 - SWU if (scaledEpsInfo_[c].Sgl > (1.0 - scaledEpsInfo_[c].Swu)) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL exceed 1.0 - SWU"; + const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL exceed 1.0 - SWU"; scaled_messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; @@ -115,14 +115,14 @@ namespace Opm { if (deck->hasKeyword("SCALECRS") && fluidSystem_ == FluidSystem::BlackOil) { // Mobilility check. if ((scaledEpsInfo_[c].Sowcr + scaledEpsInfo_[c].Swcr) >= 1.0) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR + SWCR exceed 1.0"; + const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR + SWCR exceed 1.0"; scaled_messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; } if ((scaledEpsInfo_[c].Sogcr + scaledEpsInfo_[c].Sgcr + scaledEpsInfo_[c].Swl) >= 1.0) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR + SGCR + SWL exceed 1.0"; + const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR + SGCR + SWL exceed 1.0"; scaled_messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; @@ -131,21 +131,21 @@ namespace Opm { ///Following rules come from NEXUS. if (fluidSystem_ != FluidSystem::WaterGas) { if (scaledEpsInfo_[c].Swl > scaledEpsInfo_[c].Swcr) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWL > SWCR"; + const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWL > SWCR"; scaled_messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; } if (scaledEpsInfo_[c].Swcr > scaledEpsInfo_[c].Sowcr) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWCR > SOWCR"; + const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWCR > SOWCR"; scaled_messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; } if (scaledEpsInfo_[c].Sowcr > scaledEpsInfo_[c].Swu) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR > SWU"; + const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR > SWU"; scaled_messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; @@ -154,7 +154,7 @@ namespace Opm { if (fluidSystem_ != FluidSystem::OilWater) { if (scaledEpsInfo_[c].Sgl > scaledEpsInfo_[c].Sgcr) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL > SGCR"; + const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL > SGCR"; scaled_messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; @@ -170,7 +170,7 @@ namespace Opm { } if (scaledEpsInfo_[c].Sogcr > scaledEpsInfo_[c].Sgu) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR > SGU"; + const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR > SGU"; scaled_messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; From 592450777e111c83bf07849695f957003a39edc4 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Thu, 12 May 2016 10:32:39 +0200 Subject: [PATCH 08/69] Add member hydroCarbonState to the BlackoilState The hydroCarbonState is used to store the hydroCarbonState State 1: Gas only State 2: Gas and Oil State 3: Oil only An empty vector is return at initialization as no default values are provided by the blackoilstate. --- opm/core/simulator/BlackoilState.cpp | 2 ++ opm/core/simulator/BlackoilState.hpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/opm/core/simulator/BlackoilState.cpp b/opm/core/simulator/BlackoilState.cpp index 1f51dabba..c274136a9 100644 --- a/opm/core/simulator/BlackoilState.cpp +++ b/opm/core/simulator/BlackoilState.cpp @@ -24,12 +24,14 @@ BlackoilState::BlackoilState( const BlackoilState& other ) : SimulationDataContainer(other) { setBlackoilStateReferencePointers(); + hydrocarbonstate_ = other.hydroCarbonState(); } BlackoilState& BlackoilState::operator=( const BlackoilState& other ) { SimulationDataContainer::operator=(other); setBlackoilStateReferencePointers(); + hydrocarbonstate_ = other.hydroCarbonState(); return *this; } diff --git a/opm/core/simulator/BlackoilState.hpp b/opm/core/simulator/BlackoilState.hpp index 7f45e029f..51c6c21cb 100644 --- a/opm/core/simulator/BlackoilState.hpp +++ b/opm/core/simulator/BlackoilState.hpp @@ -62,10 +62,12 @@ namespace Opm std::vector& surfacevol () { return *surfacevol_ref_; } std::vector& gasoilratio () { return *gasoilratio_ref_; } std::vector& rv () { return *rv_ref_; } + std::vector& hydroCarbonState() { return hydrocarbonstate_; } const std::vector& surfacevol () const { return *surfacevol_ref_; } const std::vector& gasoilratio () const { return *gasoilratio_ref_; } const std::vector& rv () const { return *rv_ref_; } + const std::vector& hydroCarbonState() const { return hydrocarbonstate_; } private: void setBlackoilStateReferencePointers(); @@ -73,6 +75,9 @@ namespace Opm std::vector* gasoilratio_ref_; std::vector* rv_ref_; + // A vector storing the hydro carbon state. + std::vector hydrocarbonstate_; + }; } // namespace Opm From 2a40563c7bf3c2d7d3349f90143af27c570b4b2e Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Fri, 13 May 2016 09:10:13 +0200 Subject: [PATCH 09/69] Add method for calculating the initial hydroCarbonState The following hydroCarbonState are used enum HydroCarbonState { GasOnly = 0, GasAndOil = 1, OilOnly = 2 }; Cells almost filled with water are treated as a GasAndOil state --- opm/core/simulator/BlackoilState.hpp | 6 ++++ opm/core/utility/initHydroCarbonState.hpp | 42 +++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 opm/core/utility/initHydroCarbonState.hpp diff --git a/opm/core/simulator/BlackoilState.hpp b/opm/core/simulator/BlackoilState.hpp index 51c6c21cb..905b09434 100644 --- a/opm/core/simulator/BlackoilState.hpp +++ b/opm/core/simulator/BlackoilState.hpp @@ -30,6 +30,12 @@ namespace Opm { +enum HydroCarbonState { + GasOnly = 0, + GasAndOil = 1, + OilOnly = 2 +}; + /// Simulator state for a blackoil simulator. class BlackoilState : public SimulationDataContainer { diff --git a/opm/core/utility/initHydroCarbonState.hpp b/opm/core/utility/initHydroCarbonState.hpp new file mode 100644 index 000000000..c0be0f685 --- /dev/null +++ b/opm/core/utility/initHydroCarbonState.hpp @@ -0,0 +1,42 @@ +#ifndef INITHYDROCARBONSTATE_HPP +#define INITHYDROCARBONSTATE_HPP + +#include "opm/core/simulator/BlackoilState.hpp" + +namespace Opm +{ + +void initHydroCarbonState(BlackoilState& state, const PhaseUsage& pu, const int num_cells) { + enum { Oil = BlackoilPhases::Liquid, Gas = BlackoilPhases::Vapour, Water = BlackoilPhases::Aqua }; + // hydrocarbonstate is only used when gas and oil is present + assert(pu.phase_used[Oil]); + if (!pu.phase_used[Gas]) { + return; // do nothing + } + std::vector& hydroCarbonState = state.hydroCarbonState(); + const int np = pu.num_phases; + hydroCarbonState.resize(num_cells); + std::fill(hydroCarbonState.begin(), hydroCarbonState.end(), HydroCarbonState::GasAndOil); + + // set hydrocarbon state + const double epsilon = std::sqrt(std::numeric_limits::epsilon()); + const std::vector& saturation = state.saturation(); + for (int c = 0; c < num_cells; ++c) { + if (pu.phase_used[Water]) { + if ( saturation[c*np + pu.phase_pos[ Water ]] > (1.0 - epsilon)) { + continue; // cases (almost) filled with water is treated as GasAndOil case; + } + } + if ( saturation[c*np + pu.phase_pos[ Gas ]] == 0.0) { + hydroCarbonState[c] = HydroCarbonState::OilOnly; + continue; + } + if ( saturation[c*np + pu.phase_pos[ Oil ]] == 0.0) { + hydroCarbonState[c] = HydroCarbonState::GasOnly; + } + } +} + + +} // namespace Opm +#endif // INITHYDROCARBONSTATE_HPP From 79fd23700e17382ba35e8acfdc83596681ce6650 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Fri, 13 May 2016 12:35:08 +0200 Subject: [PATCH 10/69] Fixing PR comments - Use std::vector instead of std::vector - Use the initializer list to initialize members in constructors - Fix indent - Return OilOnly for cases without gas to avoid potential trouble further down the line --- opm/core/simulator/BlackoilState.cpp | 5 +++-- opm/core/simulator/BlackoilState.hpp | 16 ++++++++-------- opm/core/utility/initHydroCarbonState.hpp | 12 +++++++----- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/opm/core/simulator/BlackoilState.cpp b/opm/core/simulator/BlackoilState.cpp index c274136a9..66d83938e 100644 --- a/opm/core/simulator/BlackoilState.cpp +++ b/opm/core/simulator/BlackoilState.cpp @@ -21,10 +21,11 @@ BlackoilState::BlackoilState( size_t num_cells , size_t num_faces , size_t num_p } BlackoilState::BlackoilState( const BlackoilState& other ) - : SimulationDataContainer(other) + : SimulationDataContainer(other), + hydrocarbonstate_(other.hydroCarbonState()) { setBlackoilStateReferencePointers(); - hydrocarbonstate_ = other.hydroCarbonState(); + } BlackoilState& BlackoilState::operator=( const BlackoilState& other ) diff --git a/opm/core/simulator/BlackoilState.hpp b/opm/core/simulator/BlackoilState.hpp index 905b09434..fe6c0dbc5 100644 --- a/opm/core/simulator/BlackoilState.hpp +++ b/opm/core/simulator/BlackoilState.hpp @@ -30,11 +30,11 @@ namespace Opm { -enum HydroCarbonState { - GasOnly = 0, - GasAndOil = 1, - OilOnly = 2 -}; + enum HydroCarbonState { + GasOnly = 0, + GasAndOil = 1, + OilOnly = 2 + }; /// Simulator state for a blackoil simulator. class BlackoilState : public SimulationDataContainer @@ -68,12 +68,12 @@ enum HydroCarbonState { std::vector& surfacevol () { return *surfacevol_ref_; } std::vector& gasoilratio () { return *gasoilratio_ref_; } std::vector& rv () { return *rv_ref_; } - std::vector& hydroCarbonState() { return hydrocarbonstate_; } + std::vector& hydroCarbonState() { return hydrocarbonstate_; } const std::vector& surfacevol () const { return *surfacevol_ref_; } const std::vector& gasoilratio () const { return *gasoilratio_ref_; } const std::vector& rv () const { return *rv_ref_; } - const std::vector& hydroCarbonState() const { return hydrocarbonstate_; } + const std::vector& hydroCarbonState() const { return hydrocarbonstate_; } private: void setBlackoilStateReferencePointers(); @@ -82,7 +82,7 @@ enum HydroCarbonState { std::vector* rv_ref_; // A vector storing the hydro carbon state. - std::vector hydrocarbonstate_; + std::vector hydrocarbonstate_; }; diff --git a/opm/core/utility/initHydroCarbonState.hpp b/opm/core/utility/initHydroCarbonState.hpp index c0be0f685..611b0639e 100644 --- a/opm/core/utility/initHydroCarbonState.hpp +++ b/opm/core/utility/initHydroCarbonState.hpp @@ -10,12 +10,14 @@ void initHydroCarbonState(BlackoilState& state, const PhaseUsage& pu, const int enum { Oil = BlackoilPhases::Liquid, Gas = BlackoilPhases::Vapour, Water = BlackoilPhases::Aqua }; // hydrocarbonstate is only used when gas and oil is present assert(pu.phase_used[Oil]); - if (!pu.phase_used[Gas]) { - return; // do nothing - } - std::vector& hydroCarbonState = state.hydroCarbonState(); - const int np = pu.num_phases; + std::vector& hydroCarbonState = state.hydroCarbonState(); hydroCarbonState.resize(num_cells); + if (!pu.phase_used[Gas]) { + // hydroCarbonState should only be used when oil and gas is present. Return OilOnly to avoid potential trouble. + std::fill(hydroCarbonState.begin(), hydroCarbonState.end(), HydroCarbonState::OilOnly); + return; + } + const int np = pu.num_phases; std::fill(hydroCarbonState.begin(), hydroCarbonState.end(), HydroCarbonState::GasAndOil); // set hydrocarbon state From 60256d5976886ced9523054f36db1af3a157507d Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Thu, 19 May 2016 09:22:03 +0800 Subject: [PATCH 11/69] use tag for terminal output control. --- .../props/satfunc/RelpermDiagnostics_impl.hpp | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp index 118666d99..188b400f9 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -83,7 +83,8 @@ namespace Opm { EclEpsGridProperties epsGridProperties; epsGridProperties.initFromDeck(deck, eclState, /*imbibition=*/false); const auto& satnum = eclState->get3DProperties().getIntGridProperty("SATNUM"); - + + const std::string tag = "Scaled endpoints"; for (int c = 0; c < nc; ++c) { const int cartIdx = compressedToCartesianIdx[c]; const std::string satnumIdx = std::to_string(satnum.iget(cartIdx)); @@ -100,7 +101,7 @@ namespace Opm { if (scaledEpsInfo_[c].Sgu > (1.0 - scaledEpsInfo_[c].Swl)) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGU exceed 1.0 - SWL"; scaled_messages_.push_back(msg); - OpmLog::warning(msg); + OpmLog::warning(tag, msg); counter_.warning += 1; } @@ -108,7 +109,7 @@ namespace Opm { if (scaledEpsInfo_[c].Sgl > (1.0 - scaledEpsInfo_[c].Swu)) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL exceed 1.0 - SWU"; scaled_messages_.push_back(msg); - OpmLog::warning(msg); + OpmLog::warning(tag, msg); counter_.warning += 1; } @@ -117,14 +118,14 @@ namespace Opm { if ((scaledEpsInfo_[c].Sowcr + scaledEpsInfo_[c].Swcr) >= 1.0) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR + SWCR exceed 1.0"; scaled_messages_.push_back(msg); - OpmLog::warning(msg); + OpmLog::warning(tag, msg); counter_.warning += 1; } if ((scaledEpsInfo_[c].Sogcr + scaledEpsInfo_[c].Sgcr + scaledEpsInfo_[c].Swl) >= 1.0) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR + SGCR + SWL exceed 1.0"; scaled_messages_.push_back(msg); - OpmLog::warning(msg); + OpmLog::warning(tag, msg); counter_.warning += 1; } } @@ -133,21 +134,21 @@ namespace Opm { if (scaledEpsInfo_[c].Swl > scaledEpsInfo_[c].Swcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWL > SWCR"; scaled_messages_.push_back(msg); - OpmLog::warning(msg); + OpmLog::warning(tag, msg); counter_.warning += 1; } if (scaledEpsInfo_[c].Swcr > scaledEpsInfo_[c].Sowcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWCR > SOWCR"; scaled_messages_.push_back(msg); - OpmLog::warning(msg); + OpmLog::warning(tag, msg); counter_.warning += 1; } if (scaledEpsInfo_[c].Sowcr > scaledEpsInfo_[c].Swu) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR > SWU"; scaled_messages_.push_back(msg); - OpmLog::warning(msg); + OpmLog::warning(tag, msg); counter_.warning += 1; } } @@ -156,7 +157,7 @@ namespace Opm { if (scaledEpsInfo_[c].Sgl > scaledEpsInfo_[c].Sgcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL > SGCR"; scaled_messages_.push_back(msg); - OpmLog::warning(msg); + OpmLog::warning(tag, msg); counter_.warning += 1; } } @@ -165,14 +166,14 @@ namespace Opm { if (scaledEpsInfo_[c].Sgcr > scaledEpsInfo_[c].Sogcr) { const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGCR > SOGCR"; scaled_messages_.push_back(msg); - OpmLog::warning(msg); + OpmLog::warning(tag, msg); counter_.warning += 1; } if (scaledEpsInfo_[c].Sogcr > scaledEpsInfo_[c].Sgu) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR > SGU"; scaled_messages_.push_back(msg); - OpmLog::warning(msg); + OpmLog::warning(tag, msg); counter_.warning += 1; } } From 78a5afde46383696dc7e9f227f2d5ad0da492336 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Thu, 19 May 2016 09:28:34 +0800 Subject: [PATCH 12/69] remove internal messages container. --- opm/core/props/satfunc/RelpermDiagnostics.cpp | 63 ------------------- opm/core/props/satfunc/RelpermDiagnostics.hpp | 5 -- .../props/satfunc/RelpermDiagnostics_impl.hpp | 39 ------------ 3 files changed, 107 deletions(-) diff --git a/opm/core/props/satfunc/RelpermDiagnostics.cpp b/opm/core/props/satfunc/RelpermDiagnostics.cpp index 9efffa52e..eddbbd853 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.cpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.cpp @@ -37,16 +37,6 @@ namespace Opm{ - - std::vector - RelpermDiagnostics::getMessages() const - { - return messages_; - } - - - - void RelpermDiagnostics::phaseCheck_(DeckConstPtr deck) { bool hasWater = deck->hasKeyword("WATER"); @@ -108,7 +98,6 @@ namespace Opm{ if (family1 && family2) { const std::string msg = "Error: Saturation families should not be mixed.\n Use either SGOF and SWOF or SGFN, SWFN and SOF3."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -117,7 +106,6 @@ namespace Opm{ const std::string msg = "Error, Saturations function must be specified using either \n \ family 1 or family 2 keywords \n \ Use either SGOF and SWOF or SGFN, SWFN and SOF3."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -218,7 +206,6 @@ namespace Opm{ //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SWOF table SATNUM = "+ regionIdx + ", saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -226,13 +213,11 @@ namespace Opm{ //Check krw column. if (krw.front() != 0.0) { const std::string msg = "Error: In SWOF table SATNUM = " + regionIdx + ", first value of krw should be 0."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krw.front() < 0.0 || krw.back() > 1.0) { const std::string msg = "Error: In SWOF table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -240,7 +225,6 @@ namespace Opm{ ///Check krow column. if (krow.front() > 1.0 || krow.back() < 0.0) { const std::string msg = "Error: In SWOF table SATNUM = "+ regionIdx + ", krow should be in range [0, 1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -261,13 +245,11 @@ namespace Opm{ //Check sw column. if (sg.front() < 0.0 || sg.back() > 1.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (sg.front() != 0.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", first value of sg should be 0."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -275,13 +257,11 @@ namespace Opm{ //Check krw column. if (krg.front() != 0.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", first value of krg should be 0."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krg.front() < 0.0 || krg.back() > 1.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -289,7 +269,6 @@ namespace Opm{ //Check krow column. if (krog.front() > 1.0 || krog.back() < 0.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", krog should be in range [0, 1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -307,33 +286,28 @@ namespace Opm{ //TODO first value means sl = swco + sor if (sl.front() < 0.0 || sl.back() > 1.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (sl.back() != 1.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", last value of sl should be 1."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krg.front() > 1.0 || krg.back() < 0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", krg shoule be in range [0, 1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krg.back() != 0.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", last value of krg hould be 0."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krog.front() < 0.0 || krog.back() > 1.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", krog shoule be in range [0, 1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -352,7 +326,6 @@ namespace Opm{ //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -360,14 +333,12 @@ namespace Opm{ //Check krw column. if (krw.front() < 0.0 || krw.back() > 1.0) { const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krw.front() != 0.0) { const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", first value of krw should be 0."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -386,7 +357,6 @@ namespace Opm{ //Check sg column. if (sg.front() < 0.0 || sg.back() > 1.0) { const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -394,13 +364,11 @@ namespace Opm{ //Check krg column. if (krg.front() < 0.0 || krg.back() > 1.0) { const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krg.front() != 0.0) { const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -421,7 +389,6 @@ namespace Opm{ //TODO: The max so = 1 - Swco if (so.front() < 0.0 || so.back() > 1.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -429,13 +396,11 @@ namespace Opm{ //Check krow column. if (krow.front() < 0.0 || krow.back() > 1.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krow.front() != 0.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krow should be 0."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -443,21 +408,18 @@ namespace Opm{ //Check krog column. if (krog.front() < 0.0 || krog.back() > 1.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", krog should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krog.front() != 0.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krog should be 0."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krog.back() != krow.back()) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", max value of krog and krow should be the same."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -477,7 +439,6 @@ namespace Opm{ //TODO: The max so = 1 - Swco if (so.front() < 0.0 || so.back() > 1.0) { const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -485,13 +446,11 @@ namespace Opm{ //Check krow column. if (kro.front() < 0.0 || kro.back() > 1.0) { const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (kro.front() != 0.0) { const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", first value of krow should be 0."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -511,7 +470,6 @@ namespace Opm{ //Check sg column. if (sg.front() < 0.0 || sg.back() > 1.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -519,13 +477,11 @@ namespace Opm{ //Check krg column. if (krg.front() < 0.0 || krg.back() > 1.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krg.front() != 0.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -534,13 +490,11 @@ namespace Opm{ //TODO check saturation sw = 1. - sg if (krgw.front() > 1.0 || krgw.back() < 0.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", krgw should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } if (krgw.back() != 0.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", last value of krgw should be 0."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -557,7 +511,6 @@ namespace Opm{ //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SGCWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -565,7 +518,6 @@ namespace Opm{ //Check critical gas column. if (sgc.front() < 0.0 || sgc.back() > 1.0) { const std::string msg = "Error: In SGCWMIS table SATNUM = " + regionIdx + ", critical gas saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -584,7 +536,6 @@ namespace Opm{ //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SORWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -592,7 +543,6 @@ namespace Opm{ //Check critical oil column. if (sor.front() < 0.0 || sor.back() > 1.0) { const std::string msg = "Error: In SORWMIS table SATNUM = " + regionIdx + ", critical oil saturation should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -611,7 +561,6 @@ namespace Opm{ //Check phase fraction column. if (frac.front() < 0.0 || frac.back() > 1.0) { const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -619,7 +568,6 @@ namespace Opm{ //Check gas relperm multiplier column. if (krgm.front() < 0.0 || krgm.back() > 1.0) { const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", gas relative permeability multiplier should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -627,7 +575,6 @@ namespace Opm{ //Check solvent relperm multiplier column. if (krsm.front() < 0.0 || krsm.back() > 1.0) { const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", solvent relative permeability multiplier should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -648,7 +595,6 @@ namespace Opm{ //Check phase fraction column. if (frac.front() < 0.0 || frac.back() > 1.0) { const std::string msg = "Error: In MISC table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -656,7 +602,6 @@ namespace Opm{ //Check miscibility column. if (misc.front() < 0.0 || misc.back() > 1.0) { const std::string msg = "Error: In MISC table SATNUM = " + regionIdx + ", miscibility should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -677,7 +622,6 @@ namespace Opm{ //Check phase fraction column. if (frac.front() < 0.0 || frac.back() > 1.0) { const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", total gas fraction should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -685,7 +629,6 @@ namespace Opm{ //Check gas_solvent relperm multiplier column. if (krgsm.front() < 0.0 || krgsm.back() > 1.0) { const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", gas+solvent relative permeability multiplier should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -693,7 +636,6 @@ namespace Opm{ //Check oil relperm multiplier column. if (krom.front() > 1.0 || krom.back() < 0.0) { const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", oil relative permeability multiplier should be in range [0,1]."; - messages_.push_back(msg); OpmLog::error(msg); counter_.error += 1; } @@ -723,13 +665,11 @@ namespace Opm{ ///Consistency check. if (unscaledEpsInfo_[satnumIdx].Sgu > (1. - unscaledEpsInfo_[satnumIdx].Swl)) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sgmax should not exceed 1-Swco."; - messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; } if (unscaledEpsInfo_[satnumIdx].Sgl > (1. - unscaledEpsInfo_[satnumIdx].Swu)) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sgco should not exceed 1-Swmax."; - messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; } @@ -763,7 +703,6 @@ namespace Opm{ } if (krow_value != krog_value) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Krow(Somax) should be equal to Krog(Somax)."; - messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; } @@ -772,13 +711,11 @@ namespace Opm{ //Mobile fluid requirements if (((unscaledEpsInfo_[satnumIdx].Sowcr + unscaledEpsInfo_[satnumIdx].Swcr)-1) >= 0) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sowcr + Swcr should be less than 1."; - messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; } if (((unscaledEpsInfo_[satnumIdx].Sogcr + unscaledEpsInfo_[satnumIdx].Sgcr + unscaledEpsInfo_[satnumIdx].Swl) - 1 ) > 0) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sogcr + Sgcr + Swco should be less than 1."; - messages_.push_back(msg); OpmLog::warning(msg); counter_.warning += 1; } diff --git a/opm/core/props/satfunc/RelpermDiagnostics.hpp b/opm/core/props/satfunc/RelpermDiagnostics.hpp index 191998582..af4df2bb4 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.hpp @@ -62,8 +62,6 @@ namespace Opm { DeckConstPtr deck, const GridT& grid); - std::vector getMessages() const; - private: enum FluidSystem { OilWater, @@ -96,9 +94,6 @@ namespace Opm { std::vector > unscaledEpsInfo_; std::vector > scaledEpsInfo_; - std::vector messages_; - ///Store scaled information. - std::vector scaled_messages_; ///Check the phase that used. void phaseCheck_(DeckConstPtr deck); diff --git a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp index 188b400f9..84783d87b 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -39,35 +39,6 @@ namespace Opm { tableCheck_(eclState, deck); unscaledEndPointsCheck_(deck, eclState); scaledEndPointsCheck_(deck, eclState, grid); - if (!messages_.empty()) { - std::sort(messages_.begin(), messages_.end()); - auto it = std::unique(messages_.begin(), messages_.end()); - messages_.erase(it, messages_.end()); - std::cout << std::endl; - for (const auto& x : messages_) { - std::cout << x << std::endl; - } - } - int limits = 0; - if (!scaled_messages_.empty()) { - std::cout << std::endl; - for (const auto& x : scaled_messages_) { - if (limits < 10) { - std::cout << x << std::endl; - limits++; - } else { - std::cout << "\nMore inconsistencies exist. Check saturation function input and .SATFUNCLOG file!" << std::endl; - break; - } - } - } - - const std::string summary_msg = "\n\nError summary:" + - std::string("\nWarnings " + std::to_string(counter_.warning)) + - std::string("\nProblems " + std::to_string(counter_.problem)) + - std::string("\nErrors " + std::to_string(counter_.error)) + - std::string("\nBugs " + std::to_string(counter_.bug))+ "\n"; - std::cout << summary_msg << std::endl; } template @@ -100,7 +71,6 @@ namespace Opm { // SGU <= 1.0 - SWL if (scaledEpsInfo_[c].Sgu > (1.0 - scaledEpsInfo_[c].Swl)) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGU exceed 1.0 - SWL"; - scaled_messages_.push_back(msg); OpmLog::warning(tag, msg); counter_.warning += 1; } @@ -108,7 +78,6 @@ namespace Opm { // SGL <= 1.0 - SWU if (scaledEpsInfo_[c].Sgl > (1.0 - scaledEpsInfo_[c].Swu)) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL exceed 1.0 - SWU"; - scaled_messages_.push_back(msg); OpmLog::warning(tag, msg); counter_.warning += 1; } @@ -117,14 +86,12 @@ namespace Opm { // Mobilility check. if ((scaledEpsInfo_[c].Sowcr + scaledEpsInfo_[c].Swcr) >= 1.0) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR + SWCR exceed 1.0"; - scaled_messages_.push_back(msg); OpmLog::warning(tag, msg); counter_.warning += 1; } if ((scaledEpsInfo_[c].Sogcr + scaledEpsInfo_[c].Sgcr + scaledEpsInfo_[c].Swl) >= 1.0) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR + SGCR + SWL exceed 1.0"; - scaled_messages_.push_back(msg); OpmLog::warning(tag, msg); counter_.warning += 1; } @@ -133,21 +100,18 @@ namespace Opm { if (fluidSystem_ != FluidSystem::WaterGas) { if (scaledEpsInfo_[c].Swl > scaledEpsInfo_[c].Swcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWL > SWCR"; - scaled_messages_.push_back(msg); OpmLog::warning(tag, msg); counter_.warning += 1; } if (scaledEpsInfo_[c].Swcr > scaledEpsInfo_[c].Sowcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWCR > SOWCR"; - scaled_messages_.push_back(msg); OpmLog::warning(tag, msg); counter_.warning += 1; } if (scaledEpsInfo_[c].Sowcr > scaledEpsInfo_[c].Swu) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR > SWU"; - scaled_messages_.push_back(msg); OpmLog::warning(tag, msg); counter_.warning += 1; } @@ -156,7 +120,6 @@ namespace Opm { if (fluidSystem_ != FluidSystem::OilWater) { if (scaledEpsInfo_[c].Sgl > scaledEpsInfo_[c].Sgcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL > SGCR"; - scaled_messages_.push_back(msg); OpmLog::warning(tag, msg); counter_.warning += 1; } @@ -165,14 +128,12 @@ namespace Opm { if (fluidSystem_ != FluidSystem::BlackOil) { if (scaledEpsInfo_[c].Sgcr > scaledEpsInfo_[c].Sogcr) { const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGCR > SOGCR"; - scaled_messages_.push_back(msg); OpmLog::warning(tag, msg); counter_.warning += 1; } if (scaledEpsInfo_[c].Sogcr > scaledEpsInfo_[c].Sgu) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR > SGU"; - scaled_messages_.push_back(msg); OpmLog::warning(tag, msg); counter_.warning += 1; } From 8564c7b6e9770a9c4d8f52b509775cd2bae4cdef Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Thu, 19 May 2016 09:47:57 +0800 Subject: [PATCH 13/69] remove internal counter. --- opm/core/props/satfunc/RelpermDiagnostics.cpp | 73 ------------------- opm/core/props/satfunc/RelpermDiagnostics.hpp | 10 --- .../props/satfunc/RelpermDiagnostics_impl.hpp | 10 --- tests/test_relpermdiagnostics.cpp | 12 +-- 4 files changed, 4 insertions(+), 101 deletions(-) diff --git a/opm/core/props/satfunc/RelpermDiagnostics.cpp b/opm/core/props/satfunc/RelpermDiagnostics.cpp index eddbbd853..d0396ad51 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.cpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.cpp @@ -24,19 +24,6 @@ namespace Opm{ - - RelpermDiagnostics::Counter::Counter() - :error(0) - ,warning(0) - ,problem(0) - ,bug(0) - { - } - - - - - void RelpermDiagnostics::phaseCheck_(DeckConstPtr deck) { bool hasWater = deck->hasKeyword("WATER"); @@ -46,31 +33,26 @@ namespace Opm{ if (hasWater && hasGas && !hasOil && !hasSolvent) { const std::string msg = "System: Water-Gas system."; - std::cout << msg << std::endl; OpmLog::info(msg); fluidSystem_ = FluidSystem::WaterGas; } if (hasWater && hasOil && !hasGas && !hasSolvent) { const std::string msg = "System: Oil-Water system."; - std::cout << msg << std::endl; OpmLog::info(msg); fluidSystem_ = FluidSystem::OilWater; } if (hasOil && hasGas && !hasWater && !hasSolvent) { const std::string msg = "System: Oil-Gas system."; - std::cout << msg << std::endl; OpmLog::info(msg); fluidSystem_ = FluidSystem::OilGas; } if (hasOil && hasWater && hasGas && !hasSolvent) { const std::string msg = "System: Black-oil system."; - std::cout << msg << std::endl; OpmLog::info(msg); fluidSystem_ = FluidSystem::BlackOil; } if (hasSolvent) { const std::string msg = "System: Solvent model."; - std::cout << msg << std::endl; OpmLog::info(msg); fluidSystem_ = FluidSystem::Solvent; } @@ -99,7 +81,6 @@ namespace Opm{ if (family1 && family2) { const std::string msg = "Error: Saturation families should not be mixed.\n Use either SGOF and SWOF or SGFN, SWFN and SOF3."; OpmLog::error(msg); - counter_.error += 1; } if (!family1 && !family2) { @@ -107,19 +88,16 @@ namespace Opm{ family 1 or family 2 keywords \n \ Use either SGOF and SWOF or SGFN, SWFN and SOF3."; OpmLog::error(msg); - counter_.error += 1; } if (family1 && !family2) { satFamily_ = SaturationFunctionFamily::FamilyI; const std::string msg = "Relative permeability input format: Saturation Family I."; - std::cout << msg << std::endl; OpmLog::info(msg); } if (!family1 && family2) { satFamily_ = SaturationFunctionFamily::FamilyII; const std::string msg = "Relative permeability input format: Saturation Family II."; - std::cout << msg << std::endl; OpmLog::info(msg); } } @@ -207,26 +185,22 @@ namespace Opm{ if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SWOF table SATNUM = "+ regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //TODO check endpoint sw.back() == 1. - Sor. //Check krw column. if (krw.front() != 0.0) { const std::string msg = "Error: In SWOF table SATNUM = " + regionIdx + ", first value of krw should be 0."; OpmLog::error(msg); - counter_.error += 1; } if (krw.front() < 0.0 || krw.back() > 1.0) { const std::string msg = "Error: In SWOF table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } ///Check krow column. if (krow.front() > 1.0 || krow.back() < 0.0) { const std::string msg = "Error: In SWOF table SATNUM = "+ regionIdx + ", krow should be in range [0, 1]."; OpmLog::error(msg); - counter_.error += 1; } ///TODO check if run with gas. } @@ -246,31 +220,26 @@ namespace Opm{ if (sg.front() < 0.0 || sg.back() > 1.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (sg.front() != 0.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", first value of sg should be 0."; OpmLog::error(msg); - counter_.error += 1; } //TODO check endpoint sw.back() == 1. - Sor. //Check krw column. if (krg.front() != 0.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", first value of krg should be 0."; OpmLog::error(msg); - counter_.error += 1; } if (krg.front() < 0.0 || krg.back() > 1.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krow column. if (krog.front() > 1.0 || krog.back() < 0.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", krog should be in range [0, 1]."; OpmLog::error(msg); - counter_.error += 1; } //TODO check if run with water. } @@ -287,29 +256,24 @@ namespace Opm{ if (sl.front() < 0.0 || sl.back() > 1.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (sl.back() != 1.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", last value of sl should be 1."; OpmLog::error(msg); - counter_.error += 1; } if (krg.front() > 1.0 || krg.back() < 0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", krg shoule be in range [0, 1]."; OpmLog::error(msg); - counter_.error += 1; } if (krg.back() != 0.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", last value of krg hould be 0."; OpmLog::error(msg); - counter_.error += 1; } if (krog.front() < 0.0 || krog.back() > 1.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", krog shoule be in range [0, 1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -327,20 +291,17 @@ namespace Opm{ if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krw column. if (krw.front() < 0.0 || krw.back() > 1.0) { const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krw.front() != 0.0) { const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", first value of krw should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -358,19 +319,16 @@ namespace Opm{ if (sg.front() < 0.0 || sg.back() > 1.0) { const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krg column. if (krg.front() < 0.0 || krg.back() > 1.0) { const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krg.front() != 0.0) { const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -390,38 +348,32 @@ namespace Opm{ if (so.front() < 0.0 || so.back() > 1.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krow column. if (krow.front() < 0.0 || krow.back() > 1.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krow.front() != 0.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krow should be 0."; OpmLog::error(msg); - counter_.error += 1; } //Check krog column. if (krog.front() < 0.0 || krog.back() > 1.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", krog should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krog.front() != 0.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krog should be 0."; OpmLog::error(msg); - counter_.error += 1; } if (krog.back() != krow.back()) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", max value of krog and krow should be the same."; OpmLog::error(msg); - counter_.error += 1; } } @@ -440,19 +392,16 @@ namespace Opm{ if (so.front() < 0.0 || so.back() > 1.0) { const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krow column. if (kro.front() < 0.0 || kro.back() > 1.0) { const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (kro.front() != 0.0) { const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", first value of krow should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -471,19 +420,16 @@ namespace Opm{ if (sg.front() < 0.0 || sg.back() > 1.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krg column. if (krg.front() < 0.0 || krg.back() > 1.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krg.front() != 0.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; OpmLog::error(msg); - counter_.error += 1; } //Check krgw column. @@ -491,12 +437,10 @@ namespace Opm{ if (krgw.front() > 1.0 || krgw.back() < 0.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", krgw should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krgw.back() != 0.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", last value of krgw should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -512,14 +456,12 @@ namespace Opm{ if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SGCWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check critical gas column. if (sgc.front() < 0.0 || sgc.back() > 1.0) { const std::string msg = "Error: In SGCWMIS table SATNUM = " + regionIdx + ", critical gas saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -537,14 +479,12 @@ namespace Opm{ if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SORWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check critical oil column. if (sor.front() < 0.0 || sor.back() > 1.0) { const std::string msg = "Error: In SORWMIS table SATNUM = " + regionIdx + ", critical oil saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -562,21 +502,18 @@ namespace Opm{ if (frac.front() < 0.0 || frac.back() > 1.0) { const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check gas relperm multiplier column. if (krgm.front() < 0.0 || krgm.back() > 1.0) { const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", gas relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check solvent relperm multiplier column. if (krsm.front() < 0.0 || krsm.back() > 1.0) { const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", solvent relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -596,14 +533,12 @@ namespace Opm{ if (frac.front() < 0.0 || frac.back() > 1.0) { const std::string msg = "Error: In MISC table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check miscibility column. if (misc.front() < 0.0 || misc.back() > 1.0) { const std::string msg = "Error: In MISC table SATNUM = " + regionIdx + ", miscibility should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -623,21 +558,18 @@ namespace Opm{ if (frac.front() < 0.0 || frac.back() > 1.0) { const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", total gas fraction should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check gas_solvent relperm multiplier column. if (krgsm.front() < 0.0 || krgsm.back() > 1.0) { const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", gas+solvent relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check oil relperm multiplier column. if (krom.front() > 1.0 || krom.back() < 0.0) { const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", oil relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -666,12 +598,10 @@ namespace Opm{ if (unscaledEpsInfo_[satnumIdx].Sgu > (1. - unscaledEpsInfo_[satnumIdx].Swl)) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sgmax should not exceed 1-Swco."; OpmLog::warning(msg); - counter_.warning += 1; } if (unscaledEpsInfo_[satnumIdx].Sgl > (1. - unscaledEpsInfo_[satnumIdx].Swu)) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sgco should not exceed 1-Swmax."; OpmLog::warning(msg); - counter_.warning += 1; } //Krow(Sou) == Krog(Sou) for three-phase @@ -704,7 +634,6 @@ namespace Opm{ if (krow_value != krog_value) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Krow(Somax) should be equal to Krog(Somax)."; OpmLog::warning(msg); - counter_.warning += 1; } } //Krw(Sw=0)=Krg(Sg=0)=Krow(So=0)=Krog(So=0)=0. @@ -712,12 +641,10 @@ namespace Opm{ if (((unscaledEpsInfo_[satnumIdx].Sowcr + unscaledEpsInfo_[satnumIdx].Swcr)-1) >= 0) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sowcr + Swcr should be less than 1."; OpmLog::warning(msg); - counter_.warning += 1; } if (((unscaledEpsInfo_[satnumIdx].Sogcr + unscaledEpsInfo_[satnumIdx].Sgcr + unscaledEpsInfo_[satnumIdx].Swl) - 1 ) > 0) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sogcr + Sgcr + Swco should be less than 1."; OpmLog::warning(msg); - counter_.warning += 1; } } } diff --git a/opm/core/props/satfunc/RelpermDiagnostics.hpp b/opm/core/props/satfunc/RelpermDiagnostics.hpp index af4df2bb4..cb5cf138f 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.hpp @@ -81,16 +81,6 @@ namespace Opm { SaturationFunctionFamily satFamily_; - struct Counter { - Counter(); - int error; - int warning; - int problem; - int bug; - }; - - Counter counter_; - std::vector > unscaledEpsInfo_; std::vector > scaledEpsInfo_; diff --git a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp index 84783d87b..65cb846db 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -72,14 +72,12 @@ namespace Opm { if (scaledEpsInfo_[c].Sgu > (1.0 - scaledEpsInfo_[c].Swl)) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGU exceed 1.0 - SWL"; OpmLog::warning(tag, msg); - counter_.warning += 1; } // SGL <= 1.0 - SWU if (scaledEpsInfo_[c].Sgl > (1.0 - scaledEpsInfo_[c].Swu)) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL exceed 1.0 - SWU"; OpmLog::warning(tag, msg); - counter_.warning += 1; } if (deck->hasKeyword("SCALECRS") && fluidSystem_ == FluidSystem::BlackOil) { @@ -87,13 +85,11 @@ namespace Opm { if ((scaledEpsInfo_[c].Sowcr + scaledEpsInfo_[c].Swcr) >= 1.0) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR + SWCR exceed 1.0"; OpmLog::warning(tag, msg); - counter_.warning += 1; } if ((scaledEpsInfo_[c].Sogcr + scaledEpsInfo_[c].Sgcr + scaledEpsInfo_[c].Swl) >= 1.0) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR + SGCR + SWL exceed 1.0"; OpmLog::warning(tag, msg); - counter_.warning += 1; } } ///Following rules come from NEXUS. @@ -101,19 +97,16 @@ namespace Opm { if (scaledEpsInfo_[c].Swl > scaledEpsInfo_[c].Swcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWL > SWCR"; OpmLog::warning(tag, msg); - counter_.warning += 1; } if (scaledEpsInfo_[c].Swcr > scaledEpsInfo_[c].Sowcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWCR > SOWCR"; OpmLog::warning(tag, msg); - counter_.warning += 1; } if (scaledEpsInfo_[c].Sowcr > scaledEpsInfo_[c].Swu) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR > SWU"; OpmLog::warning(tag, msg); - counter_.warning += 1; } } @@ -121,7 +114,6 @@ namespace Opm { if (scaledEpsInfo_[c].Sgl > scaledEpsInfo_[c].Sgcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL > SGCR"; OpmLog::warning(tag, msg); - counter_.warning += 1; } } @@ -129,13 +121,11 @@ namespace Opm { if (scaledEpsInfo_[c].Sgcr > scaledEpsInfo_[c].Sogcr) { const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGCR > SOGCR"; OpmLog::warning(tag, msg); - counter_.warning += 1; } if (scaledEpsInfo_[c].Sogcr > scaledEpsInfo_[c].Sgu) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR > SGU"; OpmLog::warning(tag, msg); - counter_.warning += 1; } } } diff --git a/tests/test_relpermdiagnostics.cpp b/tests/test_relpermdiagnostics.cpp index ae9c285e3..553606e42 100644 --- a/tests/test_relpermdiagnostics.cpp +++ b/tests/test_relpermdiagnostics.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -58,16 +58,12 @@ BOOST_AUTO_TEST_CASE(diagnosis) }); Opm::DeckConstPtr deck(parser->parseFile("../tests/relpermDiagnostics.DATA", parseContext)); eclState.reset(new EclipseState(deck, parseContext)); - GridManager gm(eclState->getInputGrid()); const UnstructuredGrid& grid = *gm.c_grid(); - std::string logFile = "LOGFILE.txt"; - std::shared_ptr prtLog = std::make_shared(logFile, Log::DefaultMessageTypes); - OpmLog::addBackend( "ECLIPSEPRTLOG" , prtLog ); + std::shared_ptr counterLog = std::make_shared(Log::DefaultMessageTypes); + OpmLog::addBackend( "COUNTERLOG" , counterLog ); RelpermDiagnostics diagnostics; diagnostics.diagnosis(eclState, deck, grid); - auto msg = diagnostics.getMessages(); - BOOST_CHECK(!msg.empty()); - BOOST_CHECK_EQUAL(msg.size(), 1); + BOOST_CHECK_EQUAL(1, counterLog->numMessages(Log::MessageType::Warning)); } BOOST_AUTO_TEST_SUITE_END() From 568101a373a04941621a187ecc995bc170c5046b Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Thu, 19 May 2016 09:48:12 +0800 Subject: [PATCH 14/69] use StreamLog to output messages. --- examples/diagnose_relperm.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/diagnose_relperm.cpp b/examples/diagnose_relperm.cpp index 6de6a9489..b0c26eda1 100644 --- a/examples/diagnose_relperm.cpp +++ b/examples/diagnose_relperm.cpp @@ -92,6 +92,9 @@ try std::string logFile = baseName + ".SATFUNCLOG"; std::shared_ptr prtLog = std::make_shared(logFile, Log::DefaultMessageTypes); OpmLog::addBackend( "ECLIPSEPRTLOG" , prtLog ); + std::shared_ptr streamLog = std::make_shared(std::cout, Log::DefaultMessageTypes); + OpmLog::addBackend( "STREAMLOG" , streamLog ); + streamLog->setMessageLimiter(std::make_shared(10)); Opm::time::StopWatch timer; timer.start(); RelpermDiagnostics diagnostic; From 3e3c028581760e1add02869898a37e1c50203bdb Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Thu, 19 May 2016 10:07:36 +0800 Subject: [PATCH 15/69] remove the prefix from raw string, using OpmLog format. --- examples/diagnose_relperm.cpp | 7 +- opm/core/props/satfunc/RelpermDiagnostics.cpp | 101 +++++++++--------- .../props/satfunc/RelpermDiagnostics_impl.hpp | 22 ++-- 3 files changed, 63 insertions(+), 67 deletions(-) diff --git a/examples/diagnose_relperm.cpp b/examples/diagnose_relperm.cpp index b0c26eda1..20d6828dd 100644 --- a/examples/diagnose_relperm.cpp +++ b/examples/diagnose_relperm.cpp @@ -92,16 +92,13 @@ try std::string logFile = baseName + ".SATFUNCLOG"; std::shared_ptr prtLog = std::make_shared(logFile, Log::DefaultMessageTypes); OpmLog::addBackend( "ECLIPSEPRTLOG" , prtLog ); + prtLog->setMessageFormatter(std::make_shared(true, false)); std::shared_ptr streamLog = std::make_shared(std::cout, Log::DefaultMessageTypes); OpmLog::addBackend( "STREAMLOG" , streamLog ); streamLog->setMessageLimiter(std::make_shared(10)); - Opm::time::StopWatch timer; - timer.start(); + streamLog->setMessageFormatter(std::make_shared(true, true)); RelpermDiagnostics diagnostic; diagnostic.diagnosis(eclState, deck, grid); - timer.stop(); - double tt = timer.secsSinceStart(); - std::cout << "relperm diagnostics: " << tt << " seconds." << std::endl; } catch (const std::exception &e) { std::cerr << "Program threw an exception: " << e.what() << "\n"; diff --git a/opm/core/props/satfunc/RelpermDiagnostics.cpp b/opm/core/props/satfunc/RelpermDiagnostics.cpp index d0396ad51..40713f245 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.cpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.cpp @@ -79,12 +79,12 @@ namespace Opm{ bool family2 = ((!swfnTables.empty() && !sgfnTables.empty()) || !sgwfnTables.empty()) && (!sof3Tables.empty() || !sof2Tables.empty()); if (family1 && family2) { - const std::string msg = "Error: Saturation families should not be mixed.\n Use either SGOF and SWOF or SGFN, SWFN and SOF3."; + const std::string msg = "Saturation families should not be mixed.\n Use either SGOF and SWOF or SGFN, SWFN and SOF3."; OpmLog::error(msg); } if (!family1 && !family2) { - const std::string msg = "Error, Saturations function must be specified using either \n \ + const std::string msg = "Saturations function must be specified using either \n \ family 1 or family 2 keywords \n \ Use either SGOF and SWOF or SGFN, SWFN and SOF3."; OpmLog::error(msg); @@ -110,7 +110,6 @@ namespace Opm{ { const int numSatRegions = deck->getKeyword("TABDIMS").getRecord(0).getItem("NTSFUN").get< int >(0); const std::string msg = "Number of saturation regions: " + std::to_string(numSatRegions) + "\n"; - std::cout << msg << std::endl; OpmLog::info(msg); const auto& tableManager = eclState->getTableManager(); const TableContainer& swofTables = tableManager.getSwofTables(); @@ -183,23 +182,23 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { - const std::string msg = "Error: In SWOF table SATNUM = "+ regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "In SWOF table SATNUM = "+ regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); } //TODO check endpoint sw.back() == 1. - Sor. //Check krw column. if (krw.front() != 0.0) { - const std::string msg = "Error: In SWOF table SATNUM = " + regionIdx + ", first value of krw should be 0."; + const std::string msg = "In SWOF table SATNUM = " + regionIdx + ", first value of krw should be 0."; OpmLog::error(msg); } if (krw.front() < 0.0 || krw.back() > 1.0) { - const std::string msg = "Error: In SWOF table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; + const std::string msg = "In SWOF table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; OpmLog::error(msg); } ///Check krow column. if (krow.front() > 1.0 || krow.back() < 0.0) { - const std::string msg = "Error: In SWOF table SATNUM = "+ regionIdx + ", krow should be in range [0, 1]."; + const std::string msg = "In SWOF table SATNUM = "+ regionIdx + ", krow should be in range [0, 1]."; OpmLog::error(msg); } ///TODO check if run with gas. @@ -218,27 +217,27 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. if (sg.front() < 0.0 || sg.back() > 1.0) { - const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "In SGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); } if (sg.front() != 0.0) { - const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", first value of sg should be 0."; + const std::string msg = "In SGOF table SATNUM = " + regionIdx + ", first value of sg should be 0."; OpmLog::error(msg); } //TODO check endpoint sw.back() == 1. - Sor. //Check krw column. if (krg.front() != 0.0) { - const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", first value of krg should be 0."; + const std::string msg = "In SGOF table SATNUM = " + regionIdx + ", first value of krg should be 0."; OpmLog::error(msg); } if (krg.front() < 0.0 || krg.back() > 1.0) { - const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; + const std::string msg = "In SGOF table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; OpmLog::error(msg); } //Check krow column. if (krog.front() > 1.0 || krog.back() < 0.0) { - const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", krog should be in range [0, 1]."; + const std::string msg = "In SGOF table SATNUM = " + regionIdx + ", krog should be in range [0, 1]."; OpmLog::error(msg); } //TODO check if run with water. @@ -254,25 +253,25 @@ namespace Opm{ //Check sl column. //TODO first value means sl = swco + sor if (sl.front() < 0.0 || sl.back() > 1.0) { - const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "In SLGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); } if (sl.back() != 1.0) { - const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", last value of sl should be 1."; + const std::string msg = "In SLGOF table SATNUM = " + regionIdx + ", last value of sl should be 1."; OpmLog::error(msg); } if (krg.front() > 1.0 || krg.back() < 0) { - const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", krg shoule be in range [0, 1]."; + const std::string msg = "In SLGOF table SATNUM = " + regionIdx + ", krg shoule be in range [0, 1]."; OpmLog::error(msg); } if (krg.back() != 0.0) { - const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", last value of krg hould be 0."; + const std::string msg = "In SLGOF table SATNUM = " + regionIdx + ", last value of krg hould be 0."; OpmLog::error(msg); } if (krog.front() < 0.0 || krog.back() > 1.0) { - const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", krog shoule be in range [0, 1]."; + const std::string msg = "In SLGOF table SATNUM = " + regionIdx + ", krog shoule be in range [0, 1]."; OpmLog::error(msg); } } @@ -289,18 +288,18 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { - const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "In SWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); } //Check krw column. if (krw.front() < 0.0 || krw.back() > 1.0) { - const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; + const std::string msg = "In SWFN table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; OpmLog::error(msg); } if (krw.front() != 0.0) { - const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", first value of krw should be 0."; + const std::string msg = "In SWFN table SATNUM = " + regionIdx + ", first value of krw should be 0."; OpmLog::error(msg); } } @@ -346,33 +345,33 @@ namespace Opm{ //Check so column. //TODO: The max so = 1 - Swco if (so.front() < 0.0 || so.back() > 1.0) { - const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "In SOF3 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); } //Check krow column. if (krow.front() < 0.0 || krow.back() > 1.0) { - const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; + const std::string msg = "In SOF3 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; OpmLog::error(msg); } if (krow.front() != 0.0) { - const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krow should be 0."; + const std::string msg = "In SOF3 table SATNUM = " + regionIdx + ", first value of krow should be 0."; OpmLog::error(msg); } //Check krog column. if (krog.front() < 0.0 || krog.back() > 1.0) { - const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", krog should be in range [0,1]."; + const std::string msg = "In SOF3 table SATNUM = " + regionIdx + ", krog should be in range [0,1]."; OpmLog::error(msg); } if (krog.front() != 0.0) { - const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krog should be 0."; + const std::string msg = "In SOF3 table SATNUM = " + regionIdx + ", first value of krog should be 0."; OpmLog::error(msg); } if (krog.back() != krow.back()) { - const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", max value of krog and krow should be the same."; + const std::string msg = "In SOF3 table SATNUM = " + regionIdx + ", max value of krog and krow should be the same."; OpmLog::error(msg); } } @@ -390,17 +389,17 @@ namespace Opm{ //Check so column. //TODO: The max so = 1 - Swco if (so.front() < 0.0 || so.back() > 1.0) { - const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "In SOF2 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); } //Check krow column. if (kro.front() < 0.0 || kro.back() > 1.0) { - const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; + const std::string msg = "In SOF2 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; OpmLog::error(msg); } if (kro.front() != 0.0) { - const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", first value of krow should be 0."; + const std::string msg = "In SOF2 table SATNUM = " + regionIdx + ", first value of krow should be 0."; OpmLog::error(msg); } } @@ -418,28 +417,28 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sg column. if (sg.front() < 0.0 || sg.back() > 1.0) { - const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "In SGWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); } //Check krg column. if (krg.front() < 0.0 || krg.back() > 1.0) { - const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; + const std::string msg = "In SGWFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; OpmLog::error(msg); } if (krg.front() != 0.0) { - const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; + const std::string msg = "In SGWFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; OpmLog::error(msg); } //Check krgw column. //TODO check saturation sw = 1. - sg if (krgw.front() > 1.0 || krgw.back() < 0.0) { - const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", krgw should be in range [0,1]."; + const std::string msg = "In SGWFN table SATNUM = " + regionIdx + ", krgw should be in range [0,1]."; OpmLog::error(msg); } if (krgw.back() != 0.0) { - const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", last value of krgw should be 0."; + const std::string msg = "In SGWFN table SATNUM = " + regionIdx + ", last value of krgw should be 0."; OpmLog::error(msg); } } @@ -454,13 +453,13 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { - const std::string msg = "Error: In SGCWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "In SGCWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); } //Check critical gas column. if (sgc.front() < 0.0 || sgc.back() > 1.0) { - const std::string msg = "Error: In SGCWMIS table SATNUM = " + regionIdx + ", critical gas saturation should be in range [0,1]."; + const std::string msg = "In SGCWMIS table SATNUM = " + regionIdx + ", critical gas saturation should be in range [0,1]."; OpmLog::error(msg); } } @@ -477,13 +476,13 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. if (sw.front() < 0.0 || sw.back() > 1.0) { - const std::string msg = "Error: In SORWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "In SORWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); } //Check critical oil column. if (sor.front() < 0.0 || sor.back() > 1.0) { - const std::string msg = "Error: In SORWMIS table SATNUM = " + regionIdx + ", critical oil saturation should be in range [0,1]."; + const std::string msg = "In SORWMIS table SATNUM = " + regionIdx + ", critical oil saturation should be in range [0,1]."; OpmLog::error(msg); } } @@ -500,19 +499,19 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check phase fraction column. if (frac.front() < 0.0 || frac.back() > 1.0) { - const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; + const std::string msg = "In SSFN table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; OpmLog::error(msg); } //Check gas relperm multiplier column. if (krgm.front() < 0.0 || krgm.back() > 1.0) { - const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", gas relative permeability multiplier should be in range [0,1]."; + const std::string msg = "In SSFN table SATNUM = " + regionIdx + ", gas relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); } //Check solvent relperm multiplier column. if (krsm.front() < 0.0 || krsm.back() > 1.0) { - const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", solvent relative permeability multiplier should be in range [0,1]."; + const std::string msg = "In SSFN table SATNUM = " + regionIdx + ", solvent relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); } } @@ -531,13 +530,13 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check phase fraction column. if (frac.front() < 0.0 || frac.back() > 1.0) { - const std::string msg = "Error: In MISC table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; + const std::string msg = "In MISC table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; OpmLog::error(msg); } //Check miscibility column. if (misc.front() < 0.0 || misc.back() > 1.0) { - const std::string msg = "Error: In MISC table SATNUM = " + regionIdx + ", miscibility should be in range [0,1]."; + const std::string msg = "In MISC table SATNUM = " + regionIdx + ", miscibility should be in range [0,1]."; OpmLog::error(msg); } } @@ -556,19 +555,19 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check phase fraction column. if (frac.front() < 0.0 || frac.back() > 1.0) { - const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", total gas fraction should be in range [0,1]."; + const std::string msg = "In MSFN table SATNUM = " + regionIdx + ", total gas fraction should be in range [0,1]."; OpmLog::error(msg); } //Check gas_solvent relperm multiplier column. if (krgsm.front() < 0.0 || krgsm.back() > 1.0) { - const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", gas+solvent relative permeability multiplier should be in range [0,1]."; + const std::string msg = "In MSFN table SATNUM = " + regionIdx + ", gas+solvent relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); } //Check oil relperm multiplier column. if (krom.front() > 1.0 || krom.back() < 0.0) { - const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", oil relative permeability multiplier should be in range [0,1]."; + const std::string msg = "In MSFN table SATNUM = " + regionIdx + ", oil relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); } } @@ -596,11 +595,11 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx + 1); ///Consistency check. if (unscaledEpsInfo_[satnumIdx].Sgu > (1. - unscaledEpsInfo_[satnumIdx].Swl)) { - const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sgmax should not exceed 1-Swco."; + const std::string msg = "In saturation table SATNUM = " + regionIdx + ", Sgmax should not exceed 1-Swco."; OpmLog::warning(msg); } if (unscaledEpsInfo_[satnumIdx].Sgl > (1. - unscaledEpsInfo_[satnumIdx].Swu)) { - const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sgco should not exceed 1-Swmax."; + const std::string msg = "In saturation table SATNUM = " + regionIdx + ", Sgco should not exceed 1-Swmax."; OpmLog::warning(msg); } @@ -632,18 +631,18 @@ namespace Opm{ krog_value = table.evaluate("KROG" , Sou); } if (krow_value != krog_value) { - const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Krow(Somax) should be equal to Krog(Somax)."; + const std::string msg = "In saturation table SATNUM = " + regionIdx + ", Krow(Somax) should be equal to Krog(Somax)."; OpmLog::warning(msg); } } //Krw(Sw=0)=Krg(Sg=0)=Krow(So=0)=Krog(So=0)=0. //Mobile fluid requirements if (((unscaledEpsInfo_[satnumIdx].Sowcr + unscaledEpsInfo_[satnumIdx].Swcr)-1) >= 0) { - const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sowcr + Swcr should be less than 1."; + const std::string msg = "In saturation table SATNUM = " + regionIdx + ", Sowcr + Swcr should be less than 1."; OpmLog::warning(msg); } if (((unscaledEpsInfo_[satnumIdx].Sogcr + unscaledEpsInfo_[satnumIdx].Sgcr + unscaledEpsInfo_[satnumIdx].Swl) - 1 ) > 0) { - const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sogcr + Sgcr + Swco should be less than 1."; + const std::string msg = "In saturation table SATNUM = " + regionIdx + ", Sogcr + Sgcr + Swco should be less than 1."; OpmLog::warning(msg); } } diff --git a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp index 65cb846db..4e0d01669 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -33,7 +33,7 @@ namespace Opm { Opm::DeckConstPtr deck, const GridT& grid) { - std::cout << "\n\n***************Saturation Functions Diagnostics***************\n\n"; + OpmLog::info("***************Saturation Functions Diagnostics***************"); phaseCheck_(deck); satFamilyCheck_(eclState); tableCheck_(eclState, deck); @@ -70,61 +70,61 @@ namespace Opm { // SGU <= 1.0 - SWL if (scaledEpsInfo_[c].Sgu > (1.0 - scaledEpsInfo_[c].Swl)) { - const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGU exceed 1.0 - SWL"; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGU exceed 1.0 - SWL"; OpmLog::warning(tag, msg); } // SGL <= 1.0 - SWU if (scaledEpsInfo_[c].Sgl > (1.0 - scaledEpsInfo_[c].Swu)) { - const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL exceed 1.0 - SWU"; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL exceed 1.0 - SWU"; OpmLog::warning(tag, msg); } if (deck->hasKeyword("SCALECRS") && fluidSystem_ == FluidSystem::BlackOil) { // Mobilility check. if ((scaledEpsInfo_[c].Sowcr + scaledEpsInfo_[c].Swcr) >= 1.0) { - const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR + SWCR exceed 1.0"; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR + SWCR exceed 1.0"; OpmLog::warning(tag, msg); } if ((scaledEpsInfo_[c].Sogcr + scaledEpsInfo_[c].Sgcr + scaledEpsInfo_[c].Swl) >= 1.0) { - const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR + SGCR + SWL exceed 1.0"; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR + SGCR + SWL exceed 1.0"; OpmLog::warning(tag, msg); } } ///Following rules come from NEXUS. if (fluidSystem_ != FluidSystem::WaterGas) { if (scaledEpsInfo_[c].Swl > scaledEpsInfo_[c].Swcr) { - const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWL > SWCR"; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWL > SWCR"; OpmLog::warning(tag, msg); } if (scaledEpsInfo_[c].Swcr > scaledEpsInfo_[c].Sowcr) { - const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWCR > SOWCR"; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWCR > SOWCR"; OpmLog::warning(tag, msg); } if (scaledEpsInfo_[c].Sowcr > scaledEpsInfo_[c].Swu) { - const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR > SWU"; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR > SWU"; OpmLog::warning(tag, msg); } } if (fluidSystem_ != FluidSystem::OilWater) { if (scaledEpsInfo_[c].Sgl > scaledEpsInfo_[c].Sgcr) { - const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL > SGCR"; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL > SGCR"; OpmLog::warning(tag, msg); } } if (fluidSystem_ != FluidSystem::BlackOil) { if (scaledEpsInfo_[c].Sgcr > scaledEpsInfo_[c].Sogcr) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGCR > SOGCR"; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGCR > SOGCR"; OpmLog::warning(tag, msg); } if (scaledEpsInfo_[c].Sogcr > scaledEpsInfo_[c].Sgu) { - const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR > SGU"; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR > SGU"; OpmLog::warning(tag, msg); } } From d2143970fc6ae14ac69999c6889c298febbcf11d Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 20 May 2016 08:54:12 +0800 Subject: [PATCH 16/69] Cleanup the prefix. --- opm/core/props/satfunc/RelpermDiagnostics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opm/core/props/satfunc/RelpermDiagnostics.cpp b/opm/core/props/satfunc/RelpermDiagnostics.cpp index 40713f245..1a6a53072 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.cpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.cpp @@ -316,17 +316,17 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sg column. if (sg.front() < 0.0 || sg.back() > 1.0) { - const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; + const std::string msg = "In SGFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); } //Check krg column. if (krg.front() < 0.0 || krg.back() > 1.0) { - const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; + const std::string msg = "In SGFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; OpmLog::error(msg); } if (krg.front() != 0.0) { - const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; + const std::string msg = "In SGFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; OpmLog::error(msg); } } From 9979c505b3c61095fcca58bcbb32f2d3d9d96610 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 20 May 2016 14:27:38 +0800 Subject: [PATCH 17/69] log the warning messages to OpmLog. --- opm/core/props/rock/RockCompressibility.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index 03f384f44..4de390013 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -64,14 +65,16 @@ namespace Opm if (rockKeyword.size() != 1) { // here it would be better not to use std::cout directly but to add the // warning to some "warning list"... - std::cout << "Can only handle a single region in ROCK ("< Date: Fri, 20 May 2016 16:13:37 +0800 Subject: [PATCH 18/69] Add enum to string functions. --- opm/core/wells/InjectionSpecification.cpp | 76 +++++++++++++++++ opm/core/wells/InjectionSpecification.hpp | 5 +- opm/core/wells/ProductionSpecification.cpp | 94 ++++++++++++++++++++++ opm/core/wells/ProductionSpecification.hpp | 4 + 4 files changed, 178 insertions(+), 1 deletion(-) diff --git a/opm/core/wells/InjectionSpecification.cpp b/opm/core/wells/InjectionSpecification.cpp index 342012467..12a3cf06f 100644 --- a/opm/core/wells/InjectionSpecification.cpp +++ b/opm/core/wells/InjectionSpecification.cpp @@ -18,4 +18,80 @@ namespace Opm } + const std::string + InjectionSpecification::ControlMode2String(const ControlMode& mode) + { + std::string stringValue; + + switch(mode) { + case ControlMode::NONE: + stringValue = "NONE"; + break; + case ControlMode::RATE: + stringValue = "RATE"; + break; + case ControlMode::RESV: + stringValue = "RESV"; + break; + case ControlMode::BHP: + stringValue = "BHP"; + break; + case ControlMode::THP: + stringValue = "THP"; + break; + case ControlMode::REIN: + stringValue = "REIN"; + break; + case ControlMode::VREP: + stringValue = "VREP"; + break; + case ControlMode::GRUP: + stringValue = "GRUP"; + break; + case ControlMode::FLD: + stringValue = "FLD"; + break; + } + + return stringValue; + } + + + const std::string + InjectionSpecification::InjectorType2String(const InjectorType& type) + { + std::string stringValue; + + switch(type) { + case InjectorType::WATER: + stringValue = "WATER"; + break; + case InjectorType::OIL: + stringValue = "OIL"; + break; + case InjectorType::GAS: + stringValue = "GAS"; + break; + } + + return stringValue; + } + + + const std::string + InjectionSpecification::GuideRateType2String(const GuideRateType& type) + { + std::string stringValue; + + switch(type) { + case GuideRateType::RAT: + stringValue = "RAT"; + break; + case GuideRateType::NONE_GRT: + stringValue = "NONE_GRT"; + break; + } + + return stringValue; + } } // namespace Opm diff --git a/opm/core/wells/InjectionSpecification.hpp b/opm/core/wells/InjectionSpecification.hpp index 74d20f6a7..db3242339 100644 --- a/opm/core/wells/InjectionSpecification.hpp +++ b/opm/core/wells/InjectionSpecification.hpp @@ -2,6 +2,7 @@ #define OPM_INJECTORSPECIFICATION_HPP #include +#include namespace Opm { @@ -25,7 +26,9 @@ namespace Opm }; InjectionSpecification(); - + const std::string ControlMode2String(const ControlMode& mode); + const std::string InjectorType2String(const InjectorType& type); + const std::string GuideRateType2String(const GuideRateType& type); InjectorType injector_type_; ControlMode control_mode_; double surface_flow_max_rate_; diff --git a/opm/core/wells/ProductionSpecification.cpp b/opm/core/wells/ProductionSpecification.cpp index 1c6d443a5..2cccd545d 100644 --- a/opm/core/wells/ProductionSpecification.cpp +++ b/opm/core/wells/ProductionSpecification.cpp @@ -19,4 +19,98 @@ namespace Opm { } + + const std::string + ProductionSpecification::ControlMode2String(const ControlMode& mode) + { + std::string stringValue; + + switch(mode) { + case ControlMode::NONE: + stringValue = "NONE"; + break; + case ControlMode::ORAT: + stringValue = "ORAT"; + break; + case ControlMode::WRAT: + stringValue = "WRAT"; + break; + case ControlMode::GRAT: + stringValue = "GRAT"; + break; + case ControlMode::LRAT: + stringValue = "LRAT"; + break; + case ControlMode::CRAT: + stringValue = "CRAT"; + break; + case ControlMode::RESV: + stringValue = "RESV"; + break; + case ControlMode::PRBL: + stringValue = "RPBL"; + break; + case ControlMode::BHP: + stringValue = "BHP"; + break; + case ControlMode::THP: + stringValue = "THP"; + break; + case ControlMode::GRUP: + stringValue = "GRUP"; + break; + case ControlMode::FLD: + stringValue = "FLD"; + break; + } + + return stringValue; + } + + + const std::string + ProductionSpecification::Procedure2String(const Procedure& type) + { + std::string stringValue; + + switch(type) { + case Procedure::NONE_P: + stringValue = "NONE_P"; + break; + case Procedure::RATE: + stringValue = "RATE"; + break; + case Procedure::WELL: + stringValue = "WELL"; + break; + } + + return stringValue; + } + + + const std::string + ProductionSpecification::GuideRateType2String(const GuideRateType& type) + { + std::string stringValue; + + switch(type) { + case GuideRateType::OIL: + stringValue = "OIL"; + break; + case GuideRateType::GAS: + stringValue = "GAS"; + break; + case GuideRateType::WATER: + stringValue = "WATER"; + break; + case GuideRateType::NONE_GRT: + stringValue = "NONE_GRT"; + break; + } + + return stringValue; + } + + } diff --git a/opm/core/wells/ProductionSpecification.hpp b/opm/core/wells/ProductionSpecification.hpp index 6d064a2f0..5d6443015 100644 --- a/opm/core/wells/ProductionSpecification.hpp +++ b/opm/core/wells/ProductionSpecification.hpp @@ -2,6 +2,7 @@ #define OPM_PRODUCTIONSPECIFICATION_HPP #include +#include namespace Opm { @@ -25,6 +26,9 @@ namespace Opm }; ProductionSpecification(); + const std::string ControlMode2String(const ControlMode& mode); + const std::string Procedure2String(const Procedure& type); + const std::string GuideRateType2String(const GuideRateType& type); ControlMode control_mode_; Procedure procedure_; From 1cb66d2b4f805c7efbfb7a0f1b45742cd0e95aed Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 20 May 2016 16:14:16 +0800 Subject: [PATCH 19/69] write well related information into OpmLog. --- opm/core/wells/WellsGroup.cpp | 32 +++++++++++++++------------- opm/core/wells/WellsManager_impl.hpp | 7 +++--- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index bf80e4640..ba4ae2b8b 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -345,9 +345,10 @@ namespace Opm mode); if (my_rate > target_rate) { - std::cout << "Group " << mode<<" target not met for group " << name() << std::endl; - std::cout << "target = " << target_rate << '\n' - << "rate = " << my_rate << std::endl; + OpmLog::warning("Group " + injSpec().ControlMode2String(mode) + + " target not met for group " + name() + "\n" + + "target = " + std::to_string(target_rate) + "\n" + + "rate = " + std::to_string(my_rate)); applyInjGroupControl(mode, target_rate, true); injSpec().control_mode_ = mode; return false; @@ -377,9 +378,10 @@ namespace Opm child_phases_summed.surf_prod_rates, mode); if (std::fabs(my_rate) > target_rate) { - std::cout << "Group" << mode << " target not met for group " << name() << std::endl; - std::cout << "target = " << target_rate << '\n' - << "rate = " << my_rate << std::endl; + OpmLog::warning("Group" + prodSpec().ControlMode2String(mode) + + " target not met for group " + name() + "\n" + + "target = " + std::to_string(target_rate) + '\n' + + "rate = " + std::to_string(my_rate)); production_violated = true; production_mode_violated = mode; break; @@ -677,9 +679,9 @@ namespace Opm ctrl_violated = is_producer ? (my_target_bhp > my_well_bhp) : (my_target_bhp < my_well_bhp); if (ctrl_violated) { - std::cout << "BHP limit violated for well " << name() << ":\n"; - std::cout << "BHP limit = " << my_target_bhp << std::endl; - std::cout << "BHP = " << my_well_bhp << std::endl; + OpmLog::info("BHP limit violated for well " + name() + ":\n" + + "BHP limit = " + std::to_string(my_target_bhp) + + "BHP = " + std::to_string(my_well_bhp)); } break; } @@ -698,9 +700,9 @@ namespace Opm const double my_rate_target = well_controls_iget_target(ctrls , ctrl_index); ctrl_violated = std::fabs(my_rate) - std::fabs(my_rate_target)> std::max(std::abs(my_rate), std::abs(my_rate_target))*1e-6; if (ctrl_violated) { - std::cout << "RESERVOIR_RATE limit violated for well " << name() << ":\n"; - std::cout << "rate limit = " << my_rate_target << std::endl; - std::cout << "rate = " << my_rate << std::endl; + OpmLog::info("RESERVOIR_RATE limit violated for well " + name() + ":\n" + + "rate limit = " + std::to_string(my_rate_target) + + "rate = " + std::to_string(my_rate)); } break; } @@ -714,9 +716,9 @@ namespace Opm const double my_rate_target = well_controls_iget_target(ctrls , ctrl_index); ctrl_violated = std::fabs(my_rate) > std::fabs(my_rate_target); if (ctrl_violated) { - std::cout << "SURFACE_RATE limit violated for well " << name() << ":\n"; - std::cout << "rate limit = " << my_rate_target << std::endl; - std::cout << "rate = " << my_rate << std::endl; + OpmLog::info("SURFACE_RATE limit violated for well " + name() + ":\n" + + "rate limit = " + std::to_string(my_rate_target) + + "rate = " + std::to_string(my_rate)); } break; } diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 9d9190313..21c51cb23 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -233,9 +234,9 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t // Check that the complete well is on this process if ( sum_completions_on_proc < completionSet->size() ) { - std::cout<< "Well "<< well->name() << " does not seem to be" - << "completely in the disjoint partition of " - << "process. Therefore we deactivate it here." << std::endl; + OpmLog::warning("Well " + well->name() + " does not seem to be" + + "completely in the disjoint partition of " + + "process. Therefore we deactivate it here."); // Mark well as not existent on this process wells_on_proc[wellIter-wells.begin()] = 0; wellperf_data[well_index_on_proc].clear(); From 407c7223f6f0a1f067ead540583186f455a3ef6c Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 23 May 2016 10:47:26 +0800 Subject: [PATCH 20/69] fix indentation and messages. --- opm/core/props/rock/RockCompressibility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index 4de390013..61c3dd54f 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -74,7 +74,7 @@ namespace Opm pref_ = rockKeyword.getRecord(0).getItem("PREF").getSIDouble(0); rock_comp_ = rockKeyword.getRecord(0).getItem("COMPRESSIBILITY").getSIDouble(0); } else { - OpmLog::warning("**** warning: no rock compressibility data found in deck (ROCK or ROCKTAB)."); + OpmLog::warning("No rock compressibility data found in deck (ROCK or ROCKTAB)."); } } From ca030efeb995801ea5488cae71303109107c5c43 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 23 May 2016 10:48:51 +0800 Subject: [PATCH 21/69] simplify the implementation. --- opm/core/wells/InjectionSpecification.cpp | 80 +++++------------ opm/core/wells/InjectionSpecification.hpp | 6 +- opm/core/wells/ProductionSpecification.cpp | 100 ++++++--------------- opm/core/wells/ProductionSpecification.hpp | 6 +- opm/core/wells/WellsGroup.cpp | 4 +- 5 files changed, 53 insertions(+), 143 deletions(-) diff --git a/opm/core/wells/InjectionSpecification.cpp b/opm/core/wells/InjectionSpecification.cpp index 12a3cf06f..fd85a7727 100644 --- a/opm/core/wells/InjectionSpecification.cpp +++ b/opm/core/wells/InjectionSpecification.cpp @@ -18,80 +18,40 @@ namespace Opm } - const std::string - InjectionSpecification::ControlMode2String(const ControlMode& mode) + std::string + InjectionSpecification::toString(const ControlMode& mode) { - std::string stringValue; - switch(mode) { - case ControlMode::NONE: - stringValue = "NONE"; - break; - case ControlMode::RATE: - stringValue = "RATE"; - break; - case ControlMode::RESV: - stringValue = "RESV"; - break; - case ControlMode::BHP: - stringValue = "BHP"; - break; - case ControlMode::THP: - stringValue = "THP"; - break; - case ControlMode::REIN: - stringValue = "REIN"; - break; - case ControlMode::VREP: - stringValue = "VREP"; - break; - case ControlMode::GRUP: - stringValue = "GRUP"; - break; - case ControlMode::FLD: - stringValue = "FLD"; - break; + case ControlMode::NONE: return "NONE"; + case ControlMode::RATE: return "RATE"; + case ControlMode::RESV: return "RESV"; + case ControlMode::BHP : return "BHP" ; + case ControlMode::THP : return "THP" ; + case ControlMode::REIN: return "REIN"; + case ControlMode::VREP: return "VREP"; + case ControlMode::GRUP: return "GRUP"; + case ControlMode::FLD : return "FLD" ; } - - return stringValue; } - const std::string - InjectionSpecification::InjectorType2String(const InjectorType& type) + std::string + InjectionSpecification::toString(const InjectorType& type) { - std::string stringValue; - switch(type) { - case InjectorType::WATER: - stringValue = "WATER"; - break; - case InjectorType::OIL: - stringValue = "OIL"; - break; - case InjectorType::GAS: - stringValue = "GAS"; - break; + case InjectorType::WATER: return "WATER"; + case InjectorType::OIL : return "OIL" ; + case InjectorType::GAS : return "GAS" ; } - - return stringValue; } - const std::string - InjectionSpecification::GuideRateType2String(const GuideRateType& type) + std::string + InjectionSpecification::toString(const GuideRateType& type) { - std::string stringValue; - switch(type) { - case GuideRateType::RAT: - stringValue = "RAT"; - break; - case GuideRateType::NONE_GRT: - stringValue = "NONE_GRT"; - break; + case GuideRateType::RAT : return "RAT" ; + case GuideRateType::NONE_GRT: return "NONE_GRT"; } - - return stringValue; } } // namespace Opm diff --git a/opm/core/wells/InjectionSpecification.hpp b/opm/core/wells/InjectionSpecification.hpp index db3242339..c5c8d93b0 100644 --- a/opm/core/wells/InjectionSpecification.hpp +++ b/opm/core/wells/InjectionSpecification.hpp @@ -26,9 +26,9 @@ namespace Opm }; InjectionSpecification(); - const std::string ControlMode2String(const ControlMode& mode); - const std::string InjectorType2String(const InjectorType& type); - const std::string GuideRateType2String(const GuideRateType& type); + std::string toString(const ControlMode& mode); + std::string toString(const InjectorType& type); + std::string toString(const GuideRateType& type); InjectorType injector_type_; ControlMode control_mode_; double surface_flow_max_rate_; diff --git a/opm/core/wells/ProductionSpecification.cpp b/opm/core/wells/ProductionSpecification.cpp index 2cccd545d..4590e082c 100644 --- a/opm/core/wells/ProductionSpecification.cpp +++ b/opm/core/wells/ProductionSpecification.cpp @@ -20,96 +20,46 @@ namespace Opm } - const std::string - ProductionSpecification::ControlMode2String(const ControlMode& mode) + std::string + ProductionSpecification::toString(const ControlMode& mode) { - std::string stringValue; - switch(mode) { - case ControlMode::NONE: - stringValue = "NONE"; - break; - case ControlMode::ORAT: - stringValue = "ORAT"; - break; - case ControlMode::WRAT: - stringValue = "WRAT"; - break; - case ControlMode::GRAT: - stringValue = "GRAT"; - break; - case ControlMode::LRAT: - stringValue = "LRAT"; - break; - case ControlMode::CRAT: - stringValue = "CRAT"; - break; - case ControlMode::RESV: - stringValue = "RESV"; - break; - case ControlMode::PRBL: - stringValue = "RPBL"; - break; - case ControlMode::BHP: - stringValue = "BHP"; - break; - case ControlMode::THP: - stringValue = "THP"; - break; - case ControlMode::GRUP: - stringValue = "GRUP"; - break; - case ControlMode::FLD: - stringValue = "FLD"; - break; + case ControlMode::NONE: return "NONE"; + case ControlMode::ORAT: return "ORAT"; + case ControlMode::WRAT: return "WRAT"; + case ControlMode::GRAT: return "GRAT"; + case ControlMode::LRAT: return "LRAT"; + case ControlMode::CRAT: return "CRAT"; + case ControlMode::RESV: return "RESV"; + case ControlMode::PRBL: return "RPBL"; + case ControlMode::BHP : return "BHP" ; + case ControlMode::THP : return "THP" ; + case ControlMode::GRUP: return "GRUP"; + case ControlMode::FLD : return "FLD" ; } - - return stringValue; } - const std::string - ProductionSpecification::Procedure2String(const Procedure& type) + std::string + ProductionSpecification::toString(const Procedure& type) { - std::string stringValue; - switch(type) { - case Procedure::NONE_P: - stringValue = "NONE_P"; - break; - case Procedure::RATE: - stringValue = "RATE"; - break; - case Procedure::WELL: - stringValue = "WELL"; - break; + case Procedure::NONE_P: return "NONE_P"; + case Procedure::RATE : return "RATE" ; + case Procedure::WELL : return "WELL" ; } - - return stringValue; } - const std::string - ProductionSpecification::GuideRateType2String(const GuideRateType& type) + std::string + ProductionSpecification::toString(const GuideRateType& type) { - std::string stringValue; - switch(type) { - case GuideRateType::OIL: - stringValue = "OIL"; - break; - case GuideRateType::GAS: - stringValue = "GAS"; - break; - case GuideRateType::WATER: - stringValue = "WATER"; - break; - case GuideRateType::NONE_GRT: - stringValue = "NONE_GRT"; - break; + case GuideRateType::OIL : return "OIL" ; + case GuideRateType::GAS : return "GAS" ; + case GuideRateType::WATER : return "WATER" ; + case GuideRateType::NONE_GRT: return "NONE_GRT"; } - - return stringValue; } diff --git a/opm/core/wells/ProductionSpecification.hpp b/opm/core/wells/ProductionSpecification.hpp index 5d6443015..3a5ba7e36 100644 --- a/opm/core/wells/ProductionSpecification.hpp +++ b/opm/core/wells/ProductionSpecification.hpp @@ -26,9 +26,9 @@ namespace Opm }; ProductionSpecification(); - const std::string ControlMode2String(const ControlMode& mode); - const std::string Procedure2String(const Procedure& type); - const std::string GuideRateType2String(const GuideRateType& type); + std::string toString(const ControlMode& mode); + std::string toString(const Procedure& type); + std::string toString(const GuideRateType& type); ControlMode control_mode_; Procedure procedure_; diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index ba4ae2b8b..1916b0dec 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -345,7 +345,7 @@ namespace Opm mode); if (my_rate > target_rate) { - OpmLog::warning("Group " + injSpec().ControlMode2String(mode) + OpmLog::warning("Group " + injSpec().toString(mode) + " target not met for group " + name() + "\n" + "target = " + std::to_string(target_rate) + "\n" + "rate = " + std::to_string(my_rate)); @@ -378,7 +378,7 @@ namespace Opm child_phases_summed.surf_prod_rates, mode); if (std::fabs(my_rate) > target_rate) { - OpmLog::warning("Group" + prodSpec().ControlMode2String(mode) + OpmLog::warning("Group" + prodSpec().toString(mode) + " target not met for group " + name() + "\n" + "target = " + std::to_string(target_rate) + '\n' + "rate = " + std::to_string(my_rate)); From 7d0833f2d287c0a5dbb1874f71c44bb5fee2f73e Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Tue, 24 May 2016 09:07:28 +0800 Subject: [PATCH 22/69] make toString() method as static. --- opm/core/wells/InjectionSpecification.hpp | 6 +++--- opm/core/wells/ProductionSpecification.hpp | 6 +++--- opm/core/wells/WellsGroup.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/opm/core/wells/InjectionSpecification.hpp b/opm/core/wells/InjectionSpecification.hpp index c5c8d93b0..e47900b7d 100644 --- a/opm/core/wells/InjectionSpecification.hpp +++ b/opm/core/wells/InjectionSpecification.hpp @@ -26,9 +26,9 @@ namespace Opm }; InjectionSpecification(); - std::string toString(const ControlMode& mode); - std::string toString(const InjectorType& type); - std::string toString(const GuideRateType& type); + static std::string toString(const ControlMode& mode); + static std::string toString(const InjectorType& type); + static std::string toString(const GuideRateType& type); InjectorType injector_type_; ControlMode control_mode_; double surface_flow_max_rate_; diff --git a/opm/core/wells/ProductionSpecification.hpp b/opm/core/wells/ProductionSpecification.hpp index 3a5ba7e36..4bae4cae5 100644 --- a/opm/core/wells/ProductionSpecification.hpp +++ b/opm/core/wells/ProductionSpecification.hpp @@ -26,9 +26,9 @@ namespace Opm }; ProductionSpecification(); - std::string toString(const ControlMode& mode); - std::string toString(const Procedure& type); - std::string toString(const GuideRateType& type); + static std::string toString(const ControlMode& mode); + static std::string toString(const Procedure& type); + static std::string toString(const GuideRateType& type); ControlMode control_mode_; Procedure procedure_; diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index 1916b0dec..6eef1e4f0 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -345,7 +345,7 @@ namespace Opm mode); if (my_rate > target_rate) { - OpmLog::warning("Group " + injSpec().toString(mode) + OpmLog::warning("Group " + InjectionSpecification::toString(mode) + " target not met for group " + name() + "\n" + "target = " + std::to_string(target_rate) + "\n" + "rate = " + std::to_string(my_rate)); @@ -378,7 +378,7 @@ namespace Opm child_phases_summed.surf_prod_rates, mode); if (std::fabs(my_rate) > target_rate) { - OpmLog::warning("Group" + prodSpec().toString(mode) + OpmLog::warning("Group" + ProductionSpecification::toString(mode) + " target not met for group " + name() + "\n" + "target = " + std::to_string(target_rate) + '\n' + "rate = " + std::to_string(my_rate)); From b0b43e97b6fa5407ace489b0cfcbdf67edb9f663 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 27 May 2016 08:59:00 +0000 Subject: [PATCH 23/69] Fix incomplete type error for std::ofstream in examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On my system I got ```c++ error: variable ‘std::ofstream file’ has initializer but incomplete type std::ofstream file(fname.str().c_str()); ``` This is fixed with this commit by including fstream. Previously, this include might have happened implicitely. --- examples/compute_initial_state.cpp | 2 ++ examples/compute_tof_from_files.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/compute_initial_state.cpp b/examples/compute_initial_state.cpp index a2b8c2ed8..356f3f42d 100644 --- a/examples/compute_initial_state.cpp +++ b/examples/compute_initial_state.cpp @@ -36,6 +36,8 @@ #include +#include + namespace { void warnIfUnusedParams(const Opm::parameter::ParameterGroup& param) diff --git a/examples/compute_tof_from_files.cpp b/examples/compute_tof_from_files.cpp index fd2069206..aedeebefe 100644 --- a/examples/compute_tof_from_files.cpp +++ b/examples/compute_tof_from_files.cpp @@ -54,7 +54,7 @@ #include #include #include - +#include namespace { From 807261b084f9b659f42cb05719e011d38e0a0c81 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 2 Jun 2016 18:27:44 +0200 Subject: [PATCH 24/69] rename "local AD" to "dense AD" --- opm/core/props/BlackoilPropertiesFromDeck.cpp | 6 +++--- .../simulator/ExplicitArraysSatDerivativesFluidState.hpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/opm/core/props/BlackoilPropertiesFromDeck.cpp b/opm/core/props/BlackoilPropertiesFromDeck.cpp index 97d0a6e65..bd1919472 100644 --- a/opm/core/props/BlackoilPropertiesFromDeck.cpp +++ b/opm/core/props/BlackoilPropertiesFromDeck.cpp @@ -244,7 +244,7 @@ namespace Opm const auto& pu = phaseUsage(); const int np = numPhases(); - typedef Opm::LocalAd::Evaluation LadEval; + typedef Opm::DenseAd::Evaluation LadEval; LadEval pLad = 0.0; LadEval TLad = 0.0; @@ -469,7 +469,7 @@ namespace Opm { const auto& pu = phaseUsage(); - typedef Opm::LocalAd::Evaluation LadEval; + typedef Opm::DenseAd::Evaluation LadEval; LadEval pLad = 0.0; LadEval TLad = 0.0; @@ -603,7 +603,7 @@ namespace Opm { const auto& pu = phaseUsage(); - typedef Opm::LocalAd::Evaluation LadEval; + typedef Opm::DenseAd::Evaluation LadEval; typedef Opm::MathToolbox Toolbox; LadEval pLad = 0.0; diff --git a/opm/core/simulator/ExplicitArraysSatDerivativesFluidState.hpp b/opm/core/simulator/ExplicitArraysSatDerivativesFluidState.hpp index d85856ecd..c6b5aa26c 100644 --- a/opm/core/simulator/ExplicitArraysSatDerivativesFluidState.hpp +++ b/opm/core/simulator/ExplicitArraysSatDerivativesFluidState.hpp @@ -20,8 +20,8 @@ #ifndef OPM_EXPLICIT_ARRAYS_SAT_DERIVATIVES_FLUID_STATE_HEADER_INCLUDED #define OPM_EXPLICIT_ARRAYS_SAT_DERIVATIVES_FLUID_STATE_HEADER_INCLUDED -#include -#include +#include +#include #include @@ -44,7 +44,7 @@ public: enum { numPhases = BlackoilPhases::MaxNumPhases }; enum { numComponents = 3 }; - typedef Opm::LocalAd::Evaluation Evaluation; + typedef Opm::DenseAd::Evaluation Evaluation; typedef Evaluation Scalar; ExplicitArraysSatDerivativesFluidState(const PhaseUsage& phaseUsage) From ec28c4684216c163cbca27d237eb337763c9387b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Fri, 20 May 2016 16:21:14 +0200 Subject: [PATCH 25/69] WellState::report() to make opm-output Well data --- opm/core/simulator/BlackoilState.cpp | 2 ++ opm/core/simulator/WellState.hpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/opm/core/simulator/BlackoilState.cpp b/opm/core/simulator/BlackoilState.cpp index 66d83938e..97d39f72b 100644 --- a/opm/core/simulator/BlackoilState.cpp +++ b/opm/core/simulator/BlackoilState.cpp @@ -1,6 +1,8 @@ #include "BlackoilState.hpp" #include #include +#include +#include using namespace Opm; diff --git a/opm/core/simulator/WellState.hpp b/opm/core/simulator/WellState.hpp index bbf0694b2..999dfcfff 100644 --- a/opm/core/simulator/WellState.hpp +++ b/opm/core/simulator/WellState.hpp @@ -22,6 +22,8 @@ #include #include +#include + #include #include #include @@ -208,6 +210,18 @@ namespace Opm return wellRates().size() / numWells(); } + virtual data::Wells report() const + { + return { { /* WellState offers no completion data, so that has to be added later */ }, + this->bhp(), + this->temperature(), + this->wellRates(), + this->perfPress(), + this->perfRates() }; + } + + virtual ~WellState() {} + private: std::vector bhp_; std::vector thp_; From 254bb2e1e6b890f39047ebdcd36cb3c8467cb570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Tue, 31 May 2016 09:59:18 +0200 Subject: [PATCH 26/69] Make struct wells unique member of WellState --- opm/core/simulator/WellState.hpp | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/opm/core/simulator/WellState.hpp b/opm/core/simulator/WellState.hpp index 999dfcfff..7fc82cc12 100644 --- a/opm/core/simulator/WellState.hpp +++ b/opm/core/simulator/WellState.hpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -51,6 +52,7 @@ namespace Opm { // clear old name mapping wellMap_.clear(); + wells_.reset( clone_wells( wells ) ); if (wells) { const int nw = wells->number_of_wells; @@ -222,6 +224,31 @@ namespace Opm virtual ~WellState() {} + WellState() = default; + WellState( const WellState& rhs ) : + bhp_( rhs.bhp_ ), + thp_( rhs.thp_ ), + temperature_( rhs.temperature_ ), + wellrates_( rhs.wellrates_ ), + perfrates_( rhs.perfrates_ ), + perfpress_( rhs.perfpress_ ), + wellMap_( rhs.wellMap_ ), + wells_( clone_wells( rhs.wells_.get() ) ) + {} + + WellState& operator=( const WellState& rhs ) { + this->bhp_ = rhs.bhp_; + this->thp_ = rhs.thp_; + this->temperature_ = rhs.temperature_; + this->wellrates_ = rhs.wellrates_; + this->perfrates_ = rhs.perfrates_; + this->perfpress_ = rhs.perfpress_; + this->wellMap_ = rhs.wellMap_; + this->wells_.reset( clone_wells( rhs.wells_.get() ) ); + + return *this; + } + private: std::vector bhp_; std::vector thp_; @@ -231,6 +258,12 @@ namespace Opm std::vector perfpress_; WellMapType wellMap_; + + protected: + struct wdel { + void operator()( Wells* w ) { destroy_wells( w ); } + }; + std::unique_ptr< Wells, wdel > wells_; }; } // namespace Opm From 2a3680f105b6628b9e47ff7b1e4ed4b435f52d76 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 6 Jun 2016 15:43:35 +0200 Subject: [PATCH 27/69] Fix to handle cases without DISGAS and VAPOIL - adds boolean has_disgas and has_vapoil to initHydroCarbonState() --- opm/core/utility/initHydroCarbonState.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opm/core/utility/initHydroCarbonState.hpp b/opm/core/utility/initHydroCarbonState.hpp index 611b0639e..222946cf7 100644 --- a/opm/core/utility/initHydroCarbonState.hpp +++ b/opm/core/utility/initHydroCarbonState.hpp @@ -6,7 +6,7 @@ namespace Opm { -void initHydroCarbonState(BlackoilState& state, const PhaseUsage& pu, const int num_cells) { +void initHydroCarbonState(BlackoilState& state, const PhaseUsage& pu, const int num_cells, const bool has_disgas, const bool has_vapoil) { enum { Oil = BlackoilPhases::Liquid, Gas = BlackoilPhases::Vapour, Water = BlackoilPhases::Aqua }; // hydrocarbonstate is only used when gas and oil is present assert(pu.phase_used[Oil]); @@ -29,11 +29,11 @@ void initHydroCarbonState(BlackoilState& state, const PhaseUsage& pu, const int continue; // cases (almost) filled with water is treated as GasAndOil case; } } - if ( saturation[c*np + pu.phase_pos[ Gas ]] == 0.0) { + if ( saturation[c*np + pu.phase_pos[ Gas ]] == 0.0 && has_disgas) { hydroCarbonState[c] = HydroCarbonState::OilOnly; continue; } - if ( saturation[c*np + pu.phase_pos[ Oil ]] == 0.0) { + if ( saturation[c*np + pu.phase_pos[ Oil ]] == 0.0 && has_vapoil) { hydroCarbonState[c] = HydroCarbonState::GasOnly; } } From 8a6243962d136b410ae1aab9ff243d44c6ab3f37 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Mon, 6 Jun 2016 14:33:54 +0200 Subject: [PATCH 28/69] rename some variables from "*Lad" to "*Eval" this was an involuntary omission in the "local AD" to "dense AD" rename... --- opm/core/props/BlackoilPropertiesFromDeck.cpp | 188 +++++++++--------- 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/opm/core/props/BlackoilPropertiesFromDeck.cpp b/opm/core/props/BlackoilPropertiesFromDeck.cpp index bd1919472..b2b6b3780 100644 --- a/opm/core/props/BlackoilPropertiesFromDeck.cpp +++ b/opm/core/props/BlackoilPropertiesFromDeck.cpp @@ -244,15 +244,15 @@ namespace Opm const auto& pu = phaseUsage(); const int np = numPhases(); - typedef Opm::DenseAd::Evaluation LadEval; + typedef Opm::DenseAd::Evaluation Eval; - LadEval pLad = 0.0; - LadEval TLad = 0.0; - LadEval RsLad = 0.0; - LadEval RvLad = 0.0; - LadEval muLad = 0.0; + Eval pEval = 0.0; + Eval TEval = 0.0; + Eval RsEval = 0.0; + Eval RvEval = 0.0; + Eval muEval = 0.0; - pLad.derivatives[0] = 1.0; + pEval.derivatives[0] = 1.0; R_.resize(n*np); this->compute_R_(n, p, T, z, cells, &R_[0]); @@ -260,30 +260,30 @@ namespace Opm for (int i = 0; i < n; ++ i) { int cellIdx = cells[i]; int pvtRegionIdx = cellPvtRegionIdx_[cellIdx]; - pLad.value = p[i]; - TLad.value = T[i]; + pEval.value = p[i]; + TEval.value = T[i]; if (pu.phase_used[BlackoilPhases::Aqua]) { - muLad = waterPvt_.viscosity(pvtRegionIdx, TLad, pLad); + muEval = waterPvt_.viscosity(pvtRegionIdx, TEval, pEval); int offset = pu.num_phases*cellIdx + pu.phase_pos[BlackoilPhases::Aqua]; - mu[offset] = muLad.value; - dmudp[offset] = muLad.derivatives[0]; + mu[offset] = muEval.value; + dmudp[offset] = muEval.derivatives[0]; } if (pu.phase_used[BlackoilPhases::Liquid]) { - RsLad.value = R_[i*np + pu.phase_pos[BlackoilPhases::Liquid]]; - muLad = oilPvt_.viscosity(pvtRegionIdx, TLad, pLad, RsLad); + RsEval.value = R_[i*np + pu.phase_pos[BlackoilPhases::Liquid]]; + muEval = oilPvt_.viscosity(pvtRegionIdx, TEval, pEval, RsEval); int offset = pu.num_phases*cellIdx + pu.phase_pos[BlackoilPhases::Liquid]; - mu[offset] = muLad.value; - dmudp[offset] = muLad.derivatives[0]; + mu[offset] = muEval.value; + dmudp[offset] = muEval.derivatives[0]; } if (pu.phase_used[BlackoilPhases::Vapour]) { - RvLad.value = R_[i*np + pu.phase_pos[BlackoilPhases::Vapour]]; - muLad = gasPvt_.viscosity(pvtRegionIdx, TLad, pLad, RvLad); + RvEval.value = R_[i*np + pu.phase_pos[BlackoilPhases::Vapour]]; + muEval = gasPvt_.viscosity(pvtRegionIdx, TEval, pEval, RvEval); int offset = pu.num_phases*cellIdx + pu.phase_pos[BlackoilPhases::Vapour]; - mu[offset] = muLad.value; - dmudp[offset] = muLad.derivatives[0]; + mu[offset] = muEval.value; + dmudp[offset] = muEval.derivatives[0]; } } } @@ -396,27 +396,27 @@ namespace Opm { const auto& pu = phaseUsage(); - typedef double LadEval; + typedef double Eval; - LadEval pLad = 0.0; - LadEval TLad = 0.0; - LadEval RsLad = 0.0; - LadEval RvLad = 0.0; + Eval pEval = 0.0; + Eval TEval = 0.0; + Eval RsEval = 0.0; + Eval RvEval = 0.0; for (int i = 0; i < n; ++ i) { int cellIdx = cells[i]; int pvtRegionIdx = cellPvtRegionIdx_[cellIdx]; - pLad = p[i]; - TLad = T[i]; + pEval = p[i]; + TEval = T[i]; int oilOffset = pu.num_phases*i + pu.phase_pos[BlackoilPhases::Liquid]; int gasOffset = pu.num_phases*i + pu.phase_pos[BlackoilPhases::Vapour]; int waterOffset = pu.num_phases*i + pu.phase_pos[BlackoilPhases::Aqua]; if (pu.phase_used[BlackoilPhases::Aqua]) { - LadEval BLad = 1.0/waterPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TLad, pLad); + Eval BEval = 1.0/waterPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TEval, pEval); - B[waterOffset] = BLad; + B[waterOffset] = BEval; } if (pu.phase_used[BlackoilPhases::Liquid]) { @@ -424,18 +424,18 @@ namespace Opm double maxRs = 0.0; if (pu.phase_used[BlackoilPhases::Vapour]) { currentRs = (z[oilOffset] == 0.0) ? 0.0 : z[gasOffset]/z[oilOffset]; - maxRs = oilPvt_.saturatedGasDissolutionFactor(pvtRegionIdx, TLad, pLad); + maxRs = oilPvt_.saturatedGasDissolutionFactor(pvtRegionIdx, TEval, pEval); } - LadEval BLad; + Eval BEval; if (currentRs >= maxRs) { - BLad = 1.0/oilPvt_.saturatedInverseFormationVolumeFactor(pvtRegionIdx, TLad, pLad); + BEval = 1.0/oilPvt_.saturatedInverseFormationVolumeFactor(pvtRegionIdx, TEval, pEval); } else { - RsLad = currentRs; - BLad = 1.0/oilPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TLad, pLad, RsLad); + RsEval = currentRs; + BEval = 1.0/oilPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TEval, pEval, RsEval); } - B[oilOffset] = BLad; + B[oilOffset] = BEval; } if (pu.phase_used[BlackoilPhases::Vapour]) { @@ -443,18 +443,18 @@ namespace Opm double maxRv = 0.0; if (pu.phase_used[BlackoilPhases::Liquid]) { currentRv = (z[gasOffset] == 0.0) ? 0.0 : z[oilOffset]/z[gasOffset]; - maxRv = gasPvt_.saturatedOilVaporizationFactor(pvtRegionIdx, TLad, pLad); + maxRv = gasPvt_.saturatedOilVaporizationFactor(pvtRegionIdx, TEval, pEval); } - LadEval BLad; + Eval BEval; if (currentRv >= maxRv) { - BLad = 1.0/gasPvt_.saturatedInverseFormationVolumeFactor(pvtRegionIdx, TLad, pLad); + BEval = 1.0/gasPvt_.saturatedInverseFormationVolumeFactor(pvtRegionIdx, TEval, pEval); } else { - RvLad = currentRv; - BLad = 1.0/gasPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TLad, pLad, RvLad); + RvEval = currentRv; + BEval = 1.0/gasPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TEval, pEval, RvEval); } - B[gasOffset] = BLad; + B[gasOffset] = BEval; } } } @@ -469,30 +469,30 @@ namespace Opm { const auto& pu = phaseUsage(); - typedef Opm::DenseAd::Evaluation LadEval; + typedef Opm::DenseAd::Evaluation Eval; - LadEval pLad = 0.0; - LadEval TLad = 0.0; - LadEval RsLad = 0.0; - LadEval RvLad = 0.0; + Eval pEval = 0.0; + Eval TEval = 0.0; + Eval RsEval = 0.0; + Eval RvEval = 0.0; - pLad.derivatives[0] = 1.0; + pEval.derivatives[0] = 1.0; for (int i = 0; i < n; ++ i) { int cellIdx = cells[i]; int pvtRegionIdx = cellPvtRegionIdx_[cellIdx]; - pLad.value = p[i]; - TLad.value = T[i]; + pEval.value = p[i]; + TEval.value = T[i]; int oilOffset = pu.num_phases*i + pu.phase_pos[BlackoilPhases::Liquid]; int gasOffset = pu.num_phases*i + pu.phase_pos[BlackoilPhases::Vapour]; int waterOffset = pu.num_phases*i + pu.phase_pos[BlackoilPhases::Aqua]; if (pu.phase_used[BlackoilPhases::Aqua]) { - LadEval BLad = 1.0/waterPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TLad, pLad); + Eval BEval = 1.0/waterPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TEval, pEval); - B[waterOffset] = BLad.value; - dBdp[waterOffset] = BLad.derivatives[0]; + B[waterOffset] = BEval.value; + dBdp[waterOffset] = BEval.derivatives[0]; } if (pu.phase_used[BlackoilPhases::Liquid]) { @@ -500,19 +500,19 @@ namespace Opm double maxRs = 0.0; if (pu.phase_used[BlackoilPhases::Vapour]) { currentRs = (z[oilOffset] == 0.0) ? 0.0 : z[gasOffset]/z[oilOffset]; - maxRs = oilPvt_.saturatedGasDissolutionFactor(pvtRegionIdx, TLad.value, pLad.value); + maxRs = oilPvt_.saturatedGasDissolutionFactor(pvtRegionIdx, TEval.value, pEval.value); } - LadEval BLad; + Eval BEval; if (currentRs >= maxRs) { - BLad = 1.0/oilPvt_.saturatedInverseFormationVolumeFactor(pvtRegionIdx, TLad, pLad); + BEval = 1.0/oilPvt_.saturatedInverseFormationVolumeFactor(pvtRegionIdx, TEval, pEval); } else { - RsLad.value = currentRs; - BLad = 1.0/oilPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TLad, pLad, RsLad); + RsEval.value = currentRs; + BEval = 1.0/oilPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TEval, pEval, RsEval); } - B[oilOffset] = BLad.value; - dBdp[oilOffset] = BLad.derivatives[0]; + B[oilOffset] = BEval.value; + dBdp[oilOffset] = BEval.derivatives[0]; } if (pu.phase_used[BlackoilPhases::Vapour]) { @@ -520,19 +520,19 @@ namespace Opm double maxRv = 0.0; if (pu.phase_used[BlackoilPhases::Liquid]) { currentRv = (z[gasOffset] == 0.0) ? 0.0 : z[oilOffset]/z[gasOffset]; - maxRv = gasPvt_.saturatedOilVaporizationFactor(pvtRegionIdx, TLad.value, pLad.value); + maxRv = gasPvt_.saturatedOilVaporizationFactor(pvtRegionIdx, TEval.value, pEval.value); } - LadEval BLad; + Eval BEval; if (currentRv >= maxRv) { - BLad = 1.0/gasPvt_.saturatedInverseFormationVolumeFactor(pvtRegionIdx, TLad, pLad); + BEval = 1.0/gasPvt_.saturatedInverseFormationVolumeFactor(pvtRegionIdx, TEval, pEval); } else { - RvLad.value = currentRv; - BLad = 1.0/gasPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TLad, pLad, RvLad); + RvEval.value = currentRv; + BEval = 1.0/gasPvt_.inverseFormationVolumeFactor(pvtRegionIdx, TEval, pEval, RvEval); } - B[gasOffset] = BLad.value; - dBdp[gasOffset] = BLad.derivatives[0]; + B[gasOffset] = BEval.value; + dBdp[gasOffset] = BEval.derivatives[0]; } } } @@ -546,16 +546,16 @@ namespace Opm { const auto& pu = phaseUsage(); - typedef double LadEval; + typedef double Eval; - LadEval pLad = 0.0; - LadEval TLad = 0.0; + Eval pEval = 0.0; + Eval TEval = 0.0; for (int i = 0; i < n; ++ i) { int cellIdx = cells[i]; int pvtRegionIdx = cellPvtRegionIdx_[cellIdx]; - pLad = p[i]; - TLad = T[i]; + pEval = p[i]; + TEval = T[i]; int oilOffset = pu.num_phases*i + pu.phase_pos[BlackoilPhases::Liquid]; int gasOffset = pu.num_phases*i + pu.phase_pos[BlackoilPhases::Vapour]; @@ -566,29 +566,29 @@ namespace Opm } if (pu.phase_used[BlackoilPhases::Liquid]) { - LadEval RsSatLad = oilPvt_.saturatedGasDissolutionFactor(pvtRegionIdx, TLad, pLad); + Eval RsSatEval = oilPvt_.saturatedGasDissolutionFactor(pvtRegionIdx, TEval, pEval); double currentRs = 0.0; if (pu.phase_used[BlackoilPhases::Vapour]) { currentRs = (z[oilOffset] == 0.0) ? 0.0 : z[gasOffset]/z[oilOffset]; } - RsSatLad = std::min(RsSatLad, currentRs); + RsSatEval = std::min(RsSatEval, currentRs); - R[oilOffset] = RsSatLad; + R[oilOffset] = RsSatEval; } if (pu.phase_used[BlackoilPhases::Vapour]) { - LadEval RvSatLad = gasPvt_.saturatedOilVaporizationFactor(pvtRegionIdx, TLad, pLad); + Eval RvSatEval = gasPvt_.saturatedOilVaporizationFactor(pvtRegionIdx, TEval, pEval); double currentRv = 0.0; if (pu.phase_used[BlackoilPhases::Liquid]) { currentRv = (z[gasOffset] == 0.0) ? 0.0 : z[oilOffset]/z[gasOffset]; } - RvSatLad = std::min(RvSatLad, currentRv); + RvSatEval = std::min(RvSatEval, currentRv); - R[gasOffset] = RvSatLad; + R[gasOffset] = RvSatEval; } } } @@ -603,19 +603,19 @@ namespace Opm { const auto& pu = phaseUsage(); - typedef Opm::DenseAd::Evaluation LadEval; - typedef Opm::MathToolbox Toolbox; + typedef Opm::DenseAd::Evaluation Eval; + typedef Opm::MathToolbox Toolbox; - LadEval pLad = 0.0; - LadEval TLad = 0.0; + Eval pEval = 0.0; + Eval TEval = 0.0; - pLad.derivatives[0] = 1.0; + pEval.derivatives[0] = 1.0; for (int i = 0; i < n; ++ i) { int cellIdx = cells[i]; int pvtRegionIdx = cellPvtRegionIdx_[cellIdx]; - pLad.value = p[i]; - TLad.value = T[i]; + pEval.value = p[i]; + TEval.value = T[i]; int oilOffset = pu.num_phases*i + pu.phase_pos[BlackoilPhases::Liquid]; int gasOffset = pu.num_phases*i + pu.phase_pos[BlackoilPhases::Vapour]; @@ -626,31 +626,31 @@ namespace Opm } if (pu.phase_used[BlackoilPhases::Liquid]) { - LadEval RsSatLad = oilPvt_.saturatedGasDissolutionFactor(pvtRegionIdx, TLad, pLad); + Eval RsSatEval = oilPvt_.saturatedGasDissolutionFactor(pvtRegionIdx, TEval, pEval); - LadEval currentRs = 0.0; + Eval currentRs = 0.0; if (pu.phase_used[BlackoilPhases::Vapour]) { currentRs = (z[oilOffset] == 0.0) ? 0.0 : z[gasOffset]/z[oilOffset]; } - RsSatLad = Toolbox::min(RsSatLad, currentRs); + RsSatEval = Toolbox::min(RsSatEval, currentRs); - R[oilOffset] = RsSatLad.value; - dRdp[oilOffset] = RsSatLad.derivatives[0]; + R[oilOffset] = RsSatEval.value; + dRdp[oilOffset] = RsSatEval.derivatives[0]; } if (pu.phase_used[BlackoilPhases::Vapour]) { - LadEval RvSatLad = gasPvt_.saturatedOilVaporizationFactor(pvtRegionIdx, TLad, pLad); + Eval RvSatEval = gasPvt_.saturatedOilVaporizationFactor(pvtRegionIdx, TEval, pEval); - LadEval currentRv = 0.0; + Eval currentRv = 0.0; if (pu.phase_used[BlackoilPhases::Liquid]) { currentRv = (z[gasOffset] == 0.0) ? 0.0 : z[oilOffset]/z[gasOffset]; } - RvSatLad = Toolbox::min(RvSatLad, currentRv); + RvSatEval = Toolbox::min(RvSatEval, currentRv); - R[gasOffset] = RvSatLad.value; - dRdp[gasOffset] = RvSatLad.derivatives[0]; + R[gasOffset] = RvSatEval.value; + dRdp[gasOffset] = RvSatEval.derivatives[0]; } } } From 008c5b7c8ffaefe62d61d6e923681b9d75b5f4c0 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 7 Jun 2016 15:00:57 +0200 Subject: [PATCH 29/69] Added utilities to compute a real L-infinity norm in parallel. --- opm/core/linalg/ParallelIstlInformation.hpp | 25 +++++++++++++++++++++ tests/test_parallelistlinformation.cpp | 10 ++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/opm/core/linalg/ParallelIstlInformation.hpp b/opm/core/linalg/ParallelIstlInformation.hpp index 97c191b39..49504dff4 100644 --- a/opm/core/linalg/ParallelIstlInformation.hpp +++ b/opm/core/linalg/ParallelIstlInformation.hpp @@ -185,6 +185,7 @@ public: /// to compute a reduction. Or with tuples of them to compute multiple reductions with only /// one global communication. /// The possible functors needed can be constructed with Opm::Reduction::makeGlobalMaxFunctor(), + /// Opm::Reduction::makeLInfinityNormFunctor(), /// Opm::Reduction::makeGlobalMinFunctor(), and /// Opm::Reduction::makeGlobalSumFunctor(). /// \tparam type of the container or the tuple of containers. @@ -574,6 +575,30 @@ private: (std::pointer_to_binary_function ((const T&(*)(const T&, const T&))std::max)); } + + namespace detail + { + /// \brief Computes the maximum of theabsolute values of two values. + template + struct MaxAbsFunctor + { + typedef T result_type; + + result_type operator()(const T& t1, const T& t2) + { + return std::max(std::abs(t1),std::abs(t2)); + } + }; + } + /// \brief Create a functor for computing a global L infinity norm + /// + /// To be used with ParallelISTLInformation::computeReduction. + template + MaskIDOperator > + makeLInfinityNormFunctor() + { + return MaskIDOperator >(); + } /// \brief Create a functor for computing a global minimum. /// /// To be used with ParallelISTLInformation::computeReduction. diff --git a/tests/test_parallelistlinformation.cpp b/tests/test_parallelistlinformation.cpp index 6bd927008..8258ad329 100644 --- a/tests/test_parallelistlinformation.cpp +++ b/tests/test_parallelistlinformation.cpp @@ -45,12 +45,13 @@ void runSumMaxMinTest(const T offset) assert(comm.indexSet()->size()==x.size()); for(auto it=comm.indexSet()->begin(), itend=comm.indexSet()->end(); it!=itend; ++it) x[it->local()]=it->global()+offset; - auto containers = std::make_tuple(x, x, x, x); + auto containers = std::make_tuple(x, x, x, x, x); auto operators = std::make_tuple(Opm::Reduction::makeGlobalSumFunctor(), Opm::Reduction::makeGlobalMaxFunctor(), Opm::Reduction::makeGlobalMinFunctor(), - Opm::Reduction::makeInnerProductFunctor()); - auto values = std::tuple(0,0,100000, 0); + Opm::Reduction::makeInnerProductFunctor(), + Opm::Reduction::makeLInfinityNormFunctor()); + auto values = std::tuple(0,0,100000, 0, 0); auto oldvalues = values; start = offset; end = start+N; @@ -59,10 +60,12 @@ void runSumMaxMinTest(const T offset) BOOST_CHECK(std::get<1>(values)==std::max(N+offset-1, std::get<1>(oldvalues))); BOOST_CHECK(std::get<2>(values)==std::min(offset, std::get<2>(oldvalues))); BOOST_CHECK(std::get<3>(values)==((end-1)*end*(2*end-1)-(start-1)*start*(2*start-1))/6+std::get<3>(oldvalues)); + BOOST_CHECK(std::get<4>(values)==std::max(std::abs(offset),std::abs(N+offset-1))); } BOOST_AUTO_TEST_CASE(tupleReductionTestInt) { + runSumMaxMinTest(-200); runSumMaxMinTest(0); runSumMaxMinTest(20); runSumMaxMinTest(-20); @@ -75,6 +78,7 @@ BOOST_AUTO_TEST_CASE(tupleReductionTestUnsignedInt) } BOOST_AUTO_TEST_CASE(tupleReductionTestFloat) { + runSumMaxMinTest(-200); runSumMaxMinTest(0); runSumMaxMinTest(20); runSumMaxMinTest(-20); From 73ed34043ee994f12f40e5cf1248f4b04bb54a3d Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Wed, 8 Jun 2016 09:45:04 +0200 Subject: [PATCH 30/69] add a blank line. --- opm/core/props/satfunc/RelpermDiagnostics_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp index 4e0d01669..2f72a2fcd 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -33,7 +33,7 @@ namespace Opm { Opm::DeckConstPtr deck, const GridT& grid) { - OpmLog::info("***************Saturation Functions Diagnostics***************"); + OpmLog::info("\n***************Saturation Functions Diagnostics***************"); phaseCheck_(deck); satFamilyCheck_(eclState); tableCheck_(eclState, deck); From 35f2559b6c4e7d2660d5ed652f899c2472483b1c Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Wed, 8 Jun 2016 09:45:32 +0200 Subject: [PATCH 31/69] Output file name and line number. --- opm/core/props/rock/RockCompressibility.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index 61c3dd54f..d77b5b6be 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -68,7 +68,9 @@ namespace Opm OpmLog::warning("Can only handle a single region in ROCK (" + std::to_string(rockKeyword.size()) + " regions specified)." - + " Ignoring all except for the first."); + + " Ignoring all except for the first.\nSee " + rockKeyword.getFileName() + + ", in line:" + std::to_string(rockKeyword.getLineNumber()) + + " for more information."); } pref_ = rockKeyword.getRecord(0).getItem("PREF").getSIDouble(0); From 77629743546f3bb05ebce3d7dd1533358301c23a Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Wed, 8 Jun 2016 11:02:13 +0200 Subject: [PATCH 32/69] Make ParallelIstlInformation::ownerMask_ accessible. This is needed in opm-simulator to calculate the parallel euclidian product of the saturations. --- opm/core/linalg/ParallelIstlInformation.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/opm/core/linalg/ParallelIstlInformation.hpp b/opm/core/linalg/ParallelIstlInformation.hpp index 49504dff4..9ffbf60ce 100644 --- a/opm/core/linalg/ParallelIstlInformation.hpp +++ b/opm/core/linalg/ParallelIstlInformation.hpp @@ -179,6 +179,17 @@ public: } return ownerMask_; } + + /// \brief Get the owner Mask. + /// + /// \return A vector with entries 0, and 1. 0 marks an index that we cannot + /// compute correct results for. 1 marks an index that this process + /// is responsible for and computes correct results in parallel. + const std::vector& getOwnerMask() const + { + return ownerMask_; + } + /// \brief Compute one or more global reductions. /// /// This function can either be used with a container, an operator, and an initial value From 84b0c8bc59b582558387dead71657395fe44c57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Wed, 18 May 2016 10:29:57 +0200 Subject: [PATCH 33/69] Check for HAVE_UMFPACK in LinearSolverFactory Check for the right preprocessor define to enable umfpack support. Matches the directive set in config.h --- opm/core/linalg/LinearSolverFactory.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opm/core/linalg/LinearSolverFactory.cpp b/opm/core/linalg/LinearSolverFactory.cpp index d2bd31204..18204cc9f 100644 --- a/opm/core/linalg/LinearSolverFactory.cpp +++ b/opm/core/linalg/LinearSolverFactory.cpp @@ -23,7 +23,7 @@ #include -#if HAVE_SUITESPARSE_UMFPACK_H +#if HAVE_UMFPACK #include #endif @@ -45,7 +45,7 @@ namespace Opm LinearSolverFactory::LinearSolverFactory() { -#if HAVE_SUITESPARSE_UMFPACK_H +#if HAVE_UMFPACK solver_.reset(new LinearSolverUmfpack); #elif HAVE_DUNE_ISTL solver_.reset(new LinearSolverIstl); @@ -65,7 +65,7 @@ namespace Opm param.getDefault("linsolver", "umfpack"); if (ls == "umfpack") { -#if HAVE_SUITESPARSE_UMFPACK_H +#if HAVE_UMFPACK solver_.reset(new LinearSolverUmfpack); #endif } From 5fe0452bd58e9af4101a74d8817a2269a09ddbba Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 13 Jun 2016 13:49:58 +0800 Subject: [PATCH 34/69] minor format changes --- opm/core/props/rock/RockCompressibility.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index d77b5b6be..ffe0ceb07 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -68,9 +68,8 @@ namespace Opm OpmLog::warning("Can only handle a single region in ROCK (" + std::to_string(rockKeyword.size()) + " regions specified)." - + " Ignoring all except for the first.\nSee " + rockKeyword.getFileName() - + ", in line:" + std::to_string(rockKeyword.getLineNumber()) - + " for more information."); + + " Ignoring all except for the first.\nFile " + rockKeyword.getFileName() + + ", line " + std::to_string(rockKeyword.getLineNumber())); } pref_ = rockKeyword.getRecord(0).getItem("PREF").getSIDouble(0); From dd26ef620cad35c24896a0ad27c070f44e516b42 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 13 Jun 2016 13:55:01 +0800 Subject: [PATCH 35/69] add "\n" at the end of the message. --- opm/core/props/rock/RockCompressibility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index ffe0ceb07..a13c22e83 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -69,7 +69,7 @@ namespace Opm + std::to_string(rockKeyword.size()) + " regions specified)." + " Ignoring all except for the first.\nFile " + rockKeyword.getFileName() - + ", line " + std::to_string(rockKeyword.getLineNumber())); + + ", line " + std::to_string(rockKeyword.getLineNumber()) + "\n"); } pref_ = rockKeyword.getRecord(0).getItem("PREF").getSIDouble(0); From 33b29e9991db6e8da60a243f2ef5daa3a874b855 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 13 Jun 2016 10:43:21 +0200 Subject: [PATCH 36/69] Revert "Check for HAVE_UMFPACK in LinearSolverFactory" This reverts commit f54c74db0637640f5fb224fab243b294cd034f15. --- opm/core/linalg/LinearSolverFactory.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opm/core/linalg/LinearSolverFactory.cpp b/opm/core/linalg/LinearSolverFactory.cpp index 18204cc9f..d2bd31204 100644 --- a/opm/core/linalg/LinearSolverFactory.cpp +++ b/opm/core/linalg/LinearSolverFactory.cpp @@ -23,7 +23,7 @@ #include -#if HAVE_UMFPACK +#if HAVE_SUITESPARSE_UMFPACK_H #include #endif @@ -45,7 +45,7 @@ namespace Opm LinearSolverFactory::LinearSolverFactory() { -#if HAVE_UMFPACK +#if HAVE_SUITESPARSE_UMFPACK_H solver_.reset(new LinearSolverUmfpack); #elif HAVE_DUNE_ISTL solver_.reset(new LinearSolverIstl); @@ -65,7 +65,7 @@ namespace Opm param.getDefault("linsolver", "umfpack"); if (ls == "umfpack") { -#if HAVE_UMFPACK +#if HAVE_SUITESPARSE_UMFPACK_H solver_.reset(new LinearSolverUmfpack); #endif } From f0900e67527827f0d94635396f287a84651c6aca Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Wed, 15 Jun 2016 11:24:20 +0800 Subject: [PATCH 37/69] unify output. --- opm/core/props/rock/RockCompressibility.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index a13c22e83..6b5ceb217 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -68,7 +68,8 @@ namespace Opm OpmLog::warning("Can only handle a single region in ROCK (" + std::to_string(rockKeyword.size()) + " regions specified)." - + " Ignoring all except for the first.\nFile " + rockKeyword.getFileName() + + " Ignoring all except for the first.\n" + + "In file " + rockKeyword.getFileName() + ", line " + std::to_string(rockKeyword.getLineNumber()) + "\n"); } From 3179a1bf5d86f5448b09f0ea9c049c24d37d25a2 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Wed, 15 Jun 2016 11:26:06 +0800 Subject: [PATCH 38/69] fix indentation issue. --- opm/core/props/rock/RockCompressibility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index 6b5ceb217..2f0b48f74 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -69,7 +69,7 @@ namespace Opm + std::to_string(rockKeyword.size()) + " regions specified)." + " Ignoring all except for the first.\n" - + "In file " + rockKeyword.getFileName() + + "In file " + rockKeyword.getFileName() + ", line " + std::to_string(rockKeyword.getLineNumber()) + "\n"); } From b0c6e43cf84e3990a0c3ab912ad7586fef54818e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 15 Jun 2016 08:57:20 +0200 Subject: [PATCH 39/69] Add operator== and operator!= to PhasePresence. This makes it simpler to write code debugging or inspecting changed phase configurations. --- opm/core/props/BlackoilPhases.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/opm/core/props/BlackoilPhases.hpp b/opm/core/props/BlackoilPhases.hpp index ebfd1f72a..679fd95da 100644 --- a/opm/core/props/BlackoilPhases.hpp +++ b/opm/core/props/BlackoilPhases.hpp @@ -60,6 +60,9 @@ namespace Opm void setFreeOil () { insert(BlackoilPhases::Liquid); } void setFreeGas () { insert(BlackoilPhases::Vapour); } + bool operator==(const PhasePresence& other) { return present_ == other.present_; } + bool operator!=(const PhasePresence& other) { return !this->operator==(other); } + private: unsigned char present_; From d065a2c095eeb79a4acf5eedbd647edc655bd52c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 15 Jun 2016 09:20:19 +0200 Subject: [PATCH 40/69] Make new ops const. --- opm/core/props/BlackoilPhases.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/core/props/BlackoilPhases.hpp b/opm/core/props/BlackoilPhases.hpp index 679fd95da..981588ff7 100644 --- a/opm/core/props/BlackoilPhases.hpp +++ b/opm/core/props/BlackoilPhases.hpp @@ -60,8 +60,8 @@ namespace Opm void setFreeOil () { insert(BlackoilPhases::Liquid); } void setFreeGas () { insert(BlackoilPhases::Vapour); } - bool operator==(const PhasePresence& other) { return present_ == other.present_; } - bool operator!=(const PhasePresence& other) { return !this->operator==(other); } + bool operator==(const PhasePresence& other) const { return present_ == other.present_; } + bool operator!=(const PhasePresence& other) const { return !this->operator==(other); } private: unsigned char present_; From a920b43e2180d2a550b8728ba856b265e68ea165 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Wed, 15 Jun 2016 15:40:38 +0800 Subject: [PATCH 41/69] Rise up a warning if equil region has no active cells. --- opm/core/simulator/initStateEquil.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/opm/core/simulator/initStateEquil.hpp b/opm/core/simulator/initStateEquil.hpp index 2b4b02b1f..bff1813ca 100644 --- a/opm/core/simulator/initStateEquil.hpp +++ b/opm/core/simulator/initStateEquil.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -389,11 +390,14 @@ namespace Opm const Grid& G , const double grav) { + int regnum = 0; for (const auto& r : reg.activeRegions()) { + regnum++ ; const auto& cells = reg.cells(r); if (cells.empty()) { - continue; + OpmLog::warning("Equilibration region " + std::to_string(regnum) + + " has no active cells"); } const int repcell = *cells.begin(); From a9c2128daa6e5d469b02b96437480bf5f3934670 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Wed, 15 Jun 2016 16:52:32 +0800 Subject: [PATCH 42/69] use correct region number. --- opm/core/simulator/initStateEquil.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/opm/core/simulator/initStateEquil.hpp b/opm/core/simulator/initStateEquil.hpp index bff1813ca..7ed55cb56 100644 --- a/opm/core/simulator/initStateEquil.hpp +++ b/opm/core/simulator/initStateEquil.hpp @@ -390,14 +390,13 @@ namespace Opm const Grid& G , const double grav) { - int regnum = 0; for (const auto& r : reg.activeRegions()) { - regnum++ ; const auto& cells = reg.cells(r); if (cells.empty()) { - OpmLog::warning("Equilibration region " + std::to_string(regnum) + OpmLog::warning("Equilibration region " + std::to_string(r) + " has no active cells"); + continue; } const int repcell = *cells.begin(); From 123159460054d65b0fbdec97e0a2cbc0bf695ef4 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Wed, 15 Jun 2016 16:53:51 +0800 Subject: [PATCH 43/69] it should be the same number in EQLNUM. --- opm/core/simulator/initStateEquil.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/simulator/initStateEquil.hpp b/opm/core/simulator/initStateEquil.hpp index 7ed55cb56..b03d488a0 100644 --- a/opm/core/simulator/initStateEquil.hpp +++ b/opm/core/simulator/initStateEquil.hpp @@ -394,7 +394,7 @@ namespace Opm const auto& cells = reg.cells(r); if (cells.empty()) { - OpmLog::warning("Equilibration region " + std::to_string(r) + OpmLog::warning("Equilibration region " + std::to_string(r + 1) + " has no active cells"); continue; } From 06ebdc9268578e50099c48c7e31a30aa0d8216bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 15 Jun 2016 10:55:42 +0200 Subject: [PATCH 44/69] Avoid ambiguous calls to abs with unsigned integers. --- opm/core/linalg/ParallelIstlInformation.hpp | 34 +++++++++++++++------ tests/test_parallelistlinformation.cpp | 5 ++- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/opm/core/linalg/ParallelIstlInformation.hpp b/opm/core/linalg/ParallelIstlInformation.hpp index 49504dff4..9dae2c4f7 100644 --- a/opm/core/linalg/ParallelIstlInformation.hpp +++ b/opm/core/linalg/ParallelIstlInformation.hpp @@ -578,18 +578,32 @@ private: namespace detail { - /// \brief Computes the maximum of theabsolute values of two values. - template - struct MaxAbsFunctor - { - typedef T result_type; - - result_type operator()(const T& t1, const T& t2) + /// \brief Computes the maximum of the absolute values of two values. + template + struct MaxAbsFunctor { - return std::max(std::abs(t1),std::abs(t2)); - } - }; + typedef T result_type; + + result_type operator()(const T& t1, const T& t2) + { + return std::max(std::abs(t1),std::abs(t2)); + } + }; + + + /// \brief Specialization to avoid ambiguous abs() for unsigned integers. + template <> + struct MaxAbsFunctor + { + typedef std::size_t result_type; + + result_type operator()(const std::size_t& t1, const std::size_t& t2) + { + return std::max(t1, t2); + } + }; } + /// \brief Create a functor for computing a global L infinity norm /// /// To be used with ParallelISTLInformation::computeReduction. diff --git a/tests/test_parallelistlinformation.cpp b/tests/test_parallelistlinformation.cpp index 8258ad329..f0a07283e 100644 --- a/tests/test_parallelistlinformation.cpp +++ b/tests/test_parallelistlinformation.cpp @@ -33,6 +33,7 @@ #include #ifdef HAVE_DUNE_ISTL + template void runSumMaxMinTest(const T offset) { @@ -60,7 +61,9 @@ void runSumMaxMinTest(const T offset) BOOST_CHECK(std::get<1>(values)==std::max(N+offset-1, std::get<1>(oldvalues))); BOOST_CHECK(std::get<2>(values)==std::min(offset, std::get<2>(oldvalues))); BOOST_CHECK(std::get<3>(values)==((end-1)*end*(2*end-1)-(start-1)*start*(2*start-1))/6+std::get<3>(oldvalues)); - BOOST_CHECK(std::get<4>(values)==std::max(std::abs(offset),std::abs(N+offset-1))); + // Must avoid std::abs() directly to prevent ambiguity with unsigned integers. + Opm::Reduction::detail::MaxAbsFunctor maxabsfunc; + BOOST_CHECK(std::get<4>(values)==maxabsfunc(offset, N+offset-1)); } BOOST_AUTO_TEST_CASE(tupleReductionTestInt) From 22c2093426e4d4ff5f34b5d1269478b6615f496b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 15 Jun 2016 14:18:11 +0200 Subject: [PATCH 45/69] Set default solver depending on configuration. --- opm/core/linalg/LinearSolverFactory.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/opm/core/linalg/LinearSolverFactory.cpp b/opm/core/linalg/LinearSolverFactory.cpp index d2bd31204..6cea69241 100644 --- a/opm/core/linalg/LinearSolverFactory.cpp +++ b/opm/core/linalg/LinearSolverFactory.cpp @@ -61,8 +61,18 @@ namespace Opm LinearSolverFactory::LinearSolverFactory(const parameter::ParameterGroup& param) { +#if HAVE_SUITESPARSE_UMFPACK_H + std::string default_solver = "umfpack"; +#elif HAVE_DUNE_ISTL + std::string default_solver = "istl"; +#elif HAVE_PETSC + std::string default_solver = "petsc"; +#else + OPM_THROW(std::runtime_error, "No linear solver available, you must have UMFPACK , dune-istl or Petsc installed to use LinearSolverFactory."); +#endif + const std::string ls = - param.getDefault("linsolver", "umfpack"); + param.getDefault("linsolver", default_solver); if (ls == "umfpack") { #if HAVE_SUITESPARSE_UMFPACK_H From 854296d71084789663b690590cec4b953229167a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 15 Jun 2016 15:01:45 +0200 Subject: [PATCH 46/69] Address review comments. --- opm/core/linalg/LinearSolverFactory.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opm/core/linalg/LinearSolverFactory.cpp b/opm/core/linalg/LinearSolverFactory.cpp index 6cea69241..f8eca83d1 100644 --- a/opm/core/linalg/LinearSolverFactory.cpp +++ b/opm/core/linalg/LinearSolverFactory.cpp @@ -68,11 +68,12 @@ namespace Opm #elif HAVE_PETSC std::string default_solver = "petsc"; #else + std::string default_solver = "no_solver_available"; OPM_THROW(std::runtime_error, "No linear solver available, you must have UMFPACK , dune-istl or Petsc installed to use LinearSolverFactory."); #endif const std::string ls = - param.getDefault("linsolver", default_solver); + param.getDefault("linsolver", default_solver); if (ls == "umfpack") { #if HAVE_SUITESPARSE_UMFPACK_H From f5d1cbfb757e973c7795e905589a0ccd1e15f4d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 16 Jun 2016 08:47:21 +0200 Subject: [PATCH 47/69] Make specialization for all unsigned integer types. --- opm/core/linalg/ParallelIstlInformation.hpp | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/opm/core/linalg/ParallelIstlInformation.hpp b/opm/core/linalg/ParallelIstlInformation.hpp index 9dae2c4f7..bd497a793 100644 --- a/opm/core/linalg/ParallelIstlInformation.hpp +++ b/opm/core/linalg/ParallelIstlInformation.hpp @@ -579,25 +579,26 @@ private: namespace detail { /// \brief Computes the maximum of the absolute values of two values. - template + template struct MaxAbsFunctor { - typedef T result_type; - - result_type operator()(const T& t1, const T& t2) + using result_type = T; + result_type operator()(const T& t1, + const T& t2) { - return std::max(std::abs(t1),std::abs(t2)); + return std::max(std::abs(t1), std::abs(t2)); } }; - - /// \brief Specialization to avoid ambiguous abs() for unsigned integers. - template <> - struct MaxAbsFunctor + // Specialization for unsigned integers. They need their own + // version since abs(x) is ambiguous (as well as somewhat + // meaningless). + template + struct MaxAbsFunctor::value>::type> { - typedef std::size_t result_type; - - result_type operator()(const std::size_t& t1, const std::size_t& t2) + using result_type = T; + result_type operator()(const T& t1, + const T& t2) { return std::max(t1, t2); } From 03104f2320f2af4b8f1a54d8e9ec68fb1cadab17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Thu, 16 Jun 2016 09:33:43 +0200 Subject: [PATCH 48/69] WellPtr and GroupPtr deprecated shared_ptr aliases are considered deprecated and has largely been removed upstream (and replaced by raw pointers). --- opm/core/wells/WellCollection.cpp | 6 +++--- opm/core/wells/WellCollection.hpp | 6 +++--- opm/core/wells/WellsGroup.cpp | 4 ++-- opm/core/wells/WellsGroup.hpp | 4 ++-- opm/core/wells/WellsManager.cpp | 8 ++++---- opm/core/wells/WellsManager.hpp | 6 +++--- opm/core/wells/WellsManager_impl.hpp | 11 +++++------ tests/test_wellcollection.cpp | 14 +++++++------- tests/test_wellsgroup.cpp | 6 +++--- 9 files changed, 32 insertions(+), 33 deletions(-) diff --git a/opm/core/wells/WellCollection.cpp b/opm/core/wells/WellCollection.cpp index ba94d0973..d1238e7c7 100644 --- a/opm/core/wells/WellCollection.cpp +++ b/opm/core/wells/WellCollection.cpp @@ -29,7 +29,7 @@ namespace Opm { - void WellCollection::addField(GroupConstPtr fieldGroup, size_t timeStep, const PhaseUsage& phaseUsage) { + void WellCollection::addField(const Group* fieldGroup, size_t timeStep, const PhaseUsage& phaseUsage) { WellsGroupInterface* fieldNode = findNode(fieldGroup->name()); if (fieldNode) { OPM_THROW(std::runtime_error, "Trying to add FIELD node, but this already exists. Can only have one FIELD node."); @@ -38,7 +38,7 @@ namespace Opm roots_.push_back(createGroupWellsGroup(fieldGroup, timeStep, phaseUsage)); } - void WellCollection::addGroup(GroupConstPtr groupChild, std::string parent_name, + void WellCollection::addGroup(const Group* groupChild, std::string parent_name, size_t timeStep, const PhaseUsage& phaseUsage) { WellsGroupInterface* parent = findNode(parent_name); if (!parent) { @@ -60,7 +60,7 @@ namespace Opm child->setParent(parent); } - void WellCollection::addWell(WellConstPtr wellChild, size_t timeStep, const PhaseUsage& phaseUsage) { + void WellCollection::addWell(const Well* wellChild, size_t timeStep, const PhaseUsage& phaseUsage) { if (wellChild->getStatus(timeStep) == WellCommon::SHUT) { //SHUT wells are not added to the well collection return; diff --git a/opm/core/wells/WellCollection.hpp b/opm/core/wells/WellCollection.hpp index b597c4b64..b00827431 100644 --- a/opm/core/wells/WellCollection.hpp +++ b/opm/core/wells/WellCollection.hpp @@ -36,11 +36,11 @@ namespace Opm { public: - void addField(GroupConstPtr fieldGroup, size_t timeStep, const PhaseUsage& phaseUsage); + void addField(const Group* fieldGroup, size_t timeStep, const PhaseUsage& phaseUsage); - void addWell(WellConstPtr wellChild, size_t timeStep, const PhaseUsage& phaseUsage); + void addWell(const Well* wellChild, size_t timeStep, const PhaseUsage& phaseUsage); - void addGroup(GroupConstPtr groupChild, std::string parent_name, + void addGroup(const Group* groupChild, std::string parent_name, size_t timeStep, const PhaseUsage& phaseUsage); /// Adds the child to the collection diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index 6eef1e4f0..558f39fc7 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -1064,7 +1064,7 @@ namespace Opm } } // anonymous namespace - std::shared_ptr createGroupWellsGroup(GroupConstPtr group, size_t timeStep, const PhaseUsage& phase_usage ) + std::shared_ptr createGroupWellsGroup(const Group* group, size_t timeStep, const PhaseUsage& phase_usage ) { InjectionSpecification injection_specification; ProductionSpecification production_specification; @@ -1099,7 +1099,7 @@ namespace Opm 'CMODE_UNDEFINED' - we do not carry that over the specification objects here. */ - std::shared_ptr createWellWellsGroup(WellConstPtr well, size_t timeStep, const PhaseUsage& phase_usage ) + std::shared_ptr createWellWellsGroup(const Well* well, size_t timeStep, const PhaseUsage& phase_usage ) { InjectionSpecification injection_specification; ProductionSpecification production_specification; diff --git a/opm/core/wells/WellsGroup.hpp b/opm/core/wells/WellsGroup.hpp index 697a23cbc..c93fcdac4 100644 --- a/opm/core/wells/WellsGroup.hpp +++ b/opm/core/wells/WellsGroup.hpp @@ -406,14 +406,14 @@ namespace Opm /// \param[in] well the Well to construct object for /// \param[in] timeStep the time step in question /// \param[in] the phase usage - std::shared_ptr createWellWellsGroup(WellConstPtr well, size_t timeStep, + std::shared_ptr createWellWellsGroup(const Well* well, size_t timeStep, const PhaseUsage& phase_usage ); /// Creates the WellsGroupInterface for the given Group /// \param[in] group the Group to construct object for /// \param[in] timeStep the time step in question /// \param[in] the phase usage - std::shared_ptr createGroupWellsGroup(GroupConstPtr group, size_t timeStep, + std::shared_ptr createGroupWellsGroup(const Group* group, size_t timeStep, const PhaseUsage& phase_usage ); } #endif /* OPM_WELLSGROUP_HPP */ diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index f9ad8569a..124d35ff1 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -414,7 +414,7 @@ namespace Opm - void WellsManager::setupWellControls(std::vector& wells, size_t timeStep, + void WellsManager::setupWellControls(std::vector< const Well* >& wells, size_t timeStep, std::vector& well_names, const PhaseUsage& phaseUsage, const std::vector& wells_on_proc) { int well_index = 0; @@ -427,7 +427,7 @@ namespace Opm continue; } - WellConstPtr well = (*wellIter); + const auto* well = (*wellIter); if (well->getStatus(timeStep) == WellCommon::STOP) { // STOPed wells are kept in the well list but marked as stopped. @@ -728,12 +728,12 @@ namespace Opm } - void WellsManager::setupGuideRates(std::vector& wells, const size_t timeStep, std::vector& well_data, std::map& well_names_to_index, + void WellsManager::setupGuideRates(std::vector< const Well* >& wells, const size_t timeStep, std::vector& well_data, std::map& well_names_to_index, const PhaseUsage& phaseUsage, const std::vector& well_potentials) { const int np = phaseUsage.num_phases; for (auto wellIter = wells.begin(); wellIter != wells.end(); ++wellIter ) { - WellConstPtr well = *wellIter; + const auto* well = *wellIter; if (well->getStatus(timeStep) == WellCommon::SHUT) { //SHUT wells does not need guide rates diff --git a/opm/core/wells/WellsManager.hpp b/opm/core/wells/WellsManager.hpp index 022871abf..fc41c2fd3 100644 --- a/opm/core/wells/WellsManager.hpp +++ b/opm/core/wells/WellsManager.hpp @@ -160,12 +160,12 @@ namespace Opm WellsManager(const WellsManager& other); WellsManager& operator=(const WellsManager& other); static void setupCompressedToCartesian(const int* global_cell, int number_of_cells, std::map& cartesian_to_compressed ); - void setupWellControls(std::vector& wells, size_t timeStep, + void setupWellControls(std::vector& wells, size_t timeStep, std::vector& well_names, const PhaseUsage& phaseUsage, const std::vector& wells_on_proc); template - void createWellsFromSpecs( std::vector& wells, size_t timeStep, + void createWellsFromSpecs( std::vector& wells, size_t timeStep, const C2F& cell_to_faces, const int* cart_dims, FC begin_face_centroids, @@ -181,7 +181,7 @@ namespace Opm std::vector& wells_on_proc); void addChildGroups(GroupTreeNodeConstPtr parentNode, std::shared_ptr< const Schedule > schedule, size_t timeStep, const PhaseUsage& phaseUsage); - void setupGuideRates(std::vector& wells, const size_t timeStep, std::vector& well_data, std::map& well_names_to_index, + void setupGuideRates(std::vector& wells, const size_t timeStep, std::vector& well_data, std::map& well_names_to_index, const PhaseUsage& phaseUsage, const std::vector& well_potentials); // Data Wells* w_; diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 21c51cb23..9cfc3c92e 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -107,7 +107,7 @@ getCubeDim(const C2F& c2f, namespace Opm { template -void WellsManager::createWellsFromSpecs(std::vector& wells, size_t timeStep, +void WellsManager::createWellsFromSpecs(std::vector& wells, size_t timeStep, const C2F& c2f, const int* cart_dims, FC begin_face_centroids, @@ -138,7 +138,7 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t // the index of the well according to the eclipse state int well_index_on_proc = 0; for (auto wellIter= wells.begin(); wellIter != wells.end(); ++wellIter) { - WellConstPtr well = (*wellIter); + const auto* well = (*wellIter); if (well->getStatus(timeStep) == WellCommon::SHUT) { continue; @@ -379,8 +379,8 @@ WellsManager::init(const Opm::EclipseStateConstPtr eclipseState, std::map well_names_to_index; auto schedule = eclipseState->getSchedule(); - std::vector wells = schedule->getWells(timeStep); - std::vector wells_on_proc; + auto wells = schedule->getWells(timeStep); + std::vector wells_on_proc; well_names.reserve(wells.size()); well_data.reserve(wells.size()); @@ -418,8 +418,7 @@ WellsManager::init(const Opm::EclipseStateConstPtr eclipseState, GroupTreeNodeConstPtr fieldNode = schedule->getGroupTree(timeStep)->getNode("FIELD"); - GroupConstPtr fieldGroup = - schedule->getGroup(fieldNode->name()); + const auto* fieldGroup = schedule->getGroup(fieldNode->name()); well_collection_.addField(fieldGroup, timeStep, pu); addChildGroups(fieldNode, schedule, timeStep, pu); diff --git a/tests/test_wellcollection.cpp b/tests/test_wellcollection.cpp index 6870853d3..6378941e0 100644 --- a/tests/test_wellcollection.cpp +++ b/tests/test_wellcollection.cpp @@ -54,24 +54,24 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) { WellCollection collection; // Add groups to WellCollection - GroupConstPtr fieldGroup = eclipseState->getSchedule()->getGroup(field->name()); + const auto* fieldGroup = eclipseState->getSchedule()->getGroup(field->name()); collection.addField(fieldGroup, 2, pu); for (auto iter = field->begin(); iter != field->end(); ++iter) { - GroupConstPtr childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name()); + const auto* childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name()); collection.addGroup(childGroupNode, fieldGroup->name(), 2, pu); } - GroupConstPtr g1Group = eclipseState->getSchedule()->getGroup(g1->name()); + const auto* g1Group = eclipseState->getSchedule()->getGroup(g1->name()); for (auto iter = g1->begin(); iter != g1->end(); ++iter) { - GroupConstPtr childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name()); + const auto* childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name()); collection.addGroup(childGroupNode, g1Group->name(), 2, pu); } - GroupConstPtr g2Group = eclipseState->getSchedule()->getGroup(g2->name()); + const auto* g2Group = eclipseState->getSchedule()->getGroup(g2->name()); for (auto iter = g2->begin(); iter != g2->end(); ++iter) { - GroupConstPtr childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name()); + const auto* childGroupNode = eclipseState->getSchedule()->getGroup((*iter).second->name()); collection.addGroup(childGroupNode, g2Group->name(), 2, pu); } @@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) { // Add wells to WellCollection WellCollection wellCollection; - std::vector wells = eclipseState->getSchedule()->getWells(); + auto wells = eclipseState->getSchedule()->getWells(); for (size_t i=0; i wells = eclipseState->getSchedule()->getWells(); + auto wells = eclipseState->getSchedule()->getWells(); for (size_t i=0; i wellsGroup = createWellWellsGroup(well, 2, pu); BOOST_CHECK_EQUAL(well->name(), wellsGroup->name()); if (well->isInjector(2)) { @@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromGroup) { std::vector nodes = eclipseState->getSchedule()->getGroupTree(2)->getNodes(); for (size_t i=0; igetSchedule()->getGroup(nodes[i]->name()); + const auto* group = eclipseState->getSchedule()->getGroup(nodes[i]->name()); std::shared_ptr wellsGroup = createGroupWellsGroup(group, 2, pu); BOOST_CHECK_EQUAL(group->name(), wellsGroup->name()); if (group->isInjectionGroup(2)) { From 5641876d1ded8166e11132a8fbb99fdf61c9da8b Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Tue, 7 Jun 2016 08:40:16 +0200 Subject: [PATCH 49/69] Fix two phase EQUIL initialization --- opm/core/simulator/initStateEquil_impl.hpp | 50 ++++++++++++---------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/opm/core/simulator/initStateEquil_impl.hpp b/opm/core/simulator/initStateEquil_impl.hpp index b3d750c34..20f56c5a4 100644 --- a/opm/core/simulator/initStateEquil_impl.hpp +++ b/opm/core/simulator/initStateEquil_impl.hpp @@ -767,28 +767,34 @@ namespace Opm double sat[BlackoilPhases::MaxNumPhases]; double threshold_sat = 1.0e-6; - sat[waterpos] = smax[waterpos]; - sat[gaspos] = smax[gaspos]; - sat[oilpos] = 1.0 - sat[waterpos] - sat[gaspos]; - if (sw > smax[waterpos]-threshold_sat ) { - sat[waterpos] = smax[waterpos]; - props.capPress(1, sat, &cell, pc, 0); - phase_pressures[oilpos][local_index] = phase_pressures[waterpos][local_index] + pc[waterpos]; - } else if (sg > smax[gaspos]-threshold_sat) { - sat[gaspos] = smax[gaspos]; - props.capPress(1, sat, &cell, pc, 0); - phase_pressures[oilpos][local_index] = phase_pressures[gaspos][local_index] - pc[gaspos]; - } - if (sg < smin[gaspos]+threshold_sat) { - sat[gaspos] = smin[gaspos]; - props.capPress(1, sat, &cell, pc, 0); - phase_pressures[gaspos][local_index] = phase_pressures[oilpos][local_index] + pc[gaspos]; - } - if (sw < smin[waterpos]+threshold_sat) { - sat[waterpos] = smin[waterpos]; - props.capPress(1, sat, &cell, pc, 0); - phase_pressures[waterpos][local_index] = phase_pressures[oilpos][local_index] - pc[waterpos]; - } + sat[oilpos] = 1.0; + if (water) { + sat[waterpos] = smax[waterpos]; + sat[oilpos] -= sat[waterpos]; + } + if (gas) { + sat[gaspos] = smax[gaspos]; + sat[oilpos] -= sat[gaspos]; + } + if (water && sw > smax[waterpos]-threshold_sat ) { + sat[waterpos] = smax[waterpos]; + props.capPress(1, sat, &cell, pc, 0); + phase_pressures[oilpos][local_index] = phase_pressures[waterpos][local_index] + pc[waterpos]; + } else if (gas && sg > smax[gaspos]-threshold_sat) { + sat[gaspos] = smax[gaspos]; + props.capPress(1, sat, &cell, pc, 0); + phase_pressures[oilpos][local_index] = phase_pressures[gaspos][local_index] - pc[gaspos]; + } + if (gas && sg < smin[gaspos]+threshold_sat) { + sat[gaspos] = smin[gaspos]; + props.capPress(1, sat, &cell, pc, 0); + phase_pressures[gaspos][local_index] = phase_pressures[oilpos][local_index] + pc[gaspos]; + } + if (water && sw < smin[waterpos]+threshold_sat) { + sat[waterpos] = smin[waterpos]; + props.capPress(1, sat, &cell, pc, 0); + phase_pressures[waterpos][local_index] = phase_pressures[oilpos][local_index] - pc[waterpos]; + } } return phase_saturations; } From 3247aaa557a994932ba3cae72a912cb0c5b25da0 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 8 Jun 2016 09:11:42 +0200 Subject: [PATCH 50/69] Fix reference pressure for oil-water problem In opm-material the wetting phase is the reference phase for two-phase problems i.e water for oil-water system, but for flow it is always oil. Add oil capillary pressure value to shift the reference phase to oil --- .../props/satfunc/SaturationPropsFromDeck.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck.cpp b/opm/core/props/satfunc/SaturationPropsFromDeck.cpp index db7ab6221..bbeae6296 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck.cpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck.cpp @@ -139,6 +139,7 @@ namespace Opm assert(cells != 0); const int np = numPhases(); + if (dpcds) { ExplicitArraysSatDerivativesFluidState fluidState(phaseUsage_); typedef ExplicitArraysSatDerivativesFluidState::Evaluation Evaluation; @@ -153,10 +154,13 @@ namespace Opm // copy the values calculated using opm-material to the target arrays for (int pcPhaseIdx = 0; pcPhaseIdx < np; ++pcPhaseIdx) { double sign = (pcPhaseIdx == BlackoilPhases::Aqua)? -1.0 : 1.0; - pc[np*i + pcPhaseIdx] = sign*capillaryPressures[pcPhaseIdx].value; - + // in opm-material the wetting phase is the reference phase + // for two-phase problems i.e water for oil-water system, + // but for flow it is always oil. Add oil (liquid) capillary pressure value + // to shift the reference phase to oil + pc[np*i + pcPhaseIdx] = capillaryPressures[BlackoilPhases::Liquid].value + sign * capillaryPressures[pcPhaseIdx].value; for (int satPhaseIdx = 0; satPhaseIdx < np; ++satPhaseIdx) - dpcds[np*np*i + satPhaseIdx*np + pcPhaseIdx] = sign*capillaryPressures[pcPhaseIdx].derivatives[satPhaseIdx]; + dpcds[np*np*i + satPhaseIdx*np + pcPhaseIdx] = capillaryPressures[BlackoilPhases::Liquid].derivatives[satPhaseIdx] + sign * capillaryPressures[pcPhaseIdx].derivatives[satPhaseIdx]; } } } else { @@ -172,7 +176,11 @@ namespace Opm // copy the values calculated using opm-material to the target arrays for (int pcPhaseIdx = 0; pcPhaseIdx < np; ++pcPhaseIdx) { double sign = (pcPhaseIdx == BlackoilPhases::Aqua)? -1.0 : 1.0; - pc[np*i + pcPhaseIdx] = sign*capillaryPressures[pcPhaseIdx]; + // in opm-material the wetting phase is the reference phase + // for two-phase problems i.e water for oil-water system, + // but for flow it is always oil. Add oil (liquid) capillary pressure value + // to shift the reference phase to oil + pc[np*i + pcPhaseIdx] = capillaryPressures[BlackoilPhases::Liquid] + sign * capillaryPressures[pcPhaseIdx]; } } } From cc100a621783b0070c8c13f6ad6c6dfd5005df6e Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 20 Jun 2016 11:14:36 +0200 Subject: [PATCH 51/69] Fix bug for OIL-GAS case - Differentiate between active and canonical phase index --- .../props/satfunc/SaturationPropsFromDeck.cpp | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck.cpp b/opm/core/props/satfunc/SaturationPropsFromDeck.cpp index bbeae6296..b800ca1e8 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck.cpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck.cpp @@ -136,7 +136,8 @@ namespace Opm double* pc, double* dpcds) const { - assert(cells != 0); + assert(cells != 0); + assert(phaseUsage_.phase_used[BlackoilPhases::Liquid]); const int np = numPhases(); @@ -152,15 +153,25 @@ namespace Opm MaterialLaw::capillaryPressures(capillaryPressures, params, fluidState); // copy the values calculated using opm-material to the target arrays - for (int pcPhaseIdx = 0; pcPhaseIdx < np; ++pcPhaseIdx) { - double sign = (pcPhaseIdx == BlackoilPhases::Aqua)? -1.0 : 1.0; + for (int canonicalPhaseIdx = 0; canonicalPhaseIdx < BlackoilPhases::MaxNumPhases; ++canonicalPhaseIdx) { + // skip unused phases + if ( ! phaseUsage_.phase_used[canonicalPhaseIdx]) + continue; + const int pcPhaseIdx = phaseUsage_.phase_pos[canonicalPhaseIdx]; + + double sign = (canonicalPhaseIdx == BlackoilPhases::Aqua)? -1.0 : 1.0; // in opm-material the wetting phase is the reference phase // for two-phase problems i.e water for oil-water system, // but for flow it is always oil. Add oil (liquid) capillary pressure value // to shift the reference phase to oil - pc[np*i + pcPhaseIdx] = capillaryPressures[BlackoilPhases::Liquid].value + sign * capillaryPressures[pcPhaseIdx].value; - for (int satPhaseIdx = 0; satPhaseIdx < np; ++satPhaseIdx) - dpcds[np*np*i + satPhaseIdx*np + pcPhaseIdx] = capillaryPressures[BlackoilPhases::Liquid].derivatives[satPhaseIdx] + sign * capillaryPressures[pcPhaseIdx].derivatives[satPhaseIdx]; + pc[np*i + pcPhaseIdx] = capillaryPressures[BlackoilPhases::Liquid].value + sign * capillaryPressures[canonicalPhaseIdx].value; + for (int canonicalSatPhaseIdx = 0; canonicalSatPhaseIdx < BlackoilPhases::MaxNumPhases; ++canonicalSatPhaseIdx) { + if ( ! phaseUsage_.phase_used[canonicalSatPhaseIdx]) + continue; + + const int satPhaseIdx = phaseUsage_.phase_pos[canonicalSatPhaseIdx]; + dpcds[np*np*i + satPhaseIdx*np + pcPhaseIdx] = capillaryPressures[BlackoilPhases::Liquid].derivatives[canonicalSatPhaseIdx] + sign * capillaryPressures[canonicalPhaseIdx].derivatives[canonicalSatPhaseIdx]; + } } } } else { @@ -174,13 +185,18 @@ namespace Opm MaterialLaw::capillaryPressures(capillaryPressures, params, fluidState); // copy the values calculated using opm-material to the target arrays - for (int pcPhaseIdx = 0; pcPhaseIdx < np; ++pcPhaseIdx) { - double sign = (pcPhaseIdx == BlackoilPhases::Aqua)? -1.0 : 1.0; + for (int canonicalPhaseIdx = 0; canonicalPhaseIdx < BlackoilPhases::MaxNumPhases; ++canonicalPhaseIdx) { + // skip unused phases + if ( ! phaseUsage_.phase_used[canonicalPhaseIdx]) + continue; + + const int pcPhaseIdx = phaseUsage_.phase_pos[canonicalPhaseIdx]; + double sign = (canonicalPhaseIdx == BlackoilPhases::Aqua)? -1.0 : 1.0; // in opm-material the wetting phase is the reference phase // for two-phase problems i.e water for oil-water system, // but for flow it is always oil. Add oil (liquid) capillary pressure value // to shift the reference phase to oil - pc[np*i + pcPhaseIdx] = capillaryPressures[BlackoilPhases::Liquid] + sign * capillaryPressures[pcPhaseIdx]; + pc[np*i + pcPhaseIdx] = capillaryPressures[BlackoilPhases::Liquid] + sign * capillaryPressures[canonicalPhaseIdx]; } } } From e9c2382b45cacc2b1dc3cf09f9cfba82a640211f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Gr=C3=B8n=C3=A5s=20Drange?= Date: Mon, 20 Jun 2016 14:13:29 +0200 Subject: [PATCH 52/69] Remove [-Wreturn-type] warnings (added throw), added copyright header --- opm/core/wells/InjectionSpecification.cpp | 22 ++++++++++++++++++++++ opm/core/wells/ProductionSpecification.cpp | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/opm/core/wells/InjectionSpecification.cpp b/opm/core/wells/InjectionSpecification.cpp index fd85a7727..30a4e805b 100644 --- a/opm/core/wells/InjectionSpecification.cpp +++ b/opm/core/wells/InjectionSpecification.cpp @@ -1,3 +1,22 @@ +/* + Copyright 2016 The Open Porous Media project. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify it under the terms + of the GNU General Public License as published by the Free Software + Foundation, either version 3 of the License, or (at your option) any later + version. + + OPM is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + OPM. If not, see . + */ + +#include #include "config.h" #include @@ -32,6 +51,7 @@ namespace Opm case ControlMode::GRUP: return "GRUP"; case ControlMode::FLD : return "FLD" ; } + throw new std::domain_error("Unknown control mode"); } @@ -43,6 +63,7 @@ namespace Opm case InjectorType::OIL : return "OIL" ; case InjectorType::GAS : return "GAS" ; } + throw new std::domain_error("Unknown injector type"); } @@ -53,5 +74,6 @@ namespace Opm case GuideRateType::RAT : return "RAT" ; case GuideRateType::NONE_GRT: return "NONE_GRT"; } + throw new std::domain_error("Unknown guide rate type"); } } // namespace Opm diff --git a/opm/core/wells/ProductionSpecification.cpp b/opm/core/wells/ProductionSpecification.cpp index 4590e082c..a23e0074e 100644 --- a/opm/core/wells/ProductionSpecification.cpp +++ b/opm/core/wells/ProductionSpecification.cpp @@ -1,3 +1,22 @@ +/* + Copyright 2016 The Open Porous Media project. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify it under the terms + of the GNU General Public License as published by the Free Software + Foundation, either version 3 of the License, or (at your option) any later + version. + + OPM is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + OPM. If not, see . + */ + +#include #include "config.h" #include @@ -37,6 +56,7 @@ namespace Opm case ControlMode::GRUP: return "GRUP"; case ControlMode::FLD : return "FLD" ; } + throw new std::domain_error("Unknown control mode"); } @@ -48,6 +68,7 @@ namespace Opm case Procedure::RATE : return "RATE" ; case Procedure::WELL : return "WELL" ; } + throw new std::domain_error("Unknown procedure"); } @@ -60,6 +81,7 @@ namespace Opm case GuideRateType::WATER : return "WATER" ; case GuideRateType::NONE_GRT: return "NONE_GRT"; } + throw new std::domain_error("Unknown guide rate type"); } From 4acd8595598e0e9e45e6e54958028f3bf8945c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Gr=C3=B8n=C3=A5s=20Drange?= Date: Mon, 20 Jun 2016 17:20:33 +0200 Subject: [PATCH 53/69] Using OPM_THROW to log messages, fixed Copyright headers --- opm/core/wells/InjectionSpecification.cpp | 11 +++++++---- opm/core/wells/ProductionSpecification.cpp | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/opm/core/wells/InjectionSpecification.cpp b/opm/core/wells/InjectionSpecification.cpp index 30a4e805b..09d11f60f 100644 --- a/opm/core/wells/InjectionSpecification.cpp +++ b/opm/core/wells/InjectionSpecification.cpp @@ -1,5 +1,6 @@ /* - Copyright 2016 The Open Porous Media project. + Copyright 2012 Sintef. + Copyright 2016 Statoil. This file is part of the Open Porous Media project (OPM). @@ -18,6 +19,8 @@ #include #include "config.h" + +#include #include namespace Opm @@ -51,7 +54,7 @@ namespace Opm case ControlMode::GRUP: return "GRUP"; case ControlMode::FLD : return "FLD" ; } - throw new std::domain_error("Unknown control mode"); + OPM_THROW(std::domain_error, "Unknown control mode " << mode << " encountered in injection specification"); } @@ -63,7 +66,7 @@ namespace Opm case InjectorType::OIL : return "OIL" ; case InjectorType::GAS : return "GAS" ; } - throw new std::domain_error("Unknown injector type"); + OPM_THROW(std::domain_error, "Unknown injector type " << type << " encountered in injection specification"); } @@ -74,6 +77,6 @@ namespace Opm case GuideRateType::RAT : return "RAT" ; case GuideRateType::NONE_GRT: return "NONE_GRT"; } - throw new std::domain_error("Unknown guide rate type"); + OPM_THROW(std::domain_error, "Unknown guide rate type " << type << " encountered in injection specification"); } } // namespace Opm diff --git a/opm/core/wells/ProductionSpecification.cpp b/opm/core/wells/ProductionSpecification.cpp index a23e0074e..20abe7157 100644 --- a/opm/core/wells/ProductionSpecification.cpp +++ b/opm/core/wells/ProductionSpecification.cpp @@ -1,5 +1,6 @@ /* - Copyright 2016 The Open Porous Media project. + Copyright 2012 Sintef. + Copyright 2016 Statoil. This file is part of the Open Porous Media project (OPM). @@ -18,6 +19,8 @@ #include #include "config.h" + +#include #include namespace Opm @@ -56,7 +59,7 @@ namespace Opm case ControlMode::GRUP: return "GRUP"; case ControlMode::FLD : return "FLD" ; } - throw new std::domain_error("Unknown control mode"); + OPM_THROW(std::domain_error, "Unknown control mode " << mode << " encountered in production specification"); } @@ -68,7 +71,7 @@ namespace Opm case Procedure::RATE : return "RATE" ; case Procedure::WELL : return "WELL" ; } - throw new std::domain_error("Unknown procedure"); + OPM_THROW(std::domain_error, "Unknown procedure " << type << " encountered in production specification"); } @@ -81,7 +84,7 @@ namespace Opm case GuideRateType::WATER : return "WATER" ; case GuideRateType::NONE_GRT: return "NONE_GRT"; } - throw new std::domain_error("Unknown guide rate type"); + OPM_THROW(std::domain_error, "Unknown guide rate type " << type << " encountered in production specification"); } From 63191a6392fc22214c48c1897570bbc5598958b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Gr=C3=B8n=C3=A5s=20Drange?= Date: Tue, 21 Jun 2016 16:10:32 +0200 Subject: [PATCH 54/69] Added DX/DY/DZ to norne_pvt.data --- tests/norne_pvt.data | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/norne_pvt.data b/tests/norne_pvt.data index bdb7af927..55192cdd6 100644 --- a/tests/norne_pvt.data +++ b/tests/norne_pvt.data @@ -15,6 +15,14 @@ DIMENS 1 1 1 / GRID +DX +1 / +DY +1 / +DZ +1 / +TOPS +1 / PROPS From 1d7e4146ed1169445bccddf6dc7e48956a743f1f Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Fri, 24 Jun 2016 13:36:05 +0200 Subject: [PATCH 55/69] Fixing some nitpicks --- opm/core/props/satfunc/SaturationPropsFromDeck.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck.cpp b/opm/core/props/satfunc/SaturationPropsFromDeck.cpp index b800ca1e8..48b1feb38 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck.cpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck.cpp @@ -155,11 +155,12 @@ namespace Opm // copy the values calculated using opm-material to the target arrays for (int canonicalPhaseIdx = 0; canonicalPhaseIdx < BlackoilPhases::MaxNumPhases; ++canonicalPhaseIdx) { // skip unused phases - if ( ! phaseUsage_.phase_used[canonicalPhaseIdx]) + if ( ! phaseUsage_.phase_used[canonicalPhaseIdx]) { continue; + } const int pcPhaseIdx = phaseUsage_.phase_pos[canonicalPhaseIdx]; - double sign = (canonicalPhaseIdx == BlackoilPhases::Aqua)? -1.0 : 1.0; + const double sign = (canonicalPhaseIdx == BlackoilPhases::Aqua)? -1.0 : 1.0; // in opm-material the wetting phase is the reference phase // for two-phase problems i.e water for oil-water system, // but for flow it is always oil. Add oil (liquid) capillary pressure value From 88ebfeba282c9ae70fa04855aaecdaea2ef6e1ac Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Mon, 27 Jun 2016 12:21:45 +0200 Subject: [PATCH 56/69] Make wells_equal work for null wells. This is needed to run test cases without wells with debugging on. Without this commit we get segmentation fault in an assert statement. --- opm/core/wells/wells.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/opm/core/wells/wells.c b/opm/core/wells/wells.c index 026b470e3..3e59efd94 100644 --- a/opm/core/wells/wells.c +++ b/opm/core/wells/wells.c @@ -545,6 +545,12 @@ bool wells_equal(const struct Wells *W1, const struct Wells *W2 , bool verbose) /* ---------------------------------------------------------------------- */ { + // Cater the case where W1 and W2 are the same (null) pointers. + if( W1 == W2 ) + { + return true; + } + bool are_equal = true; are_equal = (W1->number_of_wells == W2->number_of_wells); are_equal = are_equal && (W1->number_of_phases == W2->number_of_phases); From f976c6ee9df171936452e456b9c2e41b23a0dc99 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Mon, 27 Jun 2016 13:29:44 +0200 Subject: [PATCH 57/69] Make wells_equal work for only one null pointer. --- opm/core/wells/wells.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/opm/core/wells/wells.c b/opm/core/wells/wells.c index 3e59efd94..c986acba0 100644 --- a/opm/core/wells/wells.c +++ b/opm/core/wells/wells.c @@ -550,7 +550,11 @@ wells_equal(const struct Wells *W1, const struct Wells *W2 , bool verbose) { return true; } - + if( W1 == 0 || W2 == 0) + { + return false; + } + bool are_equal = true; are_equal = (W1->number_of_wells == W2->number_of_wells); are_equal = are_equal && (W1->number_of_phases == W2->number_of_phases); From b5f6513520875b4b9d42e444bf411b3dc347d4d0 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Mon, 27 Jun 2016 14:38:30 +0200 Subject: [PATCH 58/69] Use NULL instead of 0 in null comparison. --- opm/core/wells/wells.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/wells/wells.c b/opm/core/wells/wells.c index c986acba0..75827697f 100644 --- a/opm/core/wells/wells.c +++ b/opm/core/wells/wells.c @@ -550,7 +550,7 @@ wells_equal(const struct Wells *W1, const struct Wells *W2 , bool verbose) { return true; } - if( W1 == 0 || W2 == 0) + if( W1 == NULL || W2 == NULL) { return false; } From 7dac2201bb3111bbc7e834bb698950df03683c40 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Fri, 24 Jun 2016 16:01:12 +0200 Subject: [PATCH 59/69] WIP in adding class DynamicListEconLimited to handle the closed wells and connection dynamically based on the economic limits provied by keyword WECON --- opm/core/wells/DynamicListEconLimited.hpp | 57 +++++++++++++++++++++++ opm/core/wells/WellsManager.cpp | 7 ++- opm/core/wells/WellsManager.hpp | 6 ++- opm/core/wells/WellsManager_impl.hpp | 13 ++++-- 4 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 opm/core/wells/DynamicListEconLimited.hpp diff --git a/opm/core/wells/DynamicListEconLimited.hpp b/opm/core/wells/DynamicListEconLimited.hpp new file mode 100644 index 000000000..22123e1cb --- /dev/null +++ b/opm/core/wells/DynamicListEconLimited.hpp @@ -0,0 +1,57 @@ +/* + Copyright 2016 SINTEF ICT, Applied Mathematics. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ +#ifndef OPM_DYNAMICLISTECONLIMITED_HPP +#define OPM_DYNAMICLISTECONLIMITED_HPP + +#include +#include + +#include + +namespace Opm +{ + + /// to handle the wells and connections voilating economic limits. + class DynamicListEconLimited + { + public: + bool anyWellEconLimited() const { + return !(m_shut_wells.empty()); + }; + + bool wellEconLimited(const std::string& well_name) const { + return std::find(m_shut_wells.begin(), m_shut_wells.end(), well_name) != m_shut_wells.end(); + }; + + void addShuttedWell(const std::string& well_name) { + // the well should not be in the list + // TODO: not sure wheter a shutted well can + // still be running through some other mechanism. + assert( !wellEconLimited(well_name) ); + + m_shut_wells.push_back(well_name); + }; + + private: + std::vector m_shut_wells; + }; + +} // namespace Opm +#endif /* OPM_DYNAMICLISTECONLIMITED_HPP */ + diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index 124d35ff1..d14035abf 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -332,12 +332,15 @@ namespace Opm const double* permeability) : w_(0), is_parallel_run_(false) { - std::vector dummy_well_potentials; + std::vector dummy_well_potentials;; + // TODO: not sure about the usage of this WellsManager constructor + // TODO: not sure whether this is the correct thing to do here. + DynamicListEconLimited dummy_list_econ_limited; init(eclipseState, timeStep, UgGridHelpers::numCells(grid), UgGridHelpers::globalCell(grid), UgGridHelpers::cartDims(grid), UgGridHelpers::dimensions(grid), UgGridHelpers::cell2Faces(grid), UgGridHelpers::beginFaceCentroids(grid), - permeability, dummy_well_potentials); + permeability, dummy_list_econ_limited, dummy_well_potentials); } diff --git a/opm/core/wells/WellsManager.hpp b/opm/core/wells/WellsManager.hpp index fc41c2fd3..c43e9d095 100644 --- a/opm/core/wells/WellsManager.hpp +++ b/opm/core/wells/WellsManager.hpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -86,6 +87,7 @@ namespace Opm const F2C& f2c, FC begin_face_centroids, const double* permeability, + const DynamicListEconLimited& list_econ_limited, bool is_parallel_run=false, const std::vector& well_potentials={}); @@ -155,6 +157,7 @@ namespace Opm const C2F& cell_to_faces, FC begin_face_centroids, const double* permeability, + const DynamicListEconLimited& list_econ_limited, const std::vector& well_potentials); // Disable copying and assignment. WellsManager(const WellsManager& other); @@ -178,7 +181,8 @@ namespace Opm const std::map& cartesian_to_compressed, const double* permeability, const NTG& ntg, - std::vector& wells_on_proc); + std::vector& wells_on_proc, + const DynamicListEconLimited& list_econ_limited); void addChildGroups(GroupTreeNodeConstPtr parentNode, std::shared_ptr< const Schedule > schedule, size_t timeStep, const PhaseUsage& phaseUsage); void setupGuideRates(std::vector& wells, const size_t timeStep, std::vector& well_data, std::map& well_names_to_index, diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 9cfc3c92e..1ca0aa286 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -120,7 +120,8 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t const std::map& cartesian_to_compressed, const double* permeability, const NTG& ntg, - std::vector& wells_on_proc) + std::vector& wells_on_proc, + const DynamicListEconLimited& list_econ_limited) { if (dimensions != 3) { OPM_THROW(std::domain_error, @@ -144,6 +145,10 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t continue; } + if (list_econ_limited.wellEconLimited(well->name())) { + continue; + } + { // COMPDAT handling auto completionSet = well->getCompletions(timeStep); // shut completions and open ones stored in this process will have 1 others 0. @@ -327,13 +332,14 @@ WellsManager(const Opm::EclipseStateConstPtr eclipseState, const C2F& cell_to_faces, FC begin_face_centroids, const double* permeability, + const DynamicListEconLimited& list_econ_limited, bool is_parallel_run, const std::vector& well_potentials) : w_(0), is_parallel_run_(is_parallel_run) { init(eclipseState, timeStep, number_of_cells, global_cell, cart_dims, dimensions, - cell_to_faces, begin_face_centroids, permeability, well_potentials); + cell_to_faces, begin_face_centroids, permeability, list_econ_limited, well_potentials); } /// Construct wells from deck. @@ -348,6 +354,7 @@ WellsManager::init(const Opm::EclipseStateConstPtr eclipseState, const C2F& cell_to_faces, FC begin_face_centroids, const double* permeability, + const DynamicListEconLimited& list_econ_limited, const std::vector& well_potentials) { if (dimensions != 3) { @@ -410,7 +417,7 @@ WellsManager::init(const Opm::EclipseStateConstPtr eclipseState, dz, well_names, well_data, well_names_to_index, pu, cartesian_to_compressed, permeability, ntg, - wells_on_proc); + wells_on_proc, list_econ_limited); setupWellControls(wells, timeStep, well_names, pu, wells_on_proc); From c64d33fbd315a8c9299cfc75157fc5df3042f749 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Tue, 28 Jun 2016 09:08:37 +0200 Subject: [PATCH 60/69] adding list_econ_limited to setupWellControls --- opm/core/wells/WellsManager.cpp | 7 ++++++- opm/core/wells/WellsManager.hpp | 3 ++- opm/core/wells/WellsManager_impl.hpp | 3 ++- opm/core/wells/wells.c | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index d14035abf..3d1b9f807 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -419,7 +419,8 @@ namespace Opm void WellsManager::setupWellControls(std::vector< const Well* >& wells, size_t timeStep, std::vector& well_names, const PhaseUsage& phaseUsage, - const std::vector& wells_on_proc) { + const std::vector& wells_on_proc, + const DynamicListEconLimited& list_econ_limited) { int well_index = 0; auto well_on_proc = wells_on_proc.begin(); @@ -442,6 +443,10 @@ namespace Opm continue; } + if (list_econ_limited.wellEconLimited(well->name())) { + continue; + } + if (well->isInjector(timeStep)) { const WellInjectionProperties& injectionProperties = well->getInjectionProperties(timeStep); int ok = 1; diff --git a/opm/core/wells/WellsManager.hpp b/opm/core/wells/WellsManager.hpp index c43e9d095..79d356bff 100644 --- a/opm/core/wells/WellsManager.hpp +++ b/opm/core/wells/WellsManager.hpp @@ -165,7 +165,8 @@ namespace Opm static void setupCompressedToCartesian(const int* global_cell, int number_of_cells, std::map& cartesian_to_compressed ); void setupWellControls(std::vector& wells, size_t timeStep, std::vector& well_names, const PhaseUsage& phaseUsage, - const std::vector& wells_on_proc); + const std::vector& wells_on_proc, + const DynamicListEconLimited& list_econ_limited); template void createWellsFromSpecs( std::vector& wells, size_t timeStep, diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 1ca0aa286..12f6ac011 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -146,6 +146,7 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t } if (list_econ_limited.wellEconLimited(well->name())) { + // std::cout << " the well " << well->name() << " was closed " << std::endl; continue; } @@ -419,7 +420,7 @@ WellsManager::init(const Opm::EclipseStateConstPtr eclipseState, pu, cartesian_to_compressed, permeability, ntg, wells_on_proc, list_econ_limited); - setupWellControls(wells, timeStep, well_names, pu, wells_on_proc); + setupWellControls(wells, timeStep, well_names, pu, wells_on_proc, list_econ_limited); { GroupTreeNodeConstPtr fieldNode = diff --git a/opm/core/wells/wells.c b/opm/core/wells/wells.c index 75827697f..f1d8dc9dd 100644 --- a/opm/core/wells/wells.c +++ b/opm/core/wells/wells.c @@ -469,6 +469,8 @@ void clear_well_controls(int well_index, struct Wells *W) /* ---------------------------------------------------------------------- */ { + // printf(" well_indx = %d \n", well_index); + // printf(" W->number_of_wells = %d \n", W->number_of_wells); assert (W != NULL); assert ((0 <= well_index) && (well_index < W->number_of_wells)); From eb163e648c976cdd20950c38f39889f08343d318 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Tue, 28 Jun 2016 15:12:24 +0200 Subject: [PATCH 61/69] handling connection closing in DynamicListEconLimited due to econ limits. --- opm/core/wells/DynamicListEconLimited.hpp | 27 +++++++++++++++++++++++ opm/core/wells/WellsManager_impl.hpp | 14 ++++++++++++ 2 files changed, 41 insertions(+) diff --git a/opm/core/wells/DynamicListEconLimited.hpp b/opm/core/wells/DynamicListEconLimited.hpp index 22123e1cb..7d6e4b11d 100644 --- a/opm/core/wells/DynamicListEconLimited.hpp +++ b/opm/core/wells/DynamicListEconLimited.hpp @@ -21,6 +21,7 @@ #include #include +#include #include @@ -31,6 +32,7 @@ namespace Opm class DynamicListEconLimited { public: + bool anyWellEconLimited() const { return !(m_shut_wells.empty()); }; @@ -48,8 +50,33 @@ namespace Opm m_shut_wells.push_back(well_name); }; + // TODO: maybe completion better here + bool connectionClosedForWell(const std::string& well_name) const { + return (m_cells_closed_connections.find(well_name) != m_cells_closed_connections.end()); + } + + const std::vector& getClosedConnectionsForWell(const std::string& well_name) const { + return (m_cells_closed_connections.find(well_name)->second); + } + + std::vector& closedConnectionsForWell(const std::string& well_name) { + return (m_cells_closed_connections.find(well_name)->second); + } + + void addClosedConnectionsForWell(const std::string& well_name, + const int cell_closed_connection) { + if (connectionClosedForWell(well_name)) { + std::vector vector_cells = {cell_closed_connection}; + m_cells_closed_connections[well_name] = vector_cells; + } else { + closedConnectionsForWell(well_name).push_back(cell_closed_connection); + } + } + private: std::vector m_shut_wells; + // using grid cell number to indicate the location of the connections + std::map> m_cells_closed_connections; }; } // namespace Opm diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 12f6ac011..960b33b68 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -150,6 +150,11 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t continue; } + std::vector cells_connection_closed; + if (list_econ_limited.connectionClosedForWell(well->name())) { + cells_connection_closed = list_econ_limited.getClosedConnectionsForWell(well->name()); + } + { // COMPDAT handling auto completionSet = well->getCompletions(timeStep); // shut completions and open ones stored in this process will have 1 others 0. @@ -181,6 +186,15 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t else { int cell = cgit->second; + // check if the connection is closed due to economic limits + if (!cells_connection_closed.empty()) { + const bool connection_found = std::find(cells_connection_closed.begin(), cells_connection_closed.end(), cell) + != cells_connection_closed.end(); + if (connection_found) { + continue; + } + } + PerfData pd; pd.cell = cell; { From 28636aad5c5e3184eb952507a2f98cf44642ffcf Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Wed, 29 Jun 2016 14:46:24 +0200 Subject: [PATCH 62/69] adding stopped wells list to DynamicListEconLimited when well is closed due to rate economic limits, based on the auto shut-in configuration, the well can be STOP or SHUT. When well is closed due to all the connections are closed, it should be SHUT. --- opm/core/wells/DynamicListEconLimited.hpp | 34 ++++++++++++++--------- opm/core/wells/WellsManager.cpp | 15 +++++----- opm/core/wells/WellsManager_impl.hpp | 3 +- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/opm/core/wells/DynamicListEconLimited.hpp b/opm/core/wells/DynamicListEconLimited.hpp index 7d6e4b11d..9cde3c6c9 100644 --- a/opm/core/wells/DynamicListEconLimited.hpp +++ b/opm/core/wells/DynamicListEconLimited.hpp @@ -33,23 +33,29 @@ namespace Opm { public: - bool anyWellEconLimited() const { - return !(m_shut_wells.empty()); - }; - - bool wellEconLimited(const std::string& well_name) const { - return std::find(m_shut_wells.begin(), m_shut_wells.end(), well_name) != m_shut_wells.end(); + bool wellShuttedEconLimited(const std::string& well_name) const { + return std::find(m_shutted_wells.begin(), m_shutted_wells.end(), well_name) != m_shutted_wells.end(); }; void addShuttedWell(const std::string& well_name) { - // the well should not be in the list - // TODO: not sure wheter a shutted well can - // still be running through some other mechanism. - assert( !wellEconLimited(well_name) ); + assert( !wellShuttedEconLimited(well_name) ); + assert( !wellStoppedEconLimited(well_name) ); - m_shut_wells.push_back(well_name); + m_shutted_wells.push_back(well_name); }; + bool wellStoppedEconLimited(const std::string& well_name) const { + return std::find(m_stopped_wells.begin(), m_stopped_wells.end(), well_name) != m_stopped_wells.end(); + }; + + void addStoppedWell(const std::string& well_name) { + assert( !wellShuttedEconLimited(well_name) ); + assert( !wellStoppedEconLimited(well_name) ); + + m_stopped_wells.push_back(well_name); + } + + // TODO: maybe completion better here bool connectionClosedForWell(const std::string& well_name) const { return (m_cells_closed_connections.find(well_name) != m_cells_closed_connections.end()); @@ -65,7 +71,8 @@ namespace Opm void addClosedConnectionsForWell(const std::string& well_name, const int cell_closed_connection) { - if (connectionClosedForWell(well_name)) { + if (!connectionClosedForWell(well_name)) { + // first time adding a connection for the well std::vector vector_cells = {cell_closed_connection}; m_cells_closed_connections[well_name] = vector_cells; } else { @@ -74,7 +81,8 @@ namespace Opm } private: - std::vector m_shut_wells; + std::vector m_shutted_wells; + std::vector m_stopped_wells; // using grid cell number to indicate the location of the connections std::map> m_cells_closed_connections; }; diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index 3d1b9f807..072113b1d 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -431,22 +431,23 @@ namespace Opm continue; } - const auto* well = (*wellIter); - - if (well->getStatus(timeStep) == WellCommon::STOP) { - // STOPed wells are kept in the well list but marked as stopped. - well_controls_stop_well(w_->ctrls[well_index]); - } + const auto* well = (*wellIter); if (well->getStatus(timeStep) == WellCommon::SHUT) { //SHUT wells are not added to the well list continue; } - if (list_econ_limited.wellEconLimited(well->name())) { + if (list_econ_limited.wellShuttedEconLimited(well->name())) { continue; } + if (well->getStatus(timeStep) == WellCommon::STOP || list_econ_limited.wellStoppedEconLimited(well->name())) { + // Stopped wells are kept in the well list but marked as stopped. + well_controls_stop_well(w_->ctrls[well_index]); + } + + if (well->isInjector(timeStep)) { const WellInjectionProperties& injectionProperties = well->getInjectionProperties(timeStep); int ok = 1; diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 960b33b68..08d10f790 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -145,8 +145,7 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t continue; } - if (list_econ_limited.wellEconLimited(well->name())) { - // std::cout << " the well " << well->name() << " was closed " << std::endl; + if (list_econ_limited.wellShuttedEconLimited(well->name())) { continue; } From b4fa2b494406138568117b22b2042fcddeb7d47c Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Thu, 30 Jun 2016 15:17:13 +0200 Subject: [PATCH 63/69] removing some commented lines. --- opm/core/wells/wells.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/opm/core/wells/wells.c b/opm/core/wells/wells.c index f1d8dc9dd..75827697f 100644 --- a/opm/core/wells/wells.c +++ b/opm/core/wells/wells.c @@ -469,8 +469,6 @@ void clear_well_controls(int well_index, struct Wells *W) /* ---------------------------------------------------------------------- */ { - // printf(" well_indx = %d \n", well_index); - // printf(" W->number_of_wells = %d \n", W->number_of_wells); assert (W != NULL); assert ((0 <= well_index) && (well_index < W->number_of_wells)); From 18b76331ebde2d449ba66d6541139417ba7436b5 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Thu, 30 Jun 2016 16:20:38 +0200 Subject: [PATCH 64/69] addressing comments. no functional change. --- opm/core/wells/DynamicListEconLimited.hpp | 31 ++++++++++------------- opm/core/wells/WellsManager.cpp | 4 +-- opm/core/wells/WellsManager_impl.hpp | 7 ++--- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/opm/core/wells/DynamicListEconLimited.hpp b/opm/core/wells/DynamicListEconLimited.hpp index 9cde3c6c9..cd8a26730 100644 --- a/opm/core/wells/DynamicListEconLimited.hpp +++ b/opm/core/wells/DynamicListEconLimited.hpp @@ -17,7 +17,7 @@ along with OPM. If not, see . */ #ifndef OPM_DYNAMICLISTECONLIMITED_HPP -#define OPM_DYNAMICLISTECONLIMITED_HPP +#define OPM_DYNAMICLISTECONLIMITED_HPP #include #include @@ -28,20 +28,20 @@ namespace Opm { - /// to handle the wells and connections voilating economic limits. + /// to handle the wells and connections violating economic limits. class DynamicListEconLimited { public: - bool wellShuttedEconLimited(const std::string& well_name) const { - return std::find(m_shutted_wells.begin(), m_shutted_wells.end(), well_name) != m_shutted_wells.end(); + bool wellShutEconLimited(const std::string& well_name) const { + return std::find(m_shut_wells.begin(), m_shut_wells.end(), well_name) != m_shut_wells.end(); }; - void addShuttedWell(const std::string& well_name) { - assert( !wellShuttedEconLimited(well_name) ); + void addShutWell(const std::string& well_name) { + assert( !wellShutEconLimited(well_name) ); assert( !wellStoppedEconLimited(well_name) ); - m_shutted_wells.push_back(well_name); + m_shut_wells.push_back(well_name); }; bool wellStoppedEconLimited(const std::string& well_name) const { @@ -49,7 +49,7 @@ namespace Opm }; void addStoppedWell(const std::string& well_name) { - assert( !wellShuttedEconLimited(well_name) ); + assert( !wellShutEconLimited(well_name) ); assert( !wellStoppedEconLimited(well_name) ); m_stopped_wells.push_back(well_name); @@ -57,7 +57,7 @@ namespace Opm // TODO: maybe completion better here - bool connectionClosedForWell(const std::string& well_name) const { + bool anyConnectionClosedForWell(const std::string& well_name) const { return (m_cells_closed_connections.find(well_name) != m_cells_closed_connections.end()); } @@ -65,28 +65,25 @@ namespace Opm return (m_cells_closed_connections.find(well_name)->second); } - std::vector& closedConnectionsForWell(const std::string& well_name) { - return (m_cells_closed_connections.find(well_name)->second); - } - void addClosedConnectionsForWell(const std::string& well_name, const int cell_closed_connection) { - if (!connectionClosedForWell(well_name)) { + if (!anyConnectionClosedForWell(well_name)) { // first time adding a connection for the well std::vector vector_cells = {cell_closed_connection}; m_cells_closed_connections[well_name] = vector_cells; } else { - closedConnectionsForWell(well_name).push_back(cell_closed_connection); + std::vector& closed_connections = m_cells_closed_connections.find(well_name)->second; + closed_connections.push_back(cell_closed_connection); } } private: - std::vector m_shutted_wells; + std::vector m_shut_wells; std::vector m_stopped_wells; // using grid cell number to indicate the location of the connections std::map> m_cells_closed_connections; }; } // namespace Opm -#endif /* OPM_DYNAMICLISTECONLIMITED_HPP */ +#endif /* OPM_DYNAMICLISTECONLIMITED_HPP */ diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index 072113b1d..5a86c1139 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -332,7 +332,7 @@ namespace Opm const double* permeability) : w_(0), is_parallel_run_(false) { - std::vector dummy_well_potentials;; + std::vector dummy_well_potentials; // TODO: not sure about the usage of this WellsManager constructor // TODO: not sure whether this is the correct thing to do here. DynamicListEconLimited dummy_list_econ_limited; @@ -438,7 +438,7 @@ namespace Opm continue; } - if (list_econ_limited.wellShuttedEconLimited(well->name())) { + if (list_econ_limited.wellShutEconLimited(well->name())) { continue; } diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 08d10f790..c637eeff4 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -145,12 +145,12 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t continue; } - if (list_econ_limited.wellShuttedEconLimited(well->name())) { + if (list_econ_limited.wellShutEconLimited(well->name())) { continue; } std::vector cells_connection_closed; - if (list_econ_limited.connectionClosedForWell(well->name())) { + if (list_econ_limited.anyConnectionClosedForWell(well->name())) { cells_connection_closed = list_econ_limited.getClosedConnectionsForWell(well->name()); } @@ -187,7 +187,8 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t int cell = cgit->second; // check if the connection is closed due to economic limits if (!cells_connection_closed.empty()) { - const bool connection_found = std::find(cells_connection_closed.begin(), cells_connection_closed.end(), cell) + const bool connection_found = std::find(cells_connection_closed.begin(), + cells_connection_closed.end(), cell) != cells_connection_closed.end(); if (connection_found) { continue; From b0a4387573295dc5081cf961f312caee07ea2b4a Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Mon, 4 Jul 2016 16:21:55 +0200 Subject: [PATCH 65/69] adding default constructor for DynamicListEconLimited --- opm/core/wells/DynamicListEconLimited.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/opm/core/wells/DynamicListEconLimited.hpp b/opm/core/wells/DynamicListEconLimited.hpp index cd8a26730..22bf2355d 100644 --- a/opm/core/wells/DynamicListEconLimited.hpp +++ b/opm/core/wells/DynamicListEconLimited.hpp @@ -33,20 +33,23 @@ namespace Opm { public: + DynamicListEconLimited() { + } + bool wellShutEconLimited(const std::string& well_name) const { return std::find(m_shut_wells.begin(), m_shut_wells.end(), well_name) != m_shut_wells.end(); - }; + } void addShutWell(const std::string& well_name) { assert( !wellShutEconLimited(well_name) ); assert( !wellStoppedEconLimited(well_name) ); m_shut_wells.push_back(well_name); - }; + } bool wellStoppedEconLimited(const std::string& well_name) const { return std::find(m_stopped_wells.begin(), m_stopped_wells.end(), well_name) != m_stopped_wells.end(); - }; + } void addStoppedWell(const std::string& well_name) { assert( !wellShutEconLimited(well_name) ); From 2f3cdfd9e04189069d363fb47229303987900ee6 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Tue, 19 Jul 2016 18:13:38 +0200 Subject: [PATCH 66/69] fix incorrect derivative of rock compressibility w.r.t. pressure since f(x) = 1 + 0.5*g(x)*g(x) the derivative is f'(x) = 0 + 2*0.5*g(x) * g'(x) = g(x)*g'(x) note that the previous incorrect values do not affect the quality of the obtained results (if the tolerance of the non-linear solver is chosen to be small enough), but it may have deteriorated convergence rates. --- opm/core/props/rock/RockCompressibility.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index 2f0b48f74..b4f48ad5c 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -101,7 +101,8 @@ namespace Opm if (p_.empty()) { // Approximating poro multiplier with a quadratic curve, // we must use its derivative. - return rock_comp_ + 2 * rock_comp_ * rock_comp_ * (pressure - pref_); + const double cpnorm = rock_comp_*(pressure - pref_); + return rock_comp_ + cpnorm*rock_comp_; } else { return Opm::linearInterpolationDerivative(p_, poromult_, pressure); } From c4e5db215386bbf8f606445940ca3a8bf9b2ec38 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 13 Jul 2016 12:15:07 +0200 Subject: [PATCH 67/69] also keep track of the number of linearizations needed for the simulation --- opm/core/simulator/SimulatorReport.cpp | 2 ++ opm/core/simulator/SimulatorReport.hpp | 1 + 2 files changed, 3 insertions(+) diff --git a/opm/core/simulator/SimulatorReport.cpp b/opm/core/simulator/SimulatorReport.cpp index 2ddca2857..e860c946c 100644 --- a/opm/core/simulator/SimulatorReport.cpp +++ b/opm/core/simulator/SimulatorReport.cpp @@ -27,6 +27,7 @@ namespace Opm : pressure_time(0.0), transport_time(0.0), total_time(0.0), + total_linearizations( 0 ), total_newton_iterations( 0 ), total_linear_iterations( 0 ), verbose_(verbose) @@ -61,6 +62,7 @@ namespace Opm { os << "Total time taken (seconds): " << total_time << "\nSolver time (seconds): " << pressure_time + << "\nOverall Linearizations: " << total_linearizations << "\nOverall Newton Iterations: " << total_newton_iterations << "\nOverall Linear Iterations: " << total_linear_iterations << std::endl; diff --git a/opm/core/simulator/SimulatorReport.hpp b/opm/core/simulator/SimulatorReport.hpp index 22043918d..9e35905ad 100644 --- a/opm/core/simulator/SimulatorReport.hpp +++ b/opm/core/simulator/SimulatorReport.hpp @@ -32,6 +32,7 @@ namespace Opm double transport_time; double total_time; + unsigned int total_linearizations; unsigned int total_newton_iterations; unsigned int total_linear_iterations; From 7ff2328f3f534bc30f8d0299294f9550d647b413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Gr=C3=B8n=C3=A5s=20Drange?= Date: Mon, 8 Aug 2016 10:02:53 +0200 Subject: [PATCH 68/69] transmult and initconfig are ref's, use ref for EclipseState constructor --- examples/compute_initial_state.cpp | 2 +- examples/diagnose_relperm.cpp | 2 +- opm/core/simulator/initStateEquil.hpp | 2 +- tests/test_equil.cpp | 14 +++++++------- tests/test_norne_pvt.cpp | 2 +- tests/test_pinchprocessor.cpp | 6 +++--- tests/test_relpermdiagnostics.cpp | 2 +- tests/test_satfunc.cpp | 10 +++++----- tests/test_stoppedwells.cpp | 2 +- tests/test_wellcollection.cpp | 2 +- tests/test_wellsgroup.cpp | 4 ++-- tests/test_wellsmanager.cpp | 10 +++++----- 12 files changed, 29 insertions(+), 29 deletions(-) diff --git a/examples/compute_initial_state.cpp b/examples/compute_initial_state.cpp index 356f3f42d..2eb27d1f4 100644 --- a/examples/compute_initial_state.cpp +++ b/examples/compute_initial_state.cpp @@ -90,7 +90,7 @@ try Opm::ParseContext parseContext; Opm::ParserPtr parser(new Opm::Parser() ); Opm::DeckConstPtr deck = parser->parseFile(deck_filename , parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck, parseContext)); const double grav = param.getDefault("gravity", unit::gravity); GridManager gm(eclipseState->getInputGrid()); const UnstructuredGrid& grid = *gm.c_grid(); diff --git a/examples/diagnose_relperm.cpp b/examples/diagnose_relperm.cpp index 20d6828dd..99158109d 100644 --- a/examples/diagnose_relperm.cpp +++ b/examples/diagnose_relperm.cpp @@ -76,7 +76,7 @@ try { ParseContext::INTERNAL_ERROR_UNINITIALIZED_THPRES, InputError::IGNORE} }); Opm::DeckConstPtr deck(parser->parseFile(eclipseFilename, parseContext)); - eclState.reset(new EclipseState(deck, parseContext)); + eclState.reset(new EclipseState(*deck, parseContext)); GridManager gm(eclState->getInputGrid()); const UnstructuredGrid& grid = *gm.c_grid(); diff --git a/opm/core/simulator/initStateEquil.hpp b/opm/core/simulator/initStateEquil.hpp index b03d488a0..cbda500ee 100644 --- a/opm/core/simulator/initStateEquil.hpp +++ b/opm/core/simulator/initStateEquil.hpp @@ -200,7 +200,7 @@ namespace Opm std::vector getEquil(const Opm::EclipseState& state) { - const auto& init = *state.getInitConfig(); + const auto& init = state.getInitConfig(); if( !init.hasEquil() ) { OPM_THROW(std::domain_error, "Deck does not provide equilibration data."); diff --git a/tests/test_equil.cpp b/tests/test_equil.cpp index ed7f74ffa..caedd0af9 100644 --- a/tests/test_equil.cpp +++ b/tests/test_equil.cpp @@ -366,7 +366,7 @@ BOOST_AUTO_TEST_CASE (DeckAllDead) Opm::ParseContext parseContext; Opm::ParserPtr parser(new Opm::Parser() ); Opm::DeckConstPtr deck = parser->parseFile("deadfluids.DATA" , parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck, parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, *grid, false); Opm::EQUIL::DeckDependent::InitialStateComputer comp(props, deck, eclipseState, *grid, 10.0); const auto& pressures = comp.press(); @@ -394,7 +394,7 @@ BOOST_AUTO_TEST_CASE (CapillaryInversion) Opm::ParserPtr parser(new Opm::Parser() ); Opm::ParseContext parseContext; Opm::DeckConstPtr deck = parser->parseFile("capillary.DATA" , parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, grid, false); // Test the capillary inversion for oil-water. @@ -448,7 +448,7 @@ BOOST_AUTO_TEST_CASE (DeckWithCapillary) Opm::ParserPtr parser(new Opm::Parser() ); Opm::ParseContext parseContext; Opm::DeckConstPtr deck = parser->parseFile("capillary.DATA" , parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, grid, false); Opm::EQUIL::DeckDependent::InitialStateComputer comp(props, deck, eclipseState, grid, 10.0); @@ -489,7 +489,7 @@ BOOST_AUTO_TEST_CASE (DeckWithCapillaryOverlap) Opm::ParserPtr parser(new Opm::Parser() ); Opm::ParseContext parseContext; Opm::DeckConstPtr deck = parser->parseFile("capillary_overlap.DATA" , parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, grid, false); Opm::EQUIL::DeckDependent::InitialStateComputer comp(props, deck, eclipseState, grid, 9.80665); @@ -552,7 +552,7 @@ BOOST_AUTO_TEST_CASE (DeckWithLiveOil) Opm::ParserPtr parser(new Opm::Parser() ); Opm::ParseContext parseContext; Opm::DeckConstPtr deck = parser->parseFile("equil_liveoil.DATA" , parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, grid, false); Opm::EQUIL::DeckDependent::InitialStateComputer comp(props, deck, eclipseState, grid, 9.80665); @@ -632,7 +632,7 @@ BOOST_AUTO_TEST_CASE (DeckWithLiveGas) Opm::ParserPtr parser(new Opm::Parser() ); Opm::ParseContext parseContext; Opm::DeckConstPtr deck = parser->parseFile("equil_livegas.DATA" , parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, grid, false); Opm::EQUIL::DeckDependent::InitialStateComputer comp(props, deck, eclipseState, grid, 9.80665); @@ -715,7 +715,7 @@ BOOST_AUTO_TEST_CASE (DeckWithRSVDAndRVVD) Opm::ParserPtr parser(new Opm::Parser() ); Opm::ParseContext parseContext; Opm::DeckConstPtr deck = parser->parseFile("equil_rsvd_and_rvvd.DATA", parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, grid, false); Opm::EQUIL::DeckDependent::InitialStateComputer comp(props, deck, eclipseState, grid, 9.80665); diff --git a/tests/test_norne_pvt.cpp b/tests/test_norne_pvt.cpp index 664698fb2..4fb5b6e81 100644 --- a/tests/test_norne_pvt.cpp +++ b/tests/test_norne_pvt.cpp @@ -281,7 +281,7 @@ BOOST_AUTO_TEST_CASE( Test_Norne_PVT) { std::shared_ptr deck; deck = parser->parseFile("norne_pvt.data", parseContext); - Opm::EclipseStateConstPtr eclState(new EclipseState(deck, parseContext)); + Opm::EclipseStateConstPtr eclState(new EclipseState(*deck, parseContext)); verify_norne_oil_pvt_region1( deck, eclState ); verify_norne_oil_pvt_region2( deck, eclState ); diff --git a/tests/test_pinchprocessor.cpp b/tests/test_pinchprocessor.cpp index cba80906e..78659b8fe 100644 --- a/tests/test_pinchprocessor.cpp +++ b/tests/test_pinchprocessor.cpp @@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE(Processing) Opm::ParserPtr parser(new Opm::Parser()); Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }}); Opm::DeckConstPtr deck = parser->parseFile(filename, parseContext); - std::shared_ptr eclstate (new Opm::EclipseState(deck, parseContext)); + std::shared_ptr eclstate (new Opm::EclipseState(*deck, parseContext)); const auto& porv = eclstate->get3DProperties().getDoubleGridProperty("PORV").getData(); EclipseGridConstPtr eclgrid = eclstate->getInputGrid(); @@ -92,10 +92,10 @@ BOOST_AUTO_TEST_CASE(Processing) std::vector htrans(Opm::UgGridHelpers::numCellFaces(grid)); Grid* ug = const_cast(& grid); tpfa_htrans_compute(ug, rock.permeability(), htrans.data()); - auto transMult = eclstate->getTransMult(); + const auto& transMult = eclstate->getTransMult(); std::vector multz(nc, 0.0); for (int i = 0; i < nc; ++i) { - multz[i] = transMult->getMultiplier(global_cell[i], Opm::FaceDir::ZPlus); + multz[i] = transMult.getMultiplier(global_cell[i], Opm::FaceDir::ZPlus); } Opm::NNC nnc(deck, eclgrid); pinch.process(grid, htrans, actnum, multz, porv, nnc); diff --git a/tests/test_relpermdiagnostics.cpp b/tests/test_relpermdiagnostics.cpp index 553606e42..814fc073c 100644 --- a/tests/test_relpermdiagnostics.cpp +++ b/tests/test_relpermdiagnostics.cpp @@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE(diagnosis) { ParseContext::PARSE_RANDOM_TEXT, InputError::IGNORE} }); Opm::DeckConstPtr deck(parser->parseFile("../tests/relpermDiagnostics.DATA", parseContext)); - eclState.reset(new EclipseState(deck, parseContext)); + eclState.reset(new EclipseState(*deck, parseContext)); GridManager gm(eclState->getInputGrid()); const UnstructuredGrid& grid = *gm.c_grid(); std::shared_ptr counterLog = std::make_shared(Log::DefaultMessageTypes); diff --git a/tests/test_satfunc.cpp b/tests/test_satfunc.cpp index b5630589a..898acf12a 100644 --- a/tests/test_satfunc.cpp +++ b/tests/test_satfunc.cpp @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE (GwsegStandard) Opm::ParserPtr parser(new Opm::Parser() ); Opm::ParseContext parseContext; Opm::DeckConstPtr deck = parser->parseFile("satfuncStandard.DATA", parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, grid, param, false); const int np = 3; @@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE (GwsegEPSBase) Opm::ParserPtr parser(new Opm::Parser() ); Opm::ParseContext parseContext; Opm::DeckConstPtr deck = parser->parseFile("satfuncEPSBase.DATA" , parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, grid, param, false); const int np = 3; @@ -241,7 +241,7 @@ BOOST_AUTO_TEST_CASE (GwsegEPS_A) Opm::ParseContext parseContext; Opm::ParserPtr parser(new Opm::Parser() ); Opm::DeckConstPtr deck = parser->parseFile("satfuncEPS_A.DATA" , parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, grid, param, false); const int np = 3; @@ -493,7 +493,7 @@ BOOST_AUTO_TEST_CASE (GwsegEPS_C) Opm::ParserPtr parser(new Opm::Parser() ); Opm::ParseContext parseContext; Opm::DeckConstPtr deck = parser->parseFile("satfuncEPS_C.DATA", parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, grid, param, false); const int np = 3; @@ -596,7 +596,7 @@ BOOST_AUTO_TEST_CASE (GwsegEPS_D) Opm::ParserPtr parser(new Opm::Parser() ); Opm::ParseContext parseContext; Opm::DeckConstPtr deck = parser->parseFile("satfuncEPS_D.DATA" , parseContext); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::BlackoilPropertiesFromDeck props(deck, eclipseState, grid, param, false); const int np = 3; diff --git a/tests/test_stoppedwells.cpp b/tests/test_stoppedwells.cpp index b67a148d2..219377d7f 100644 --- a/tests/test_stoppedwells.cpp +++ b/tests/test_stoppedwells.cpp @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells) Opm::ParseContext parseContext; Opm::DeckConstPtr deck(parser->parseFile(filename , parseContext)); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck , parseContext)); Opm::GridManager gridManager(eclipseState->getInputGrid()); double target_surfacerate_inj; diff --git a/tests/test_wellcollection.cpp b/tests/test_wellcollection.cpp index 6378941e0..35860e9a2 100644 --- a/tests/test_wellcollection.cpp +++ b/tests/test_wellcollection.cpp @@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) { std::string scheduleFile("wells_group.data"); ParseContext parseContext; DeckConstPtr deck = parser->parseFile(scheduleFile, parseContext); - EclipseStateConstPtr eclipseState(new EclipseState(deck, parseContext)); + EclipseStateConstPtr eclipseState(new EclipseState(*deck, parseContext)); PhaseUsage pu = phaseUsageFromDeck(eclipseState); GroupTreeNodePtr field=eclipseState->getSchedule()->getGroupTree(2)->getNode("FIELD"); diff --git a/tests/test_wellsgroup.cpp b/tests/test_wellsgroup.cpp index 08baa9b16..f6e24cd41 100644 --- a/tests/test_wellsgroup.cpp +++ b/tests/test_wellsgroup.cpp @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromWell) { std::string scheduleFile("wells_group.data"); ParseContext parseContext; DeckConstPtr deck = parser->parseFile(scheduleFile, parseContext); - EclipseStateConstPtr eclipseState(new EclipseState(deck , parseContext)); + EclipseStateConstPtr eclipseState(new EclipseState(*deck , parseContext)); PhaseUsage pu = phaseUsageFromDeck(eclipseState); auto wells = eclipseState->getSchedule()->getWells(); @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromGroup) { ParseContext parseContext; std::string scheduleFile("wells_group.data"); DeckConstPtr deck = parser->parseFile(scheduleFile, parseContext); - EclipseStateConstPtr eclipseState(new EclipseState(deck , parseContext)); + EclipseStateConstPtr eclipseState(new EclipseState(*deck , parseContext)); PhaseUsage pu = phaseUsageFromDeck(eclipseState); std::vector nodes = eclipseState->getSchedule()->getGroupTree(2)->getNodes(); diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index 2d2587405..cb8cd7ad0 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -181,7 +181,7 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works) { Opm::ParseContext parseContext; Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck, parseContext)); Opm::GridManager gridManager(eclipseState->getInputGrid()); { @@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(WellsEqual) { Opm::ParseContext parseContext; Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck, parseContext)); Opm::GridManager gridManager(eclipseState->getInputGrid()); Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid(), NULL); @@ -234,7 +234,7 @@ BOOST_AUTO_TEST_CASE(ControlsEqual) { Opm::ParserPtr parser(new Opm::Parser()); Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck, parseContext)); Opm::GridManager gridManager(eclipseState->getInputGrid()); Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid(), NULL); @@ -257,7 +257,7 @@ BOOST_AUTO_TEST_CASE(WellShutOK) { Opm::ParseContext parseContext; Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck, parseContext)); Opm::GridManager gridManager(eclipseState->getInputGrid()); Opm::WellsManager wellsManager2(eclipseState, 2, *gridManager.c_grid(), NULL); @@ -274,7 +274,7 @@ BOOST_AUTO_TEST_CASE(WellSTOPOK) { Opm::ParseContext parseContext; Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext)); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext)); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(*deck, parseContext)); Opm::GridManager gridManager(eclipseState->getInputGrid()); Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid(), NULL); From 656e9438c8f5bd8dfb2e9f96c0ca02456b1ac4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Gr=C3=B8n=C3=A5s=20Drange?= Date: Mon, 8 Aug 2016 15:58:17 +0200 Subject: [PATCH 69/69] Minor tweaks and updates in test blackoilstate --- tests/test_blackoilstate.cpp | 48 +++++++++++++++++------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/tests/test_blackoilstate.cpp b/tests/test_blackoilstate.cpp index b1942dbb0..25d41c82c 100644 --- a/tests/test_blackoilstate.cpp +++ b/tests/test_blackoilstate.cpp @@ -37,20 +37,16 @@ std::vector get_testBlackoilStateActnum() { } BOOST_AUTO_TEST_CASE(EqualsDifferentDeckReturnFalse) { - - ParseContext parseContext; const string filename1 = "testBlackoilState1.DATA"; const string filename2 = "testBlackoilState2.DATA"; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr deck1(parser->parseFile(filename1, parseContext)); - auto eg1 = std::make_shared(deck1); + const auto es1 = Opm::Parser::parse(filename1); + auto eg1 = es1.getInputGridCopy(); std::vector actnum = get_testBlackoilStateActnum(); eg1->resetACTNUM(actnum.data()); - - Opm::DeckConstPtr deck2(parser->parseFile(filename2, parseContext)); - auto eg2 = std::make_shared(deck2); + const auto es2 = Opm::Parser::parse(filename2); + auto eg2 = es2.getInputGrid(); GridManager gridManager1(eg1); const UnstructuredGrid& grid1 = *gridManager1.c_grid(); @@ -61,7 +57,7 @@ BOOST_AUTO_TEST_CASE(EqualsDifferentDeckReturnFalse) { BlackoilState state1( UgGridHelpers::numCells( grid1 ) , UgGridHelpers::numFaces( grid1 ) , 3); BlackoilState state2( UgGridHelpers::numCells( grid2 ) , UgGridHelpers::numFaces( grid2 ) , 3); - BOOST_CHECK_EQUAL( false , state1.equal(state2) ); + BOOST_CHECK( ! state1.equal(state2) ); } @@ -70,10 +66,10 @@ BOOST_AUTO_TEST_CASE(EqualsDifferentDeckReturnFalse) { BOOST_AUTO_TEST_CASE(EqualsNumericalDifferenceReturnFalse) { const string filename = "testBlackoilState1.DATA"; - Opm::ParseContext parseContext; - Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr deck(parser->parseFile(filename , parseContext)); - auto eg = std::make_shared(deck); + + const auto es = Opm::Parser::parse(filename); + auto eg = es.getInputGridCopy(); + std::vector actnum = get_testBlackoilStateActnum(); eg->resetACTNUM(actnum.data()); @@ -84,33 +80,33 @@ BOOST_AUTO_TEST_CASE(EqualsNumericalDifferenceReturnFalse) { BlackoilState state2( UgGridHelpers::numCells( grid ) , UgGridHelpers::numFaces( grid ) , 3); - BOOST_CHECK_EQUAL( true , state1.equal(state2) ); + BOOST_CHECK( state1.equal(state2) ); { std::vector& p1 = state1.pressure(); std::vector& p2 = state2.pressure(); p1[0] = p1[0] * 2 + 1; - BOOST_CHECK_EQUAL( false , state1.equal(state2) ); + BOOST_CHECK( ! state1.equal(state2) ); p1[0] = p2[0]; - BOOST_CHECK_EQUAL( true , state1.equal(state2) ); + BOOST_CHECK( state1.equal(state2) ); } { std::vector& gor1 = state1.gasoilratio(); std::vector& gor2 = state2.gasoilratio(); gor1[0] = gor1[0] * 2 + 1; - BOOST_CHECK_EQUAL( false , state1.equal(state2) ); + BOOST_CHECK( ! state1.equal(state2) ); gor1[0] = gor2[0]; - BOOST_CHECK_EQUAL( true , state1.equal(state2) ); + BOOST_CHECK( state1.equal(state2) ); } { std::vector& p1 = state1.facepressure(); std::vector& p2 = state2.facepressure(); p1[0] = p1[0] * 2 + 1; - BOOST_CHECK_EQUAL( false , state1.equal(state2) ); + BOOST_CHECK( ! state1.equal(state2) ); p1[0] = p2[0]; - BOOST_CHECK_EQUAL( true , state1.equal(state2) ); + BOOST_CHECK( state1.equal(state2) ); } { @@ -119,9 +115,9 @@ BOOST_AUTO_TEST_CASE(EqualsNumericalDifferenceReturnFalse) { if (f1.size() > 0 ) { f1[0] = f1[0] * 2 + 1; - BOOST_CHECK_EQUAL( false , state1.equal(state2) ); + BOOST_CHECK( ! state1.equal(state2) ); f1[0] = f2[0]; - BOOST_CHECK_EQUAL( true , state1.equal(state2) ); + BOOST_CHECK( state1.equal(state2) ); } } { @@ -130,9 +126,9 @@ BOOST_AUTO_TEST_CASE(EqualsNumericalDifferenceReturnFalse) { if (sv1.size() > 0) { sv1[0] = sv1[0] * 2 + 1; - BOOST_CHECK_EQUAL( false , state1.equal(state2) ); + BOOST_CHECK( ! state1.equal(state2) ); sv1[0] = sv2[0]; - BOOST_CHECK_EQUAL( true , state1.equal(state2) ); + BOOST_CHECK( state1.equal(state2) ); } } { @@ -140,8 +136,8 @@ BOOST_AUTO_TEST_CASE(EqualsNumericalDifferenceReturnFalse) { std::vector& sat2 = state2.saturation(); sat1[0] = sat1[0] * 2 + 1; - BOOST_CHECK_EQUAL( false , state1.equal(state2) ); + BOOST_CHECK( ! state1.equal(state2) ); sat1[0] = sat2[0]; - BOOST_CHECK_EQUAL( true , state1.equal(state2) ); + BOOST_CHECK( state1.equal(state2) ); } }