From 4d1f364a40b2105fc2f94c0d8f15e9ac3bb0cd9d Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 8 Dec 2014 13:45:30 +0800 Subject: [PATCH] fix cmax issues. --- .../FullyImplicitCompressiblePolymerSolver.cpp | 16 ++++++++++------ .../FullyImplicitCompressiblePolymerSolver.hpp | 3 +-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp index 15648fc5b..485f9ac46 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp @@ -202,9 +202,10 @@ namespace { WellStateFullyImplicitBlackoil& xw, const std::vector& polymer_inflow) { + // Initial max concentration of this time step from PolymerBlackoilState. + cmax_ = Eigen::Map(&x.maxconcentration()[0], Opm::AutoDiffGrid::numCells(grid_)); const SolutionState state = constantState(x, xw); - computeCmax(x, state.concentration); computeAccum(state, 0); const double atol = 1.0e-12; @@ -241,6 +242,9 @@ 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); } @@ -483,15 +487,15 @@ namespace { void FullyImplicitCompressiblePolymerSolver:: - computeCmax(PolymerBlackoilState& state, - const ADB& c) + computeCmax(PolymerBlackoilState& state) { const int nc = grid_.number_of_cells; - for (int i = 0; i < nc; ++i) { - cmax_(i) = std::max(cmax_(i), c.value()(i)); + V tmp = V::Zero(nc); + for (int i = 0; i < nc; ++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()); } diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp index 2b1dc5ed1..d2db12108 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp @@ -196,8 +196,7 @@ namespace Opm { const ADB& c) const; void - computeCmax(PolymerBlackoilState& state, - const ADB& c); + computeCmax(PolymerBlackoilState& state); ADB computeMc(const SolutionState& state) const;