mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Only copy perfPhaseRates if number of perforations is equal.
The number of perforations may change due to completions beeing shut. If the number of perforations changes the perfPhaseRates are set to equal the wellRates/(number of perforations) instead of the values from the previous time step.
This commit is contained in:
@@ -43,7 +43,7 @@ namespace Opm
|
|||||||
{
|
{
|
||||||
typedef WellState BaseType;
|
typedef WellState BaseType;
|
||||||
public:
|
public:
|
||||||
typedef std::array< int, 2 > mapentry_t;
|
typedef std::array< int, 3 > mapentry_t;
|
||||||
typedef std::map< std::string, mapentry_t > WellMapType;
|
typedef std::map< std::string, mapentry_t > WellMapType;
|
||||||
|
|
||||||
using BaseType :: wellRates;
|
using BaseType :: wellRates;
|
||||||
@@ -78,15 +78,18 @@ namespace Opm
|
|||||||
const WellControls* ctrl = wells->ctrls[w];
|
const WellControls* ctrl = wells->ctrls[w];
|
||||||
std::string name( wells->name[ w ] );
|
std::string name( wells->name[ w ] );
|
||||||
assert( name.size() > 0 );
|
assert( name.size() > 0 );
|
||||||
mapentry_t& wellMapEntry = wellMap_[ name ];
|
mapentry_t& wellMapEntry = wellMap_[name];
|
||||||
wellMapEntry[ 0 ] = w ;
|
wellMapEntry[ 0 ] = w;
|
||||||
wellMapEntry[ 1 ] = wells->well_connpos[w ] ;
|
wellMapEntry[ 1 ] = wells->well_connpos[w];
|
||||||
|
// also store the number of perforations in this well
|
||||||
|
const int num_perf_this_well = wells->well_connpos[w + 1] - wells->well_connpos[w];
|
||||||
|
wellMapEntry[ 2 ] = num_perf_this_well;
|
||||||
|
|
||||||
if (well_controls_well_is_stopped(ctrl)) {
|
if (well_controls_well_is_stopped(ctrl)) {
|
||||||
// Shut well: perfphaserates_ are all zero.
|
// Shut well: perfphaserates_ are all zero.
|
||||||
} else {
|
} else {
|
||||||
// Open well: Initialize perfphaserates_ to well
|
// Open well: Initialize perfphaserates_ to well
|
||||||
// rates divided by the number of perforations.
|
// rates divided by the number of perforations.
|
||||||
const int num_perf_this_well = wells->well_connpos[w + 1] - wells->well_connpos[w];
|
|
||||||
for (int perf = wells->well_connpos[w]; perf < wells->well_connpos[w + 1]; ++perf) {
|
for (int perf = wells->well_connpos[w]; perf < wells->well_connpos[w + 1]; ++perf) {
|
||||||
for (int p = 0; p < np; ++p) {
|
for (int p = 0; p < np; ++p) {
|
||||||
perfphaserates_[np*perf + p] = wellRates()[np*w + p] / double(num_perf_this_well);
|
perfphaserates_[np*perf + p] = wellRates()[np*w + p] / double(num_perf_this_well);
|
||||||
@@ -128,14 +131,29 @@ namespace Opm
|
|||||||
|
|
||||||
// perfPhaseRates
|
// perfPhaseRates
|
||||||
int oldPerf = (*it).second[ 1 ] * np;
|
int oldPerf = (*it).second[ 1 ] * np;
|
||||||
for (int perf = wells->well_connpos[ newIndex ]*np;
|
const int num_perf_old_well = (*it).second[ 2 ];
|
||||||
perf < wells->well_connpos[ newIndex + 1]*np; ++perf, ++oldPerf )
|
const int num_perf_this_well = wells->well_connpos[newIndex + 1] - wells->well_connpos[newIndex];
|
||||||
|
// copy perforation rates when the number of perforations is equal,
|
||||||
|
// otherwise initialize perfphaserates to well rates divided by the number of perforations.
|
||||||
|
if( num_perf_old_well == num_perf_this_well )
|
||||||
{
|
{
|
||||||
perfPhaseRates()[ perf ] = prevState.perfPhaseRates()[ oldPerf ];
|
for (int perf = wells->well_connpos[ newIndex ]*np;
|
||||||
|
perf < wells->well_connpos[ newIndex + 1]*np; ++perf, ++oldPerf )
|
||||||
|
{
|
||||||
|
perfPhaseRates()[ perf ] = prevState.perfPhaseRates()[ oldPerf ];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int perf = wells->well_connpos[newIndex]; perf < wells->well_connpos[newIndex + 1]; ++perf) {
|
||||||
|
for (int p = 0; p < np; ++p) {
|
||||||
|
perfPhaseRates()[np*perf + p] = wellRates()[np*newIndex + p] / double(num_perf_this_well);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// currentControls
|
// currentControls
|
||||||
|
// WARNING: This may be error prone if the number of controls change.
|
||||||
currentControls()[ newIndex ] = prevState.currentControls()[ oldIndex ];
|
currentControls()[ newIndex ] = prevState.currentControls()[ oldIndex ];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user