Minor refactoring of VFPProperties to prepare for support for VFPINJ tables

This commit is contained in:
babrodtk
2015-08-10 08:53:42 +02:00
parent 15d3171ae1
commit 3260e978da
3 changed files with 111 additions and 68 deletions
+16 -24
View File
@@ -28,7 +28,7 @@
#include <algorithm>
#include <memory>
#include <vector>
#include <map>
#include <sstream>
#include <boost/test/unit_test.hpp>
@@ -136,8 +136,7 @@ struct TrivialFixture {
data);
//Initialize properties that use the table
properties.reset(new Opm::VFPProperties());
properties->init(&table);
properties.reset(new Opm::VFPProperties(NULL, &table));
}
std::shared_ptr<Opm::VFPProperties> properties;
@@ -171,10 +170,10 @@ BOOST_AUTO_TEST_CASE(GetTable)
initProperties();
//Table 1 has been initialized
properties->bhp(1, 0.0, 0.0, 0.0, 0.0, 0.0);
properties->prod_bhp(1, 0.0, 0.0, 0.0, 0.0, 0.0);
//Table 2 does not exist.
BOOST_CHECK_THROW(properties->bhp(2, 0.0, 0.0, 0.0, 0.0, 0.0), std::invalid_argument);
BOOST_CHECK_THROW(properties->prod_bhp(2, 0.0, 0.0, 0.0, 0.0, 0.0), std::invalid_argument);
}
/**
@@ -201,7 +200,7 @@ BOOST_AUTO_TEST_CASE(InterpolateZero)
const double v = m / static_cast<double>(n-1);
//Note order of arguments!
sum += properties->bhp(1, v, x, y, z, u);
sum += properties->prod_bhp(1, v, x, y, z, u);
}
}
}
@@ -236,7 +235,7 @@ BOOST_AUTO_TEST_CASE(InterpolateOne)
const double v = m / static_cast<double>(n-1);
//Note order of arguments!
sum += properties->bhp(1, v, x, y, z, u);
sum += properties->prod_bhp(1, v, x, y, z, u);
}
}
}
@@ -277,7 +276,7 @@ BOOST_AUTO_TEST_CASE(InterpolatePlane)
reference_sum += reference;
//Note order of arguments!
double value = properties->bhp(1, v, x, y, z, u);
double value = properties->prod_bhp(1, v, x, y, z, u);
sum += value;
double abs_diff = std::abs(value - reference);
@@ -326,7 +325,7 @@ BOOST_AUTO_TEST_CASE(ExtrapolatePlane)
reference_sum += reference;
//Note order of arguments!
double value = properties->bhp(1, v, x, y, z, u);
double value = properties->prod_bhp(1, v, x, y, z, u);
sum += value;
double abs_diff = std::abs(value - reference);
@@ -394,7 +393,7 @@ BOOST_AUTO_TEST_CASE(ExtrapolatePlaneADB)
ADB gfr = ADB::constant(zz);
ADB alq = ADB::constant(uu);
ADB bhp_val = properties->bhp(1, flo, thp, wfr, gfr, alq);
ADB bhp_val = properties->prod_bhp(1, flo, thp, wfr, gfr, alq);
double value = 0.0;
double reference = 0.0;
@@ -474,7 +473,7 @@ BOOST_AUTO_TEST_CASE(InterpolateADBAndQs)
ADB alq = ADB::constant(alq_vals);
//Call the bhp function
ADB bhp = properties->bhp(1, *wells, qs, thp, alq);
ADB bhp = properties->prod_bhp(1, *wells, qs, thp, alq);
//Calculate reference
//First, find the three phases
@@ -722,17 +721,10 @@ BOOST_AUTO_TEST_CASE(ParseInterpolateRealisticVFPPROD)
BOOST_REQUIRE(deck->hasKeyword("VFPPROD"));
BOOST_CHECK_EQUAL(deck->numKeywords("VFPPROD"), 1);
std::vector<Opm::VFPProdTable> tables;
Opm::VFPProdTable table;
table.init(deck->getKeyword("VFPPROD", 1), units);
int num_tables = deck->numKeywords("VFPPROD");
for (int i=0; i<num_tables; ++i) {
Opm::DeckKeywordConstPtr keyword = deck->getKeyword("VFPPROD", i);
tables.push_back(Opm::VFPProdTable());
tables[i].init(keyword, units);
}
Opm::VFPProperties properties;
properties.init(tables);
Opm::VFPProperties properties(NULL, &table);
//Do some rudimentary testing
//Get the BHP as a function of rate, thp, wfr, gfr, alq
@@ -771,7 +763,7 @@ BOOST_AUTO_TEST_CASE(ParseInterpolateRealisticVFPPROD)
double a_i = 0.0;
//Value given as pascal, convert to barsa for comparison with reference
double value_i = properties.bhp(32, f_i, t_i, w_i, g_i, a_i) * 10.0e-6;
double value_i = properties.prod_bhp(32, f_i, t_i, w_i, g_i, a_i) * 10.0e-6;
double abs_diff = std::abs(value_i - reference[i]);
sad += abs_diff;
@@ -792,8 +784,8 @@ BOOST_AUTO_TEST_CASE(ParseInterpolateRealisticVFPPROD)
std::cout << "];" << std::endl;
#endif
BOOST_CHECK_SMALL(max_d, 1.0e-12);
BOOST_CHECK_SMALL(sad, 1.0e-9);
BOOST_CHECK_SMALL(max_d, max_d_tol);
BOOST_CHECK_SMALL(sad, sad_tol);
}
/**