Merge pull request #544 from osae/equil-init

Equil init
This commit is contained in:
Atgeirr Flø Rasmussen
2014-04-04 22:39:37 +02:00
16 changed files with 4137 additions and 0 deletions

38
tests/capillary.DATA Normal file
View File

@@ -0,0 +1,38 @@
WATER
OIL
GAS
TABDIMS
1 1 40 20 1 20 /
EQLDIMS
-- NTEQUL
1 /
PVDO
100 1.0 1.0
200 0.9 1.0
/
PVDG
100 0.010 0.1
200 0.005 0.2
/
SWOF
0.2 0 1 0.4
1 1 0 0.1
/
SGOF
0 0 1 0.2
0.8 1 0 0.5
/
DENSITY
700 1000 1
/
EQUIL
50 150 50 0.25 20 0.35 1* 1* 0
/

View File

@@ -0,0 +1,128 @@
NOECHO
RUNSPEC ======
WATER
OIL
GAS
TABDIMS
1 1 40 20 1 20 /
DIMENS
1 1 20
/
WELLDIMS
30 10 2 30 /
START
1 'JAN' 1990 /
NSTACK
25 /
EQLDIMS
-- NTEQUL
1 /
FMTOUT
FMTIN
GRID ======
DXV
1.0
/
DYV
1.0
/
DZV
20*5.0
/
PORO
20*0.2
/
PERMZ
20*1.0
/
PERMY
20*100.0
/
PERMX
20*100.0
/
BOX
1 1 1 1 1 1 /
TOPS
0.0
/
PROPS ======
PVDO
100 1.0 1.0
200 0.9 1.0
/
PVDG
100 0.010 0.1
200 0.005 0.2
/
SWOF
0.2 0 1 0.9
1 1 0 0.1
/
SGOF
0 0 1 0.2
0.8 1 0 0.5
/
PVTW
--RefPres Bw Comp Vw Cv
1. 1.0 4.0E-5 0.96 0.0 /
ROCK
--RefPres Comp
1. 5.0E-5 /
DENSITY
700 1000 1
/
SOLUTION ======
EQUIL
45 150 50 0.25 45 0.35 1* 1* 0
/
RPTSOL
'PRES' 'PGAS' 'PWAT' 'SOIL' 'SWAT' 'SGAS' 'RESTART=2' /
SUMMARY ======
RUNSUM
SEPARATE
SCHEDULE ======
RPTSCHED
'PRES' 'PGAS' 'PWAT' 'SOIL' 'SWAT' 'SGAS' 'RESTART=3' 'NEWTON=2' /
END

38
tests/deadfluids.DATA Normal file
View File

@@ -0,0 +1,38 @@
WATER
OIL
GAS
TABDIMS
1 1 40 20 1 20 /
EQLDIMS
-- NTEQUL
1 /
PVDO
100 1.0 1.0
200 0.5 1.0
/
PVDG
100 0.05 0.1
200 0.02 0.2
/
SWOF
0 0 1 0
1 1 0 0
/
SGOF
0 0 1 0
1 1 0 0
/
DENSITY
700 1000 10
/
EQUIL
5 150 5 0 2 0 1* 1* 0
/

131
tests/equil_livegas.DATA Normal file
View File

@@ -0,0 +1,131 @@
NOECHO
RUNSPEC ======
WATER
OIL
GAS
VAPOIL
TABDIMS
1 1 40 20 1 20 /
DIMENS
1 1 20
/
WELLDIMS
30 10 2 30 /
START
1 'JAN' 1990 /
NSTACK
25 /
EQLDIMS
-- NTEQUL
1 /
FMTOUT
FMTIN
GRID ======
DXV
1.0
/
DYV
1.0
/
DZV
20*5.0
/
PORO
20*0.2
/
PERMZ
20*1.0
/
PERMY
20*100.0
/
PERMX
20*100.0
/
BOX
1 1 1 1 1 1 /
TOPS
0.0
/
PROPS ======
PVDO
100 1.0 1.0
200 0.9 1.0
/
PVTG
-- Pg Rv Bg Vg
100 0.0001 0.010 0.1
0.0 0.0104 0.1 /
200 0.0004 0.005 0.2
0.0 0.0054 0.2 /
/
SWOF
0.2 0 1 0.9
1 1 0 0.1
/
SGOF
0 0 1 0.2
0.8 1 0 0.5
/
PVTW
--RefPres Bw Comp Vw Cv
1. 1.0 4.0E-5 0.96 0.0 /
ROCK
--RefPres Comp
1. 5.0E-5 /
DENSITY
700 1000 1
/
SOLUTION ======
EQUIL
45 150 50 0.25 45 0.35 1* 1* 0
/
RPTSOL
'PRES' 'PGAS' 'PWAT' 'SOIL' 'SWAT' 'SGAS' 'RS' 'RESTART=2' /
SUMMARY ======
RUNSUM
SEPARATE
SCHEDULE ======
RPTSCHED
'PRES' 'PGAS' 'PWAT' 'SOIL' 'SWAT' 'SGAS' 'RS' 'RESTART=3' 'NEWTON=2' /
END

140
tests/equil_liveoil.DATA Normal file
View File

