mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3156 from joakim-hove/well-init-restart-bug
Well init restart bug
This commit is contained in:
commit
481c72a0fc
@ -618,7 +618,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initFromRestartFile(const RestartValue& restartValues OPM_UNUSED){
|
void initFromRestartFile(const RestartValue& restartValues OPM_UNUSED){
|
||||||
// not implemented
|
throw std::logic_error("initFromRestartFile() method not implemented for class eclwellmanager");
|
||||||
}
|
}
|
||||||
|
|
||||||
const WellStateFullyImplicitBlackoil& wellState() const
|
const WellStateFullyImplicitBlackoil& wellState() const
|
||||||
|
@ -573,7 +573,7 @@ namespace Opm {
|
|||||||
void wellTesting(const int timeStepIdx, const double simulationTime, Opm::DeferredLogger& deferred_logger);
|
void wellTesting(const int timeStepIdx, const double simulationTime, Opm::DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
// convert well data from opm-common to well state from opm-core
|
// convert well data from opm-common to well state from opm-core
|
||||||
void wellsToState( const data::Wells& wells,
|
void loadRestartData( const data::Wells& wells,
|
||||||
const data::GroupAndNetworkValues& grpNwrkValues,
|
const data::GroupAndNetworkValues& grpNwrkValues,
|
||||||
const PhaseUsage& phases,
|
const PhaseUsage& phases,
|
||||||
const bool handle_ms_well,
|
const bool handle_ms_well,
|
||||||
|
@ -630,7 +630,7 @@ namespace Opm {
|
|||||||
const size_t numCells = Opm::UgGridHelpers::numCells(grid());
|
const size_t numCells = Opm::UgGridHelpers::numCells(grid());
|
||||||
const bool handle_ms_well = (param_.use_multisegment_well_ && anyMSWellOpenLocal());
|
const bool handle_ms_well = (param_.use_multisegment_well_ && anyMSWellOpenLocal());
|
||||||
this->wellState().resize(wells_ecl_, local_parallel_well_info_, schedule(), handle_ms_well, numCells, phaseUsage, well_perf_data_, summaryState, globalNumWells); // Resize for restart step
|
this->wellState().resize(wells_ecl_, local_parallel_well_info_, schedule(), handle_ms_well, numCells, phaseUsage, well_perf_data_, summaryState, globalNumWells); // Resize for restart step
|
||||||
wellsToState(restartValues.wells, restartValues.grp_nwrk, phaseUsage, handle_ms_well, this->wellState());
|
loadRestartData(restartValues.wells, restartValues.grp_nwrk, phaseUsage, handle_ms_well, this->wellState());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->commitWellState();
|
this->commitWellState();
|
||||||
@ -1865,11 +1865,11 @@ namespace Opm {
|
|||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
void
|
void
|
||||||
BlackoilWellModel<TypeTag>::
|
BlackoilWellModel<TypeTag>::
|
||||||
wellsToState( const data::Wells& wells,
|
loadRestartData( const data::Wells& rst_wells,
|
||||||
const data::GroupAndNetworkValues& grpNwrkValues,
|
const data::GroupAndNetworkValues& grpNwrkValues,
|
||||||
const PhaseUsage& phases,
|
const PhaseUsage& phases,
|
||||||
const bool handle_ms_well,
|
const bool handle_ms_well,
|
||||||
WellStateFullyImplicitBlackoil& state) const
|
WellStateFullyImplicitBlackoil& state) const
|
||||||
{
|
{
|
||||||
using GPMode = Group::ProductionCMode;
|
using GPMode = Group::ProductionCMode;
|
||||||
using GIMode = Group::InjectionCMode;
|
using GIMode = Group::InjectionCMode;
|
||||||
@ -1892,50 +1892,38 @@ namespace Opm {
|
|||||||
|
|
||||||
for( const auto& wm : state.wellMap() ) {
|
for( const auto& wm : state.wellMap() ) {
|
||||||
const auto well_index = wm.second[ 0 ];
|
const auto well_index = wm.second[ 0 ];
|
||||||
const auto& well = wells.at( wm.first );
|
const auto& rst_well = rst_wells.at( wm.first );
|
||||||
state.bhp()[ well_index ] = well.bhp;
|
state.bhp()[ well_index ] = rst_well.bhp;
|
||||||
state.temperature()[ well_index ] = well.temperature;
|
state.temperature()[ well_index ] = rst_well.temperature;
|
||||||
|
|
||||||
if (well.current_control.isProducer) {
|
if (rst_well.current_control.isProducer) {
|
||||||
state.currentProductionControls()[ well_index ] = well.current_control.prod;
|
state.currentProductionControls()[ well_index ] = rst_well.current_control.prod;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
state.currentInjectionControls()[ well_index ] = well.current_control.inj;
|
state.currentInjectionControls()[ well_index ] = rst_well.current_control.inj;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto wellrate_index = well_index * np;
|
const auto wellrate_index = well_index * np;
|
||||||
for( size_t i = 0; i < phs.size(); ++i ) {
|
for( size_t i = 0; i < phs.size(); ++i ) {
|
||||||
assert( well.rates.has( phs[ i ] ) );
|
assert( rst_well.rates.has( phs[ i ] ) );
|
||||||
state.wellRates()[ wellrate_index + i ] = well.rates.get( phs[ i ] );
|
state.wellRates()[ wellrate_index + i ] = rst_well.rates.get( phs[ i ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto perforation_pressure = []( const data::Connection& comp ) {
|
auto * perf_pressure = state.perfPress().data() + wm.second[1];
|
||||||
return comp.pressure;
|
auto * perf_rates = state.perfRates().data() + wm.second[1];
|
||||||
};
|
auto * perf_phase_rates = state.perfPhaseRates().data() + wm.second[1]*np;
|
||||||
|
const auto& perf_data = this->well_perf_data_[well_index];
|
||||||
|
|
||||||
const auto perforation_reservoir_rate = []( const data::Connection& comp ) {
|
for (std::size_t perf_index = 0; perf_index < perf_data.size(); perf_index++) {
|
||||||
return comp.reservoir_rate;
|
const auto& pd = perf_data[perf_index];
|
||||||
};
|
const auto& rst_connection = rst_well.connections[pd.ecl_index];
|
||||||
std::transform( well.connections.begin(),
|
perf_pressure[perf_index] = rst_connection.pressure;
|
||||||
well.connections.end(),
|
perf_rates[perf_index] = rst_connection.reservoir_rate;
|
||||||
state.perfPress().begin() + wm.second[ 1 ],
|
for (int phase_index = 0; phase_index < np; ++phase_index)
|
||||||
perforation_pressure );
|
perf_phase_rates[perf_index*np + phase_index] = rst_connection.rates.get(phs[phase_index]);
|
||||||
|
|
||||||
std::transform( well.connections.begin(),
|
|
||||||
well.connections.end(),
|
|
||||||
state.perfRates().begin() + wm.second[ 1 ],
|
|
||||||
perforation_reservoir_rate );
|
|
||||||
|
|
||||||
int local_comp_index = 0;
|
|
||||||
for (const data::Connection& comp : well.connections) {
|
|
||||||
const int global_comp_index = wm.second[1] + local_comp_index;
|
|
||||||
for (int phase_index = 0; phase_index < np; ++phase_index) {
|
|
||||||
state.perfPhaseRates()[global_comp_index*np + phase_index] = comp.rates.get(phs[phase_index]);
|
|
||||||
}
|
|
||||||
++local_comp_index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle_ms_well && !well.segments.empty()) {
|
if (handle_ms_well && !rst_well.segments.empty()) {
|
||||||
// we need the well_ecl_ information
|
// we need the well_ecl_ information
|
||||||
const std::string& well_name = wm.first;
|
const std::string& well_name = wm.first;
|
||||||
const Well& well_ecl = getWellEcl(well_name);
|
const Well& well_ecl = getWellEcl(well_name);
|
||||||
@ -1943,7 +1931,7 @@ namespace Opm {
|
|||||||
const WellSegments& segment_set = well_ecl.getSegments();
|
const WellSegments& segment_set = well_ecl.getSegments();
|
||||||
|
|
||||||
const int top_segment_index = state.topSegmentIndex(well_index);
|
const int top_segment_index = state.topSegmentIndex(well_index);
|
||||||
const auto& segments = well.segments;
|
const auto& segments = rst_well.segments;
|
||||||
|
|
||||||
// \Note: eventually we need to hanlde the situations that some segments are shut
|
// \Note: eventually we need to hanlde the situations that some segments are shut
|
||||||
assert(0u + segment_set.size() == segments.size());
|
assert(0u + segment_set.size() == segments.size());
|
||||||
|
Loading…
Reference in New Issue
Block a user