using getWellConvergence in BlackoilModelEbos

Tested with SPE1.

TODO: with the current way, we are not outputting any well residual
information. We need to address what kind of residual information we
want to output with the new well model.
This commit is contained in:
Kai Bao 2017-07-21 16:01:32 +02:00
parent ab67635134
commit f1677015fe
3 changed files with 18 additions and 23 deletions

View File

@ -909,7 +909,6 @@ namespace Opm {
Vector CNV(numComp);
Vector mass_balance_residual(numComp);
Vector well_flux_residual(numComp);
bool converged_MB = true;
bool converged_CNV = true;
@ -923,8 +922,7 @@ namespace Opm {
converged_CNV = converged_CNV && (CNV[compIdx] < tol_cnv);
// Well flux convergence is only for fluid phases, not other materials
// in our current implementation.
well_flux_residual[compIdx] = B_avg[compIdx] * maxNormWell[compIdx];
converged_Well = converged_Well && (well_flux_residual[compIdx] < tol_wells);
converged_Well = wellModel().getWellConvergence(ebosSimulator_, B_avg);
residual_norms.push_back(CNV[compIdx]);
}
@ -961,9 +959,9 @@ namespace Opm {
for (int compIdx = 0; compIdx < numComp; ++compIdx) {
msg += " CNV(" + key[ compIdx ] + ") ";
}
for (int compIdx = 0; compIdx < numComp; ++compIdx) {
/* for (int compIdx = 0; compIdx < numComp; ++compIdx) {
msg += " W-FLUX(" + key[ compIdx ] + ")";
}
} */
OpmLog::note(msg);
}
std::ostringstream ss;
@ -976,9 +974,9 @@ namespace Opm {
for (int compIdx = 0; compIdx < numComp; ++compIdx) {
ss << std::setw(11) << CNV[compIdx];
}
for (int compIdx = 0; compIdx < numComp; ++compIdx) {
ss << std::setw(11) << well_flux_residual[compIdx];
}
// for (int compIdx = 0; compIdx < numComp; ++compIdx) {
// ss << std::setw(11) << well_flux_residual[compIdx];
// }
ss.precision(oprec);
ss.flags(oflags);
OpmLog::note(ss.str());
@ -988,13 +986,13 @@ namespace Opm {
const auto& phaseName = FluidSystem::phaseName(flowPhaseToEbosPhaseIdx(phaseIdx));
if (std::isnan(mass_balance_residual[phaseIdx])
|| std::isnan(CNV[phaseIdx])
|| (phaseIdx < numPhases() && std::isnan(well_flux_residual[phaseIdx]))) {
|| std::isnan(CNV[phaseIdx])) {
// || (phaseIdx < numPhases() && std::isnan(well_flux_residual[phaseIdx]))) {
OPM_THROW(Opm::NumericalProblem, "NaN residual for phase " << phaseName);
}
if (mass_balance_residual[phaseIdx] > maxResidualAllowed()
|| CNV[phaseIdx] > maxResidualAllowed()
|| (phaseIdx < numPhases() && well_flux_residual[phaseIdx] > maxResidualAllowed())) {
|| CNV[phaseIdx] > maxResidualAllowed()) {
// || (phaseIdx < numPhases() && well_flux_residual[phaseIdx] > maxResidualAllowed())) {
OPM_THROW(Opm::NumericalProblem, "Too large residual for phase " << phaseName);
}
}

View File

@ -236,7 +236,7 @@ enum WellVariablePositions {
std::vector<double> residual() const;
bool getWellConvergence(Simulator& ebosSimulator,
const int iteration) const;
const std::vector<Scalar>& B_avg) const;
void computeWellConnectionPressures(const Simulator& ebosSimulator,
const WellState& xw);

View File

@ -901,11 +901,16 @@ namespace Opm {
const int nw = wells().number_of_wells;
WellState well_state0 = well_state;
const int numComp = numComponents();
std::vector< Scalar > B_avg( numComp, Scalar() );
computeAverageFormationFactor(ebosSimulator, B_avg);
int it = 0;
bool converged;
do {
assembleWellEq(ebosSimulator, dt, well_state, true);
converged = getWellConvergence(ebosSimulator, it);
converged = getWellConvergence(ebosSimulator, B_avg);
// checking whether the group targets are converged
if (wellCollection()->groupControlActive()) {
@ -998,16 +1003,8 @@ namespace Opm {
bool
StandardWellsDense<TypeTag>::
getWellConvergence(Simulator& ebosSimulator,
const int iteration) const
const std::vector<Scalar>& B_avg) const
{
typedef double Scalar;
typedef std::vector< Scalar > Vector;
const int numComp = numComponents();
std::vector< Scalar > B_avg( numComp, Scalar() );
computeAverageFormationFactor(ebosSimulator, B_avg);
bool converged_well = true;
// TODO: to check the strategy here