@@ -0,0 +1,140 @@
NOECHO
RUNSPEC ======
WATER
OIL
GAS
DISGAS
TABDIMS
1 1 40 20 1 20 /
DIMENS
1 1 20
/
WELLDIMS
30 10 2 30 /
START
1 'JAN' 1990 /
NSTACK
25 /
EQLDIMS
-- NTEQUL
1 /
FMTOUT
FMTIN
GRID ======
DXV
1.0
/
DYV
1.0
/
DZV
20*5.0
/
PORO
20*0.2
/
PERMZ
20*1.0
/
PERMY
20*100.0
/
PERMX
20*100.0
/
BOX
1 1 1 1 1 1 /
TOPS
0.0
/
PROPS ======
PVTO
-- Rs Pbub Bo Vo
0 1. 1.0000 1.20 /
20 40. 1.0120 1.17 /
40 80. 1.0255 1.14 /
60 120. 1.0380 1.11 /
80 160. 1.0510 1.08 /
100 200. 1.0630 1.06 /
120 240. 1.0750 1.03 /
140 280. 1.0870 1.00 /
160 320. 1.0985 .98 /
180 360. 1.1100 .95 /
200 400. 1.1200 .94
500. 1.1189 .94 /
/
PVDG
100 0.010 0.1
200 0.005 0.2
/
SWOF
0.2 0 1 0.9
1 1 0 0.1
/
SGOF
0 0 1 0.2
0.8 1 0 0.5
/
PVTW
--RefPres Bw Comp Vw Cv
1. 1.0 4.0E-5 0.96 0.0 /
ROCK
--RefPres Comp
1. 5.0E-5 /
DENSITY
700 1000 1
/
SOLUTION ======
EQUIL
45 150 50 0.25 45 0.35 1* 1* 0
/
RPTSOL
'PRES' 'PGAS' 'PWAT' 'SOIL' 'SWAT' 'SGAS' 'RS' 'RESTART=2' /
SUMMARY ======
RUNSUM
SEPARATE
SCHEDULE ======
RPTSCHED
'PRES' 'PGAS' 'PWAT' 'SOIL' 'SWAT' 'SGAS' 'RS' 'RESTART=3' 'NEWTON=2' /
END

View File

@@ -0,0 +1,65 @@
WATER
OIL
GAS
DISGAS
DIMENS
1 1 20
/
DXV
1.0
/
DYV
1.0
/
DZV
20*5.0
/
TOPS
4*0.0
/
PVTO
-- Rs Pbub Bo Vo
0 1. 1.0000 1.20 /
100 40. 1.0120 1.17 /
200 80. 1.0255 1.14 /
300 120. 1.0380 1.11 /
400 160. 1.0510 1.08 /
500 200. 1.0630 1.06 /
600 240. 1.0750 1.03 /
700 280. 1.0870 1.00 /
800 320. 1.0985 .98 /
900 360. 1.1100 .95 /
1000 400. 1.1200 .94
500. 1.1189 .94 /
/
PVDG
100 0.010 0.1
200 0.005 0.2
/
SWOF
0.2 0 1 0.9
1 1 0 0.1
/
SGOF
0 0 1 0.2
0.8 1 0 0.5
/
DENSITY
700 1000 1
/
EQUIL
45 150 50 0.25 45 0.35
/

View File

@@ -0,0 +1,151 @@
NOECHO
RUNSPEC ======
WATER
OIL
GAS
DISGAS
VAPOIL
TABDIMS
1 1 40 20 1 20 /
DIMENS
1 1 20
/
WELLDIMS
30 10 2 30 /
START
1 'JAN' 1990 /
NSTACK
25 /
EQLDIMS
-- NTEQUL
1 /
FMTOUT
FMTIN
GRID ======
DXV
1.0
/
DYV
1.0
/
DZV
20*5.0
/
PORO
20*0.2
/
PERMZ
20*1.0
/
PERMY
20*100.0
/
PERMX
20*100.0
/
BOX
1 1 1 1 1 1 /
TOPS
0.0
/
PROPS ======
PVTO
-- Rs Pbub Bo Vo
0 1. 1.0000 1.20 /
20 40. 1.0120 1.17 /
40 80. 1.0255 1.14 /
60 120. 1.0380 1.11 /
80 160. 1.0510 1.08 /
100 200. 1.0630 1.06 /
120 240. 1.0750 1.03 /
140 280. 1.0870 1.00 /
160 320. 1.0985 .98 /
180 360. 1.1100 .95 /
200 400. 1.1200 .94
500. 1.1189 .94 /
/
PVTG
-- Pg Rv Bg Vg
100 0.0001 0.010 0.1
0.0 0.0104 0.1 /
200 0.0004 0.005 0.2
0.0 0.0054 0.2 /
/
SWOF
0.2 0 1 0.9
1 1 0 0.1
/
SGOF
0 0 1 0.2
0.8 1 0 0.5
/
PVTW
--RefPres Bw Comp Vw Cv
1. 1.0 4.0E-5 0.96 0.0 /
ROCK
--RefPres Comp
1. 5.0E-5 /
DENSITY
700 1000 1
/
SOLUTION ======
EQUIL
45 150 50 0.25 45 0.35 1 1 0
/
RSVD
0 0.0
100 100. /
RVVD
0. 0.
100. 0.0001 /
RPTSOL
'PRES' 'PGAS' 'PWAT' 'SOIL' 'SWAT' 'SGAS' 'RS' 'RESTART=2' /
SUMMARY ======
RUNSUM
SEPARATE
SCHEDULE ======
RPTSCHED
'PRES' 'PGAS' 'PWAT' 'SOIL' 'SWAT' 'SGAS' 'RS' 'RESTART=3' 'NEWTON=2' /
END

764
tests/test_equil.cpp Normal file
View File

