mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #840 from jokva/output-data-wells-sans-vectors
WIP: Output data wells sans vectors
This commit is contained in:
commit
77abb6de1c
@ -21,6 +21,9 @@
|
||||
#ifndef OPM_SIMULATORS_COMPAT_HPP
|
||||
#define OPM_SIMULATORS_COMPAT_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include <opm/common/data/SimulationDataContainer.hpp>
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
#include <opm/core/simulator/BlackoilState.hpp>
|
||||
@ -167,14 +170,59 @@ inline void solutionToSim( const data::Solution& sol,
|
||||
|
||||
|
||||
|
||||
inline void wellsToState( const data::Wells& wells,
|
||||
PhaseUsage phases,
|
||||
WellState& state ) {
|
||||
|
||||
using rt = data::Rates::opt;
|
||||
|
||||
inline void wellsToState( const data::Wells& wells, WellState& state ) {
|
||||
state.bhp() = wells.bhp;
|
||||
state.temperature() = wells.temperature;
|
||||
state.wellRates() = wells.well_rate;
|
||||
state.perfPress() = wells.perf_pressure;
|
||||
state.perfRates() = wells.perf_rate;
|
||||
const auto np = phases.num_phases;
|
||||
|
||||
std::vector< rt > phs( np );
|
||||
if( phases.phase_used[BlackoilPhases::Aqua] ) {
|
||||
phs.at( phases.phase_pos[BlackoilPhases::Aqua] ) = rt::wat;
|
||||
}
|
||||
|
||||
if( phases.phase_used[BlackoilPhases::Liquid] ) {
|
||||
phs.at( phases.phase_pos[BlackoilPhases::Liquid] ) = rt::oil;
|
||||
}
|
||||
|
||||
if( phases.phase_used[BlackoilPhases::Vapour] ) {
|
||||
phs.at( phases.phase_pos[BlackoilPhases::Vapour] ) = rt::gas;
|
||||
}
|
||||
|
||||
for( const auto& wm : state.wellMap() ) {
|
||||
const auto well_index = wm.second[ 0 ];
|
||||
const auto& well = wells.at( wm.first );
|
||||
|
||||
state.bhp()[ well_index ] = well.bhp;
|
||||
state.temperature()[ well_index ] = well.temperature;
|
||||
|
||||
const auto wellrate_index = well_index * np;
|
||||
for( size_t i = 0; i < phs.size(); ++i ) {
|
||||
assert( well.rates.has( phs[ i ] ) );
|
||||
state.wellRates()[ wellrate_index + i ] = well.rates.get( phs[ i ] );
|
||||
}
|
||||
|
||||
using PerfPairTypeAlias = decltype( *well.completions.begin() );
|
||||
const auto perforation_pressure = []( const PerfPairTypeAlias& p ) {
|
||||
return p.second.pressure;
|
||||
};
|
||||
|
||||
const auto perforation_reservoir_rate = []( const PerfPairTypeAlias& p ) {
|
||||
return p.second.reservoir_rate;
|
||||
};
|
||||
|
||||
std::transform( well.completions.begin(),
|
||||
well.completions.end(),
|
||||
state.perfPress().begin() + wm.second[ 1 ],
|
||||
perforation_pressure );
|
||||
|
||||
std::transform( well.completions.begin(),
|
||||
well.completions.end(),
|
||||
state.perfRates().begin() + wm.second[ 1 ],
|
||||
perforation_reservoir_rate );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ namespace Opm
|
||||
Opm::UgGridHelpers::numCells(grid) );
|
||||
|
||||
solutionToSim( restarted.first, phaseusage, simulatorstate );
|
||||
wellsToState( restarted.second, wellstate );
|
||||
wellsToState( restarted.second, phaseusage, wellstate );
|
||||
}
|
||||
|
||||
|
||||
|
@ -196,9 +196,23 @@ namespace Opm
|
||||
data::Wells res = WellState::report(pu);
|
||||
|
||||
const int nw = this->numWells();
|
||||
// If there are now wells numPhases throws a floating point
|
||||
// exception.
|
||||
const int np = nw ? this->numPhases() : -1;
|
||||
if( nw == 0 ) return res;
|
||||
const int np = pu.num_phases;
|
||||
|
||||
|
||||
using rt = data::Rates::opt;
|
||||
std::vector< rt > phs( np );
|
||||
if( pu.phase_used[BlackoilPhases::Aqua] ) {
|
||||
phs.at( pu.phase_pos[BlackoilPhases::Aqua] ) = rt::wat;
|
||||
}
|
||||
|
||||
if( pu.phase_used[BlackoilPhases::Liquid] ) {
|
||||
phs.at( pu.phase_pos[BlackoilPhases::Liquid] ) = rt::oil;
|
||||
}
|
||||
|
||||
if( pu.phase_used[BlackoilPhases::Vapour] ) {
|
||||
phs.at( pu.phase_pos[BlackoilPhases::Vapour] ) = rt::gas;
|
||||
}
|
||||
|
||||
/* this is a reference or example on **how** to convert from
|
||||
* WellState to something understood by opm-output. it is intended
|
||||
@ -207,47 +221,22 @@ namespace Opm
|
||||
* representations.
|
||||
*/
|
||||
|
||||
for( auto w = 0; w < nw; ++w ) {
|
||||
using rt = data::Rates::opt;
|
||||
std::map< size_t, data::Completion > completions;
|
||||
for( const auto& wt : this->wellMap() ) {
|
||||
const auto w = wt.second[ 0 ];
|
||||
auto& well = res.at( wt.first );
|
||||
well.control = this->currentControls()[ w ];
|
||||
|
||||
// completions aren't supported yet
|
||||
//const auto* begin = wells_->well_connpos + w;
|
||||
//const auto* end = wells_->well_connpos + w + 1;
|
||||
//for( auto* i = begin; i != end; ++i ) {
|
||||
// const auto perfrate = this->perfPhaseRates().begin() + *i;
|
||||
// data::Rates perfrates;
|
||||
// perfrates.set( rt::wat, *(perfrate + 0) );
|
||||
// perfrates.set( rt::oil, *(perfrate + 1) );
|
||||
// perfrates.set( rt::gas, *(perfrate + 2) );
|
||||
int local_comp_index = 0;
|
||||
for( auto& cpair : well.completions ) {
|
||||
const auto rates = this->perfPhaseRates().begin()
|
||||
+ (np * wt.second[ 1 ])
|
||||
+ (np * local_comp_index);
|
||||
++local_comp_index;
|
||||
|
||||
// const size_t active_index = wells_->well_cells[ *i ];
|
||||
|
||||
// completions.emplace( active_index,
|
||||
// data::Completion{ active_index, perfrates } );
|
||||
//}
|
||||
|
||||
const auto wellrate_index = np * w;
|
||||
const auto& wv = this->wellRates();
|
||||
|
||||
data::Rates wellrates;
|
||||
if( pu.phase_used[BlackoilPhases::Aqua] ) {
|
||||
wellrates.set( rt::wat, wv[ wellrate_index + pu.phase_pos[BlackoilPhases::Aqua] ] );
|
||||
for( int i = 0; i < np; ++i ) {
|
||||
cpair.second.rates.set( phs[ i ], *(rates + i) );
|
||||
}
|
||||
}
|
||||
|
||||
if( pu.phase_used[BlackoilPhases::Liquid] ) {
|
||||
wellrates.set( rt::oil, wv[ wellrate_index + pu.phase_pos[BlackoilPhases::Liquid] ] );
|
||||
}
|
||||
|
||||
if( pu.phase_used[BlackoilPhases::Vapour] ) {
|
||||
wellrates.set( rt::gas, wv[ wellrate_index + pu.phase_pos[BlackoilPhases::Vapour] ] );
|
||||
}
|
||||
|
||||
const double bhp = this->bhp()[ w ];
|
||||
const double thp = this->thp()[ w ];
|
||||
|
||||
res.emplace( wells_->name[ w ],
|
||||
data::Well { wellrates, bhp, thp, std::move( completions ) } );
|
||||
}
|
||||
|
||||
return res;
|
||||
|
Loading…
Reference in New Issue
Block a user