Merge pull request #229 from totto82/output_conv

Output the total mass balance residual
This commit is contained in:
Atgeirr Flø Rasmussen 2014-11-10 15:58:33 +01:00
commit 47fa31a69c
2 changed files with 20 additions and 19 deletions

View File

@ -328,7 +328,7 @@ namespace Opm {
/// Compute convergence based on total mass balance (tol_mb) and maximum
/// residual mass balance (tol_cnv).
bool getConvergence(const double dt);
bool getConvergence(const double dt, const int iteration);
void detectNewtonOscillations(const std::vector<std::vector<double>>& residual_history,
const int it, const double relaxRelTol,

View File

@ -285,17 +285,11 @@ namespace {
bool converged = false;
double omega = 1.;
const double r0 = residualNorm();
residual_history.push_back(residuals());
converged = getConvergence(dt);
int it = 0;
std::cout << "\nIteration Residual\n"
<< std::setw(9) << it << std::setprecision(9)
<< std::setw(18) << r0 << std::endl;
converged = getConvergence(dt,it);
const int sizeNonLinear = residual_.sizeNonLinear();
V dxOld = V::Zero(sizeNonLinear);
@ -325,16 +319,12 @@ namespace {
assemble(pvdt, x, xw);
const double r = residualNorm();
residual_history.push_back(residuals());
converged = getConvergence(dt);
// increase iteration counter
++it;
std::cout << std::setw(9) << it << std::setprecision(9)
<< std::setw(18) << r << std::endl;
converged = getConvergence(dt,it);
}
if (!converged) {
@ -1816,7 +1806,7 @@ namespace {
template<class T>
bool
FullyImplicitBlackoilSolver<T>::getConvergence(const double dt)
FullyImplicitBlackoilSolver<T>::getConvergence(const double dt, const int iteration)
{
const double tol_mb = 1.0e-7;
const double tol_cnv = 1.0e-3;
@ -1879,11 +1869,13 @@ namespace {
RG_sum = RG.sum();
}
double tempValue = tol_mb * pvSum /dt;
const double mass_balance_residual_water = fabs(BW_avg*RW_sum) * pvSum / dt;
const double mass_balance_residual_oil = fabs(BO_avg*RO_sum) * pvSum / dt;
const double mass_balance_residual_gas = fabs(BG_avg*RG_sum) * pvSum / dt;
bool converged_MB = (fabs(BW_avg*RW_sum) < tempValue)
&& (fabs(BO_avg*RO_sum) < tempValue)
&& (fabs(BG_avg*RG_sum) < tempValue);
bool converged_MB = (mass_balance_residual_water < tol_mb)
&& (mass_balance_residual_oil< tol_mb)
&& (mass_balance_residual_gas < tol_mb);
bool converged_CNV = (CNVW < tol_cnv) && (CNVO < tol_cnv) && (CNVG < tol_cnv);
@ -1894,6 +1886,15 @@ namespace {
bool converged = converged_MB && converged_CNV && converged_Well;
std::cout << "\nIteration OIL WATER GAS WELL-FLOW WELL-CONTROL\n"
<< std::setw(9) << iteration << std::setprecision(4)
<< std::setw(13) << mass_balance_residual_water
<< std::setw(13) << mass_balance_residual_oil
<< std::setw(13) << mass_balance_residual_gas
<< std::setw(13) << residualWellFlux
<< std::setw(13) << residualWell
<< std::endl;
#ifdef OPM_VERBOSE
std::cout << " CNVW " << CNVW << " CNVO " << CNVO << " CNVG " << CNVG << std::endl;
std::cout << " converged_MB " << converged_MB << " converged_CNV " << converged_CNV