Store global index instead of active index in well completions

Fix bug in output of completion related stuff when run on mulitiple
cores.
This commit is contained in:
Tor Harald Sandve
2018-02-08 10:40:13 +01:00
parent 55ed844438
commit 206241c9ae
6 changed files with 14 additions and 15 deletions

View File

@@ -102,10 +102,10 @@ namespace Opm {
};
struct Completion {
using active_index = size_t;
using global_index = size_t;
static const constexpr int restart_size = 2;
active_index index;
global_index index;
Rates rates;
double pressure;
double reservoir_rate;
@@ -146,7 +146,7 @@ namespace Opm {
}
double get(const std::string& well_name , Completion::active_index completion_grid_index, Rates::opt m) const {
double get(const std::string& well_name , Completion::global_index completion_grid_index, Rates::opt m) const {
const auto& witr = this->find( well_name );
if( witr == this->end() ) return 0.0;

View File

@@ -164,7 +164,7 @@ void RFT::writeTimeStep( std::vector< const Well* > wells,
if( !grid.cellActive( i, j, k ) ) continue;
const auto index = grid.activeIndex( i, j, k );
const auto index = grid.getGlobalIndex( i, j, k );
const double depth = grid.getCellDepth( i, j, k );
const auto& completionData = std::find_if( wellData.completions.begin(),

View File

@@ -364,13 +364,13 @@ std::vector< double > serialize_OPM_XWEL( const data::Wells& wells,
std::vector< double > xwel;
for( const auto* sched_well : sched_wells ) {
if( wells.count( sched_well->name() ) == 0 ) {
if( wells.count( sched_well->name() ) == 0 || sched_well->getStatus(report_step) == Opm::WellCommon::SHUT) {
const auto elems = (sched_well->getCompletions( report_step ).size()
* (phases.size() + data::Completion::restart_size))
+ 2 /* bhp, temperature */
+ phases.size();
// write zeros if no well data is provided
// write zeros if no well data is provided or it is shut
xwel.insert( xwel.end(), elems, 0.0 );
continue;
}

View File

@@ -225,8 +225,7 @@ inline quantity crate( const fn_args& args ) {
// NUMS array in the eclispe SMSPEC file; the values in this array
// are offset 1 - whereas we need to use this index here to look
// up a completion with offset 0.
const auto global_index = args.num - 1;
const auto active_index = args.grid.activeIndex( global_index );
const size_t global_index = args.num - 1;
if( args.schedule_wells.empty() ) return zero;
const auto& name = args.schedule_wells.front()->name();
@@ -236,7 +235,7 @@ inline quantity crate( const fn_args& args ) {
const auto& completion = std::find_if( well.completions.begin(),
well.completions.end(),
[=]( const data::Completion& c ) {
return c.index == active_index;
return c.index == global_index;
} );
if( completion == well.completions.end() ) return zero;

View File

@@ -139,12 +139,12 @@ BOOST_AUTO_TEST_CASE(test_RFT) {
std::vector<Opm::data::Completion> well1_comps(9);
for (size_t i = 0; i < 9; ++i) {
Opm::data::Completion well_comp { grid.activeIndex(8,8,i) ,r1, 0.0 , 0.0, (double)i, 0.1*i,0.2*i};
Opm::data::Completion well_comp { grid.getGlobalIndex(8,8,i) ,r1, 0.0 , 0.0, (double)i, 0.1*i,0.2*i};
well1_comps[i] = well_comp;
}
std::vector<Opm::data::Completion> well2_comps(6);
for (size_t i = 0; i < 6; ++i) {
Opm::data::Completion well_comp { grid.activeIndex(3,3,i+3) ,r2, 0.0 , 0.0, (double)i, i*0.1,i*0.2};
Opm::data::Completion well_comp { grid.getGlobalIndex(3,3,i+3) ,r2, 0.0 , 0.0, (double)i, i*0.1,i*0.2};
well2_comps[i] = well_comp;
}
@@ -229,12 +229,12 @@ BOOST_AUTO_TEST_CASE(test_RFT2) {
std::vector<Opm::data::Completion> well1_comps(9);
for (size_t i = 0; i < 9; ++i) {
Opm::data::Completion well_comp { grid.activeIndex(8,8,i) ,r1, 0.0 , 0.0, (double)i, 0.1*i,0.2*i};
Opm::data::Completion well_comp { grid.getGlobalIndex(8,8,i) ,r1, 0.0 , 0.0, (double)i, 0.1*i,0.2*i};
well1_comps[i] = well_comp;
}
std::vector<Opm::data::Completion> well2_comps(6);
for (size_t i = 0; i < 6; ++i) {
Opm::data::Completion well_comp { grid.activeIndex(3,3,i+3) ,r2, 0.0 , 0.0, (double)i, i*0.1,i*0.2};
Opm::data::Completion well_comp { grid.getGlobalIndex(3,3,i+3) ,r2, 0.0 , 0.0, (double)i, i*0.1,i*0.2};
well2_comps[i] = well_comp;
}

View File

@@ -144,8 +144,8 @@ static data::Wells result_wells() {
crates2.set( rt::reservoir_gas, 300.8 / day );
/*
The active index assigned to the completion must be manually
syncronized with the active index in the COMPDAT keyword in the
The global index assigned to the completion must be manually
syncronized with the global index in the COMPDAT keyword in the
input deck.
*/
data::Completion well1_comp1 { 0 , crates1, 1.9 , 123.4};