Merge pull request #2690 from joakim-hove/readonly-testing

Readonly testing
This commit is contained in:
Joakim Hove 2021-09-17 12:05:32 +02:00 committed by GitHub
commit 0355a71abd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 2000 additions and 2043 deletions

View File

@ -64,6 +64,11 @@ namespace {
Opm::filesystem::remove_all(this->root_);
}
std::string org_path(const std::string& fname) {
return Opm::filesystem::canonical( this->orig_ / fname );
}
private:
Opm::filesystem::path root_;
Opm::filesystem::path area_;

View File

@ -51,9 +51,11 @@
#include <opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/io/eclipse/EclFile.hpp>
#include "tests/WorkArea.cpp"
BOOST_AUTO_TEST_CASE(CreateMissingDIMENS_throws) {
Opm::Deck deck;
Opm::Parser parser;
@ -1838,123 +1840,115 @@ BOOST_AUTO_TEST_CASE(SAVE_FIELD_UNITS) {
Opm::NNC nnc(grid1, deck);
bool formatted = false;
{
WorkArea work;
time_t timer;
time(&timer);
time_t timer;
time(&timer);
std::string cwd = Opm::filesystem::current_path().c_str();
std::string testDir = cwd + "/tmp_dir_" + std::to_string(timer);
std::string fileName = "TMP.EGRID";
grid1.save(fileName, formatted, nnc.input(), units);
if ( Opm::filesystem::exists( testDir )) {
Opm::filesystem::remove_all(testDir);
Opm::EclIO::EclFile file1(fileName);
// Values getZCORNed from the grid needs to be converted from SI to Field units
// and then converted from double to single precissions before comparing with values saved to
// the EGRID file
// check coord
const std::vector<float> coord_egrid = file1.get<float>("COORD");
std::vector<double> coord_input_si = grid1.getCOORD();
BOOST_CHECK(coord_egrid.size() == coord_input_si.size());
std::vector<float> coord_input_f;
coord_input_f.reserve(coord_input_si.size());
for (size_t n = 0; n < coord_egrid.size(); n++) {
coord_input_f.push_back(static_cast<float>(units.from_si(length, coord_input_si[n])));
BOOST_CHECK_CLOSE(coord_input_f[n], coord_egrid[n], 1e-6);
}
// check zcorn
const std::vector<float> zcorn_egrid = file1.get<float>("ZCORN");
std::vector<double> zcorn_input_si = grid1.getZCORN();
BOOST_CHECK(zcorn_egrid.size() == zcorn_input_si.size());
std::vector<float> zcorn_input_f;
zcorn_input_f.reserve(zcorn_input_si.size());
for (size_t n = 0; n < zcorn_egrid.size(); n++) {
zcorn_input_f.push_back(static_cast<float>(units.from_si(length, zcorn_input_si[n])));
BOOST_CHECK_CLOSE(zcorn_input_f[n], zcorn_egrid[n], 1e-6);
}
BOOST_CHECK(file1.hasKey("GRIDUNIT"));
const std::vector<std::string> gridunits = file1.get<std::string>("GRIDUNIT");
BOOST_CHECK(gridunits[0] == "FEET");
// input deck do not hold MAPAXES or MAPUNITS entries. Below keywords should not be written to EGRID file
BOOST_CHECK(!file1.hasKey("MAPAXES"));
BOOST_CHECK(!file1.hasKey("MAPUNITS"));
// this deck do not have any nnc. Below keywords should not be written to EGRID file
BOOST_CHECK(!file1.hasKey("NNCHEAD"));
BOOST_CHECK(!file1.hasKey("NNC1"));
BOOST_CHECK(!file1.hasKey("NNC2"));
// testing deck in field units and MAPUNITS in METRES
auto deck2 = parser.parseString(deckData2);
Opm::EclipseState es2(deck2);
Opm::UnitSystem units2 = es.getDeckUnitSystem();
const auto& grid2 = es2.getInputGrid();
Opm::NNC nnc2(grid2, deck2);
std::string fileName2 = "TMP2.FEGRID";
grid2.save(fileName2, true, nnc2.input(), units);
Opm::EclIO::EclFile file2(fileName2);
const std::vector<std::string>& test_mapunits2 = file2.get<std::string>("MAPUNITS");
BOOST_CHECK(test_mapunits2[0] == "METRES");
const std::vector<float>& test_mapaxes2 = file2.get<float>("MAPAXES");
BOOST_CHECK(test_mapaxes2.size() == ref2_mapaxes.size());
for (size_t n = 0; n < ref2_mapaxes.size(); n++) {
BOOST_CHECK_EQUAL(ref2_mapaxes[n], test_mapaxes2[n]);
}
// testing deck in field units and MAPUNITS in FEET
auto deck3 = parser.parseString(deckData3);
Opm::EclipseState es3(deck3);
Opm::UnitSystem units3 = es.getDeckUnitSystem();
const auto& grid3 = es3.getInputGrid();
Opm::NNC nnc3(grid3, deck3);
std::string fileName3 = "TMP3.FEGRID";
grid3.save(fileName3, true, nnc3.input(), units3);
Opm::EclIO::EclFile file3(fileName3);
const std::vector<std::string>& test_mapunits3 = file3.get<std::string>("MAPUNITS");
BOOST_CHECK(test_mapunits3[0] == "FEET");
const std::vector<float>& test_mapaxes3 = file3.get<float>("MAPAXES");
BOOST_CHECK(test_mapaxes3.size() == ref3_mapaxes.size());
for (size_t n = 0; n < ref3_mapaxes.size(); n++) {
BOOST_CHECK(ref3_mapaxes[n] == test_mapaxes3[n]);
}
}
Opm::filesystem::create_directory(testDir);
std::string fileName = testDir + "/" + "TMP.EGRID";
grid1.save(fileName, formatted, nnc.input(), units);
Opm::EclIO::EclFile file1(fileName);
// Values getZCORNed from the grid needs to be converted from SI to Field units
// and then converted from double to single precissions before comparing with values saved to
// the EGRID file
// check coord
const std::vector<float> coord_egrid = file1.get<float>("COORD");
std::vector<double> coord_input_si = grid1.getCOORD();
BOOST_CHECK( coord_egrid.size() == coord_input_si.size());
std::vector<float> coord_input_f;
coord_input_f.reserve(coord_input_si.size());
for (size_t n =0; n< coord_egrid.size(); n++) {
coord_input_f.push_back( static_cast<float>(units.from_si(length, coord_input_si[n])));
BOOST_CHECK_CLOSE( coord_input_f[n] , coord_egrid[n], 1e-6 );
}
// check zcorn
const std::vector<float> zcorn_egrid = file1.get<float>("ZCORN");
std::vector<double> zcorn_input_si = grid1.getZCORN();
BOOST_CHECK( zcorn_egrid.size() == zcorn_input_si.size());
std::vector<float> zcorn_input_f;
zcorn_input_f.reserve(zcorn_input_si.size());
for (size_t n =0; n< zcorn_egrid.size(); n++) {
zcorn_input_f.push_back( static_cast<float>(units.from_si(length, zcorn_input_si[n])));
BOOST_CHECK_CLOSE( zcorn_input_f[n] , zcorn_egrid[n], 1e-6 );
}
BOOST_CHECK( file1.hasKey("GRIDUNIT"));
const std::vector<std::string> gridunits = file1.get<std::string>("GRIDUNIT");
BOOST_CHECK( gridunits[0]=="FEET");
// input deck do not hold MAPAXES or MAPUNITS entries. Below keywords should not be written to EGRID file
BOOST_CHECK( !file1.hasKey("MAPAXES"));
BOOST_CHECK( !file1.hasKey("MAPUNITS"));
// this deck do not have any nnc. Below keywords should not be written to EGRID file
BOOST_CHECK( !file1.hasKey("NNCHEAD"));
BOOST_CHECK( !file1.hasKey("NNC1"));
BOOST_CHECK( !file1.hasKey("NNC2"));
// testing deck in field units and MAPUNITS in METRES
auto deck2 = parser.parseString( deckData2) ;
Opm::EclipseState es2(deck2);
Opm::UnitSystem units2 = es.getDeckUnitSystem();
const auto& grid2 = es2.getInputGrid();
Opm::NNC nnc2(grid2, deck2 );
std::string fileName2 = testDir + "/" + "TMP2.FEGRID";
grid2.save(fileName2, true, nnc2.input(), units);
Opm::EclIO::EclFile file2(fileName2);
const std::vector<std::string>& test_mapunits2 = file2.get<std::string>("MAPUNITS");
BOOST_CHECK( test_mapunits2[0] == "METRES");
const std::vector<float>& test_mapaxes2 = file2.get<float>("MAPAXES");
BOOST_CHECK( test_mapaxes2.size() == ref2_mapaxes.size());
for (size_t n =0; n< ref2_mapaxes.size(); n++) {
BOOST_CHECK_EQUAL( ref2_mapaxes[n], test_mapaxes2[n]);
}
// testing deck in field units and MAPUNITS in FEET
auto deck3 = parser.parseString( deckData3) ;
Opm::EclipseState es3(deck3);
Opm::UnitSystem units3 = es.getDeckUnitSystem();
const auto& grid3 = es3.getInputGrid();
Opm::NNC nnc3(grid3, deck3);
std::string fileName3 = testDir + "/" + "TMP3.FEGRID";
grid3.save(fileName3, true, nnc3.input(), units3);
Opm::EclIO::EclFile file3(fileName3);
const std::vector<std::string>& test_mapunits3 = file3.get<std::string>("MAPUNITS");
BOOST_CHECK( test_mapunits3[0] == "FEET");
const std::vector<float>& test_mapaxes3 = file3.get<float>("MAPAXES");
BOOST_CHECK( test_mapaxes3.size() == ref3_mapaxes.size());
for (size_t n =0; n< ref3_mapaxes.size(); n++) {
BOOST_CHECK( ref3_mapaxes[n] == test_mapaxes3[n]);
}
Opm::filesystem::remove_all(testDir);
}
BOOST_AUTO_TEST_CASE(SAVE_METRIC_UNITS) {
@ -2035,119 +2029,110 @@ BOOST_AUTO_TEST_CASE(SAVE_METRIC_UNITS) {
time_t timer;
time(&timer);
std::string cwd = Opm::filesystem::current_path().c_str();
std::string testDir = cwd + "/tmp_dir_" + std::to_string(timer);
{
WorkArea work;
std::string fileName = "TMP.FEGRID";
grid1.save(fileName, formatted, nnc.input(), units1);
if ( Opm::filesystem::exists( testDir )) {
Opm::filesystem::remove_all(testDir);
Opm::EclIO::EclFile file1(fileName);
// Values getZCORNed from the grid have same units as input deck (metric), however these needs to be
// converted from double to single precissions before comparing with values saved to the EGRID file
// check coord
const std::vector<float> coord_egrid = file1.get<float>("COORD");
std::vector<double> coord_input_si = grid1.getCOORD();
BOOST_CHECK(coord_egrid.size() == coord_input_si.size());
std::vector<float> coord_input_f;
coord_input_f.reserve(coord_input_si.size());
for (size_t n = 0; n < coord_egrid.size(); n++) {
coord_input_f.push_back(static_cast<float>(units1.from_si(length, coord_input_si[n])));
BOOST_CHECK_CLOSE(coord_input_f[n], coord_egrid[n], 1e-6);
}
// check zcorn
const std::vector<float> zcorn_egrid = file1.get<float>("ZCORN");
std::vector<double> zcorn_input_si = grid1.getZCORN();
BOOST_CHECK(zcorn_egrid.size() == zcorn_input_si.size());
std::vector<float> zcorn_input_f;
zcorn_input_f.reserve(zcorn_input_si.size());
for (size_t n = 0; n < zcorn_egrid.size(); n++) {
zcorn_input_f.push_back(static_cast<float>(units1.from_si(length, zcorn_input_si[n])));
BOOST_CHECK_CLOSE(zcorn_input_f[n], zcorn_egrid[n], 1e-6);
}
BOOST_CHECK(file1.hasKey("GRIDUNIT"));
const std::vector<std::string> gridunits = file1.get<std::string>("GRIDUNIT");
BOOST_CHECK(gridunits[0] == "METRES");
BOOST_CHECK(file1.hasKey("MAPAXES"));
std::vector<float> mapaxes = file1.get<float>("MAPAXES");
for (size_t n = 0; n < 6; n++) {
BOOST_CHECK_CLOSE(mapaxes[n], ref_mapaxes1[n], 1e-6);
}
BOOST_CHECK(file1.hasKey("MAPUNITS"));
const std::vector<std::string> mapunits = file1.get<std::string>("MAPUNITS");
BOOST_CHECK(gridunits[0] == "METRES");
BOOST_CHECK(file1.hasKey("NNCHEAD"));
const std::vector<int> nnchead = file1.get<int>("NNCHEAD");
BOOST_CHECK(nnchead[0] == static_cast<int>(nnc.input().size()));
std::vector<int> ref_nnc1 = {6, 7, 8};
std::vector<int> ref_nnc2 = {26, 27, 28};
BOOST_CHECK(file1.hasKey("NNC1"));
BOOST_CHECK(file1.hasKey("NNC2"));
const std::vector<int> nnc1 = file1.get<int>("NNC1");
const std::vector<int> nnc2 = file1.get<int>("NNC2");
BOOST_CHECK(nnc1.size() == nnc2.size());
for (size_t n = 0; n < nnc1.size(); n++) {
BOOST_CHECK(nnc1[n] == ref_nnc1[n]);
}
for (size_t n = 0; n < nnc2.size(); n++) {
BOOST_CHECK(nnc2[n] == ref_nnc2[n]);
}
// testing deck in metric units with mapaxes in field units
auto deck2 = parser.parseString(deckData2);
Opm::EclipseState es2(deck2);
Opm::UnitSystem units2 = es2.getDeckUnitSystem();
const auto& grid2 = es2.getInputGrid();
// Opm::NNC nnc( deck2 );
std::string fileName2 = "TMP2.FEGRID";
grid2.save(fileName2, true, nnc.input(), units2);
Opm::EclIO::EclFile file2(fileName2);
const std::vector<std::string>& test_mapunits2 = file2.get<std::string>("MAPUNITS");
BOOST_CHECK(test_mapunits2[0] == "FEET");
const std::vector<float>& test_mapaxes2 = file2.get<float>("MAPAXES");
BOOST_CHECK(test_mapaxes2.size() == ref_mapaxes2.size());
for (size_t n = 0; n < ref_mapaxes2.size(); n++) {
BOOST_CHECK(ref_mapaxes2[n] == test_mapaxes2[n]);
}
}
Opm::filesystem::create_directory(testDir);
std::string fileName = testDir + "/" + "TMP.FEGRID";
grid1.save(fileName, formatted, nnc.input(), units1);
Opm::EclIO::EclFile file1(fileName);
// Values getZCORNed from the grid have same units as input deck (metric), however these needs to be
// converted from double to single precissions before comparing with values saved to the EGRID file
// check coord
const std::vector<float> coord_egrid = file1.get<float>("COORD");
std::vector<double> coord_input_si = grid1.getCOORD();
BOOST_CHECK( coord_egrid.size() == coord_input_si.size());
std::vector<float> coord_input_f;
coord_input_f.reserve(coord_input_si.size());
for (size_t n =0; n< coord_egrid.size(); n++) {
coord_input_f.push_back( static_cast<float>(units1.from_si(length, coord_input_si[n])));
BOOST_CHECK_CLOSE( coord_input_f[n] , coord_egrid[n], 1e-6 );
}
// check zcorn
const std::vector<float> zcorn_egrid = file1.get<float>("ZCORN");
std::vector<double> zcorn_input_si = grid1.getZCORN();
BOOST_CHECK( zcorn_egrid.size() == zcorn_input_si.size());
std::vector<float> zcorn_input_f;
zcorn_input_f.reserve(zcorn_input_si.size());
for (size_t n =0; n< zcorn_egrid.size(); n++) {
zcorn_input_f.push_back( static_cast<float>(units1.from_si(length, zcorn_input_si[n])));
BOOST_CHECK_CLOSE( zcorn_input_f[n] , zcorn_egrid[n], 1e-6 );
}
BOOST_CHECK( file1.hasKey("GRIDUNIT"));
const std::vector<std::string> gridunits = file1.get<std::string>("GRIDUNIT");
BOOST_CHECK( gridunits[0]=="METRES");
BOOST_CHECK( file1.hasKey("MAPAXES"));
std::vector<float> mapaxes = file1.get<float>("MAPAXES");
for (size_t n = 0; n < 6; n++) {
BOOST_CHECK_CLOSE( mapaxes[n] , ref_mapaxes1[n], 1e-6 );
}
BOOST_CHECK( file1.hasKey("MAPUNITS"));
const std::vector<std::string> mapunits = file1.get<std::string>("MAPUNITS");
BOOST_CHECK( gridunits[0]=="METRES");
BOOST_CHECK( file1.hasKey("NNCHEAD"));
const std::vector<int> nnchead = file1.get<int>("NNCHEAD");
BOOST_CHECK( nnchead[0] == static_cast<int>(nnc.input().size()) );
std::vector<int> ref_nnc1 = { 6, 7, 8 };
std::vector<int> ref_nnc2 = { 26, 27, 28 };
BOOST_CHECK( file1.hasKey("NNC1"));
BOOST_CHECK( file1.hasKey("NNC2"));
const std::vector<int> nnc1 = file1.get<int>("NNC1");
const std::vector<int> nnc2 = file1.get<int>("NNC2");
BOOST_CHECK( nnc1.size() == nnc2.size() );
for (size_t n =0; n< nnc1.size(); n++) {
BOOST_CHECK( nnc1[n] == ref_nnc1[n] );
}
for (size_t n =0; n< nnc2.size(); n++) {
BOOST_CHECK( nnc2[n] == ref_nnc2[n] );
}
// testing deck in metric units with mapaxes in field units
auto deck2 = parser.parseString( deckData2) ;
Opm::EclipseState es2(deck2);
Opm::UnitSystem units2 = es2.getDeckUnitSystem();
const auto& grid2 = es2.getInputGrid();
//Opm::NNC nnc( deck2 );
std::string fileName2 = testDir + "/" + "TMP2.FEGRID";
grid2.save(fileName2, true, nnc.input(), units2);
Opm::EclIO::EclFile file2(fileName2);
const std::vector<std::string>& test_mapunits2 = file2.get<std::string>("MAPUNITS");
BOOST_CHECK( test_mapunits2[0] == "FEET");
const std::vector<float>& test_mapaxes2 = file2.get<float>("MAPAXES");
BOOST_CHECK( test_mapaxes2.size() == ref_mapaxes2.size());
for (size_t n =0; n< ref_mapaxes2.size(); n++) {
BOOST_CHECK( ref_mapaxes2[n] == test_mapaxes2[n]);
}
Opm::filesystem::remove_all(testDir);
}
BOOST_AUTO_TEST_CASE(CalcCellDims) {
@ -2775,106 +2760,107 @@ BOOST_AUTO_TEST_CASE(TEST_GDFILE_2) {
const auto& grid1a = es1a.getInputGrid();
Opm::NNC nnc(grid1a, deck1a);
{
WorkArea work;
grid1a.save("BAD_CP_M.EGRID", false, nnc.input(), units1a);
grid1a.save("BAD_CP_M.EGRID", false, nnc.input(), units1a);
auto deck1b = parser.parseString(deckData1b);
Opm::EclipseState es1b(deck1b);
Opm::UnitSystem units1b = es1b.getDeckUnitSystem();
const auto& grid1b = es1b.getInputGrid();
auto deck1b = parser.parseString( deckData1b) ;
Opm::EclipseState es1b( deck1b );
Opm::UnitSystem units1b = es1b.getDeckUnitSystem();
const auto& grid1b = es1b.getInputGrid();
grid1b.save("BAD_CP_F.EGRID", false, nnc.input(), units1b);
grid1b.save("BAD_CP_F.EGRID", false, nnc.input(), units1b);
auto deck1 = parser.parseString(deckData1);
Opm::EclipseGrid grid1(deck1);
auto deck1 = parser.parseString( deckData1) ;
Opm::EclipseGrid grid1( deck1);
Opm::EclIO::EclFile file1("BAD_CP_M.EGRID");
Opm::EclIO::EclFile file1("BAD_CP_M.EGRID");
// actnum not defined in deck. keyword GDFILE not present in the DECK
// check that coord and zcorn from deck-grid identical to coord and zcorn
// from egrid - grid
// actnum not defined in deck. keyword GDFILE not present in the DECK
// check that coord and zcorn from deck-grid identical to coord and zcorn
// from egrid - grid
std::vector<double> coordGrid1 = grid1.getCOORD();
std::vector<double> zcornGrid1 = grid1.getZCORN();
std::vector<float> coordGrid1_f(coordGrid1.begin(), coordGrid1.end());
std::vector<float> zcornGrid1_f(zcornGrid1.begin(), zcornGrid1.end());
std::vector<double> coordGrid1 = grid1.getCOORD();
std::vector<double> zcornGrid1 = grid1.getZCORN();
std::vector<float> coordGrid1_f(coordGrid1.begin(), coordGrid1.end() );
std::vector<float> zcornGrid1_f(zcornGrid1.begin(), zcornGrid1.end() );
const std::vector<float> coord_egrid_f = file1.get<float>("COORD");
const std::vector<float> zcorn_egrid_f = file1.get<float>("ZCORN");
const std::vector<float> coord_egrid_f = file1.get<float>("COORD");
const std::vector<float> zcorn_egrid_f = file1.get<float>("ZCORN");
BOOST_CHECK(coordGrid1.size() == coord_egrid_f.size());
BOOST_CHECK(zcornGrid1.size() == zcorn_egrid_f.size());
BOOST_CHECK( coordGrid1.size() == coord_egrid_f.size() );
BOOST_CHECK( zcornGrid1.size() == zcorn_egrid_f.size() );
for (size_t n = 0; n < coordGrid1.size(); n++) {
BOOST_CHECK(coordGrid1_f[n] == coord_egrid_f[n]);
}
for (size_t n = 0; n < coordGrid1.size(); n++){
BOOST_CHECK( coordGrid1_f[n] == coord_egrid_f[n] );
for (size_t n = 0; n < zcornGrid1.size(); n++) {
BOOST_CHECK(zcornGrid1_f[n] == zcorn_egrid_f[n]);
}
// all cells are active, since ACTNUM not present
std::vector<int> actGrid1 = grid1.getACTNUM();
for (size_t n = 0; n < actGrid1.size(); n++) {
BOOST_CHECK(actGrid1[n] == 1);
}
auto deck2 = parser.parseString(deckData2);
Opm::EclipseGrid grid2(deck2);
std::vector<int> actGrid2 = grid2.getACTNUM();
// check that actnum is reset from gdfile
for (size_t n = 0; n < actGrid2.size(); n++) {
BOOST_CHECK(actGrid2[n] == ref_act_egrid[n]);
}
auto deck3a = parser.parseString(deckData3a);
Opm::EclipseGrid grid3a(deck3a);
// mapunits and mapaxes define in deck (only)
std::vector<int> actGrid3 = grid3a.getACTNUM();
// check that actnum is reset from gdfile, ACTNUM input in deck
// but before keyword GDFILE
for (size_t n = 0; n < actGrid3.size(); n++) {
BOOST_CHECK(actGrid3[n] == ref_act_egrid[n]);
}
// check that depth values are in SI units
for (size_t n = 0; n < refDepthGrid3a.size(); n++) {
BOOST_CHECK_CLOSE(grid3a.getCellDepth(n), refDepthGrid3a[n], 1e-3);
}
auto deck3b = parser.parseString(deckData3b);
Opm::EclipseGrid grid3b(deck3b);
// mapunits and mapaxes both in egrid and deck. Uses properties
// from the egrid keyword gdfile input after MAPUNITS and MAPAXES
actGrid3 = grid3b.getACTNUM();
// check that actnum is reset from deck since input after keyword GDFILE
for (size_t n = 0; n < actGrid3.size(); n++) {
BOOST_CHECK(actGrid3[n] == ref_act_deck3[n]);
}
// check that depth values are converted from Field to SI units
for (size_t n = 0; n < refDepthGrid3b.size(); n++) {
BOOST_CHECK_CLOSE(grid3b.getCellDepth(n), refDepthGrid3b[n], 1e-3);
}
// mapunits and mapaxes both in egrid and deck. Uses properties
// from the deck sinze these are input after GDfile
auto deck3c = parser.parseString(deckData3c);
Opm::EclipseGrid grid3c(deck3c);
}
for (size_t n = 0; n < zcornGrid1.size(); n++){
BOOST_CHECK( zcornGrid1_f[n] == zcorn_egrid_f[n] );
}
// all cells are active, since ACTNUM not present
std::vector<int> actGrid1 = grid1.getACTNUM();
for (size_t n = 0; n < actGrid1.size(); n++){
BOOST_CHECK( actGrid1[n] == 1 );
}
auto deck2 = parser.parseString( deckData2) ;
Opm::EclipseGrid grid2( deck2);
std::vector<int> actGrid2 = grid2.getACTNUM();
// check that actnum is reset from gdfile
for (size_t n = 0; n < actGrid2.size(); n++){
BOOST_CHECK( actGrid2[n] == ref_act_egrid[n] );
}
auto deck3a = parser.parseString( deckData3a) ;
Opm::EclipseGrid grid3a( deck3a);
// mapunits and mapaxes define in deck (only)
std::vector<int> actGrid3 = grid3a.getACTNUM();
// check that actnum is reset from gdfile, ACTNUM input in deck
// but before keyword GDFILE
for (size_t n = 0; n < actGrid3.size(); n++){
BOOST_CHECK( actGrid3[n] == ref_act_egrid[n] );
}
// check that depth values are in SI units
for (size_t n = 0; n < refDepthGrid3a.size(); n++){
BOOST_CHECK_CLOSE( grid3a.getCellDepth(n), refDepthGrid3a[n], 1e-3 );
}
auto deck3b = parser.parseString( deckData3b) ;
Opm::EclipseGrid grid3b( deck3b);
// mapunits and mapaxes both in egrid and deck. Uses properties
// from the egrid keyword gdfile input after MAPUNITS and MAPAXES
actGrid3 = grid3b.getACTNUM();
// check that actnum is reset from deck since input after keyword GDFILE
for (size_t n = 0; n < actGrid3.size(); n++){
BOOST_CHECK( actGrid3[n] == ref_act_deck3[n] );
}
// check that depth values are converted from Field to SI units
for (size_t n = 0; n < refDepthGrid3b.size(); n++){
BOOST_CHECK_CLOSE( grid3b.getCellDepth(n), refDepthGrid3b[n], 1e-3 );
}
// mapunits and mapaxes both in egrid and deck. Uses properties
// from the deck sinze these are input after GDfile
auto deck3c = parser.parseString( deckData3c) ;
Opm::EclipseGrid grid3c( deck3c);
}
BOOST_AUTO_TEST_CASE(TEST_COLLAPSED_CELL) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -35,6 +35,8 @@
#include <stdio.h>
#include <tuple>
#include "tests/WorkArea.cpp"
using namespace Opm::EclIO;
template<typename InputIterator1, typename InputIterator2>
@ -172,55 +174,55 @@ BOOST_AUTO_TEST_CASE(TestERft_1) {
BOOST_AUTO_TEST_CASE(TestERft_2) {
std::string testFile="SPE1CASE1.RFT";
std::string testFile = "SPE1CASE1.RFT";
std::string outFile="TEST.RFT";
std::string outFile = "TEST.RFT";
{
EclOutput eclTest(outFile, false);
WorkArea work;
work.copyIn(testFile);
{
EclOutput eclTest(outFile, false);
ERft rft1(testFile);
ERft rft1(testFile);
auto rftList = rft1.listOfRftReports();
auto rftList = rft1.listOfRftReports();
for (auto& rft : rftList) {
std::string wellName = std::get<0>(rft);
auto date = std::get<1>(rft);
for (auto& rft : rftList) {
std::string wellName = std::get<0>(rft);
auto date = std::get<1>(rft);
auto arrayList = rft1.listOfRftArrays(wellName, date);
auto arrayList = rft1.listOfRftArrays(wellName, date);
for (auto& array : arrayList) {
std::string arrName = std::get<0>(array);
eclArrType arrType = std::get<1>(array);
for (auto& array : arrayList) {
std::string arrName = std::get<0>(array);
eclArrType arrType = std::get<1>(array);
if (arrType == INTE) {
std::vector<int> vect = rft1.getRft<int>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == REAL) {
std::vector<float> vect = rft1.getRft<float>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == DOUB) {
std::vector<double> vect = rft1.getRft<double>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == LOGI) {
std::vector<bool> vect = rft1.getRft<bool>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == CHAR) {
std::vector<std::string> vect = rft1.getRft<std::string>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == MESS) {
eclTest.write(arrName, std::vector<char>());
} else {
std::cout << "unknown type " << std::endl;
exit(1);
if (arrType == INTE) {
std::vector<int> vect = rft1.getRft<int>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == REAL) {
std::vector<float> vect = rft1.getRft<float>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == DOUB) {
std::vector<double> vect = rft1.getRft<double>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == LOGI) {
std::vector<bool> vect = rft1.getRft<bool>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == CHAR) {
std::vector<std::string> vect = rft1.getRft<std::string>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == MESS) {
eclTest.write(arrName, std::vector<char>());
} else {
std::cout << "unknown type " << std::endl;
exit(1);
}
}
}
}
BOOST_CHECK_EQUAL(compare_files(testFile, outFile), true);
}
BOOST_CHECK_EQUAL(compare_files(testFile, outFile), true);
if (remove(outFile.c_str())==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}

View File

@ -41,6 +41,8 @@
#include <opm/common/utility/FileSystem.hpp>
#include "tests/WorkArea.cpp"
using namespace Opm::EclIO;
template<typename InputIterator1, typename InputIterator2>
@ -221,8 +223,10 @@ BOOST_AUTO_TEST_CASE(TestERst_2) {
// using API for ERst to read all array from a binary unified restart file1
// Then write the data back to a new file and check that new file is identical with input file
ERst rst1(testFile);
WorkArea work;
work.copyIn(testFile);
ERst rst1(testFile);
{
EclOutput eclTest(outFile, false);
@ -230,7 +234,6 @@ BOOST_AUTO_TEST_CASE(TestERst_2) {
for (size_t i = 0; i < seqnums.size(); i++) {
rst1.loadReportStepNumber(seqnums[i]);
auto rstArrays = rst1.listOfRstArrays(seqnums[i]);
for (auto& array : rstArrays) {
@ -242,10 +245,6 @@ BOOST_AUTO_TEST_CASE(TestERst_2) {
}
BOOST_CHECK_EQUAL(compare_files(testFile, outFile), true);
if (remove(outFile.c_str()) == -1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}
@ -257,28 +256,26 @@ BOOST_AUTO_TEST_CASE(TestERst_3) {
// using API for ERst to read all array from a formatted unified restart file1
// Then write the data back to a new file and check that new file is identical with input file
WorkArea work;
work.copyIn(testFile);
ERst rst1(testFile);
{
EclOutput eclTest(outFile, true);
EclOutput eclTest(outFile, true);
std::vector<int> seqnums = rst1.listOfReportStepNumbers();
for (unsigned int i = 0; i < seqnums.size(); i++) {
rst1.loadReportStepNumber(seqnums[i]);
std::vector<int> seqnums = rst1.listOfReportStepNumbers();
for (unsigned int i=0; i<seqnums.size(); i++) {
rst1.loadReportStepNumber(seqnums[i]);
auto rstArrays = rst1.listOfRstArrays(seqnums[i]);
auto rstArrays = rst1.listOfRstArrays(seqnums[i]);
for (auto& array : rstArrays) {
std::string name = std::get<0>(array);
eclArrType arrType = std::get<1>(array);
readAndWrite(eclTest, rst1, name, seqnums[i], arrType);
for (auto& array : rstArrays) {
std::string name = std::get<0>(array);
eclArrType arrType = std::get<1>(array);
readAndWrite(eclTest, rst1, name, seqnums[i], arrType);
}
}
}
BOOST_CHECK_EQUAL(compare_files(testFile, outFile), true);
if (remove(outFile.c_str() )== -1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}

View File

@ -35,6 +35,7 @@
#include <math.h>
#include <stdio.h>
#include <tuple>
#include "tests/WorkArea.cpp"
using Opm::EclIO::ESmry;
@ -401,11 +402,14 @@ BOOST_AUTO_TEST_CASE(TestCreateRSM) {
ESmry smry1("SPE1CASE1.SMSPEC");
smry1.LoadData();
smry1.write_rsm_file();
BOOST_CHECK(fs::exists("SPE1CASE1.RSM"));
{
WorkArea work;
smry1.write_rsm_file();
BOOST_CHECK(fs::exists("SPE1CASE1.RSM"));
smry1.write_rsm_file("TEST.RSM");
BOOST_CHECK(fs::exists("TEST.RSM"));
smry1.write_rsm_file("TEST.RSM");
BOOST_CHECK(fs::exists("TEST.RSM"));
}
}
BOOST_AUTO_TEST_CASE(TestUnits) {
@ -430,6 +434,7 @@ BOOST_AUTO_TEST_CASE(Test_all_available) {
std::vector<int> nums (8, 0);
WorkArea work;
{
Opm::EclIO::EclOutput smspec1("TMP1.SMSPEC", false);
smspec1.write<int>("INTEHEAD", {1,100});
@ -489,13 +494,6 @@ BOOST_AUTO_TEST_CASE(Test_all_available) {
Opm::EclIO::ESmry smry2("TMP1.SMSPEC");
BOOST_CHECK_EQUAL( smry2.all_steps_available(), false);
if (Opm::filesystem::exists("TMP1.SMSPEC"))
Opm::filesystem::remove("TMP1.SMSPEC");
if (Opm::filesystem::exists("TMP1.UNSMRY"))
Opm::filesystem::remove("TMP1.UNSMRY");
}
BOOST_AUTO_TEST_CASE(Test_all_available_w_restart) {
@ -511,6 +509,7 @@ BOOST_AUTO_TEST_CASE(Test_all_available_w_restart) {
std::vector<int> nums (8, 0);
WorkArea work;
{
Opm::EclIO::EclOutput smspec1("BASE1.SMSPEC", false);
smspec1.write<int>("INTEHEAD", {1,100});
@ -648,18 +647,6 @@ BOOST_AUTO_TEST_CASE(Test_all_available_w_restart) {
Opm::EclIO::ESmry smry3("RST2.SMSPEC", true);
BOOST_CHECK_EQUAL( smry3.all_steps_available(), false);
if (Opm::filesystem::exists("BASE1.SMSPEC"))
Opm::filesystem::remove("BASE1.SMSPEC");
if (Opm::filesystem::exists("BASE1.UNSMRY"))
Opm::filesystem::remove("BASE1.UNSMRY");
if (Opm::filesystem::exists("RST2.SMSPEC"))
Opm::filesystem::remove("RST2.SMSPEC");
if (Opm::filesystem::exists("RST2.UNSMRY"))
Opm::filesystem::remove("RST2.UNSMRY");
}

View File

@ -89,6 +89,7 @@ void write_header(std::ofstream& ofileH, std::string& arrName, int size, std::st
BOOST_AUTO_TEST_CASE(TestEclFile_X231) {
WorkArea work;
std::string filename = "TEST.DAT";
std::string arrName = "TESTX231";
@ -100,17 +101,17 @@ BOOST_AUTO_TEST_CASE(TestEclFile_X231) {
std::ofstream ofileH;
ofileH.open(filename, std::ios_base::binary);
int size = static_cast<int>((-1) * std::pow(2,31) + 10);
int size = static_cast<int>((-1) * std::pow(2, 31) + 10);
write_header(ofileH, arrName, -1, std::string("X231"));
write_header(ofileH, arrName, size, std::string("INTE"));
int sizeData = ivect.size()*sizeof(int);
int sizeData = ivect.size() * sizeof(int);
sizeData = flipEndianInt(sizeData);
ofileH.write(reinterpret_cast<char*>(&sizeData), sizeof(sizeData));
for (auto v : ivect){
for (auto v : ivect) {
int fval = flipEndianInt(v);
ofileH.write(reinterpret_cast<char*>(&fval), sizeof(fval));
}
@ -122,7 +123,7 @@ BOOST_AUTO_TEST_CASE(TestEclFile_X231) {
EclFile test1(filename);
auto array = test1.get<int>(arrName);
for (size_t n = 0; n < 10; n++){
for (size_t n = 0; n < 10; n++) {
BOOST_CHECK_EQUAL(array[n], ivect[n]);
}
}
@ -283,6 +284,7 @@ BOOST_AUTO_TEST_CASE(TestEcl_Write_binary) {
// writing vectors to test file (TEST.DAT) using class EclOutput
WorkArea work;
{
EclOutput eclTest(testFile, false);
@ -292,13 +294,10 @@ BOOST_AUTO_TEST_CASE(TestEcl_Write_binary) {
eclTest.write("XCON",xcon);
eclTest.write("KEYWORDS",keywords);
eclTest.write("ENDSOL",std::vector<char>());
}
work.copyIn(inputFile);
BOOST_CHECK_EQUAL(compare_files(inputFile, testFile), true);
if (remove(testFile.c_str())==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}
BOOST_AUTO_TEST_CASE(TestEcl_Write_formatted) {
@ -319,20 +318,20 @@ BOOST_AUTO_TEST_CASE(TestEcl_Write_formatted) {
// writing vectors to test file (TEST.FDAT) using class EclOutput
EclOutput eclTest(testFile, true);
{
WorkArea work;
EclOutput eclTest(testFile, true);
eclTest.write("ICON",icon);
eclTest.write("LOGIHEAD",logihead);
eclTest.write("PORV",porv);
eclTest.write("XCON",xcon);
eclTest.write("KEYWORDS",keywords);
eclTest.write("ENDSOL",std::vector<char>());
eclTest.write("ICON",icon);
eclTest.write("LOGIHEAD",logihead);
eclTest.write("PORV",porv);
eclTest.write("XCON",xcon);
eclTest.write("KEYWORDS",keywords);
eclTest.write("ENDSOL",std::vector<char>());
BOOST_CHECK_EQUAL(compare_files(inputFile, testFile), true);
if (remove(testFile.c_str())==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
work.copyIn(inputFile);
BOOST_CHECK_EQUAL(compare_files(inputFile, testFile), true);
}
}
BOOST_AUTO_TEST_CASE(TestEcl_Write_formatted_not_finite) {
@ -372,6 +371,7 @@ BOOST_AUTO_TEST_CASE(TestEcl_getList) {
EclFile file1(inputFile);
file1.loadData();
WorkArea work;
{
EclOutput eclTest(testFile, false);
@ -407,16 +407,13 @@ BOOST_AUTO_TEST_CASE(TestEcl_getList) {
}
}
work.copyIn(inputFile);
BOOST_CHECK_EQUAL(compare_files(inputFile, testFile), true);
if (remove(testFile.c_str())==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}
BOOST_AUTO_TEST_CASE(TestEcl_Write_CHAR) {
WorkArea work;
std::string testFile1="TEST.FDAT";
std::string testFile2="TEST2.DAT";
@ -532,13 +529,4 @@ BOOST_AUTO_TEST_CASE(TestEcl_Write_CHAR) {
auto arrayList =file1.getList();
BOOST_CHECK(std::get<1>(arrayList[0]) == Opm::EclIO::C0NN);
}
if (remove(testFile1.c_str())==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
if (remove(testFile2.c_str())==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}

View File

@ -31,6 +31,7 @@
#include <opm/io/eclipse/EclOutput.hpp>
#include <iomanip>
#include "tests/WorkArea.cpp"
using Opm::EclIO::EGrid;
using Opm::EclIO::ESmry;
@ -318,6 +319,7 @@ BOOST_AUTO_TEST_CASE(gridCompare) {
std::vector<int> nnc1;
std::vector<int> nnc2;
std::vector<int> actnum;
WorkArea work;
//-------------------------------------------------------------
// base: identical grids
@ -432,17 +434,10 @@ BOOST_AUTO_TEST_CASE(gridCompare) {
test6.loadGrids();
BOOST_CHECK_THROW(test6.gridCompare(),std::runtime_error);
if (remove("TMP1.EGRID")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
if (remove("TMP2.EGRID")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}
BOOST_AUTO_TEST_CASE(results_init_1) {
WorkArea work;
std::vector<std::vector<int>> intData1;
std::vector<std::vector<float>> floatData1;
@ -520,14 +515,6 @@ BOOST_AUTO_TEST_CASE(results_init_1) {
BOOST_CHECK_THROW(test1a.results_init(),std::runtime_error);
if (remove("TMP1.INIT")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP2.INIT")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}
BOOST_AUTO_TEST_CASE(results_init_2) {
@ -548,6 +535,7 @@ BOOST_AUTO_TEST_CASE(results_init_2) {
std::vector<float> poro2(12,0.25);
std::vector<int> fipnum2(12,1);
WorkArea work;
// ---------------------------------------------------------------------------
// array PORV requires strict tolerances, 1e-6
@ -625,17 +613,10 @@ BOOST_AUTO_TEST_CASE(results_init_2) {
ECLRegressionTest test3("TMP1", "TMP2", 1e-3, 1e-3);
BOOST_CHECK_THROW(test3.results_init(),std::runtime_error);
if (remove("TMP1.INIT")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP2.INIT")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}
BOOST_AUTO_TEST_CASE(results_unrst_1) {
WorkArea work;
using Date = std::tuple<int, int, int>;
std::vector<int> seqnum1 = {0,1,4,7};
@ -760,17 +741,10 @@ BOOST_AUTO_TEST_CASE(results_unrst_1) {
// should fail
BOOST_CHECK_THROW(test2a.results_rst(),std::runtime_error);
if (remove("TMP1.UNRST")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP2.UNRST")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}
BOOST_AUTO_TEST_CASE(results_unrst_2) {
WorkArea work;
using Date = std::tuple<int, int, int>;
std::vector<int> seqnum1 = {0,1,4,7};
@ -857,17 +831,11 @@ BOOST_AUTO_TEST_CASE(results_unrst_2) {
test1.results_rst();
if (remove("TMP1.UNRST")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP2.UNRST")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}
BOOST_AUTO_TEST_CASE(results_unrst_3) {
WorkArea work;
using Date = std::tuple<int, int, int>;
std::vector<int> seqnum1 = {0,1,4,7};
@ -971,18 +939,11 @@ BOOST_AUTO_TEST_CASE(results_unrst_3) {
// should get deviations for two keywords
BOOST_CHECK_EQUAL(test2.countDev(),2);
if (remove("TMP1.UNRST")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP2.UNRST")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
};
}
BOOST_AUTO_TEST_CASE(results_unsmry_1) {
WorkArea work;
std::vector<std::string> keywords1 = {"TIME", "YEARS", "FOPR", "FOPT", "WOPR", "WOPR", "WBHP", "WBHP", "ROIP"};
std::vector<std::string> wgnames1 = {":+:+:+:+", ":+:+:+:+", "FIELD", "FIELD", "A-1H", "A-2H", "A-1H", "A-2H", ":+:+:+:+"};
std::vector<int> nums1 = {-32767, -32767, 0, 0, 1, 2, 1, 2, 1};
@ -1072,29 +1033,12 @@ BOOST_AUTO_TEST_CASE(results_unsmry_1) {
// should fail since not found in any of the cases
test2a.compareSpesificKeyword("XXXXX");
BOOST_CHECK_THROW(test2a.results_smry(),std::runtime_error);
if (remove("TMP1.SMSPEC")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP2.SMSPEC")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP1.UNSMRY")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP2.UNSMRY")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
}
BOOST_AUTO_TEST_CASE(results_unsmry_2) {
WorkArea work;
std::vector<std::string> keywords1 = {"TIME", "YEARS", "FOPR", "FOPT", "WOPR", "WOPR", "WBHP", "WBHP", "ROIP"};
std::vector<std::string> wgnames1 = {":+:+:+:+", ":+:+:+:+", "FIELD", "FIELD", "A-1H", "A-2H", "A-1H", "A-2H", ":+:+:+:+"};
std::vector<int> nums1 = {-32767, -32767, 0, 0, 1, 2, 1, 2, 1};
@ -1153,23 +1097,6 @@ BOOST_AUTO_TEST_CASE(results_unsmry_2) {
// should get deviations for two keywords
BOOST_CHECK_EQUAL(test2.countDev(),2);
if (remove("TMP1.SMSPEC")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP2.SMSPEC")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP1.UNSMRY")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP2.UNSMRY")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
}
@ -1189,6 +1116,7 @@ BOOST_AUTO_TEST_CASE(results_unsmry_3) {
BOOST_AUTO_TEST_CASE(results_rft_1) {
WorkArea work;
using Date = std::tuple<int, int, int>;
std::vector<float> time1 = {0.0, 40.0, 50.0};
@ -1321,22 +1249,10 @@ BOOST_AUTO_TEST_CASE(results_rft_1) {
ECLRegressionTest test2("TMP1", "TMP3", 1e-3, 1e-3);
BOOST_CHECK_THROW(test2.results_rft(),std::runtime_error);
if (remove("TMP1.RFT")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP2.RFT")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP3.RFT")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
}
BOOST_AUTO_TEST_CASE(results_rft_2) {
WorkArea work;
using Date = std::tuple<int, int, int>;
std::vector<float> time1 = {0.0, 40.0, 50.0};
@ -1436,14 +1352,5 @@ BOOST_AUTO_TEST_CASE(results_rft_2) {
// should get deviations for two keywords
BOOST_CHECK_EQUAL(test3.countDev(), 2);
if (remove("TMP1.RFT")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
if (remove("TMP2.RFT")==-1) {
std::cout << " > Warning! temporary file was not deleted" << std::endl;
}
}

View File

@ -37,6 +37,9 @@
#include <stdio.h>
#include <tuple>
#include "tests/WorkArea.cpp"
using Opm::EclIO::ESmry;
using Opm::EclIO::ExtESmry;
@ -150,9 +153,9 @@ std::vector<float> getFrom(const std::vector<float> &ref_vect,int from){
}
BOOST_AUTO_TEST_CASE(TestExtESmry_1) {
if (Opm::filesystem::exists("SPE1CASE1.ESMRY"))
Opm::filesystem::remove("SPE1CASE1.ESMRY");
WorkArea work;
work.copyIn("SPE1CASE1.SMSPEC");
work.copyIn("SPE1CASE1.UNSMRY");
ESmry smry1("SPE1CASE1.SMSPEC");
@ -212,10 +215,6 @@ BOOST_AUTO_TEST_CASE(TestExtESmry_1) {
ExtESmry esmry2("SPE1CASE1.ESMRY");
esmry2.loadData();
if (Opm::filesystem::exists("SPE1CASE1.ESMRY"))
Opm::filesystem::remove("SPE1CASE1.ESMRY");
}
BOOST_AUTO_TEST_CASE(TestExtESmry_2) {
@ -236,7 +235,7 @@ BOOST_AUTO_TEST_CASE(TestExtESmry_2) {
// this is what the summary file from the restart run would be if the restart was 100% perfect.
// changing summary keywords to make the file realistic.
WorkArea work;
std::vector <float> time_ref, wgpr_prod_ref, wbhp_prod_ref, wbhp_inj_ref, fgor_ref, bpr_111_ref, bpr_10103_ref;
getRefSmryVect(time_ref, wgpr_prod_ref, wbhp_prod_ref, wbhp_inj_ref,fgor_ref, bpr_111_ref, bpr_10103_ref);
@ -244,9 +243,9 @@ BOOST_AUTO_TEST_CASE(TestExtESmry_2) {
// defaulting second argument, loadBaseRunData. Only data from the restarted run
// will be loaded. No data from base run (SPE1CASE1 in this case)
if (Opm::filesystem::exists("SPE1CASE1.ESMRY"))
Opm::filesystem::remove("SPE1CASE1.ESMRY");
work.copyIn("SPE1CASE1.SMSPEC");
work.copyIn("SPE1CASE1.UNSMRY");
work.copyIn("SPE1CASE1_RST60.ESMRY");
ESmry smry1("SPE1CASE1.SMSPEC");
smry1.make_esmry_file();
@ -302,10 +301,6 @@ BOOST_AUTO_TEST_CASE(TestExtESmry_2) {
for (unsigned int i=0;i< smryVect.size();i++)
BOOST_REQUIRE_CLOSE (smryVect[i], ref_rst60[i], 0.01);
if (Opm::filesystem::exists("SPE1CASE1.ESMRY"))
Opm::filesystem::remove("SPE1CASE1.ESMRY");
}
BOOST_AUTO_TEST_CASE(TestESmry_3) {
@ -325,7 +320,10 @@ BOOST_AUTO_TEST_CASE(TestESmry_3) {
// this is what the summary file from the restart run would be if the restart was 100% perfect.
// changing summary keywords to make the file realistic.
WorkArea work;
work.copyIn("SPE1CASE1.SMSPEC");
work.copyIn("SPE1CASE1.UNSMRY");
work.copyIn("SPE1CASE1_RST60.ESMRY");
std::vector <float> time_ref, wgpr_prod_ref, wbhp_prod_ref, wbhp_inj_ref, fgor_ref, bpr_111_ref, bpr_10103_ref;
@ -334,8 +332,6 @@ BOOST_AUTO_TEST_CASE(TestESmry_3) {
// second argument, loadBaseRunData = true. Both data from restarted run and base run loaded
// vectors should be equal to reference vectors (from SPE1CASE1)
if (Opm::filesystem::exists("SPE1CASE1.ESMRY"))
Opm::filesystem::remove("SPE1CASE1.ESMRY");
ESmry smry1("SPE1CASE1.SMSPEC");
smry1.make_esmry_file();
@ -377,8 +373,5 @@ BOOST_AUTO_TEST_CASE(TestESmry_3) {
for (unsigned int i=0;i< smryVect.size();i++)
BOOST_REQUIRE_CLOSE (smryVect[i], bpr_10103_ref[i], 0.01);
if (Opm::filesystem::exists("SPE1CASE1.ESMRY"))
Opm::filesystem::remove("SPE1CASE1.ESMRY");
}

View File

@ -46,6 +46,7 @@
#include <tuple>
#include <stdio.h>
#include "tests/WorkArea.cpp"
void verifyWellState(const std::string& rst_filename, const Opm::Schedule& schedule) {
@ -197,7 +198,9 @@ void verifyWellState(const std::string& rst_filename, const Opm::Schedule& sched
BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) {
WorkArea work;
std::string eclipse_data_filename = "testblackoilstate3.DATA";
work.copyIn(eclipse_data_filename);
auto python = std::make_shared<Opm::Python>();
Opm::Parser parser;