Merge branch 'fix_cmax' into wpolymer_schedule

This commit is contained in:
Liu Ming 2014-12-08 10:02:38 +08:00
commit 953cddce98
4 changed files with 14 additions and 27 deletions

View File

@ -135,12 +135,7 @@ namespace Opm
if (ads_index_ == Desorption) {
simpleAdsorptionBoth(c, c_ads, dc_ads_dc, if_with_der);
} else if (ads_index_ == NoDesorption) {
if (c < cmax) {
simpleAdsorption(cmax, c_ads);
dc_ads_dc = 0.;
} else {
simpleAdsorptionBoth(c, c_ads, dc_ads_dc, if_with_der);
}
simpleAdsorptionBoth(std::max(c, cmax), c_ads, dc_ads_dc, if_with_der);
} else {
OPM_THROW(std::runtime_error, "Invalid Adsoption index");
}

View File

@ -257,8 +257,7 @@ namespace Opm {
const SolutionState& state);
void
computeCmax(PolymerBlackoilState& state,
const ADB& c);
computeCmax(PolymerBlackoilState& state);
ADB
computeMc(const SolutionState& state) const;

View File

@ -275,15 +275,16 @@ namespace {
{
const V pvdt = geo_.poreVolume() / dt;
// Initial max concentration of this time step from PolymerBlackoilState.
cmax_ = Eigen::Map<V>(&x.maxconcentration()[0], Opm::AutoDiffGrid::numCells(grid_));
if (active_[Gas]) { updatePrimalVariableFromState(x); }
{
const SolutionState state = constantState(x, xw);
computeCmax(x, state.concentration);
computeAccum(state, 0);
computeWellConnectionPressures(state, xw);
}
std::vector<std::vector<double>> residual_history;
assemble(pvdt, x, xw, polymer_inflow);
@ -342,6 +343,8 @@ namespace {
std::cerr << "Failed to compute converged solution in " << it << " iterations. Ignoring!\n";
// OPM_THROW(std::runtime_error, "Failed to compute converged solution in " << it << " iterations.");
}
// Update max concentration.
computeCmax(x);
}
@ -647,14 +650,14 @@ namespace {
template<class T>
void FullyImplicitBlackoilPolymerSolver<T>::computeCmax(PolymerBlackoilState& state,
const ADB& c)
void FullyImplicitBlackoilPolymerSolver<T>::computeCmax(PolymerBlackoilState& state)
{
const int nc = AutoDiffGrid::numCells(grid_);
V tmp = V::Zero(nc);
for (int i = 0; i < nc; ++i) {
cmax_(i) = std::max(cmax_(i), c.value()(i));
tmp[i] = std::max(state.maxconcentration()[i], state.concentration()[i]);
}
std::copy(&cmax_[0], &cmax_[0] + nc, state.maxconcentration().begin());
std::copy(&tmp[0], &tmp[0] + nc, state.maxconcentration().begin());
}

View File

@ -233,9 +233,8 @@ namespace Opm {
double res_factor = polymer_props_.resFactor();
double factor = (res_factor -1.) / max_ads;
V rk = one + factor * ads;
V krw_eff = krw / rk;
return krw_eff;
return krw / rk;
}
@ -257,17 +256,8 @@ namespace Opm {
double res_factor = polymer_props_.resFactor();
double factor = (res_factor - 1.) / max_ads;
ADB rk = one + ads * factor;
ADB dkrw_ds = krw / rk;
ADB dkrw_dc = -factor * krw / (rk * rk) * ads ;
const int num_blocks = c.numBlocks();
std::vector<ADB::M> jacs(num_blocks);
for (int block = 0; block < num_blocks; ++block) {
jacs[block] = dkrw_ds.derivative()[block] * sw.derivative()[block]
+ dkrw_dc.derivative()[block] * c.derivative()[block];
}
return ADB::function(krw_eff, jacs);
return krw / rk;
}
}// namespace Opm