From 3c35e767d435037dbe08febc0ec1bcac339a0157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 17 Nov 2016 09:47:58 +0100 Subject: [PATCH] Remove tests that were moved to opm-output. --- tests/test_EclipseWriteRFTHandler.cpp | 232 -------------- tests/test_EclipseWriter.cpp | 421 -------------------------- tests/test_writeReadRestartFile.cpp | 350 --------------------- tests/test_writenumwells.cpp | 198 ------------ 4 files changed, 1201 deletions(-) delete mode 100755 tests/test_EclipseWriteRFTHandler.cpp delete mode 100644 tests/test_EclipseWriter.cpp delete mode 100644 tests/test_writeReadRestartFile.cpp delete mode 100644 tests/test_writenumwells.cpp diff --git a/tests/test_EclipseWriteRFTHandler.cpp b/tests/test_EclipseWriteRFTHandler.cpp deleted file mode 100755 index 7b9142e7..00000000 --- a/tests/test_EclipseWriteRFTHandler.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* - Copyright 2015 Statoil ASA. - - 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 "config.h" - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - -#define BOOST_TEST_MODULE EclipseRFTWriter -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -namespace { - -void verifyRFTFile(const std::string& rft_filename) { - - ecl_rft_file_type * new_rft_file = ecl_rft_file_alloc(rft_filename.c_str()); - std::shared_ptr rft_file; - rft_file.reset(new_rft_file, ecl_rft_file_free); - - //Get RFT node for well/time OP_1/10 OKT 2008 - time_t recording_time = util_make_datetime(0, 0, 0, 10, 10, 2008); - ecl_rft_node_type * ecl_rft_node = ecl_rft_file_get_well_time_rft(rft_file.get() , "OP_1" , recording_time); - BOOST_CHECK(ecl_rft_node_is_RFT(ecl_rft_node)); - - //Verify RFT data for completions (ijk) 9 9 1, 9 9 2 and 9 9 3 for OP_1 - const ecl_rft_cell_type * ecl_rft_cell1 = ecl_rft_node_lookup_ijk(ecl_rft_node, 8, 8, 0); - const ecl_rft_cell_type * ecl_rft_cell2 = ecl_rft_node_lookup_ijk(ecl_rft_node, 8, 8, 1); - const ecl_rft_cell_type * ecl_rft_cell3 = ecl_rft_node_lookup_ijk(ecl_rft_node, 8, 8, 2); - - BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell1), 210088*0.00001, 0.00001); - BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell2), 210188*0.00001, 0.00001); - BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell3), 210288*0.00001, 0.00001); - - BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell1), 0.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell2), 0.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell3), 0.0); - - BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell1), 0.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell2), 0.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell3), 0.0); - - BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell1), 1.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell2), 1.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell3), 1.0); - - BOOST_CHECK_EQUAL(ecl_rft_cell_get_depth(ecl_rft_cell1), (0.250 + (0.250/2))); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_depth(ecl_rft_cell2), (2*0.250 + (0.250/2))); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_depth(ecl_rft_cell3), (3*0.250 + (0.250/2))); -} - - - - -const Opm::Deck createDeck(const std::string& input_str) { - Opm::ParserPtr parser = std::make_shared(); - const Opm::Deck& deck = parser->parseString(input_str , Opm::ParseContext()); - return deck; -} - - -std::shared_ptr createWellState(std::shared_ptr blackoilState) -{ - std::shared_ptr wellState = std::make_shared(); - wellState->init(0, *blackoilState); - return wellState; -} - - - -std::shared_ptr createBlackoilState(int timeStepIdx, std::shared_ptr ourFineGridManagerPtr) -{ - const UnstructuredGrid &ug_grid = *ourFineGridManagerPtr->c_grid(); - - std::shared_ptr blackoilState = std::make_shared(Opm::UgGridHelpers::numCells( ug_grid ) , Opm::UgGridHelpers::numFaces( ug_grid ), 3); - size_t numCells = Opm::UgGridHelpers::numCells( ug_grid ); - - auto &pressure = blackoilState->pressure(); - for (size_t cellIdx = 0; cellIdx < numCells; ++cellIdx) { - pressure[cellIdx] = timeStepIdx*1e5 + 1e4 + cellIdx; - } - return blackoilState; -} - - - -std::shared_ptr createEclipseWriter(std::shared_ptr deck, - std::shared_ptr eclipseState, - std::shared_ptr ourFineGridManagerPtr, - const int * compressedToCartesianCellIdx) -{ - Opm::parameter::ParameterGroup params; - params.insertParameter("deck_filename", "testcase.data"); - - Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck); - - const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid(); - - std::shared_ptr eclipseWriter = std::make_shared(params, - eclipseState, - phaseUsage, - ourFinerUnstructuredGrid.number_of_cells, - compressedToCartesianCellIdx); - - return eclipseWriter; -} - -} - -BOOST_AUTO_TEST_CASE(test_EclipseWriterRFTHandler) -{ - const std::string& deckString = - "RUNSPEC\n" - "OIL\n" - "GAS\n" - "WATER\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "DXV\n" - "10*0.25 /\n" - "DYV\n" - "10*0.25 /\n" - "DZV\n" - "10*0.25 /\n" - "TOPS\n" - "100*0.25 /\n" - "\n" - "START -- 0 \n" - "1 NOV 1979 / \n" - "SCHEDULE\n" - "DATES -- 1\n" - " 1 DES 1979/ \n" - "/\n" - "WELSPECS\n" - " 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" - " 'OP_2' 'OP' 4 4 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" - "/\n" - "COMPDAT\n" - " 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - " 'OP_1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n" - " 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - " 'OP_2' 4 4 4 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - "/\n" - "DATES -- 2\n" - " 10 OKT 2008 / \n" - "/\n" - "WRFT \n" - "/ \n" - "WELOPEN\n" - " 'OP_1' OPEN / \n" - " 'OP_2' OPEN / \n" - "/\n" - "DATES -- 3\n" - " 10 NOV 2008 / \n" - "/\n"; - - - - test_work_area_type * new_ptr = test_work_area_alloc("test_EclipseWriterRFTHandler"); - std::shared_ptr test_area; - test_area.reset(new_ptr, test_work_area_free); - - std::shared_ptr deck = createDeck(deckString); - std::shared_ptr eclipseState = std::make_shared(deck , Opm::ParseContext()); - - std::shared_ptr simulatorTimer = std::make_shared(); - simulatorTimer->init(eclipseState->getSchedule()->getTimeMap()); - - std::shared_ptr ourFineGridManagerPtr = std::make_shared(eclipseState->getInputGrid()); - const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid(); - const int* compressedToCartesianCellIdx = Opm::UgGridHelpers::globalCell(ourFinerUnstructuredGrid); - - std::shared_ptr eclipseWriter = createEclipseWriter(deck, - eclipseState, - ourFineGridManagerPtr, - compressedToCartesianCellIdx); - eclipseWriter->writeInit(*simulatorTimer); - - - for (; simulatorTimer->currentStepNum() < simulatorTimer->numSteps(); ++ (*simulatorTimer)) { - std::shared_ptr blackoilState2 = createBlackoilState(simulatorTimer->currentStepNum(),ourFineGridManagerPtr); - std::shared_ptr wellState = createWellState(blackoilState2); - eclipseWriter->writeTimeStep(*simulatorTimer, *blackoilState2, *wellState, false); - } - - std::string cwd(test_work_area_get_cwd(test_area.get())); - std::string rft_filename = cwd + "/TESTCASE.RFT"; - verifyRFTFile(rft_filename); - -} - - - diff --git a/tests/test_EclipseWriter.cpp b/tests/test_EclipseWriter.cpp deleted file mode 100644 index c6fdf2d3..00000000 --- a/tests/test_EclipseWriter.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/* - Copyright 2014 Andreas Lauser - - 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 "config.h" - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - -#define BOOST_TEST_MODULE EclipseWriter -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -// ERT stuff -#include -#include -#include - -#include - -std::shared_ptr eclWriter; -std::shared_ptr simTimer; -std::shared_ptr deck; -std::shared_ptr eclipseState; -std::shared_ptr ourFineGridManagerPtr; -std::shared_ptr blackoilState; -std::shared_ptr wellState; - -void createEclipseWriter(const char *deckString) -{ - Opm::ParseContext parseContext; - Opm::ParserConstPtr parser(new Opm::Parser()); - deck = parser->parseString(deckString, parseContext); - - Opm::parameter::ParameterGroup params; - params.insertParameter("deck_filename", "foo.data"); - - eclipseState.reset(new Opm::EclipseState(deck , parseContext)); - - auto eclGrid = eclipseState->getInputGrid(); - BOOST_CHECK(eclGrid->getNX() == 3); - BOOST_CHECK(eclGrid->getNY() == 3); - BOOST_CHECK(eclGrid->getNZ() == 3); - BOOST_CHECK(eclGrid->getCartesianSize() == 3*3*3); - - simTimer.reset(new Opm::SimulatorTimer()); - simTimer->init(eclipseState->getSchedule()->getTimeMap()); - - // also create an UnstructuredGrid (required to create a BlackoilState) - Opm::EclipseGridConstPtr constEclGrid(eclGrid); - ourFineGridManagerPtr.reset(new Opm::GridManager(constEclGrid)); - - const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid(); - BOOST_CHECK(ourFinerUnstructuredGrid.cartdims[0] == 3); - BOOST_CHECK(ourFinerUnstructuredGrid.cartdims[1] == 3); - BOOST_CHECK(ourFinerUnstructuredGrid.cartdims[2] == 3); - - BOOST_CHECK(ourFinerUnstructuredGrid.number_of_cells == 3*3*3); - - Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck); - eclWriter.reset(new Opm::EclipseWriter(params, - eclipseState, - phaseUsage, - ourFinerUnstructuredGrid.number_of_cells, - 0)); - - // this check is disabled so far, because UnstructuredGrid uses some weird definition - // of the term "face". For this grid, "number_of_faces" is 108 which is - // 2*6*numCells... - //BOOST_CHECK(ourFinerUnstructuredGrid.number_of_faces == 4*4*4); - - int numCells = ourFinerUnstructuredGrid.number_of_cells; - for (int cellIdx = 0; cellIdx < numCells; ++cellIdx) - BOOST_CHECK(ourFinerUnstructuredGrid.global_cell[cellIdx] == cellIdx); -} - -void createBlackoilState(int timeStepIdx) -{ - // allocate a new BlackoilState object - const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid(); - blackoilState.reset(new Opm::BlackoilState( Opm::UgGridHelpers::numCells( ourFinerUnstructuredGrid ) , Opm::UgGridHelpers::numFaces( ourFinerUnstructuredGrid ), 3)); - - size_t numCells = ourFinerUnstructuredGrid.number_of_cells; - size_t numFaces = ourFinerUnstructuredGrid.number_of_faces; - - BOOST_CHECK(blackoilState->pressure().size() == numCells); - BOOST_CHECK(blackoilState->facepressure().size() == numFaces); - BOOST_CHECK(blackoilState->faceflux().size() == numFaces); - BOOST_CHECK(blackoilState->saturation().size() == numCells*3); - BOOST_CHECK(blackoilState->gasoilratio().size() == numCells); - BOOST_CHECK(blackoilState->rv().size() == numCells); - - // this check is disabled because BlackoilState does not seem to allocate memory for - // this field. This means that it is probably unused and unneeded. - //BOOST_CHECK(blackoilState->surfacevol().size() == numCells*3); - - // fill the state object with some data. The fun with this class is that it does not - // exhibit a proper c++ way to do this (i.e., getter + setter methods). Instead - // references to the arrays must be retrieved from the object and manipulated - // directly. Don't try to call resize() or anything else which is not politically - // correct on them! - auto &pressure = blackoilState->pressure(); - auto &facepressure = blackoilState->facepressure(); - auto &faceflux = blackoilState->faceflux(); - auto &saturation = blackoilState->saturation(); - auto &gasoilratio = blackoilState->gasoilratio(); - auto &rv = blackoilState->rv(); - for (size_t cellIdx = 0; cellIdx < numCells; ++cellIdx) { - pressure[cellIdx] = timeStepIdx*1e5 + 1e4 + cellIdx; - - // set the phase saturations. Some fun with direct index manipulation is to be - // had... - saturation[3*cellIdx + 0] = timeStepIdx*1e5 +2.1e4 + cellIdx; // oil - saturation[3*cellIdx + 1] = timeStepIdx*1e5 +2.2e4 + cellIdx; // gas - saturation[3*cellIdx + 2] = timeStepIdx*1e5 +2.3e4 + cellIdx; // water - - // oil vaporization factor - rv[cellIdx] = timeStepIdx*1e5 +3e4 + cellIdx; - - // gas dissolution factor - gasoilratio[cellIdx] = timeStepIdx*1e5 + 4e4 + cellIdx; - } - - // face specific data - for (size_t faceIdx = 0; faceIdx < numFaces; ++faceIdx) { - facepressure[faceIdx] = timeStepIdx*1e5 + 5e4 + faceIdx; - faceflux[faceIdx] = timeStepIdx*1e5 + 6e4 + faceIdx; - } -} - -void createWellState(int /*timeStepIdx*/) -{ - // allocate a new BlackoilState object - wellState.reset(new Opm::WellState); - wellState->init(0, *blackoilState); -} - -void getErtData(ecl_kw_type *eclKeyword, std::vector &data) -{ - size_t kwSize = ecl_kw_get_size(eclKeyword); - float* ertData = static_cast(ecl_kw_iget_ptr(eclKeyword, 0)); - - data.resize(kwSize); - std::copy(ertData, ertData + kwSize, data.begin()); -} - -void getErtData(ecl_kw_type *eclKeyword, std::vector &data) -{ - size_t kwSize = ecl_kw_get_size(eclKeyword); - int* ertData = static_cast(ecl_kw_iget_ptr(eclKeyword, 0)); - - data.resize(kwSize); - std::copy(ertData, ertData + kwSize, data.begin()); -} - -void compareErtData(const std::vector &src, const std::vector &dst, double tolerance) -{ - BOOST_CHECK_EQUAL(src.size(), dst.size()); - if (src.size() != dst.size()) - return; - - for (size_t i = 0; i < src.size(); ++i) - BOOST_CHECK_CLOSE(src[i], dst[i], tolerance); -} - -void compareErtData(const std::vector &src, const std::vector &dst) -{ - BOOST_CHECK_EQUAL(src.size(), dst.size()); - if (src.size() != dst.size()) - return; - - for (size_t i = 0; i < src.size(); ++i) - BOOST_CHECK_EQUAL(src[i], dst[i]); -} - -void checkEgridFile() -{ - size_t numCells = ourFineGridManagerPtr->c_grid()->number_of_cells; - - // use ERT directly to inspect the EGRID file produced by EclipseWriter - auto egridFile = fortio_open_reader("FOO.EGRID", /*isFormated=*/0, ECL_ENDIAN_FLIP); - - auto eclGrid = eclipseState->getInputGrid(); - - ecl_kw_type *eclKeyword; - // yes, that's an assignment! - while ((eclKeyword = ecl_kw_fread_alloc(egridFile))) { - std::string keywordName(ecl_kw_get_header(eclKeyword)); - if (keywordName == "COORD") { - std::vector sourceData, resultData; - eclGrid->exportCOORD(sourceData); - getErtData(eclKeyword, resultData); - compareErtData(sourceData, resultData, /*percentTolerance=*/1e-6); - } - else if (keywordName == "ZCORN") { - std::vector sourceData, resultData; - eclGrid->exportZCORN(sourceData); - getErtData(eclKeyword, resultData); - compareErtData(sourceData, resultData, /*percentTolerance=*/1e-6); - } - else if (keywordName == "ACTNUM") { - std::vector sourceData, resultData; - eclGrid->exportACTNUM(sourceData); - getErtData(eclKeyword, resultData); - - if (resultData.size() == numCells && sourceData.size() == 0) { - sourceData.resize(numCells); - std::fill(sourceData.begin(), sourceData.end(), 1); - } - - compareErtData(sourceData, resultData); - } - - ecl_kw_free(eclKeyword); - } - - fortio_fclose(egridFile); -} - -void checkInitFile() -{ - // use ERT directly to inspect the INIT file produced by EclipseWriter - auto initFile = fortio_open_reader("FOO.INIT", /*isFormated=*/0, ECL_ENDIAN_FLIP); - - ecl_kw_type *eclKeyword; - // yes, that's an assignment! - while ((eclKeyword = ecl_kw_fread_alloc(initFile))) { - std::string keywordName(ecl_kw_get_header(eclKeyword)); - - if (keywordName == "PORO") { - const std::vector &sourceData = deck->getKeyword("PORO").getSIDoubleData(); - std::vector resultData; - getErtData(eclKeyword, resultData); - - compareErtData(sourceData, resultData, /*percentTolerance=*/1e-4); - } - - if (keywordName == "PERMX") { - std::vector sourceData = deck->getKeyword("PERMX").getSIDoubleData(); - std::vector resultData; - getErtData(eclKeyword, resultData); - - // convert the data from ERT from Field to SI units (mD to m^2) - for (size_t i = 0; i < resultData.size(); ++i) { - resultData[i] *= 9.869233e-16; - } - - compareErtData(sourceData, resultData, /*percentTolerance=*/1e-4); - } - - ecl_kw_free(eclKeyword); - } - - fortio_fclose(initFile); -} - -void checkRestartFile(int timeStepIdx) -{ - size_t numCells = ourFineGridManagerPtr->c_grid()->number_of_cells; - - Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck); - int numActivePhases = phaseUsage.num_phases; - int waterPhaseIdx = phaseUsage.phase_pos[Opm::BlackoilPhases::Aqua]; - int gasPhaseIdx = phaseUsage.phase_pos[Opm::BlackoilPhases::Vapour]; - - for (int i = 0; i <= timeStepIdx; ++i) { - createBlackoilState(i); - - // use ERT directly to inspect the restart file produced by EclipseWriter - auto rstFile = fortio_open_reader("FOO.UNRST", /*isFormated=*/0, ECL_ENDIAN_FLIP); - - int curSeqnum = -1; - ecl_kw_type *eclKeyword; - // yes, that's an assignment! - while ((eclKeyword = ecl_kw_fread_alloc(rstFile))) { - std::string keywordName(ecl_kw_get_header(eclKeyword)); - - if (keywordName == "SEQNUM") { - curSeqnum = *static_cast(ecl_kw_iget_ptr(eclKeyword, 0)); - } - if (curSeqnum != i) - continue; - - if (keywordName == "PRESSURE") { - std::vector sourceData = blackoilState->pressure(); - std::vector resultData; - getErtData(eclKeyword, resultData); - - // convert the data from ERT from Metric to SI units (bar to Pa) - for (size_t ii = 0; ii < resultData.size(); ++ii) { - resultData[ii] *= 1e5; - } - - compareErtData(sourceData, resultData, /*percentTolerance=*/1e-4); - } - - if (keywordName == "SWAT") { - std::vector sourceData; - std::vector resultData; - getErtData(eclKeyword, resultData); - - // extract the water saturation from the black-oil state - sourceData.resize(numCells); - for (size_t ii = 0; ii < sourceData.size(); ++ii) { - // again, fun with direct index manipulation... - sourceData[ii] = blackoilState->saturation()[ii*numActivePhases + waterPhaseIdx]; - } - - compareErtData(sourceData, resultData, /*percentTolerance=*/1e-4); - } - - if (keywordName == "SGAS") { - std::vector sourceData; - std::vector resultData; - getErtData(eclKeyword, resultData); - - // extract the water saturation from the black-oil state - sourceData.resize(numCells); - for (size_t ii = 0; ii < sourceData.size(); ++ii) { - // again, fun with direct index manipulation... - sourceData[ii] = blackoilState->saturation()[ii*numActivePhases + gasPhaseIdx]; - } - - compareErtData(sourceData, resultData, /*percentTolerance=*/1e-4); - } - } - - fortio_fclose(rstFile); - } -} - -void checkSummaryFile(int /*timeStepIdx*/) -{ - // TODO -} - -BOOST_AUTO_TEST_CASE(EclipseWriterIntegration) -{ - const char *deckString = - "RUNSPEC\n" - "INIT\n" - "UNIFOUT\n" - "OIL\n" - "GAS\n" - "WATER\n" - "METRIC\n" - "DIMENS\n" - "3 3 3/\n" - "GRID\n" - "DXV\n" - "1.0 2.0 3.0 /\n" - "DYV\n" - "4.0 5.0 6.0 /\n" - "DZV\n" - "7.0 8.0 9.0 /\n" - "TOPS\n" - "9*100 /\n" - "PROPS\n" - "PORO\n" - "27*0.3 /\n" - "PERMX\n" - "27*1 /\n" - "SOLUTION\n" - "RPTRST\n" - "BASIC=2\n" - "/\n" - "SCHEDULE\n" - "TSTEP\n" - "1.0 2.0 3.0 4.0 /\n" - "WELSPECS\n" - "'INJ' 'G' 1 1 2000 'GAS' /\n" - "'PROD' 'G' 3 3 1000 'OIL' /\n" - "/\n"; - - createEclipseWriter(deckString); - - eclWriter->writeInit(*simTimer); - - checkEgridFile(); - checkInitFile(); - - for (; simTimer->currentStepNum() < simTimer->numSteps(); ++ (*simTimer)) { - createBlackoilState(simTimer->currentStepNum()); - createWellState(simTimer->currentStepNum()); - eclWriter->writeTimeStep(*simTimer, *blackoilState, *wellState, false); - checkRestartFile(simTimer->currentStepNum()); - checkSummaryFile(simTimer->currentStepNum()); - } -} diff --git a/tests/test_writeReadRestartFile.cpp b/tests/test_writeReadRestartFile.cpp deleted file mode 100644 index 7158d531..00000000 --- a/tests/test_writeReadRestartFile.cpp +++ /dev/null @@ -1,350 +0,0 @@ - -/* - Copyright 2014 Statoil IT - 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 "config.h" - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - -#define BOOST_TEST_MODULE EclipseWriter -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// ERT stuff -#include -#include -#include -#include -#include -#include - -#include - - -std::string input = - "RUNSPEC\n" - "OIL\n" - "GAS\n" - "WATER\n" - "DISGAS\n" - "VAPOIL\n" - "UNIFOUT\n" - "UNIFIN\n" - "DIMENS\n" - " 10 10 10 /\n" - - "GRID\n" - "DXV\n" - "10*0.25 /\n" - "DYV\n" - "10*0.25 /\n" - "DZV\n" - "10*0.25 /\n" - "TOPS\n" - "100*0.25 /\n" - "\n" - - "SOLUTION\n" - "RESTART\n" - "TESTWELLSTATE 1/\n" - "\n" - - "START -- 0 \n" - "1 NOV 1979 / \n" - - "SCHEDULE\n" - "SKIPREST\n" - "RPTRST\n" - "BASIC=1\n" - "/\n" - "DATES -- 1\n" - " 10 OKT 2008 / \n" - "/\n" - "WELSPECS\n" - " 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" - " 'OP_2' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" - "/\n" - "COMPDAT\n" - " 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - " 'OP_2' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n" - " 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - "/\n" - "WCONPROD\n" - "'OP_1' 'OPEN' 'ORAT' 20000 4* 1000 /\n" - "/\n" - "WCONINJE\n" - "'OP_2' 'GAS' 'OPEN' 'RATE' 100 200 400 /\n" - "/\n" - - "DATES -- 2\n" - " 20 JAN 2011 / \n" - "/\n" - "WELSPECS\n" - " 'OP_3' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" - "/\n" - "COMPDAT\n" - " 'OP_3' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - "/\n" - "WCONPROD\n" - "'OP_3' 'OPEN' 'ORAT' 20000 4* 1000 /\n" - "/\n" - - "DATES -- 3\n" - " 15 JUN 2013 / \n" - "/\n" - "COMPDAT\n" - " 'OP_2' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - " 'OP_1' 9 9 7 7 'SHUT' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - "/\n" - - "DATES -- 4\n" - " 22 APR 2014 / \n" - "/\n" - "WELSPECS\n" - " 'OP_4' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" - "/\n" - "COMPDAT\n" - " 'OP_4' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - " 'OP_3' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - "/\n" - "WCONPROD\n" - "'OP_4' 'OPEN' 'ORAT' 20000 4* 1000 /\n" - "/\n" - - "DATES -- 5\n" - " 30 AUG 2014 / \n" - "/\n" - "WELSPECS\n" - " 'OP_5' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" - "/\n" - "COMPDAT\n" - " 'OP_5' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - "/\n" - "WCONPROD\n" - "'OP_5' 'OPEN' 'ORAT' 20000 4* 1000 /\n" - "/\n" - - "DATES -- 6\n" - " 15 SEP 2014 / \n" - "/\n" - "WCONPROD\n" - "'OP_3' 'SHUT' 'ORAT' 20000 4* 1000 /\n" - "/\n" - - "DATES -- 7\n" - " 9 OCT 2014 / \n" - "/\n" - "WELSPECS\n" - " 'OP_6' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" - "/\n" - "COMPDAT\n" - " 'OP_6' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - "/\n" - "WCONPROD\n" - "'OP_6' 'OPEN' 'ORAT' 20000 4* 1000 /\n" - "/\n" - "TSTEP -- 8\n" - "10 /" - "/\n"; - - -std::shared_ptr createBlackOilState(Opm::EclipseGridConstPtr eclGrid , const Opm::PhaseUsage& phaseUsage) { - - std::shared_ptr grid(new Opm::GridManager(eclGrid)); - const UnstructuredGrid& ug_grid = *(grid->c_grid()); - std::shared_ptr blackoilState(new Opm::BlackoilState( Opm::UgGridHelpers::numCells(ug_grid) , Opm::UgGridHelpers::numFaces(ug_grid) , phaseUsage.num_phases) ); - - return blackoilState; -} - -Opm::EclipseWriterPtr createEclipseWriter(const Opm::Deck& deck, - Opm::EclipseStatePtr eclipseState, - std::string& eclipse_data_filename) { - - Opm::parameter::ParameterGroup params; - params.insertParameter("deck_filename", eclipse_data_filename); - - const Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck); - - Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params, - eclipseState, - phaseUsage, - eclipseState->getInputGrid()->getCartesianSize(), - 0)); - return eclWriter; -} - -void setValuesInWellState(std::shared_ptr wellState){ - wellState->bhp()[0] = 1.23; - wellState->bhp()[1] = 2.34; - - wellState->temperature()[0] = 3.45; - wellState->temperature()[1] = 4.56; - - wellState->wellRates()[0] = 5.67; - wellState->wellRates()[1] = 6.78; - wellState->wellRates()[2] = 7.89; - wellState->wellRates()[3] = 8.90; - wellState->wellRates()[4] = 9.01; - wellState->wellRates()[5] = 10.12; - - wellState->perfPress()[0] = 20.41; - wellState->perfPress()[1] = 21.19; - wellState->perfPress()[2] = 22.41; - wellState->perfPress()[3] = 23.19; - wellState->perfPress()[4] = 24.41; - wellState->perfPress()[5] = 25.19; - wellState->perfPress()[6] = 26.41; - wellState->perfPress()[7] = 27.19; - wellState->perfPress()[8] = 28.41; - - wellState->perfRates()[0] = 30.45; - wellState->perfRates()[1] = 31.19; - wellState->perfRates()[2] = 32.45; - wellState->perfRates()[3] = 33.19; - wellState->perfRates()[4] = 34.45; - wellState->perfRates()[5] = 35.19; - wellState->perfRates()[6] = 36.45; - wellState->perfRates()[7] = 37.19; - wellState->perfRates()[8] = 38.45; -} - -BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData) -{ - std::string eclipse_data_filename = "TestWellState.DATA"; - test_work_area_type * test_area = test_work_area_alloc("EclipseReadWriteWellStateData"); - - Opm::Parser parser; - Opm::ParseContext parseContext; - const Opm::Deck& deck = parser.parseString(input, parseContext); - Opm::EclipseStatePtr eclipseState(new Opm::EclipseState(deck , parseContext)); - Opm::EclipseWriterPtr eclipseWriter = createEclipseWriter(deck, eclipseState, eclipse_data_filename); - - std::shared_ptr simTimer( new Opm::SimulatorTimer() ); - simTimer->init(eclipseState->getSchedule()->getTimeMap()); - eclipseWriter->writeInit(*simTimer); - std::shared_ptr wellState(new Opm::WellState()); - Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck); - - Opm::GridManager gridManager(deck); - Opm::WellsManager wellsManager(eclipseState, 1, *gridManager.c_grid(), NULL); - const Wells* wells = wellsManager.c_wells(); - std::shared_ptr blackoilState = createBlackOilState(eclipseState->getInputGrid(), phaseUsage); - wellState->init(wells, *blackoilState); - - //Set test data for pressure - std::vector& pressure = blackoilState->pressure(); - for (std::vector::iterator iter = pressure.begin(); iter != pressure.end(); ++iter) { - *iter = 6.0; - } - - //Set test data for temperature - std::vector& temperature = blackoilState->temperature(); - for (std::vector::iterator iter = temperature.begin(); iter != temperature.end(); ++iter) { - *iter = 7.0; - } - - //Set test data for saturation water - std::vector swatdata(1000, 8); - Opm::EclipseIOUtil::addToStripedData(swatdata, blackoilState->saturation(), phaseUsage.phase_pos[Opm::BlackoilPhases::Aqua], phaseUsage.num_phases); - - //Set test data for saturation gas - std::vector sgasdata(1000, 9); - Opm::EclipseIOUtil::addToStripedData(sgasdata, blackoilState->saturation(), phaseUsage.phase_pos[Opm::BlackoilPhases::Vapour], phaseUsage.num_phases); - - // Set test data for rs - double rs = 300.0; - std::vector& rs_vec = blackoilState->gasoilratio(); - for (std::vector::iterator rs_iter = rs_vec.begin(); rs_iter != rs_vec.end(); ++ rs_iter) { - *rs_iter = rs; - rs = rs + 1.0; - } - - // Set testdata for rv - double rv = 400.0; - std::vector& rv_vec = blackoilState->rv(); - for (std::vector::iterator rv_iter = rv_vec.begin(); rv_iter != rv_vec.end(); ++rv_iter) { - *rv_iter = rv; - rv = rv + 1.0; - } - - setValuesInWellState(wellState); - simTimer->setCurrentStepNum(1); - eclipseWriter->writeTimeStep(*simTimer, *blackoilState, *wellState , false); - - std::shared_ptr wellStateRestored(new Opm::WellState()); - wellStateRestored->init(wells, *blackoilState); - - //Read and verify OPM XWEL data, and solution data: pressure, temperature, saturation data, rs and rv - std::shared_ptr blackoilStateRestored = createBlackOilState(eclipseState->getInputGrid(), phaseUsage); - Opm::init_from_restart_file(eclipseState, Opm::UgGridHelpers::numCells(*gridManager.c_grid()), phaseUsage, *blackoilStateRestored, *wellStateRestored); - - BOOST_CHECK_EQUAL_COLLECTIONS(wellState->bhp().begin(), wellState->bhp().end(), wellStateRestored->bhp().begin(), wellStateRestored->bhp().end()); - BOOST_CHECK_EQUAL_COLLECTIONS(wellState->temperature().begin(), wellState->temperature().end(), wellStateRestored->temperature().begin(), wellStateRestored->temperature().end()); - BOOST_CHECK_EQUAL_COLLECTIONS(wellState->wellRates().begin(), wellState->wellRates().end(), wellStateRestored->wellRates().begin(), wellStateRestored->wellRates().end()); - BOOST_CHECK_EQUAL_COLLECTIONS(wellState->perfRates().begin(), wellState->perfRates().end(), wellStateRestored->perfRates().begin(), wellStateRestored->perfRates().end()); - BOOST_CHECK_EQUAL_COLLECTIONS(wellState->perfPress().begin(), wellState->perfPress().end(), wellStateRestored->perfPress().begin(), wellStateRestored->perfPress().end()); - - std::vector swat_restored; - std::vector swat; - std::vector sgas_restored; - std::vector sgas; - Opm::EclipseIOUtil::extractFromStripedData(blackoilStateRestored->saturation(), swat_restored, phaseUsage.phase_pos[Opm::BlackoilPhases::Aqua], phaseUsage.num_phases); - Opm::EclipseIOUtil::extractFromStripedData(blackoilState->saturation(), swat, phaseUsage.phase_pos[Opm::BlackoilPhases::Aqua], phaseUsage.num_phases); - Opm::EclipseIOUtil::extractFromStripedData(blackoilStateRestored->saturation(), sgas_restored, phaseUsage.phase_pos[Opm::BlackoilPhases::Vapour], phaseUsage.num_phases); - Opm::EclipseIOUtil::extractFromStripedData(blackoilState->saturation(), sgas, phaseUsage.phase_pos[Opm::BlackoilPhases::Vapour], phaseUsage.num_phases); - - for (size_t cellindex = 0; cellindex < 10; ++cellindex) { - BOOST_CHECK_CLOSE(blackoilState->pressure()[cellindex], blackoilStateRestored->pressure()[cellindex], 0.00001); - BOOST_CHECK_CLOSE(blackoilState->temperature()[cellindex], blackoilStateRestored->temperature()[cellindex], 0.00001); - BOOST_CHECK_CLOSE(swat[cellindex], swat_restored[cellindex], 0.00001); - BOOST_CHECK_CLOSE(sgas[cellindex], sgas_restored[cellindex], 0.00001); - } - - - for (size_t cellindex = 0; cellindex < 10; ++cellindex) { - BOOST_CHECK_CLOSE(blackoilState->gasoilratio()[cellindex], blackoilStateRestored->gasoilratio()[cellindex], 0.0000001); - BOOST_CHECK_CLOSE(blackoilState->rv()[cellindex], blackoilStateRestored->rv()[cellindex], 0.0000001); - } - - test_work_area_free(test_area); -} diff --git a/tests/test_writenumwells.cpp b/tests/test_writenumwells.cpp deleted file mode 100644 index 19f31f88..00000000 --- a/tests/test_writenumwells.cpp +++ /dev/null @@ -1,198 +0,0 @@ - -/* - Copyright 2014 Statoil IT - 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 "config.h" - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - -#define BOOST_TEST_MODULE EclipseWriter -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -// ERT stuff -#include -#include -#include -#include -#include -#include - -#include - - -void verifyWellState(const std::string& rst_filename, - Opm::EclipseGridConstPtr ecl_grid, - Opm::ScheduleConstPtr schedule) { - - well_info_type * well_info = well_info_alloc(ecl_grid->c_ptr()); - well_info_load_rstfile(well_info, rst_filename.c_str(), false); - - //Verify numwells - int numwells = well_info_get_num_wells(well_info); - BOOST_CHECK(numwells == (int)schedule->numWells()); - - std::vector wells = schedule->getWells(); - - for (int i = 0; i < numwells; ++i) { - - //Verify wellnames - const char * wellname = well_info_iget_well_name(well_info, i); - Opm::WellConstPtr well = wells.at(i); - BOOST_CHECK(wellname == well->name()); - - // Verify well-head position data - well_ts_type * well_ts = well_info_get_ts(well_info , wellname); - well_state_type * well_state = well_ts_iget_state(well_ts, 0); - const well_conn_type * well_head = well_state_get_wellhead(well_state, ECL_GRID_GLOBAL_GRID); - BOOST_CHECK(well_conn_get_i(well_head) == well->getHeadI()); - BOOST_CHECK(well_conn_get_j(well_head) == well->getHeadJ()); - - for (int j = 0; j < well_ts_get_size(well_ts); ++j) { - well_state = well_ts_iget_state(well_ts, j); - - //Verify welltype - int ert_well_type = well_state_get_type(well_state); - WellType welltype = well->isProducer(j) ? PRODUCER : INJECTOR; - Opm::WellInjector::TypeEnum injectortype = well->getInjectionProperties(j).injectorType; - int ecl_converted_welltype = Opm::EclipseWriter::eclipseWellTypeMask(welltype, injectortype); - int ert_converted_welltype = well_state_translate_ecl_type_int(ecl_converted_welltype); - BOOST_CHECK(ert_well_type == ert_converted_welltype); - - //Verify wellstatus - int ert_well_status = well_state_is_open(well_state) ? 1 : 0; - - Opm::WellCommon::StatusEnum status = well->getStatus(j); - int wellstatus = Opm::EclipseWriter::eclipseWellStatusMask(status); - - BOOST_CHECK(ert_well_status == wellstatus); - - //Verify number of completion connections - const well_conn_collection_type * well_connections = well_state_get_global_connections( well_state ); - size_t num_wellconnections = well_conn_collection_get_size(well_connections); - - int report_nr = well_state_get_report_nr(well_state); - Opm::CompletionSetConstPtr completions_set = well->getCompletions((size_t)report_nr); - - BOOST_CHECK(num_wellconnections == completions_set->size()); - - //Verify coordinates for each completion connection - for (size_t k = 0; k < num_wellconnections; ++k) { - const well_conn_type * well_connection = well_conn_collection_iget_const(well_connections , k); - - Opm::CompletionConstPtr completion = completions_set->get(k); - - BOOST_CHECK(well_conn_get_i(well_connection) == completion->getI()); - BOOST_CHECK(well_conn_get_j(well_connection) == completion->getJ()); - BOOST_CHECK(well_conn_get_k(well_connection) == completion->getK()); - } - } - } - - well_info_free(well_info); -} - - -std::shared_ptr createBlackOilState(Opm::EclipseGridConstPtr eclGrid) { - - std::shared_ptr grid(new Opm::GridManager(eclGrid)); - const UnstructuredGrid& ug_grid = *(grid->c_grid()); - std::shared_ptr blackoilState(new Opm::BlackoilState( Opm::UgGridHelpers::numCells(ug_grid) , Opm::UgGridHelpers::numFaces(ug_grid) , 3 )); - - return blackoilState; -} - - -const Opm::Deck createDeck(const std::string& eclipse_data_filename) { - Opm::ParserPtr parser(new Opm::Parser()); - const Opm::Deck& deck = parser->parseFile(eclipse_data_filename , Opm::ParseContext()); - - return deck; -} - - -Opm::EclipseWriterPtr createEclipseWriter(const Opm::Deck& deck, - Opm::EclipseStatePtr eclipseState, - std::string& eclipse_data_filename) { - - Opm::parameter::ParameterGroup params; - params.insertParameter("deck_filename", eclipse_data_filename); - - const Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck); - - Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params, - eclipseState, - phaseUsage, - eclipseState->getInputGrid()->getCartesianSize(), - 0)); - return eclWriter; -} - - -BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) -{ - std::string eclipse_data_filename = "testBlackoilState3.DATA"; - std::string eclipse_restart_filename = "TESTBLACKOILSTATE3.X0004"; - - - test_work_area_type * test_area = test_work_area_alloc("TEST_EclipseWriteNumWells"); - test_work_area_copy_file(test_area, eclipse_data_filename.c_str()); - - Opm::ParseContext parseContext; - const Opm::Deck deck = createDeck(eclipse_data_filename); - Opm::EclipseStatePtr eclipseState(new Opm::EclipseState(deck , parseContext)); - Opm::EclipseWriterPtr eclipseWriter = createEclipseWriter(deck, eclipseState, eclipse_data_filename); - - std::shared_ptr simTimer( new Opm::SimulatorTimer() ); - simTimer->init(eclipseState->getSchedule()->getTimeMap()); - - eclipseWriter->writeInit(*simTimer); - - std::shared_ptr wellState(new Opm::WellState()); - std::shared_ptr blackoilState = createBlackOilState(eclipseState->getInputGrid()); - wellState->init(0, *blackoilState); - - int countTimeStep = eclipseState->getSchedule()->getTimeMap()->numTimesteps(); - - for(int timestep=0; timestep <= countTimeStep; ++timestep){ - simTimer->setCurrentStepNum(timestep); - eclipseWriter->writeTimeStep(*simTimer, *blackoilState, *wellState, false); - } - - verifyWellState(eclipse_restart_filename, eclipseState->getInputGrid(), eclipseState->getSchedule()); - - test_work_area_free(test_area); -}