adjust serialization of VFPProdTable

This commit is contained in:
Arne Morten Kvarving
2020-02-12 15:38:02 +01:00
parent 649818730c
commit 99c019a6bb
6 changed files with 21 additions and 37 deletions

View File

@@ -1132,8 +1132,7 @@ std::size_t packSize(const VFPProdTable& data,
packSize(data.getWFRAxis(), comm) +
packSize(data.getGFRAxis(), comm) +
packSize(data.getALQAxis(), comm) +
data.getTable().num_elements() *
packSize(double(), comm);
packSize(data.getTable(), comm);
}
std::size_t packSize(const WellTestConfig::WTESTWell& data,
@@ -2868,8 +2867,7 @@ void pack(const VFPProdTable& data,
pack(data.getWFRAxis(), buffer, position, comm);
pack(data.getGFRAxis(), buffer, position, comm);
pack(data.getALQAxis(), buffer, position, comm);
for (size_t i = 0; i < data.getTable().num_elements(); ++i)
pack(*(data.getTable().data() + i), buffer, position, comm);
pack(data.getTable(), buffer, position, comm);
}
void pack(const WellTestConfig::WTESTWell& data,
@@ -5070,15 +5068,7 @@ void unpack(VFPProdTable& data,
unpack(wfrAxis, buffer, position, comm);
unpack(gfrAxis, buffer, position, comm);
unpack(alqAxis, buffer, position, comm);
VFPProdTable::extents extents;
extents[0] = thpAxis.size();
extents[1] = wfrAxis.size();
extents[2] = gfrAxis.size();
extents[3] = alqAxis.size();
extents[4] = floAxis.size();
table.resize(extents);
for (size_t i = 0; i < table.num_elements(); ++i)
unpack(*(table.data() + i), buffer, position, comm);
unpack(table, buffer, position, comm);
data = VFPProdTable(tableNum, datumDepth, floType, wfrType,
gfrType, alqType, floAxis, thpAxis,

View File

@@ -332,7 +332,7 @@ inline VFPEvaluation operator*(
* Helper function which interpolates data using the indices etc. given in the inputs.
*/
inline VFPEvaluation interpolate(
const VFPProdTable::array_type& array,
const VFPProdTable& table,
const InterpData& flo_i,
const InterpData& thp_i,
const InterpData& wfr_i,
@@ -361,7 +361,7 @@ inline VFPEvaluation interpolate(
const int fi = flo_i.ind_[f];
//Copy element
nn[t][w][g][a][f].value = array[ti][wi][gi][ai][fi];
nn[t][w][g][a][f].value = table(ti,wi,gi,ai,fi);
}
}
}
@@ -522,7 +522,7 @@ inline VFPEvaluation bhp(const VFPProdTable* table,
auto gfr_i = detail::findInterpData( gfr, table->getGFRAxis());
auto alq_i = detail::findInterpData( alq, table->getALQAxis());
detail::VFPEvaluation retval = detail::interpolate(table->getTable(), flo_i, thp_i, wfr_i, gfr_i, alq_i);
detail::VFPEvaluation retval = detail::interpolate(*table, flo_i, thp_i, wfr_i, gfr_i, alq_i);
return retval;
}

View File

@@ -57,7 +57,6 @@ double VFPProdProperties::thp(int table_id,
const double& bhp_arg,
const double& alq) const {
const VFPProdTable* table = detail::getTable(m_tables, table_id);
const VFPProdTable::array_type& data = table->getTable();
//Find interpolation variables
double flo = detail::getFlo(aqua, liquid, vapour, table->getFloType());
@@ -80,7 +79,7 @@ double VFPProdProperties::thp(int table_id,
std::vector<double> bhp_array(nthp);
for (int i=0; i<nthp; ++i) {
auto thp_i = detail::findInterpData(thp_array[i], thp_array);
bhp_array[i] = detail::interpolate(data, flo_i, thp_i, wfr_i, gfr_i, alq_i).value;
bhp_array[i] = detail::interpolate(*table, flo_i, thp_i, wfr_i, gfr_i, alq_i).value;
}
double retval = detail::findTHP(bhp_array, thp_array, bhp_arg);
@@ -131,7 +130,7 @@ bhpwithflo(const std::vector<double>& flos,
for (size_t i = 0; i < flos.size(); ++i) {
// Value of FLO is negative in OPM for producers, but positive in VFP table
const auto flo_i = detail::findInterpData(-flos[i], table->getFloAxis());
const detail::VFPEvaluation bhp_val = detail::interpolate(table->getTable(), flo_i, thp_i, wfr_i, gfr_i, alq_i);
const detail::VFPEvaluation bhp_val = detail::interpolate(*table, flo_i, thp_i, wfr_i, gfr_i, alq_i);
// TODO: this kind of breaks the conventions for the functions here by putting dp within the function
bhps[i] = bhp_val.value - dp;

View File

@@ -102,7 +102,7 @@ public:
auto gfr_i = detail::findInterpData( gfr.value(), table->getGFRAxis());
auto alq_i = detail::findInterpData( alq, table->getALQAxis()); //assume constant
detail::VFPEvaluation bhp_val = detail::interpolate(table->getTable(), flo_i, thp_i, wfr_i, gfr_i, alq_i);
detail::VFPEvaluation bhp_val = detail::interpolate(*table, flo_i, thp_i, wfr_i, gfr_i, alq_i);
bhp = (bhp_val.dwfr * wfr) + (bhp_val.dgfr * gfr) - (bhp_val.dflo * flo);
bhp.setValue(bhp_val.value);

View File

@@ -321,16 +321,9 @@ Opm::VFPInjTable getVFPInjTable()
Opm::VFPProdTable getVFPProdTable()
{
Opm::VFPProdTable::array_type table;
Opm::VFPProdTable::extents shape;
shape[0] = 1;
shape[1] = 2;
shape[2] = 3;
shape[3] = 4;
shape[4] = 5;
table.resize(shape);
double foo = 1.0;
for (size_t i = 0; i < table.num_elements(); ++i)
*(table.data() + i) = foo++;
table.resize(1*2*3*4*5);
std::iota(table.begin(), table.end(), 1.0);
return Opm::VFPProdTable(1, 2.0, Opm::VFPProdTable::FLO_OIL,
Opm::VFPProdTable::WFR_WOR,
Opm::VFPProdTable::GFR_GLR,

View File

@@ -124,10 +124,8 @@ struct TrivialFixture {
nz(gfr_axis.size()),
nu(alq_axis.size()),
nv(flo_axis.size()),
size{{ nx, ny, nz, nu, nv }},
data(size)
data(nx*ny*nz*nu*nv)
{
}
~TrivialFixture() {
@@ -143,7 +141,7 @@ struct TrivialFixture {
for (int k=0; k<nz; ++k) {
for (int l=0; l<nu; ++l) {
for (int m=0; m<nv; ++m) {
data[i][j][k][l][m] = value;
(*this)(i,j,k,l,m) = value;
}
}
}
@@ -166,7 +164,7 @@ struct TrivialFixture {
for (int m=0; m<nv; ++m) {
double v = m / static_cast<double>(nv-1);
// table[thp_idx][wfr_idx][gfr_idx][alq_idx][flo_idx];
data[i][j][k][l][m] = x + 2*y + 3*z + 4*u + 5*v;
(*this)(i,j,k,l,m) = x + 2*y + 3*z + 4*u + 5*v;
}
}
}
@@ -187,7 +185,7 @@ struct TrivialFixture {
for (int k=0; k<nz; ++k) {
for (int l=0; l<nu; ++l) {
for (int m=0; m<nv; ++m) {
data[i][j][k][l][m] = randx / max_val;
(*this)(i,j,k,l,m) = randx / max_val;
randx = (randx*1103515245 + 12345);
}
}
@@ -214,6 +212,11 @@ struct TrivialFixture {
properties.reset(new Opm::VFPProdProperties(table.get()));
}
double& operator()(size_t thp_idx, size_t wfr_idx, size_t gfr_idx, size_t alq_idx, size_t flo_idx) {
return data[thp_idx*ny*nz*nu*nv + wfr_idx*nz*nu*nv + gfr_idx*nu*nv + alq_idx*nv + flo_idx];
}
std::shared_ptr<Opm::VFPProdProperties> properties;
@@ -231,7 +234,6 @@ private:
int nz;
int nu;
int nv;
Opm::VFPProdTable::extents size;
Opm::VFPProdTable::array_type data;
};