Minor performance improvement for non-VFP runs

This commit is contained in:
babrodtk 2015-08-18 10:24:57 +02:00
parent 3fddf86eef
commit 139071d39e
5 changed files with 57 additions and 13 deletions

View File

@ -374,6 +374,8 @@ namespace Opm {
bool getWellConvergence(const int iteration);
bool isVFPActive(const WellState& well_state) const;
std::vector<ADB>
computePressures(const ADB& po,
const ADB& sw,

View File

@ -774,17 +774,14 @@ namespace detail {
{
using namespace Opm::AutoDiffGrid;
if (true) {
// Create the primary variables.
// If we have VFP tables, we need the well connection
// pressures for the "simple" hydrostatic correction
// between well depth and vfp table depth.
if (isVFPActive(well_state)) {
SolutionState state = asImpl().variableState(reservoir_state, well_state);
if (true || initial_assembly) {
// Create the (constant, derivativeless) initial state.
SolutionState state0 = state;
asImpl().makeConstantState(state0);
computeWellConnectionPressures(state0, well_state);
}
SolutionState state0 = state;
asImpl().makeConstantState(state0);
computeWellConnectionPressures(state0, well_state);
}
// Possibly switch well controls and updating well state to
@ -845,7 +842,7 @@ namespace detail {
asImpl().updatePerfPhaseRatesAndPressures(cq_s, state, well_state);
asImpl().addWellFluxEq(cq_s, state);
asImpl().addWellContributionToMassBalanceEq(cq_s, state, well_state);
addWellControlEq(state, well_state, aliveWells);
addWellControlEq(state, well_state, aliveWells);
}
@ -1211,6 +1208,37 @@ namespace detail {
} //Namespace
template <class Grid, class Implementation>
bool BlackoilModelBase<Grid, Implementation>::isVFPActive(const WellState& xw) const
{
if( ! wellsActive() ) {
return false;
}
if ( vfp_properties_->getProd()->empty() && vfp_properties_->getInj()->empty() ) {
return false;
}
const int nw = wells().number_of_wells;
//Loop over all wells
for (int w = 0; w < nw; ++w) {
const WellControls* wc = wells().ctrls[w];
const int nwc = well_controls_get_num(wc);
//Loop over all controls
for (int c=0; c < nwc; ++c) {
const WellControlType ctrl_type = well_controls_iget_type(wc, c);
if (ctrl_type == THP) {
return true;
}
}
}
return false;
}
template <class Grid, class Implementation>
void BlackoilModelBase<Grid, Implementation>::updateWellControls(WellState& xw) const

View File

@ -132,6 +132,13 @@ public:
*/
const VFPInjTable* getTable(const int table_id) const;
/**
* Returns true if no vfp tables are in the current map
*/
inline const bool empty() const {
return m_tables.empty();
}
private:
// Map which connects the table number with the table itself
std::map<int, const VFPInjTable*> m_tables;

View File

@ -143,6 +143,13 @@ public:
*/
const VFPProdTable* getTable(const int table_id) const;
/**
* Returns true if no vfp tables are in the current map
*/
inline const bool empty() const {
return m_tables.empty();
}
private:
// Map which connects the table number with the table itself
std::map<int, const VFPProdTable*> m_tables;

View File

@ -58,14 +58,14 @@ public:
/**
* Returns the VFP properties for injection wells
*/
const VFPInjProperties* getInj() const {
inline const VFPInjProperties* getInj() const {
return m_inj.get();
}
/**
* Returns the VFP properties for production wells
*/
const VFPProdProperties* getProd() const {
inline const VFPProdProperties* getProd() const {
return m_prod.get();
}