removing the use of cast between base class and derived class
between WellsGroupInterface and WellsGroup, WellNode.
This commit is contained in:
parent
32e9b26ce8
commit
352c185edf
@ -271,8 +271,7 @@ namespace Opm
|
|||||||
// find a node needs to update targets, then update targets for all the wellls inside the group.
|
// find a node needs to update targets, then update targets for all the wellls inside the group.
|
||||||
// if (leaf_nodes_[i]->shouldUpdateWellTargets() && !leaf_nodes_[i]->individualControl()) {
|
// if (leaf_nodes_[i]->shouldUpdateWellTargets() && !leaf_nodes_[i]->individualControl()) {
|
||||||
if (!leaf_nodes_[i]->individualControl()) {
|
if (!leaf_nodes_[i]->individualControl()) {
|
||||||
// TODO: will remove dynamic_cast with interface revision.
|
WellsGroupInterface* parent_node = leaf_nodes_[i]->getParent();
|
||||||
WellsGroup* parent_node = dynamic_cast<Opm::WellsGroup *>(leaf_nodes_[i]->getParent());
|
|
||||||
// update the target within this group.
|
// update the target within this group.
|
||||||
if (leaf_nodes_[i]->isProducer()) {
|
if (leaf_nodes_[i]->isProducer()) {
|
||||||
parent_node->updateWellProductionTargets(well_rates);
|
parent_node->updateWellProductionTargets(well_rates);
|
||||||
|
@ -246,6 +246,15 @@ namespace Opm
|
|||||||
should_update_well_targets_ = should_update_well_targets;
|
should_update_well_targets_ = should_update_well_targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WellsGroupInterface::individualControl() const {
|
||||||
|
return individual_control_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WellsGroupInterface::setIndividualControl(const bool individual_control) {
|
||||||
|
individual_control_ = individual_control;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ============== WellsGroup members =============
|
// ============== WellsGroup members =============
|
||||||
|
|
||||||
@ -687,9 +696,8 @@ namespace Opm
|
|||||||
double rate_individual_control = 0.;
|
double rate_individual_control = 0.;
|
||||||
|
|
||||||
for (size_t i = 0; i < children_.size(); ++i) {
|
for (size_t i = 0; i < children_.size(); ++i) {
|
||||||
const std::shared_ptr<Opm::WellNode> well_node = std::dynamic_pointer_cast<Opm::WellNode>(children_[i]);
|
if (children_[i]->individualControl() && children_[i]->isProducer()) {
|
||||||
if (well_node->individualControl() && well_node->isProducer()) {
|
rate_individual_control += std::abs(children_[i]->getLiquidProductionRate(well_rates));
|
||||||
rate_individual_control += std::abs(well_node->getLiquidProductionRate(well_rates));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,11 +706,10 @@ namespace Opm
|
|||||||
const double my_guide_rate = productionGuideRate(true);
|
const double my_guide_rate = productionGuideRate(true);
|
||||||
|
|
||||||
for (size_t i = 0; i < children_.size(); ++i) {
|
for (size_t i = 0; i < children_.size(); ++i) {
|
||||||
const std::shared_ptr<Opm::WellNode> well_node = std::dynamic_pointer_cast<Opm::WellNode>(children_[i]);
|
if (!children_[i]->individualControl() && children_[i]->isProducer()) {
|
||||||
if (!well_node->individualControl() && well_node->isProducer()) {
|
const double children_guide_rate = children_[i]->productionGuideRate(true);
|
||||||
const double children_guide_rate = well_node->productionGuideRate(true);
|
children_[i]->applyProdGroupControl(control_mode, (children_guide_rate/my_guide_rate) * rate_for_group_control, true);
|
||||||
well_node->applyProdGroupControl(control_mode, (children_guide_rate/my_guide_rate) * rate_for_group_control, true);
|
children_[i]->setShouldUpdateWellTargets(false);
|
||||||
well_node->setShouldUpdateWellTargets(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -712,19 +719,31 @@ namespace Opm
|
|||||||
// NOT doing anything yet.
|
// NOT doing anything yet.
|
||||||
// Will finish it when having an examples with more than one injection wells within same injection group.
|
// Will finish it when having an examples with more than one injection wells within same injection group.
|
||||||
for (size_t i = 0; i < children_.size(); ++i) {
|
for (size_t i = 0; i < children_.size(); ++i) {
|
||||||
if (!children_[i]->individualControl() && std::dynamic_pointer_cast<Opm::WellNode>(children_[i])->isInjector()) {
|
if (!children_[i]->individualControl() && children_[i]->isInjector()) {
|
||||||
children_[i]->setShouldUpdateWellTargets(false);
|
children_[i]->setShouldUpdateWellTargets(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool WellsGroupInterface::individualControl() const {
|
bool WellsGroup::isProducer() const
|
||||||
return individual_control_;
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void WellsGroupInterface::setIndividualControl(const bool individual_control) {
|
bool WellsGroup::isInjector() const
|
||||||
individual_control_ = individual_control;
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
double WellsGroup::getLiquidProductionRate(const std::vector<double>& /*well_rates*/) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
double WellsGroup::getOilProductionRate(const std::vector<double>& /*well_rates*/) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
double WellsGroup::getWaterProductionRate(const std::vector<double>& /*well_rates*/) const
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1136,6 +1155,13 @@ namespace Opm
|
|||||||
return getTotalProductionFlow(well_rates, BlackoilPhases::Aqua);
|
return getTotalProductionFlow(well_rates, BlackoilPhases::Aqua);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WellNode::updateWellProductionTargets(const std::vector<double>& /*well_rates*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void WellNode::updateWellInjectionTargets(const std::vector<double>& /*well_rates*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -217,6 +217,25 @@ namespace Opm
|
|||||||
|
|
||||||
virtual bool setShouldUpdateWellTargets(const bool);
|
virtual bool setShouldUpdateWellTargets(const bool);
|
||||||
|
|
||||||
|
/// Whether it is a production well
|
||||||
|
/// Should only appy for WellNode
|
||||||
|
virtual bool isProducer() const = 0;
|
||||||
|
|
||||||
|
/// Whether it is an injection well
|
||||||
|
/// Should only appy for WellNode
|
||||||
|
virtual bool isInjector() const = 0;
|
||||||
|
|
||||||
|
virtual double getLiquidProductionRate(const std::vector<double>& well_rates) const = 0;
|
||||||
|
|
||||||
|
virtual double getOilProductionRate(const std::vector<double>& well_rates) const = 0;
|
||||||
|
|
||||||
|
virtual double getWaterProductionRate(const std::vector<double>& well_rates) const = 0;
|
||||||
|
|
||||||
|
virtual void updateWellProductionTargets(const std::vector<double>& well_rates) = 0;
|
||||||
|
|
||||||
|
virtual void updateWellInjectionTargets(const std::vector<double>& well_rates) = 0;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Calculates the correct rate for the given ProductionSpecification::ControlMode
|
/// Calculates the correct rate for the given ProductionSpecification::ControlMode
|
||||||
double rateByMode(const double* res_rates,
|
double rateByMode(const double* res_rates,
|
||||||
@ -325,9 +344,23 @@ namespace Opm
|
|||||||
virtual void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
|
virtual void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
|
||||||
const std::vector<double>& well_surfacerates_phase);
|
const std::vector<double>& well_surfacerates_phase);
|
||||||
|
|
||||||
void updateWellProductionTargets(const std::vector<double>& well_rates);
|
virtual void updateWellProductionTargets(const std::vector<double>& well_rates);
|
||||||
|
|
||||||
void updateWellInjectionTargets(const std::vector<double>& well_rates);
|
virtual void updateWellInjectionTargets(const std::vector<double>& well_rates);
|
||||||
|
|
||||||
|
/// Whether it is a production well
|
||||||
|
/// Should only appy for WellNode
|
||||||
|
virtual bool isProducer() const;
|
||||||
|
|
||||||
|
/// Whether it is an injection well
|
||||||
|
/// Should only appy for WellNode
|
||||||
|
virtual bool isInjector() const;
|
||||||
|
|
||||||
|
virtual double getLiquidProductionRate(const std::vector<double>& well_rates) const;
|
||||||
|
|
||||||
|
virtual double getOilProductionRate(const std::vector<double>& well_rates) const;
|
||||||
|
|
||||||
|
virtual double getWaterProductionRate(const std::vector<double>& well_rates) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::shared_ptr<WellsGroupInterface> > children_;
|
std::vector<std::shared_ptr<WellsGroupInterface> > children_;
|
||||||
@ -422,15 +455,20 @@ namespace Opm
|
|||||||
const std::vector<double>& well_surfacerates_phase);
|
const std::vector<double>& well_surfacerates_phase);
|
||||||
int groupControlIndex() const;
|
int groupControlIndex() const;
|
||||||
|
|
||||||
bool isProducer() const;
|
virtual bool isProducer() const;
|
||||||
|
|
||||||
bool isInjector() const;
|
virtual bool isInjector() const;
|
||||||
|
|
||||||
double getLiquidProductionRate(const std::vector<double>& well_rates) const;
|
virtual double getLiquidProductionRate(const std::vector<double>& well_rates) const;
|
||||||
|
|
||||||
double getOilProductionRate(const std::vector<double>& well_rates) const;
|
virtual double getOilProductionRate(const std::vector<double>& well_rates) const;
|
||||||
|
|
||||||
|
virtual double getWaterProductionRate(const std::vector<double>& well_rates) const;
|
||||||
|
|
||||||
|
virtual void updateWellProductionTargets(const std::vector<double>& well_rates);
|
||||||
|
|
||||||
|
virtual void updateWellInjectionTargets(const std::vector<double>& well_rates);
|
||||||
|
|
||||||
double getWaterProductionRate(const std::vector<double>& well_rates) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Wells* wells_;
|
Wells* wells_;
|
||||||
|
Loading…
Reference in New Issue
Block a user