Implement residualNorm()

This is a prerequisite to having a working Newton loop.
This commit is contained in:
Bård Skaflestad 2013-05-24 11:28:36 +02:00
parent 12e4557b08
commit 604f8666a6

View File

@ -29,6 +29,8 @@
#include <opm/core/utility/ErrorMacros.hpp> #include <opm/core/utility/ErrorMacros.hpp>
#include <cmath>
namespace { namespace {
std::vector<int> std::vector<int>
buildAllCells(const int nc) buildAllCells(const int nc)
@ -153,18 +155,18 @@ namespace Opm {
computeAccum(state, 0); computeAccum(state, 0);
} }
#if 0
const double atol = 1.0e-15; const double atol = 1.0e-15;
#if 0
const double rtol = 5.0e-10; const double rtol = 5.0e-10;
const int maxit = 15; const int maxit = 15;
#endif #endif
assemble(dtpv, x); assemble(dtpv, x);
#if 0
const double r0 = residualNorm(); const double r0 = residualNorm();
int it = 0;
bool resTooLarge = r0 > atol; bool resTooLarge = r0 > atol;
#if 0
int it = 0;
while (resTooLarge && (it < maxit)) { while (resTooLarge && (it < maxit)) {
solveJacobianSystem(x); solveJacobianSystem(x);
@ -176,11 +178,10 @@ namespace Opm {
it += 1; it += 1;
} }
#endif
if (resTooLarge) { if (resTooLarge) {
THROW("Failed to compute converge solution"); THROW("Failed to compute converge solution");
} }
#endif
} }
private: private:
@ -465,6 +466,21 @@ namespace Opm {
rq_[ actph ].mflux = upwind.select(b * mob) * head; rq_[ actph ].mflux = upwind.select(b * mob) * head;
} }
double
residualNorm() const
{
double r = 0;
for (std::vector<ADB>::const_iterator
b = residual_.reservoir.begin(),
e = residual_.reservoir.end();
b != e; ++b)
{
r = std::max(r, (*b).value().matrix().norm());
}
return r;
}
ADB ADB
fluidViscosity(const int phase, fluidViscosity(const int phase,
const ADB& p , const ADB& p ,