From 322da86bb16d6a15ca7b0614b99e10df545f7ee3 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Thu, 6 Feb 2014 11:03:59 +0100 Subject: [PATCH 1/6] [cmake] Makes arbitrary build subdirectories possible. Instead of guessing the suffix or subdir of the build directory, we now simply compare PROJECT_{BINARY,SOURCE]_DIR to detect it. By this e.g. opm-core/opm-parallel is a possible build directory, too. --- cmake/Modules/Findcjson.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/Findcjson.cmake b/cmake/Modules/Findcjson.cmake index fde5a782..305f05b1 100644 --- a/cmake/Modules/Findcjson.cmake +++ b/cmake/Modules/Findcjson.cmake @@ -31,13 +31,14 @@ if (CMAKE_SIZEOF_VOID_P) math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}") endif (CMAKE_SIZEOF_VOID_P) +string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/?(.*)" "\\1" BUILD_DIR_SUFFIX "${PROJECT_BINARY_DIR}") + find_library (CJSON_LIBRARY NAMES "cjson" HINTS "${CJSON_ROOT}" PATHS "${PROJECT_BINARY_DIR}/../opm-parser" - "${PROJECT_BINARY_DIR}/../opm-parser-build" - "${PROJECT_BINARY_DIR}/../../opm-parser/build" - "${PROJECT_BINARY_DIR}/../../opm-parser/cmake-build" + "${PROJECT_BINARY_DIR}/../opm-parser${BUILD_DIR_SUFFIX}" + "${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}" PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "opm/json" DOC "Path to cjson library archive/shared object files" From 6c0438ab815d309310732f9b4f25de5274951b70 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Thu, 6 Feb 2014 12:41:10 +0100 Subject: [PATCH 2/6] Whitespace change that replaces introduced tab with spaces. --- cmake/Modules/Findcjson.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/Findcjson.cmake b/cmake/Modules/Findcjson.cmake index 305f05b1..57055739 100644 --- a/cmake/Modules/Findcjson.cmake +++ b/cmake/Modules/Findcjson.cmake @@ -38,7 +38,7 @@ find_library (CJSON_LIBRARY HINTS "${CJSON_ROOT}" PATHS "${PROJECT_BINARY_DIR}/../opm-parser" "${PROJECT_BINARY_DIR}/../opm-parser${BUILD_DIR_SUFFIX}" - "${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}" + "${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}" PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "opm/json" DOC "Path to cjson library archive/shared object files" From 00b802dd4176a0e145de2edbec7ce08d8b8c62f3 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Thu, 6 Feb 2014 13:17:43 +0100 Subject: [PATCH 3/6] [cmake] Support more arbitrary sibling/subdir build directories for opm-parser. --- cmake/Modules/Findopm-parser.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake index 5f2701ed..67680015 100644 --- a/cmake/Modules/Findopm-parser.cmake +++ b/cmake/Modules/Findopm-parser.cmake @@ -31,6 +31,10 @@ if ((NOT OPM_PARSER_ROOT) AND OPM_ROOT) set (OPM_PARSER_ROOT "${OPM_ROOT}/opm-parser") endif () +# Detect the build dir suffix or subdirectory +string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/?(.*)" "\\1" BUILD_DIR_SUFFIX "${PROJECT_BINARY_DIR}") + +message("PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} PROJECT_BINARY_DIR=${PROJECT_BINARY_DIR} BUILD_DIR_SUFFIX=${BUILD_DIR_SUFFIX}") # if a root is specified, then don't search in system directories # or in relative directories to this one if (OPM_PARSER_ROOT) @@ -43,9 +47,8 @@ else () "${PROJECT_SOURCE_DIR}/../opm-parser") set (_opm_parser_build "${PROJECT_BINARY_DIR}/../opm-parser" - "${PROJECT_BINARY_DIR}/../opm-parser-build" - "${PROJECT_BINARY_DIR}/../../opm-parser/build" - "${PROJECT_BINARY_DIR}/../../opm-parser/cmake-build") + "${PROJECT_BINARY_DIR}/../opm-parser${BUILD_DIR_SUFFIX}" + "${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}") endif () # use this header as signature @@ -82,6 +85,7 @@ if (CMAKE_SIZEOF_VOID_P) math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}") endif (CMAKE_SIZEOF_VOID_P) +message("_opm_parser_build=${_opm_parser_build}") # these libraries constitute the parser core find_library (OPM_PARSER_LIBRARY NAMES "Parser" From 786aa125f215bea284a477fdebb8e67602501743 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Thu, 6 Feb 2014 13:21:23 +0100 Subject: [PATCH 4/6] Removed printf debugging messages --- cmake/Modules/Findopm-parser.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake index 67680015..2698209f 100644 --- a/cmake/Modules/Findopm-parser.cmake +++ b/cmake/Modules/Findopm-parser.cmake @@ -34,7 +34,6 @@ endif () # Detect the build dir suffix or subdirectory string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/?(.*)" "\\1" BUILD_DIR_SUFFIX "${PROJECT_BINARY_DIR}") -message("PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} PROJECT_BINARY_DIR=${PROJECT_BINARY_DIR} BUILD_DIR_SUFFIX=${BUILD_DIR_SUFFIX}") # if a root is specified, then don't search in system directories # or in relative directories to this one if (OPM_PARSER_ROOT) @@ -85,7 +84,6 @@ if (CMAKE_SIZEOF_VOID_P) math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}") endif (CMAKE_SIZEOF_VOID_P) -message("_opm_parser_build=${_opm_parser_build}") # these libraries constitute the parser core find_library (OPM_PARSER_LIBRARY NAMES "Parser" From 61b3a4618c4e8a778b714dd55d0a76da16373dac Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Thu, 6 Feb 2014 13:29:01 +0100 Subject: [PATCH 5/6] [cmake] Do not use find_package in config mode for opm-parser. Currently opm-parser does not create opm-parser-config.cmake files. Therefore building with duncontrol fails as it sets opm-parser_DIR. With this patch we force CMake to always use module mode for finding which fixes this. --- cmake/Modules/OpmFind.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/Modules/OpmFind.cmake b/cmake/Modules/OpmFind.cmake index 58501ba9..592a9830 100644 --- a/cmake/Modules/OpmFind.cmake +++ b/cmake/Modules/OpmFind.cmake @@ -59,6 +59,7 @@ set (_opm_proj_exemptions dune-istl dune-grid dune-geometry + opm-parser ) # although a DUNE module, it is delivered in the OPM suite From 8cdaf7d05d7d124bf039af49bb04d04c3cb9e262 Mon Sep 17 00:00:00 2001 From: Kristian Flikka Date: Thu, 6 Feb 2014 16:31:35 +0100 Subject: [PATCH 6/6] Removed WELOPEN from constructor, added throwing on non OPEN/SHUT statuses --- CMakeLists_files.cmake | 1 + opm/core/wells/WellsManager.cpp | 32 +++----------------- tests/test_wellsmanager.cpp | 23 ++++++++++++++ tests/wells_manager_data_expanded.data | 12 ++++++-- tests/wells_manager_data_wellSTOP.data | 42 ++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 30 deletions(-) create mode 100755 tests/wells_manager_data_wellSTOP.data diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 6b194b47..891b094c 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -183,6 +183,7 @@ list (APPEND TEST_DATA_FILES tests/testBlackoilState2.DATA tests/wells_manager_data.data tests/wells_manager_data_expanded.data + tests/wells_manager_data_wellSTOP.data ) # originally generated with the command: diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index 2241cacd..49857d06 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -312,34 +312,6 @@ namespace Opm setupWellControls(wells, timeStep, well_names, pu); - if (deck.hasField("WELOPEN")) { - const WELOPEN& welopen = deck.getWELOPEN(); - for (size_t i = 0; i < welopen.welopen.size(); ++i) { - WelopenLine line = welopen.welopen[i]; - std::string wellname = line.well_; - std::map::const_iterator it = well_names_to_index.find(wellname); - if (it == well_names_to_index.end()) { - OPM_THROW(std::runtime_error, "Trying to open/shut well with name: \"" << wellname<<"\" but it's not registered under WELSPECS."); - } - const int index = it->second; - if (line.openshutflag_ == "SHUT") { - int cur_ctrl = well_controls_get_current(w_->ctrls[index]); - if (cur_ctrl >= 0) { - well_controls_invert_current(w_->ctrls[index]); - } - assert(well_controls_get_current(w_->ctrls[index]) < 0); - } else if (line.openshutflag_ == "OPEN") { - int cur_ctrl = well_controls_get_current(w_->ctrls[index]); - if (cur_ctrl < 0) { - well_controls_invert_current(w_->ctrls[index]); - } - assert(well_controls_get_current(w_->ctrls[index]) >= 0); - } else { - OPM_THROW(std::runtime_error, "Unknown Open/close keyword: \"" << line.openshutflag_<< "\". Allowed values: OPEN, SHUT."); - } - } - } - // Build the well_collection_ well group hierarchy. if (deck.hasField("GRUPTREE")) { std::cout << "Found gruptree" << std::endl; @@ -1200,6 +1172,10 @@ namespace Opm for (auto wellIter= wells.begin(); wellIter != wells.end(); ++wellIter) { WellConstPtr well = (*wellIter); + if ( !( well->getStatus( timeStep ) == WellCommon::SHUT || well->getStatus( timeStep ) == WellCommon::OPEN) ) { + OPM_THROW(std::runtime_error, "Currently we do not support well status " << WellCommon::Status2String(well->getStatus( timeStep ))); + } + if (well->isInjector(timeStep)) { clear_well_controls(well_index, w_); int ok = 1; diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index fd3c7102..0caf67f1 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -262,6 +262,14 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works_ExpandedData) { BOOST_CHECK(wells_equal( wellsManager.c_wells(), oldWellsManager.c_wells(), true)); } + + Deck.setCurrentEpoch(2); + { + Opm::WellsManager wellsManager(eclipseState, 2,Deck, *gridManager.c_grid(), NULL); + Opm::WellsManager oldWellsManager(Deck, *gridManager.c_grid(), NULL); + + BOOST_CHECK(wells_equal( wellsManager.c_wells(), oldWellsManager.c_wells(), true)); + } } @@ -303,3 +311,18 @@ BOOST_AUTO_TEST_CASE(ControlsEqual) { } + +BOOST_AUTO_TEST_CASE(WellHasSTOP_ExceptionIsThrown) { + Opm::EclipseGridParser Deck("wells_manager_data_wellSTOP.data"); + Opm::GridManager gridManager(Deck); + + Opm::ParserPtr parser(new Opm::Parser()); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(parser->parseFile("wells_manager_data_wellSTOP.data"))); + + Deck.setCurrentEpoch(0); + + BOOST_CHECK_THROW( new Opm::WellsManager(eclipseState, 0, Deck, *gridManager.c_grid(), NULL), std::runtime_error ); +} + + + diff --git a/tests/wells_manager_data_expanded.data b/tests/wells_manager_data_expanded.data index dae5e7cb..67207768 100755 --- a/tests/wells_manager_data_expanded.data +++ b/tests/wells_manager_data_expanded.data @@ -72,7 +72,15 @@ WCONINJE TSTEP -14.0 - / +14.0 / +/ + +WELOPEN + 'INJ1' 'SHUT' 5* / +/ + +TSTEP +14.0 / +/ END diff --git a/tests/wells_manager_data_wellSTOP.data b/tests/wells_manager_data_wellSTOP.data new file mode 100755 index 00000000..bdcbc381 --- /dev/null +++ b/tests/wells_manager_data_wellSTOP.data @@ -0,0 +1,42 @@ +OIL +GAS +WATER + +DIMENS + 10 10 5 / + +GRID + +DXV +10*1000.0 / + +DYV +10*1000.0 / + +DZV +10.0 20.0 30.0 10.0 5.0 / + +DEPTHZ +121*2000 +/ + +SCHEDULE + +WELSPECS + 'INJ1' 'G' 1 1 8335 'GAS' / + 'PROD1' 'G' 10 10 8400 'OIL' / +/ + +COMPDAT + 'INJ1' 1 1 1 1 'OPEN' 1 10.6092 0.5 / + 'PROD1' 10 3 3 3 'OPEN' 0 10.6092 0.5 / +/ + +WELOPEN + 'INJ1' 'STOP' 5* / +/ + +TSTEP + 10 / + +END