@@ -0,0 +1,764 @@
/*
Copyright 2014 SINTEF ICT, Applied Mathematics.
*/
#include "config.h"
/* --- Boost.Test boilerplate --- */
#if HAVE_DYNAMIC_BOOST_TEST
#define BOOST_TEST_DYN_LINK
#endif
#define NVERBOSE // Suppress own messages when throw()ing
#define BOOST_TEST_MODULE UnitsTest
#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
/* --- our own headers --- */
#include <opm/core/simulator/initStateEquil.hpp>
#include <opm/core/grid.h>
#include <opm/core/grid/cart_grid.h>
#include <opm/core/grid/GridManager.hpp>
#include <opm/core/props/BlackoilPropertiesBasic.hpp>
#include <opm/core/props/BlackoilPropertiesFromDeck.hpp>
#include <opm/core/props/BlackoilPhases.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/core/pressure/msmfem/partition.h>
#include <opm/core/utility/parameters/ParameterGroup.hpp>
#include <opm/core/utility/Units.hpp>
#include <array>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
BOOST_AUTO_TEST_SUITE ()
BOOST_AUTO_TEST_CASE (PhasePressure)
{
typedef std::vector<double> PVal;
typedef std::vector<PVal> PPress;
std::shared_ptr<UnstructuredGrid>
G(create_grid_cart3d(10, 1, 10), destroy_grid);
Opm::parameter::ParameterGroup param;
{
using Opm::unit::kilogram;
using Opm::unit::meter;
using Opm::unit::cubic;
std::stringstream dens; dens << 700*kilogram/cubic(meter);
param.insertParameter("rho2", dens.str());
}
typedef Opm::BlackoilPropertiesBasic Props;
Props props(param, G->dimensions, G->number_of_cells);
typedef Opm::Equil::DensityCalculator<Opm::BlackoilPropertiesInterface> RhoCalc;
RhoCalc calc(props, 0);
Opm::Equil::EquilRecord record =
{
{ 0 , 1e5 } , // Datum depth, pressure
{ 5 , 0 } , // Zwoc , Pcow_woc
{ 0 , 0 } // Zgoc , Pcgo_goc
};
Opm::Equil::EquilReg<RhoCalc>
region(record, calc,
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
props.phaseUsage());
std::vector<int> cells(G->number_of_cells);
std::iota(cells.begin(), cells.end(), 0);
const double grav = 10;
const PPress ppress = Opm::Equil::phasePressures(*G, region, cells, grav);
const int first = 0, last = G->number_of_cells - 1;
const double reltol = 1.0e-8;
BOOST_CHECK_CLOSE(ppress[0][first] , 90e3 , reltol);
BOOST_CHECK_CLOSE(ppress[0][last ] , 180e3 , reltol);
BOOST_CHECK_CLOSE(ppress[1][first] , 103.5e3 , reltol);
BOOST_CHECK_CLOSE(ppress[1][last ] , 166.5e3 , reltol);
}
BOOST_AUTO_TEST_CASE (CellSubset)
{
typedef std::vector<double> PVal;
typedef std::vector<PVal> PPress;
std::shared_ptr<UnstructuredGrid>
G(create_grid_cart3d(10, 1, 10), destroy_grid);
Opm::parameter::ParameterGroup param;
{
using Opm::unit::kilogram;
using Opm::unit::meter;
using Opm::unit::cubic;
std::stringstream dens; dens << 700*kilogram/cubic(meter);
param.insertParameter("rho2", dens.str());
}
typedef Opm::BlackoilPropertiesBasic Props;
Props props(param, G->dimensions, G->number_of_cells);
typedef Opm::Equil::DensityCalculator<Opm::BlackoilPropertiesInterface> RhoCalc;
RhoCalc calc(props, 0);
Opm::Equil::EquilRecord record[] =
{
{
{ 0 , 1e5 } , // Datum depth, pressure
{ 2.5 , -0.075e5 } , // Zwoc , Pcow_woc
{ 0 , 0 } // Zgoc , Pcgo_goc
}
,
{
{ 5 , 1.35e5 } , // Datum depth, pressure
{ 7.5 , -0.225e5 } , // Zwoc , Pcow_woc
{ 5 , 0 } // Zgoc , Pcgo_goc
}
};
Opm::Equil::EquilReg<RhoCalc> region[] =
{
Opm::Equil::EquilReg<RhoCalc>(record[0], calc,
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
props.phaseUsage())
,
Opm::Equil::EquilReg<RhoCalc>(record[0], calc,
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
props.phaseUsage())
,
Opm::Equil::EquilReg<RhoCalc>(record[1], calc,
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
props.phaseUsage())
,
Opm::Equil::EquilReg<RhoCalc>(record[1], calc,
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
props.phaseUsage())
};
const int cdim[] = { 2, 1, 2 };
int ncoarse = cdim[0];
for (std::size_t d = 1; d < 3; ++d) { ncoarse *= cdim[d]; }
std::vector< std::vector<int> > cells(ncoarse);
for (int c = 0; c < G->number_of_cells; ++c) {
int ci = c;
const int i = ci % G->cartdims[0]; ci /= G->cartdims[0];
const int j = ci % G->cartdims[1];
const int k = ci / G->cartdims[1];
const int ic = (i / (G->cartdims[0] / cdim[0]));
const int jc = (j / (G->cartdims[1] / cdim[1]));
const int kc = (k / (G->cartdims[2] / cdim[2]));
const int ix = ic + cdim[0]*(jc + cdim[1]*kc);
assert ((0 <= ix) && (ix < ncoarse));
cells[ix].push_back(c);
}
PPress ppress(2, PVal(G->number_of_cells, 0));
for (std::vector< std::vector<int> >::const_iterator
r = cells.begin(), e = cells.end();
r != e; ++r)
{
const int rno = int(r - cells.begin());
const double grav = 10;
const PPress p =
Opm::Equil::phasePressures(*G, region[rno], *r, grav);
PVal::size_type i = 0;
for (std::vector<int>::const_iterator
c = r->begin(), ce = r->end();
c != ce; ++c, ++i)
{
assert (i < p[0].size());
ppress[0][*c] = p[0][i];
ppress[1][*c] = p[1][i];
}
}
const int first = 0, last = G->number_of_cells - 1;
const double reltol = 1.0e-8;
BOOST_CHECK_CLOSE(ppress[0][first] , 105e3 , reltol);
BOOST_CHECK_CLOSE(ppress[0][last ] , 195e3 , reltol);
BOOST_CHECK_CLOSE(ppress[1][first] , 103.5e3 , reltol);
BOOST_CHECK_CLOSE(ppress[1][last ] , 166.5e3 , reltol);
}
BOOST_AUTO_TEST_CASE (RegMapping)
{
typedef std::vector<double> PVal;
typedef std::vector<PVal> PPress;
std::shared_ptr<UnstructuredGrid>
G(create_grid_cart3d(10, 1, 10), destroy_grid);
Opm::parameter::ParameterGroup param;
{
using Opm::unit::kilogram;
using Opm::unit::meter;
using Opm::unit::cubic;
std::stringstream dens; dens << 700*kilogram/cubic(meter);
param.insertParameter("rho2", dens.str());
}
typedef Opm::BlackoilPropertiesBasic Props;
Props props(param, G->dimensions, G->number_of_cells);
typedef Opm::Equil::DensityCalculator<Opm::BlackoilPropertiesInterface> RhoCalc;
RhoCalc calc(props, 0);
Opm::Equil::EquilRecord record[] =
{
{
{ 0 , 1e5 } , // Datum depth, pressure
{ 2.5 , -0.075e5 } , // Zwoc , Pcow_woc
{ 0 , 0 } // Zgoc , Pcgo_goc
}
,
{
{ 5 , 1.35e5 } , // Datum depth, pressure
{ 7.5 , -0.225e5 } , // Zwoc , Pcow_woc
{ 5 , 0 } // Zgoc , Pcgo_goc
}
};
Opm::Equil::EquilReg<RhoCalc> region[] =
{
Opm::Equil::EquilReg<RhoCalc>(record[0], calc,
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
props.phaseUsage())
,
Opm::Equil::EquilReg<RhoCalc>(record[0], calc,
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
props.phaseUsage())
,
Opm::Equil::EquilReg<RhoCalc>(record[1], calc,
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
props.phaseUsage())
,
Opm::Equil::EquilReg<RhoCalc>(record[1], calc,
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
std::make_shared<Opm::Equil::Miscibility::NoMixing>(),
props.phaseUsage())
};
std::vector<int> eqlnum(G->number_of_cells);
{
std::vector<int> cells(G->number_of_cells);
std::iota(cells.begin(), cells.end(), 0);
const int cdim[] = { 2, 1, 2 };
int ncoarse = cdim[0];
for (std::size_t d = 1; d < 3; ++d) { ncoarse *= cdim[d]; }
partition_unif_idx(G->dimensions, G->number_of_cells,
G->cartdims, cdim,
&cells[0], &eqlnum[0]);
}
Opm::RegionMapping<> eqlmap(eqlnum);
PPress ppress(2, PVal(G->number_of_cells, 0));
for (int r = 0, e = eqlmap.numRegions(); r != e; ++r)
{
const Opm::RegionMapping<>::CellRange&
rng = eqlmap.cells(r);
const int rno = r;
const double grav = 10;
const PPress p =
Opm::Equil::phasePressures(*G, region[rno], rng, grav);
PVal::size_type i = 0;
for (Opm::RegionMapping<>::CellRange::const_iterator
c = rng.begin(), ce = rng.end();
c != ce; ++c, ++i)
{
assert (i < p[0].size());
ppress[0][*c] = p[0][i];
ppress[1][*c] = p[1][i];
}
}
const int first = 0, last = G->number_of_cells - 1;
const double reltol = 1.0e-8;
BOOST_CHECK_CLOSE(ppress[0][first] , 105e3 , reltol);
BOOST_CHECK_CLOSE(ppress[0][last ] , 195e3 , reltol);
BOOST_CHECK_CLOSE(ppress[1][first] , 103.5e3 , reltol);
BOOST_CHECK_CLOSE(ppress[1][last ] , 166.5e3 , reltol);
}
BOOST_AUTO_TEST_CASE (DeckAllDead)
{
std::shared_ptr<UnstructuredGrid>
grid(create_grid_cart3d(1, 1, 10), destroy_grid);
Opm::ParserPtr parser(new Opm::Parser() );
Opm::DeckConstPtr deck = parser->parseFile("deadfluids.DATA");
Opm::BlackoilPropertiesFromDeck props(deck, *grid, false);
Opm::Equil::DeckDependent::InitialStateComputer<Opm::DeckConstPtr> comp(props, deck, *grid, 10.0);
const auto& pressures = comp.press();
BOOST_REQUIRE(pressures.size() == 3);
BOOST_REQUIRE(int(pressures[0].size()) == grid->number_of_cells);
const int first = 0, last = grid->number_of_cells - 1;
// The relative tolerance is too loose to be very useful,
// but the answer we are checking is the result of an ODE
// solver, and it is unclear if we should check it against
// the true answer or something else.
const double reltol = 1.0e-3;
BOOST_CHECK_CLOSE(pressures[0][first] , 1.496329839e7 , reltol);
BOOST_CHECK_CLOSE(pressures[0][last ] , 1.50473245e7 , reltol);
BOOST_CHECK_CLOSE(pressures[1][last] , 1.50473245e7 , reltol);
}
BOOST_AUTO_TEST_CASE (CapillaryInversion)
{
// Test setup.
Opm::GridManager gm(1, 1, 40, 1.0, 1.0, 2.5);
const UnstructuredGrid& grid = *(gm.c_grid());
Opm::ParserPtr parser(new Opm::Parser() );
Opm::DeckConstPtr deck = parser->parseFile("capillary.DATA");
Opm::BlackoilPropertiesFromDeck props(deck, grid, false);
// Test the capillary inversion for oil-water.
const int cell = 0;
const double reltol = 1.0e-7;
{
const int phase = 0;
const bool increasing = false;
const std::vector<double> pc = { 10.0e5, 0.5e5, 0.4e5, 0.3e5, 0.2e5, 0.1e5, 0.099e5, 0.0e5, -10.0e5 };
const std::vector<double> s = { 0.2, 0.2, 0.2, 0.466666666666, 0.733333333333, 1.0, 1.0, 1.0, 1.0 };
BOOST_REQUIRE(pc.size() == s.size());
for (size_t i = 0; i < pc.size(); ++i) {
const double s_computed = Opm::Equil::satFromPc(props, phase, cell, pc[i], increasing);
BOOST_CHECK_CLOSE(s_computed, s[i], reltol);
}
}
// Test the capillary inversion for gas-oil.
{
const int phase = 2;
const bool increasing = true;
const std::vector<double> pc = { 10.0e5, 0.6e5, 0.5e5, 0.4e5, 0.3e5, 0.2e5, 0.1e5, 0.0e5, -10.0e5 };
const std::vector<double> s = { 0.8, 0.8, 0.8, 0.533333333333, 0.266666666666, 0.0, 0.0, 0.0, 0.0 };
BOOST_REQUIRE(pc.size() == s.size());
for (size_t i = 0; i < pc.size(); ++i) {
const double s_computed = Opm::Equil::satFromPc(props, phase, cell, pc[i], increasing);
BOOST_CHECK_CLOSE(s_computed, s[i], reltol);
}
}
// Test the capillary inversion for gas-water.
{
const int water = 0;
const int gas = 2;
const std::vector<double> pc = { 0.9e5, 0.8e5, 0.6e5, 0.4e5, 0.3e5 };
const std::vector<double> s = { 0.2, 0.333333333333, 0.6, 0.866666666666, 1.0 };
BOOST_REQUIRE(pc.size() == s.size());
for (size_t i = 0; i < pc.size(); ++i) {
const double s_computed = Opm::Equil::satFromSumOfPcs(props, water, gas, cell, pc[i]);
BOOST_CHECK_CLOSE(s_computed, s[i], reltol);
}
}
}
BOOST_AUTO_TEST_CASE (DeckWithCapillary)
{
Opm::GridManager gm(1, 1, 20, 1.0, 1.0, 5.0);
const UnstructuredGrid& grid = *(gm.c_grid());
Opm::ParserPtr parser(new Opm::Parser() );
Opm::DeckConstPtr deck = parser->parseFile("capillary.DATA");
Opm::BlackoilPropertiesFromDeck props(deck, grid, false);
Opm::Equil::DeckDependent::InitialStateComputer<Opm::DeckConstPtr> comp(props, deck, grid, 10.0);
const auto& pressures = comp.press();
BOOST_REQUIRE(pressures.size() == 3);
BOOST_REQUIRE(int(pressures[0].size()) == grid.number_of_cells);
const int first = 0, last = grid.number_of_cells - 1;
// The relative tolerance is too loose to be very useful,
// but the answer we are checking is the result of an ODE
// solver, and it is unclear if we should check it against
// the true answer or something else.
const double reltol = 1.0e-6;
BOOST_CHECK_CLOSE(pressures[0][first] , 1.469769063e7 , reltol);
BOOST_CHECK_CLOSE(pressures[0][last ] , 1.545e7 , reltol);
BOOST_CHECK_CLOSE(pressures[1][last] , 1.546e7 , reltol);
const auto& sats = comp.saturation();
const std::vector<double> s[3]{
{ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.425893333333, 0.774026666666, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0.00736, 0.792746666666, 0.8, 0.8, 0.8, 0.8, 0.574106666666, 0.225973333333, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0.8, 0.8, 0.8, 0.79264, 0.007253333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
for (int phase = 0; phase < 3; ++phase) {
BOOST_REQUIRE(sats[phase].size() == s[phase].size());
for (size_t i = 0; i < s[phase].size(); ++i) {
BOOST_CHECK_CLOSE(sats[phase][i], s[phase][i], reltol);
}
}
}
BOOST_AUTO_TEST_CASE (DeckWithCapillaryOverlap)
{
Opm::GridManager gm(1, 1, 20, 1.0, 1.0, 5.0);
const UnstructuredGrid& grid = *(gm.c_grid());
Opm::ParserPtr parser(new Opm::Parser() );
Opm::DeckConstPtr deck = parser->parseFile("capillary_overlap.DATA");
Opm::BlackoilPropertiesFromDeck props(deck, grid, false);
Opm::Equil::DeckDependent::InitialStateComputer<Opm::DeckConstPtr> comp(props, deck, grid, 9.80665);
const auto& pressures = comp.press();
BOOST_REQUIRE(pressures.size() == 3);
BOOST_REQUIRE(int(pressures[0].size()) == grid.number_of_cells);
const int first = 0, last = grid.number_of_cells - 1;
// The relative tolerance is too loose to be very useful,
// but the answer we are checking is the result of an ODE
// solver, and it is unclear if we should check it against
// the true answer or something else.
const double reltol = 1.0e-6;
const double reltol_ecl = 1.0;
BOOST_CHECK_CLOSE(pressures[0][first], 1.48324e+07, reltol_ecl); // eclipse
BOOST_CHECK_CLOSE(pressures[0][last], 1.54801e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[1][first], 1.49224e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[1][last], 1.54901e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[0][first] , 14832467.14, reltol); // opm
BOOST_CHECK_CLOSE(pressures[0][last ] , 15479883.47, reltol);
BOOST_CHECK_CLOSE(pressures[1][last ] , 15489883.47, reltol);
const auto& sats = comp.saturation();
// std::cout << "Saturations:\n";
// for (const auto& sat : sats) {
// for (const double s : sat) {
// std::cout << s << ' ';
// }
// std::cout << std::endl;
// }
const std::vector<double> s_ecl[3]{// eclipse
{ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.22874042, 0.53397995, 0.78454906, 0.91542006, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.20039, 0.08458, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.77125955, 0.46602005, 0.015063271, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
const std::vector<double> s_opm[3]{ // opm
{ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2289309090909091, 0.53406545454545451, 0.78458, 0.9154, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2002466666666666, 0.0846, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.77106909090909093, 0.46593454545454549, 0.015173333333333336, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
for (int phase = 0; phase < 3; ++phase) {
BOOST_REQUIRE(sats[phase].size() == s_opm[phase].size());
for (size_t i = 0; i < s_opm[phase].size(); ++i) {
//std::cout << std::setprecision(10) << sats[phase][i] << '\n';
BOOST_CHECK_CLOSE(sats[phase][i], s_ecl[phase][i], reltol_ecl);
BOOST_CHECK_CLOSE(sats[phase][i], s_opm[phase][i], reltol);
}
}
}
BOOST_AUTO_TEST_CASE (DeckWithLiveOil)
{
Opm::GridManager gm(1, 1, 20, 1.0, 1.0, 5.0);
const UnstructuredGrid& grid = *(gm.c_grid());
Opm::ParserPtr parser(new Opm::Parser() );
Opm::DeckConstPtr deck = parser->parseFile("equil_liveoil.DATA");
Opm::BlackoilPropertiesFromDeck props(deck, grid, false);
Opm::Equil::DeckDependent::InitialStateComputer<Opm::DeckConstPtr> comp(props, deck, grid, 9.80665);
const auto& pressures = comp.press();
BOOST_REQUIRE(pressures.size() == 3);
BOOST_REQUIRE(int(pressures[0].size()) == grid.number_of_cells);
const int first = 0, last = grid.number_of_cells - 1;
// The relative tolerance is too loose to be very useful,
// but the answer we are checking is the result of an ODE
// solver, and it is unclear if we should check it against
// the true answer or something else.
const double reltol = 1.0e-6;
const double reltol_ecl = 1.0;
BOOST_CHECK_CLOSE(pressures[0][first], 1.48324e+07, reltol_ecl); // eclipse
BOOST_CHECK_CLOSE(pressures[0][last], 1.54801e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[1][first], 1.49224e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[1][last], 1.54901e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[0][first], 1.483246714e7, reltol); // opm
BOOST_CHECK_CLOSE(pressures[0][last], 1.547991652e7, reltol);
BOOST_CHECK_CLOSE(pressures[1][first], 1.492246714e7, reltol);
BOOST_CHECK_CLOSE(pressures[1][last], 1.548991652e7, reltol);
const auto& sats = comp.saturation();
// std::cout << "Saturations:\n";
// for (const auto& sat : sats) {
// for (const double s : sat) {
// std::cout << s << ' ';
// }
// std::cout << std::endl;
// }
const std::vector<double> s_ecl[3]{ // eclipse
{ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.22898, 0.53422, 0.78470, 0.91531, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.20073, 0.08469, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.77102, 0.46578, 0.01458, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
const std::vector<double> s_opm[3]{ // opm
{ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2291709091, 0.5343054545, 0.78472, 0.91529, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2005866667, 0.08471, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.7708290909, 0.4656945455, 0.01469333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
for (int phase = 0; phase < 3; ++phase) {
BOOST_REQUIRE(sats[phase].size() == s_opm[phase].size());
for (size_t i = 0; i < s_opm[phase].size(); ++i) {
//std::cout << std::setprecision(10) << sats[phase][i] << '\n';
BOOST_CHECK_CLOSE(sats[phase][i], s_opm[phase][i], reltol);
BOOST_CHECK_CLOSE(sats[phase][i], s_ecl[phase][i], reltol_ecl);
}
std::cout << std::endl;
}
const auto& rs = comp.rs();
const std::vector<double> rs_opm {74.612335679539058, 74.649052116644228, 74.685786561426298, 74.722539022717172, // opm
74.759309509353145, 74.796098030174733, 74.8329045940269, 74.869729209758916,
74.906571886224327, 75.090675116639048, 75.0, 75.0,
75.0, 75.0, 75.0, 75.0,
75.0, 75.0, 75.0, 75.0};
const std::vector<double> rs_ecl {74.612228, 74.648956, 74.685707, 74.722473, // eclipse
74.759254, 74.796051, 74.832870, 74.875145,
74.969231, 75.090706, 75.000000, 75.000000,
75.000000, 75.000000, 75.000000, 75.000000,
75.000000, 75.000000, 75.000000, 75.000000};
for (size_t i = 0; i < rs_opm.size(); ++i) {
//std::cout << std::setprecision(10) << sats[phase][i] << '\n';
BOOST_CHECK_CLOSE(rs[i], rs_opm[i], reltol);
BOOST_CHECK_CLOSE(rs[i], rs_ecl[i], reltol_ecl);
}
}
BOOST_AUTO_TEST_CASE (DeckWithLiveGas)
{
Opm::GridManager gm(1, 1, 20, 1.0, 1.0, 5.0);
const UnstructuredGrid& grid = *(gm.c_grid());
Opm::ParserPtr parser(new Opm::Parser() );
Opm::DeckConstPtr deck = parser->parseFile("equil_livegas.DATA");
Opm::BlackoilPropertiesFromDeck props(deck, grid, false);
Opm::Equil::DeckDependent::InitialStateComputer<Opm::DeckConstPtr> comp(props, deck, grid, 9.80665);
const auto& pressures = comp.press();
BOOST_REQUIRE(pressures.size() == 3);
BOOST_REQUIRE(int(pressures[0].size()) == grid.number_of_cells);
const int first = 0, last = grid.number_of_cells - 1;
// The relative tolerance is too loose to be very useful,
// but the answer we are checking is the result of an ODE
// solver, and it is unclear if we should check it against
// the true answer or something else.
const double reltol = 1.0e-6;
const double reltol_ecl = 1.0;
BOOST_CHECK_CLOSE(pressures[0][first], 1.48215e+07, reltol_ecl); // eclipse
BOOST_CHECK_CLOSE(pressures[0][last], 1.54801e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[1][first], 1.49115e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[1][last], 1.54901e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[0][first], 1.482150311e7, reltol); // opm
BOOST_CHECK_CLOSE(pressures[0][last], 1.547988347e7, reltol);
BOOST_CHECK_CLOSE(pressures[1][first], 1.491150311e7, reltol);
BOOST_CHECK_CLOSE(pressures[1][last], 1.548988347e7, reltol);
const auto& sats = comp.saturation();
// std::cout << "Saturations:\n";
// for (const auto& sat : sats) {
// for (const double s : sat) {
// std::cout << s << ' ';
// }
// std::cout << std::endl;
// }
const std::vector<double> s_ecl[3]{ // eclipse
{ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.24285614, 0.53869015, 0.78454906, 0.91542006, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.18311, 0.08458, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.75714386, 0.46130988, 0.032345835, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
const std::vector<double> s_opm[3]{ // opm
{ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.24310545, 0.5388, 0.78458, 0.91540, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.18288667, 0.0846, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.75689455, 0.4612, 0.03253333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
for (int phase = 0; phase < 3; ++phase) {
BOOST_REQUIRE(sats[phase].size() == s_opm[phase].size());
for (size_t i = 0; i < s_opm[phase].size(); ++i) {
//std::cout << std::setprecision(10) << sats[phase][i] << '\n';
BOOST_CHECK_CLOSE(sats[phase][i], s_opm[phase][i], 100.*reltol);
BOOST_CHECK_CLOSE(sats[phase][i], s_ecl[phase][i], reltol_ecl);
}
std::cout << std::endl;
}
const auto& rv = comp.rv();
const std::vector<double> rv_opm { // opm
2.4884509e-4, 2.4910378e-4, 2.4936267e-4, 2.4962174e-4,
2.4988100e-4, 2.5014044e-4, 2.5040008e-4, 2.5065990e-4,
2.5091992e-4, 2.5118012e-4, 2.5223082e-4, 2.5105e-4,
2.5105e-4, 2.5105e-4, 2.5105e-4, 2.5105e-4,
2.5105e-4, 2.5105e-4, 2.5105e-4, 2.5105e-4};
const std::vector<double> rv_ecl { // eclipse
0.24884584E-03, 0.24910446E-03, 0.24936325E-03, 0.24962222E-03,
0.24988138E-03, 0.25014076E-03, 0.25040031E-03, 0.25066003E-03,
0.25091995E-03, 0.25118008E-03, 0.25223137E-03, 0.25104999E-03,
0.25104999E-03, 0.25104999E-03, 0.25104999E-03, 0.25104999E-03,
0.25104999E-03, 0.25104999E-03, 0.25104999E-03, 0.25104999E-03};
for (size_t i = 0; i < rv_opm.size(); ++i) {
//std::cout << std::setprecision(10) << sats[phase][i] << '\n';
BOOST_CHECK_CLOSE(rv[i], rv_opm[i], 100.*reltol);
BOOST_CHECK_CLOSE(rv[i], rv_ecl[i], reltol_ecl);
}
}
BOOST_AUTO_TEST_CASE (DeckWithRSVDAndRVVD)
{
Opm::GridManager gm(1, 1, 20, 1.0, 1.0, 5.0);
const UnstructuredGrid& grid = *(gm.c_grid());
Opm::ParserPtr parser(new Opm::Parser() );
Opm::DeckConstPtr deck = parser->parseFile("equil_rsvd_and_rvvd.DATA");
Opm::BlackoilPropertiesFromDeck props(deck, grid, false);
Opm::Equil::DeckDependent::InitialStateComputer<Opm::DeckConstPtr> comp(props, deck, grid, 9.80665);
const auto& pressures = comp.press();
BOOST_REQUIRE(pressures.size() == 3);
BOOST_REQUIRE(int(pressures[0].size()) == grid.number_of_cells);
const int first = 0, last = grid.number_of_cells - 1;
// The relative tolerance is too loose to be very useful,
// but the answer we are checking is the result of an ODE
// solver, and it is unclear if we should check it against
// the true answer or something else.
const double reltol = 1.0e-6;
const double reltol_ecl = 1.0;
BOOST_CHECK_CLOSE(pressures[0][first], 1.48350e+07, reltol_ecl); // eclipse
BOOST_CHECK_CLOSE(pressures[0][last], 1.54794e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[1][first], 1.49250e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[1][last], 1.54894e+07, reltol_ecl);
BOOST_CHECK_CLOSE(pressures[0][first], 1.483499660e7, reltol); // opm
BOOST_CHECK_CLOSE(pressures[0][last], 1.547924516e7, reltol);
BOOST_CHECK_CLOSE(pressures[1][first], 1.492499660e7, reltol);
BOOST_CHECK_CLOSE(pressures[1][last], 1.548924516e7, reltol);
const auto& sats = comp.saturation();
// std::cout << "Saturations:\n";
// for (const auto& sat : sats) {
// for (const double s : sat) {
// std::cout << s << ' ';
// }
// std::cout << std::endl;
// }
const std::vector<double> s_ecl[3]{ // eclipse
{ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.22206347, 0.52871972, 0.78150368, 0.91819441, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.19656529, 0.081805572, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.77793652, 0.47128031, 0.021931054, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
const std::vector<double> s_opm[3]{ // opm
{ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.22232000, 0.52882909, 0.78153000, 0.91817000, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.19636333, 0.08183000, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.77768000, 0.47117091, 0.02210667, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
for (int phase = 0; phase < 3; ++phase) {
BOOST_REQUIRE(sats[phase].size() == s_opm[phase].size());
for (size_t i = 0; i < s_opm[phase].size(); ++i) {
//std::cout << std::setprecision(10) << sats[phase][i] << '\n';
BOOST_CHECK_CLOSE(sats[phase][i], s_opm[phase][i], 100.*reltol);
BOOST_CHECK_CLOSE(sats[phase][i], s_ecl[phase][i], reltol_ecl);
}
std::cout << std::endl;
}
const auto& rs = comp.rs();
const std::vector<double> rs_opm { // opm
74.624983020822540, 74.659590408801634, 74.694380353364522, 74.729353362649505,
74.764509945812975, 74.799850613032362, 74.835375875509555, 74.87108624547416,
74.906982236186707, 75.088917653469309, 52.5, 57.5,
62.5, 67.5, 72.5, 76.45954840804761,
76.70621044909619, 76.952877357524045, 77.199549133522638, 77.446225777283587};
const std::vector<double> rs_ecl { // eclipse
74.625114, 74.659706, 74.694481, 74.729439,
74.764580, 74.799904, 74.835419, 74.875252,
74.968628, 75.088951, 52.500000, 57.500000,
62.500000, 67.500000, 72.500000, 76.168388,
76.349953, 76.531532, 76.713142, 76.894775,};
const auto& rv = comp.rv();
const std::vector<double> rv_opm { // opm
2.50e-6, 7.50e-6, 1.25e-5, 1.75e-5,
2.25e-5, 2.75e-5, 3.25e-5, 3.75e-5,
4.25e-5, 2.51158386e-4, 2.52203372e-4, 5.75e-5,
6.25e-5, 6.75e-5, 7.25e-5, 7.75e-5,
8.25e-5, 8.75e-5, 9.25e-5, 9.75e-5};
const std::vector<double> rv_ecl { // eclipse
0.24999999E-05, 0.74999998E-05, 0.12500000E-04, 0.17500000E-04,
0.22500000E-04, 0.27500000E-04, 0.32500000E-04, 0.37500002E-04,
0.42500000E-04, 0.25115837E-03, 0.25220393E-03, 0.57500001E-04,
0.62500003E-04, 0.67499997E-04, 0.72499999E-04, 0.77500001E-04,
0.82500002E-04, 0.87499997E-04, 0.92499999E-04, 0.97500000E-04};
for (size_t i = 0; i < rv_opm.size(); ++i) {
//std::cout << std::setprecision(10) << sats[phase][i] << '\n';
BOOST_CHECK_CLOSE(rs[i], rs_opm[i], 100*reltol);
BOOST_CHECK_CLOSE(rs[i], rs_ecl[i], reltol_ecl);
BOOST_CHECK_CLOSE(rv[i], rv_opm[i], 100.*reltol);
BOOST_CHECK_CLOSE(rv[i], rv_ecl[i], reltol_ecl);
}
}
BOOST_AUTO_TEST_SUITE_END()

View File

@@ -0,0 +1,64 @@
/*
Copyright 2014 SINTEF ICT, Applied Mathematics.
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"
/* --- Boost.Test boilerplate --- */
#if HAVE_DYNAMIC_BOOST_TEST
#define BOOST_TEST_DYN_LINK
#endif
#define NVERBOSE // Suppress own messages when throw()ing
#define BOOST_TEST_MODULE UnitsTest
#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
/* --- our own headers --- */
#include <opm/core/utility/RegionMapping.hpp>
BOOST_AUTO_TEST_SUITE ()
BOOST_AUTO_TEST_CASE (RegionMapping)
{
// 0 1 2 3 4 5 6 7 8
std::vector<int> regions = { 2, 5, 2, 4, 2, 7, 6, 3, 6 };
Opm::RegionMapping<> rm(regions);
for (size_t i = 0; i < regions.size(); ++i) {
BOOST_CHECK_EQUAL(rm.region(i), regions[i]);
}
std::vector<int> region_ids = { 2, 3, 4, 5, 6, 7 };
std::vector< std::vector<int> > region_cells = { { 0, 2, 4 }, { 7 }, { 3 }, { 1 }, { 6, 8 }, { 5 } };
BOOST_REQUIRE_EQUAL(rm.numRegions(), region_ids.size());
for (size_t i = 0; i < region_ids.size(); ++i) {
auto cells = rm.cells(region_ids[i]);
BOOST_REQUIRE_EQUAL(std::distance(cells.begin(), cells.end()), region_cells[i].size());
size_t count = 0;
for (auto iter = cells.begin(); iter != cells.end(); ++iter, ++count) {
BOOST_CHECK_EQUAL(*iter, region_cells[i][count]);
}
}
}
BOOST_AUTO_TEST_SUITE_END()