putting more things in the prototyping test.

This commit is contained in:
Kai Bao 2016-10-06 18:00:36 +02:00
parent e0dd9bfabd
commit e323f15d2f
3 changed files with 44 additions and 4 deletions

View File

@ -1043,6 +1043,7 @@ namespace detail {
int it = 0;
bool converged;
do {
std::cout << "in solveWellEq " << std::endl;
// bhp and Q for the wells
std::vector<V> vars0;
vars0.reserve(2);
@ -1057,6 +1058,17 @@ namespace detail {
asImpl().wellModel().addWellControlEq(wellSolutionState, well_state, aliveWells, residual_);
converged = getWellConvergence(it);
if (asImpl().wellModel().justUpdateWellTargets()) {
std::cout << "converged changed to false due to justUpdateWellTargets " << std::endl;
converged = false;
asImpl().wellModel().setJustUpdateWellTargets(false);
}
if (converged && asImpl().wellModel().needUpdateWellTargets()) {
std::cout << "converged changed to false due to needUpdateWellTargets " << std::endl;
converged = false;
}
if (converged) {
break;
}
@ -1078,6 +1090,9 @@ namespace detail {
const Eigen::VectorXd& dx = solver.solve(total_residual_v.matrix());
assert(dx.size() == total_residual_v.size());
asImpl().wellModel().updateWellState(dx.array(), dpMaxRel(), well_state);
std::cout << "after updateWellState " << std::endl;
asImpl().wellModel().updateWellControls(well_state);
std::cout << " justUpdateWellTargets " << asImpl().wellModel().justUpdateWellTargets() << std::endl;
}
// We have to update the well controls regardless whether there are local
// wells active or not as parallel logging will take place that needs to
@ -1118,6 +1133,7 @@ namespace detail {
}
const bool failed = false; // Not needed in this method.
const int linear_iters = 0; // Not needed in this method
std::cout << " end of solveWellEq " << std::endl;
return IterationReport{failed, converged, linear_iters, it};
}

View File

@ -191,6 +191,18 @@ namespace Opm {
const WellState& well_state,
DynamicListEconLimited& list_econ_limited) const;
bool justUpdateWellTargets() const {
return well_collection_->justUpdateWellTargets();
}
bool needUpdateWellTargets() const {
return well_collection_->needUpdateWellTargets();
}
void setJustUpdateWellTargets(const bool flag) const {
well_collection_->setJustUpdateWellTargets(flag);
}
protected:
bool wells_active_;
const Wells* wells_;

View File

@ -711,10 +711,11 @@ namespace Opm
if( !localWellsActive() ) return ;
std::cout << " StandardWells updateWellControls " << std::endl;
if (well_collection_->needUpdateWellTargets() ) {
well_collection_->updateWellTargets(xw);
std::cout << " well_collection_ need to update well targets " << std::endl;
std::cin.ignore();
well_collection_->updateWellTargets(xw);
for (size_t i = 0; i < well_collection_->numNode(); ++i) {
well_collection_->getNode(i)->setShouldUpdateWellTargets(false);
}
@ -790,17 +791,28 @@ namespace Opm
if (ctrl_index == well_node->groupControlIndex()) {
std::cout << "well " << well_node->name() << " is switching from individual control to group control " << std::endl;
well_node->setIndividualControl(false);
well_node->setShouldUpdateWellTargets(true);
std::cout << "well_name " << well_node->name() << " should update well target? " << well_node->shouldUpdateWellTargets() << std::endl;
}
} else {
if (ctrl_index != well_node->groupControlIndex()) {
well_node->setIndividualControl(true);
std::cout << "well " << well_node->name() << " is switching from group control to individual control " << std::endl;
well_node->setShouldUpdateWellTargets(true);
std::cout << "well_name " << well_node->name() << " should update well target? " << well_node->shouldUpdateWellTargets() << std::endl;
}
}
well_node->setShouldUpdateWellTargets(true);
} else {
// no constraints got broken
// the wells running under group control should set to be under group control
auto* well_node = dynamic_cast<Opm::WellNode *>(well_collection_->findNode(std::string(wells().name[w])));
if (well_node->individualControl()) {
if (current == well_node->groupControlIndex()) {
well_node->setIndividualControl(false);
}
}
}
// Updating well state and primary variables.
// Target values are used as initial conditions for BHP, THP, and SURFACE_RATE
const double target = well_controls_iget_target(wc, current);