1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
/*
Copyright 2014 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 <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#define NVERBOSE // Suppress own messages when throw()ing
#define BOOST_TEST_MODULE TEST_UG
#include <boost/test/unit_test.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 < 71
#include <boost/test/floating_point_comparison.hpp>
#else
#include <boost/test/tools/floating_point_comparison.hpp>
#endif
/* --- our own headers --- */
#include <algorithm>
#include <vector>
#include <opm/grid/UnstructuredGrid.h>
#include <opm/grid/cornerpoint_grid.h> /* compute_geometry */
#include <opm/grid/GridManager.hpp> /* compute_geometry */
#include <opm/grid/GridHelpers.hpp>
#include <opm/grid/cpgpreprocess/preprocess.h>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
using namespace std;
BOOST_AUTO_TEST_CASE(Equal) {
const std::string filename1 = "CORNERPOINT_ACTNUM.DATA";
const char *deck2Data =
"RUNSPEC\n"
"\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"
"PORO\n"
" 1000*0.15 /\n"
"EDIT\n"
"\n";
Opm::Parser parser;
Opm::Deck deck1 = parser.parseFile( filename1);
Opm::EclipseState es1(deck1);
Opm::Deck deck2 = parser.parseString( deck2Data);
Opm::EclipseState es2(deck2);
BOOST_CHECK( deck1.hasKeyword("ZCORN") );
BOOST_CHECK( deck1.hasKeyword("COORD") );
Opm::GridManager grid1(es1.getInputGrid());
Opm::GridManager grid2(es2.getInputGrid());
const UnstructuredGrid* cgrid1 = grid1.c_grid();
const UnstructuredGrid* cgrid2 = grid2.c_grid();
BOOST_CHECK( grid_equal( cgrid1 , cgrid1 ));
BOOST_CHECK( grid_equal( cgrid2 , cgrid2 ));
BOOST_CHECK( !grid_equal( cgrid1 , cgrid2 ));
}
// TODO This method might be obsolete after using EclipseState to generate grid
BOOST_AUTO_TEST_CASE(EqualEclipseGrid) {
const std::string filename = "CORNERPOINT_ACTNUM.DATA";
Opm::Parser parser;
Opm::Deck deck = parser.parseFile( filename);
Opm::EclipseState es(deck);
auto grid = es.getInputGrid();
Opm::GridManager gridM(es.getInputGrid());
const UnstructuredGrid* cgrid1 = gridM.c_grid();
struct UnstructuredGrid * cgrid2;
{
struct grdecl g;
const auto& dimens = deck["DIMENS"].back();
const auto& coord = deck["COORD"].back();
const auto& zcorn = deck["ZCORN"].back();
const auto& actnum = deck["ACTNUM"].back();
g.dims[0] = dimens.getRecord(0).getItem("NX").get< int >(0);
g.dims[1] = dimens.getRecord(0).getItem("NY").get< int >(0);
g.dims[2] = dimens.getRecord(0).getItem("NZ").get< int >(0);
g.coord = coord.getSIDoubleData().data();
g.zcorn = zcorn.getSIDoubleData().data();
g.actnum = actnum.getIntData().data();
cgrid2 = create_grid_cornerpoint(&g , 0.0);
if (!cgrid2)
throw std::runtime_error("Failed to construct grid.");
}
BOOST_CHECK( grid_equal( cgrid1 , cgrid2 ));
auto actnum = Opm::UgGridHelpers::createACTNUM(*cgrid1);
BOOST_CHECK_EQUAL( actnum.size(), 500 );
for (std::size_t i=0; i < 100; i++) {
BOOST_CHECK_EQUAL(actnum[i + 200], 1);
for (std::size_t j=0; j < 2; j++) {
BOOST_CHECK_EQUAL(actnum[i + j * 100], 0);
BOOST_CHECK_EQUAL(actnum[i + j * 100 + 300], 0);
}
}
destroy_grid( cgrid2 );
}
BOOST_AUTO_TEST_CASE(TOPS_Fully_Specified) {
const char *deck1Data =
"RUNSPEC\n"
"\n"
"DIMENS\n"
" 10 10 3 /\n"
"GRID\n"
"DX\n"
"300*1000 /\n"
"DY\n"
"300*1000 /\n"
"DZ\n"
"100*20 100*30 100*50 /\n"
"TOPS\n"
"100*8325 /\n"
"PORO\n"
" 300*0.15 /\n"
"EDIT\n"
"\n";
const char *deck2Data =
"RUNSPEC\n"
"\n"
"DIMENS\n"
" 10 10 3 /\n"
"GRID\n"
"DX\n"
"300*1000 /\n"
"DY\n"
"300*1000 /\n"
"DZ\n"
"100*20 100*30 100*50 /\n"
"TOPS\n"
"100*8325 100*8345 100*8375/\n"
"PORO\n"
" 300*0.15 /\n"
"EDIT\n"
"\n";
Opm::Parser parser;
const Opm::Deck& deck1 = parser.parseString(deck1Data);
const Opm::Deck& deck2 = parser.parseString(deck2Data);
Opm::EclipseState es1(deck1);
Opm::EclipseState es2(deck2);
Opm::GridManager gridM1(es1.getInputGrid());
Opm::GridManager gridM2(es2.getInputGrid());
const UnstructuredGrid* cgrid1 = gridM1.c_grid();
const UnstructuredGrid* cgrid2 = gridM2.c_grid();
BOOST_CHECK(grid_equal(cgrid1, cgrid2));
Opm::EclipseGrid grid = Opm::UgGridHelpers::createEclipseGrid( *cgrid1 , es1.getInputGrid( ) );
auto actnum = Opm::UgGridHelpers::createACTNUM(*cgrid1);
for (std::size_t g = 0; g < 300; g++)
BOOST_CHECK_EQUAL(actnum[g], 1);
}
|