2016-03-16 04:42:50 -05:00
|
|
|
/*
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
2017-01-06 07:38:12 -06:00
|
|
|
#define BOOST_TEST_MODULE EclipseIO
|
2016-03-16 04:42:50 -05:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
2017-01-06 07:38:12 -06:00
|
|
|
#include <opm/output/eclipse/EclipseIO.hpp>
|
2016-10-03 07:52:39 -05:00
|
|
|
#include <opm/output/data/Cells.hpp>
|
2016-03-16 04:42:50 -05:00
|
|
|
|
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
|
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
|
|
|
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
2017-10-02 05:40:28 -05:00
|
|
|
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
2016-03-16 04:42:50 -05:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
2016-04-15 07:45:26 -05:00
|
|
|
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
|
2016-10-10 10:27:18 -05:00
|
|
|
#include <opm/parser/eclipse/Units/Units.hpp>
|
2016-06-23 04:39:18 -05:00
|
|
|
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
2016-03-16 04:42:50 -05:00
|
|
|
|
|
|
|
// ERT stuff
|
2017-02-17 08:17:08 -06:00
|
|
|
#include <ert/util/ert_unique_ptr.hpp>
|
2018-09-13 10:25:33 -05:00
|
|
|
#include <ert/util/test_work_area.h>
|
2017-02-17 08:17:08 -06:00
|
|
|
|
2016-03-16 04:42:50 -05:00
|
|
|
#include <ert/ecl/ecl_kw.h>
|
2017-02-17 08:17:08 -06:00
|
|
|
#include <ert/ecl/ecl_grid.h>
|
2016-03-16 04:42:50 -05:00
|
|
|
#include <ert/ecl/ecl_endian_flip.h>
|
2016-06-23 04:39:18 -05:00
|
|
|
#include <ert/ecl/ecl_file.h>
|
2016-09-19 12:28:06 -05:00
|
|
|
#include <ert/ecl/ecl_util.h>
|
2017-02-17 08:17:08 -06:00
|
|
|
|
2017-11-14 07:51:39 -06:00
|
|
|
|
2017-02-17 08:17:08 -06:00
|
|
|
#include <ert/ecl_well/well_info.h>
|
2016-03-16 04:42:50 -05:00
|
|
|
|
|
|
|
#include <memory>
|
2017-11-14 07:51:39 -06:00
|
|
|
#include <map>
|
2016-03-16 04:42:50 -05:00
|
|
|
|
2016-05-09 03:34:46 -05:00
|
|
|
using namespace Opm;
|
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
data::Solution createBlackoilState( int timeStepIdx, int numCells ) {
|
2016-03-16 04:42:50 -05:00
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
std::vector< double > pressure( numCells );
|
|
|
|
std::vector< double > swat( numCells );
|
|
|
|
std::vector< double > sgas( numCells );
|
|
|
|
std::vector< double > rs( numCells );
|
|
|
|
std::vector< double > rv( numCells );
|
2016-03-16 04:42:50 -05:00
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
for( int cellIdx = 0; cellIdx < numCells; ++cellIdx) {
|
2016-03-16 04:42:50 -05:00
|
|
|
|
|
|
|
pressure[cellIdx] = timeStepIdx*1e5 + 1e4 + cellIdx;
|
2016-05-13 08:44:08 -05:00
|
|
|
sgas[cellIdx] = timeStepIdx*1e5 +2.2e4 + cellIdx;
|
|
|
|
swat[cellIdx] = timeStepIdx*1e5 +2.3e4 + cellIdx;
|
2016-03-16 04:42:50 -05:00
|
|
|
|
|
|
|
// oil vaporization factor
|
|
|
|
rv[cellIdx] = timeStepIdx*1e5 +3e4 + cellIdx;
|
|
|
|
// gas dissolution factor
|
2016-05-13 08:44:08 -05:00
|
|
|
rs[cellIdx] = timeStepIdx*1e5 + 4e4 + cellIdx;
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
data::Solution solution;
|
2016-03-16 04:42:50 -05:00
|
|
|
|
2016-10-06 01:16:33 -05:00
|
|
|
solution.insert( "PRESSURE" , UnitSystem::measure::pressure , pressure, data::TargetType::RESTART_SOLUTION );
|
|
|
|
solution.insert( "SWAT" , UnitSystem::measure::identity , swat, data::TargetType::RESTART_SOLUTION );
|
|
|
|
solution.insert( "SGAS" , UnitSystem::measure::identity , sgas, data::TargetType::RESTART_SOLUTION );
|
|
|
|
solution.insert( "RS" , UnitSystem::measure::identity , rs, data::TargetType::RESTART_SOLUTION );
|
|
|
|
solution.insert( "RV" , UnitSystem::measure::identity , rv, data::TargetType::RESTART_SOLUTION );
|
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
return solution;
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
template< typename T >
|
|
|
|
std::vector< T > getErtData( ecl_kw_type *eclKeyword ) {
|
2016-03-16 04:42:50 -05:00
|
|
|
size_t kwSize = ecl_kw_get_size(eclKeyword);
|
2016-05-13 08:44:08 -05:00
|
|
|
T* ertData = static_cast< T* >(ecl_kw_iget_ptr(eclKeyword, 0));
|
2016-03-16 04:42:50 -05:00
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
return { ertData, ertData + kwSize };
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
template< typename T, typename U >
|
|
|
|
void compareErtData(const std::vector< T > &src,
|
|
|
|
const std::vector< U > &dst,
|
|
|
|
double tolerance ) {
|
2016-03-16 04:42:50 -05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-04-29 03:14:06 -05:00
|
|
|
void compareErtData(const std::vector<int> &src, const std::vector<int> &dst)
|
|
|
|
{
|
2016-05-13 08:44:08 -05:00
|
|
|
BOOST_CHECK_EQUAL_COLLECTIONS( src.begin(), src.end(),
|
|
|
|
dst.begin(), dst.end() );
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
void checkEgridFile( const EclipseGrid& eclGrid ) {
|
2017-01-06 07:38:12 -06:00
|
|
|
// use ERT directly to inspect the EGRID file produced by EclipseIO
|
2016-03-16 04:42:50 -05:00
|
|
|
auto egridFile = fortio_open_reader("FOO.EGRID", /*isFormated=*/0, ECL_ENDIAN_FLIP);
|
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
const auto numCells = eclGrid.getNX() * eclGrid.getNY() * eclGrid.getNZ();
|
2016-03-16 04:42:50 -05:00
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
while( auto* eclKeyword = ecl_kw_fread_alloc( egridFile ) ) {
|
2016-03-16 04:42:50 -05:00
|
|
|
std::string keywordName(ecl_kw_get_header(eclKeyword));
|
|
|
|
if (keywordName == "COORD") {
|
2016-05-13 08:44:08 -05:00
|
|
|
std::vector< double > sourceData;
|
2019-08-24 07:59:52 -05:00
|
|
|
sourceData = eclGrid.getCOORD();
|
2016-05-13 08:44:08 -05:00
|
|
|
auto resultData = getErtData< float >( eclKeyword );
|
|
|
|
compareErtData(sourceData, resultData, 1e-6);
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
else if (keywordName == "ZCORN") {
|
2016-05-13 08:44:08 -05:00
|
|
|
std::vector< double > sourceData;
|
2019-08-24 07:59:52 -05:00
|
|
|
sourceData = eclGrid.getZCORN();
|
2016-05-13 08:44:08 -05:00
|
|
|
auto resultData = getErtData< float >( eclKeyword );
|
2016-03-16 04:42:50 -05:00
|
|
|
compareErtData(sourceData, resultData, /*percentTolerance=*/1e-6);
|
|
|
|
}
|
|
|
|
else if (keywordName == "ACTNUM") {
|
2016-05-13 08:44:08 -05:00
|
|
|
std::vector< int > sourceData( numCells );
|
2019-08-24 07:59:52 -05:00
|
|
|
sourceData = eclGrid.getACTNUM();
|
2016-05-13 08:44:08 -05:00
|
|
|
auto resultData = getErtData< int >( eclKeyword );
|
2016-03-16 04:42:50 -05:00
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
if( sourceData.empty() )
|
|
|
|
sourceData.assign( numCells, 1 );
|
2016-03-16 04:42:50 -05:00
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
compareErtData( sourceData, resultData );
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ecl_kw_free(eclKeyword);
|
|
|
|
}
|
|
|
|
|
|
|
|
fortio_fclose(egridFile);
|
|
|
|
}
|
|
|
|
|
2017-02-17 08:17:08 -06:00
|
|
|
void loadWells( const char* grid_file , const char* restart_file ) {
|
|
|
|
ecl_grid_type * grid = ecl_grid_alloc( grid_file );
|
|
|
|
well_info_type * well_info = well_info_alloc( grid );
|
|
|
|
|
|
|
|
well_info_load_rstfile( well_info , restart_file, true);
|
|
|
|
|
|
|
|
well_info_free( well_info );
|
|
|
|
ecl_grid_free( grid );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-06 01:16:33 -05:00
|
|
|
void checkInitFile( const Deck& deck, const data::Solution& simProps) {
|
2017-01-06 07:38:12 -06:00
|
|
|
// use ERT directly to inspect the INIT file produced by EclipseIO
|
2016-06-23 04:39:18 -05:00
|
|
|
ERT::ert_unique_ptr<ecl_file_type , ecl_file_close> initFile(ecl_file_open( "FOO.INIT" , 0 ));
|
2016-03-16 04:42:50 -05:00
|
|
|
|
2016-09-06 00:54:21 -05:00
|
|
|
for (int k=0; k < ecl_file_get_size( initFile.get() ); k++) {
|
|
|
|
ecl_kw_type * eclKeyword = ecl_file_iget_kw( initFile.get( ) , k );
|
2016-03-16 04:42:50 -05:00
|
|
|
std::string keywordName(ecl_kw_get_header(eclKeyword));
|
|
|
|
|
|
|
|
if (keywordName == "PORO") {
|
2016-05-13 08:44:08 -05:00
|
|
|
const auto &sourceData = deck.getKeyword("PORO").getSIDoubleData();
|
|
|
|
auto resultData = getErtData< float >( eclKeyword );
|
|
|
|
compareErtData(sourceData, resultData, 1e-4);
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (keywordName == "PERMX") {
|
2016-05-13 08:44:08 -05:00
|
|
|
const auto& sourceData = deck.getKeyword("PERMX").getSIDoubleData();
|
|
|
|
auto resultData = getErtData< float >( eclKeyword );
|
2016-03-16 04:42:50 -05:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
compareErtData(sourceData, resultData, 1e-4);
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-15 09:40:21 -06:00
|
|
|
/*
|
|
|
|
These keyword should always be in the INIT file, irrespective of
|
|
|
|
whether they appear in the inut deck or not.
|
|
|
|
*/
|
|
|
|
BOOST_CHECK( ecl_file_has_kw( initFile.get() , "NTG" ));
|
2016-07-14 02:22:11 -05:00
|
|
|
BOOST_CHECK( ecl_file_has_kw( initFile.get() , "FIPNUM" ));
|
|
|
|
BOOST_CHECK( ecl_file_has_kw( initFile.get() , "SATNUM" ));
|
|
|
|
|
2016-06-23 04:39:18 -05:00
|
|
|
for (const auto& prop : simProps) {
|
2016-10-06 09:31:41 -05:00
|
|
|
BOOST_CHECK( ecl_file_has_kw( initFile.get() , prop.first.c_str()) );
|
2016-06-23 04:39:18 -05:00
|
|
|
}
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
|
2016-05-13 08:44:08 -05:00
|
|
|
void checkRestartFile( int timeStepIdx ) {
|
2016-09-09 06:57:29 -05:00
|
|
|
for (int i = 1; i <= timeStepIdx; ++i) {
|
2016-05-13 08:44:08 -05:00
|
|
|
auto sol = createBlackoilState( i, 3 * 3 * 3 );
|
2016-03-16 04:42:50 -05:00
|
|
|
|
2017-01-06 07:38:12 -06:00
|
|
|
// use ERT directly to inspect the restart file produced by EclipseIO
|
2016-03-16 04:42:50 -05:00
|
|
|
auto rstFile = fortio_open_reader("FOO.UNRST", /*isFormated=*/0, ECL_ENDIAN_FLIP);
|
|
|
|
|
|
|
|
int curSeqnum = -1;
|
2016-05-13 08:44:08 -05:00
|
|
|
while( auto* eclKeyword = ecl_kw_fread_alloc(rstFile) ) {
|
2016-03-16 04:42:50 -05:00
|
|
|
std::string keywordName(ecl_kw_get_header(eclKeyword));
|
|
|
|
|
|
|
|
if (keywordName == "SEQNUM") {
|
|
|
|
curSeqnum = *static_cast<int*>(ecl_kw_iget_ptr(eclKeyword, 0));
|
|
|
|
}
|
|
|
|
if (curSeqnum != i)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (keywordName == "PRESSURE") {
|
2016-05-13 08:44:08 -05:00
|
|
|
const auto resultData = getErtData< float >( eclKeyword );
|
2016-10-06 01:16:33 -05:00
|
|
|
for( auto& x : sol.data("PRESSURE") )
|
2016-05-13 08:44:08 -05:00
|
|
|
x /= Metric::Pressure;
|
2016-03-16 04:42:50 -05:00
|
|
|
|
2016-10-06 01:16:33 -05:00
|
|
|
compareErtData( sol.data("PRESSURE"), resultData, 1e-4 );
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (keywordName == "SWAT") {
|
2016-05-13 08:44:08 -05:00
|
|
|
const auto resultData = getErtData< float >( eclKeyword );
|
2016-10-06 01:16:33 -05:00
|
|
|
compareErtData(sol.data("SWAT"), resultData, 1e-4);
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (keywordName == "SGAS") {
|
2016-05-13 08:44:08 -05:00
|
|
|
const auto resultData = getErtData< float >( eclKeyword );
|
2016-10-06 01:16:33 -05:00
|
|
|
compareErtData( sol.data("SGAS"), resultData, 1e-4 );
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
2016-08-20 12:19:21 -05:00
|
|
|
|
|
|
|
if (keywordName == "KRO")
|
|
|
|
BOOST_CHECK_EQUAL( 1.0 * i * ecl_kw_get_size( eclKeyword ) , ecl_kw_element_sum_float( eclKeyword ));
|
|
|
|
|
|
|
|
if (keywordName == "KRG")
|
|
|
|
BOOST_CHECK_EQUAL( 10.0 * i * ecl_kw_get_size( eclKeyword ) , ecl_kw_element_sum_float( eclKeyword ));
|
2016-03-16 04:42:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fortio_fclose(rstFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-06 07:38:12 -06:00
|
|
|
BOOST_AUTO_TEST_CASE(EclipseIOIntegration) {
|
2016-03-29 07:45:48 -05:00
|
|
|
const char *deckString =
|
|
|
|
"RUNSPEC\n"
|
|
|
|
"UNIFOUT\n"
|
|
|
|
"OIL\n"
|
|
|
|
"GAS\n"
|
|
|
|
"WATER\n"
|
|
|
|
"METRIC\n"
|
|
|
|
"DIMENS\n"
|
|
|
|
"3 3 3/\n"
|
|
|
|
"GRID\n"
|
2016-06-23 03:44:47 -05:00
|
|
|
"INIT\n"
|
2016-03-29 07:45:48 -05:00
|
|
|
"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"
|
2016-07-14 02:22:11 -05:00
|
|
|
"REGIONS\n"
|
|
|
|
"SATNUM\n"
|
|
|
|
"27*2 /\n"
|
|
|
|
"FIPNUM\n"
|
|
|
|
"27*3 /\n"
|
2016-03-29 07:45:48 -05:00
|
|
|
"SOLUTION\n"
|
|
|
|
"RPTRST\n"
|
|
|
|
"BASIC=2\n"
|
|
|
|
"/\n"
|
|
|
|
"SCHEDULE\n"
|
|
|
|
"TSTEP\n"
|
2016-09-09 06:57:29 -05:00
|
|
|
"1.0 2.0 3.0 4.0 5.0 6.0 7.0 /\n"
|
2016-03-29 07:45:48 -05:00
|
|
|
"WELSPECS\n"
|
|
|
|
"'INJ' 'G' 1 1 2000 'GAS' /\n"
|
|
|
|
"'PROD' 'G' 3 3 1000 'OIL' /\n"
|
|
|
|
"/\n";
|
|
|
|
|
2016-09-09 06:57:29 -05:00
|
|
|
auto write_and_check = [&]( int first = 1, int last = 5 ) {
|
2019-01-03 11:05:19 -06:00
|
|
|
auto deck = Parser().parseString( deckString);
|
|
|
|
auto es = EclipseState( deck );
|
2016-10-13 07:15:58 -05:00
|
|
|
auto& eclGrid = es.getInputGrid();
|
2019-01-03 11:05:19 -06:00
|
|
|
Schedule schedule(deck, eclGrid, es.get3DProperties(), es.runspec());
|
|
|
|
SummaryConfig summary_config( deck, schedule, es.getTableManager( ));
|
2019-09-19 09:17:38 -05:00
|
|
|
SummaryState st(std::chrono::system_clock::now());
|
2016-10-13 07:15:58 -05:00
|
|
|
es.getIOConfig().setBaseName( "FOO" );
|
2016-05-13 08:44:08 -05:00
|
|
|
|
2017-10-02 05:40:28 -05:00
|
|
|
EclipseIO eclWriter( es, eclGrid , schedule, summary_config);
|
2016-05-13 08:44:08 -05:00
|
|
|
|
2016-10-06 09:31:41 -05:00
|
|
|
using measure = UnitSystem::measure;
|
|
|
|
using TargetType = data::TargetType;
|
2016-09-19 12:28:06 -05:00
|
|
|
auto start_time = ecl_util_make_date( 10, 10, 2008 );
|
2016-06-23 04:39:18 -05:00
|
|
|
std::vector<double> tranx(3*3*3);
|
|
|
|
std::vector<double> trany(3*3*3);
|
|
|
|
std::vector<double> tranz(3*3*3);
|
2016-10-06 09:31:41 -05:00
|
|
|
data::Solution eGridProps {
|
|
|
|
{ "TRANX", { measure::transmissibility, tranx, TargetType::INIT } },
|
|
|
|
{ "TRANY", { measure::transmissibility, trany, TargetType::INIT } },
|
|
|
|
{ "TRANZ", { measure::transmissibility, tranz, TargetType::INIT } },
|
2016-09-09 06:57:29 -05:00
|
|
|
};
|
2016-06-23 04:39:18 -05:00
|
|
|
|
2017-11-20 03:53:45 -06:00
|
|
|
std::map<std::string, std::vector<int>> int_data = {{"STR_ULONGNAME" , {1,1,1,1,1,1,1,1} } };
|
2017-11-14 07:51:39 -06:00
|
|
|
|
|
|
|
std::vector<int> v(27); v[2] = 67; v[26] = 89;
|
2017-11-20 02:39:25 -06:00
|
|
|
int_data["STR_V"] = v;
|
2016-10-03 08:36:19 -05:00
|
|
|
|
2016-11-17 09:08:08 -06:00
|
|
|
eclWriter.writeInitial( );
|
2017-11-14 07:51:39 -06:00
|
|
|
|
2017-11-20 03:53:45 -06:00
|
|
|
BOOST_CHECK_THROW( eclWriter.writeInitial( eGridProps , int_data) , std::invalid_argument);
|
2017-11-14 07:51:39 -06:00
|
|
|
|
2017-11-20 02:39:25 -06:00
|
|
|
int_data.erase("STR_ULONGNAME");
|
|
|
|
eclWriter.writeInitial( eGridProps , int_data );
|
2016-05-13 08:44:08 -05:00
|
|
|
|
|
|
|
data::Wells wells;
|
|
|
|
|
2016-09-09 06:57:29 -05:00
|
|
|
for( int i = first; i < last; ++i ) {
|
2016-10-06 01:16:33 -05:00
|
|
|
data::Solution sol = createBlackoilState( i, 3 * 3 * 3 );
|
2017-02-15 07:50:17 -06:00
|
|
|
sol.insert("KRO", measure::identity , std::vector<double>(3*3*3 , i), TargetType::RESTART_AUXILIARY);
|
|
|
|
sol.insert("KRG", measure::identity , std::vector<double>(3*3*3 , i*10), TargetType::RESTART_AUXILIARY);
|
2016-10-06 01:16:33 -05:00
|
|
|
|
2018-04-28 05:52:28 -05:00
|
|
|
RestartValue restart_value(sol, wells);
|
2016-09-09 06:57:29 -05:00
|
|
|
auto first_step = ecl_util_make_date( 10 + i, 11, 2008 );
|
2019-06-03 10:35:26 -05:00
|
|
|
eclWriter.writeTimeStep( st,
|
|
|
|
i,
|
2018-04-28 05:52:28 -05:00
|
|
|
false,
|
|
|
|
first_step - start_time,
|
2019-06-14 07:38:25 -05:00
|
|
|
restart_value);
|
2016-05-13 08:44:08 -05:00
|
|
|
|
|
|
|
checkRestartFile( i );
|
|
|
|
}
|
2016-09-09 06:57:29 -05:00
|
|
|
|
2016-10-13 07:15:58 -05:00
|
|
|
checkInitFile( deck , eGridProps);
|
2016-06-23 04:39:18 -05:00
|
|
|
checkEgridFile( eclGrid );
|
2017-02-17 08:17:08 -06:00
|
|
|
loadWells( "FOO.EGRID", "FOO.UNRST" );
|
2016-09-09 06:57:29 -05:00
|
|
|
|
2017-11-20 04:03:19 -06:00
|
|
|
ecl_file_type * ecl_file = ecl_file_open("FOO.INIT", 0);
|
2017-11-20 03:53:45 -06:00
|
|
|
BOOST_CHECK( ecl_file_has_kw(ecl_file, "STR_V") );
|
2017-11-14 07:51:39 -06:00
|
|
|
ecl_kw_type * kw = ecl_file_iget_named_kw(ecl_file, "STR_V", 0);
|
2017-11-20 04:03:19 -06:00
|
|
|
BOOST_CHECK(67 == ecl_kw_iget_as_double(kw, 2));
|
|
|
|
BOOST_CHECK(89 == ecl_kw_iget_as_double(kw, 26));
|
2017-11-14 07:51:39 -06:00
|
|
|
|
|
|
|
|
2016-09-09 06:57:29 -05:00
|
|
|
std::ifstream file( "FOO.UNRST", std::ios::binary );
|
|
|
|
std::streampos file_size = 0;
|
|
|
|
|
|
|
|
file_size = file.tellg();
|
|
|
|
file.seekg( 0, std::ios::end );
|
|
|
|
file_size = file.tellg() - file_size;
|
|
|
|
|
|
|
|
return file_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* write the file and calculate the file size. FOO.UNRST should be
|
|
|
|
* overwitten for every time step, i.e. the file size should not change
|
|
|
|
* between runs. This is to verify that UNRST files are properly
|
|
|
|
* overwritten, which they used not to.
|
|
|
|
*
|
|
|
|
* * https://github.com/OPM/opm-simulators/issues/753
|
|
|
|
* * https://github.com/OPM/opm-output/pull/61
|
|
|
|
*/
|
2018-09-13 10:25:33 -05:00
|
|
|
|
|
|
|
test_work_area_type * work_area = test_work_area_alloc("test_ecl_writer");
|
2016-09-09 06:57:29 -05:00
|
|
|
const auto file_size = write_and_check();
|
|
|
|
|
|
|
|
for( int i = 0; i < 3; ++i )
|
|
|
|
BOOST_CHECK_EQUAL( file_size, write_and_check() );
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check that "restarting" and writing over previous timesteps does not
|
|
|
|
* change the file size, if the total amount of steps are the same
|
|
|
|
*/
|
|
|
|
BOOST_CHECK_EQUAL( file_size, write_and_check( 3, 5 ) );
|
|
|
|
|
|
|
|
/* verify that adding steps from restart also increases file size */
|
|
|
|
BOOST_CHECK( file_size < write_and_check( 3, 7 ) );
|
|
|
|
|
|
|
|
/*
|
|
|
|
* verify that restarting a simulation, then writing fewer steps truncates
|
|
|
|
* the file
|
|
|
|
*/
|
|
|
|
BOOST_CHECK_EQUAL( file_size, write_and_check( 3, 5 ) );
|
2018-09-13 10:25:33 -05:00
|
|
|
test_work_area_free(work_area);
|
2016-03-29 07:45:48 -05:00
|
|
|
}
|
2016-09-25 11:31:34 -05:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(OPM_XWEL) {
|
|
|
|
}
|