adding isProducer() and isProjector() to wellNode class.

Did not see type() function there, while it should still be a okay idea.
This commit is contained in:
Kai Bao 2016-10-07 13:37:35 +02:00
parent 7926a58fae
commit 86e41a8937
2 changed files with 22 additions and 6 deletions

View File

@ -701,7 +701,7 @@ namespace Opm
// Report on our rates.
const int np = phaseUsage().num_phases;
for (int phase = 0; phase < np; ++phase) {
if (wells_->type[self_index_] == INJECTOR) {
if (isInjector()) {
summed_phases.res_inj_rates[phase] = well_reservoirrates_phase[np*self_index_ + phase];
summed_phases.surf_inj_rates[phase] = well_surfacerates_phase[np*self_index_ + phase];
} else {
@ -711,7 +711,6 @@ namespace Opm
}
// Check constraints.
bool is_producer = (wells_->type[self_index_] == PRODUCER);
const WellControls * ctrls = wells_->ctrls[self_index_];
for (int ctrl_index = 0; ctrl_index < well_controls_get_num(ctrls); ++ctrl_index) {
if (ctrl_index == well_controls_get_current(ctrls) || ctrl_index == group_control_index_) {
@ -725,7 +724,7 @@ namespace Opm
case BHP: {
const double my_well_bhp = well_bhp[self_index_];
const double my_target_bhp = well_controls_iget_target( ctrls , ctrl_index);
ctrl_violated = is_producer ? (my_target_bhp > my_well_bhp)
ctrl_violated = isProducer() ? (my_target_bhp > my_well_bhp)
: (my_target_bhp < my_well_bhp);
if (ctrl_violated) {
OpmLog::info("BHP limit violated for well " + name() + ":\n"
@ -859,7 +858,7 @@ namespace Opm
// && (injSpec().control_mode_ != InjectionSpecification::GRUP && injSpec().control_mode_ != InjectionSpecification::NONE)) {
// return;
// }
if (wells_->type[self_index_] != INJECTOR) {
if ( !isInjector() ) {
assert(target == 0.0);
return;
}
@ -904,7 +903,7 @@ namespace Opm
double WellNode::getTotalProductionFlow(const std::vector<double>& phase_flows,
const BlackoilPhases::PhaseIndex phase)
{
if (type() == INJECTOR) {
if (isInjector()) {
return 0.0;
}
return phase_flows[self_index_*phaseUsage().num_phases + phaseUsage().phase_pos[phase]];
@ -938,7 +937,7 @@ namespace Opm
std::cout << "Returning" << std::endl;
return;
} */
if (wells_->type[self_index_] != PRODUCER) {
if ( !isProducer() ) {
// assert(target == 0.0);
return;
}
@ -1056,6 +1055,19 @@ namespace Opm
}
/// Returing whether the well is a producer
bool WellNode::isProducer() const
{
return (type() == PRODUCER);
}
/// Returing whether the well is a injector
bool WellNode::isInjector() const
{
return (type() == INJECTOR);
}
namespace
{

View File

@ -420,6 +420,10 @@ namespace Opm
const std::vector<double>& well_surfacerates_phase);
int groupControlIndex() const;
bool isProducer() const;
bool isInjector() const;
private:
Wells* wells_;
int self_index_;