Use the global number of cells for the average.

This number is still wrong in master but well become correct once
PR #1107 is merged.
This commit is contained in:
Markus Blatt 2017-03-24 15:12:42 +01:00
parent a6f6e4806e
commit cde162b3d6
3 changed files with 15 additions and 6 deletions

View File

@ -179,11 +179,14 @@ namespace Opm {
const double gravity = detail::getGravity(geo_.gravity(), UgGridHelpers::dimensions(grid_));
const std::vector<double> pv(geo_.poreVolume().data(), geo_.poreVolume().data() + geo_.poreVolume().size());
const std::vector<double> depth(geo_.z().data(), geo_.z().data() + geo_.z().size());
well_model_.init(fluid_.phaseUsage(), active_, &vfp_properties_, gravity, depth, pv, &rate_converter_);
// Wells are active if they are active wells on at least
// one process.
int wellsActive = localWellsActive() ? 1 : 0;
wellsActive = grid_.comm().max(wellsActive);
wellModel().setWellsActive( localWellsActive() );
// compute global sum of number of cells
global_nc_ = detail::countGlobalCells(grid_);
well_model_.init(fluid_.phaseUsage(), active_, &vfp_properties_, gravity, depth, pv, &rate_converter_, global_nc_);
if (!istlSolver_)
{
OPM_THROW(std::logic_error,"solver down cast to ISTLSolver failed");

View File

@ -103,7 +103,8 @@ enum WellVariablePositions {
const double gravity_arg,
const std::vector<double>& depth_arg,
const std::vector<double>& pv_arg,
const RateConverterType* rate_converter);
const RateConverterType* rate_converter,
long int global_nc);
template <typename Simulator>
@ -299,6 +300,8 @@ enum WellVariablePositions {
BVector resWell_;
long int global_nc_;
mutable BVector Cx_;
mutable BVector invDrw_;
mutable BVector scaleAddRes_;

View File

@ -41,8 +41,12 @@ namespace Opm {
const double gravity_arg,
const std::vector<double>& depth_arg,
const std::vector<double>& pv_arg,
const RateConverterType* rate_converter)
const RateConverterType* rate_converter,
long int global_nc)
{
// has to be set always for the convergence check!
global_nc_ = global_nc;
if ( ! localWellsActive() ) {
return;
}
@ -923,7 +927,6 @@ namespace Opm {
typedef std::vector< Scalar > Vector;
const int np = numPhases();
const int nc = numCells();
const double tol_wells = param_.tolerance_wells_;
const double maxResidualAllowed = param_.max_residual_allowed_;
@ -956,7 +959,7 @@ namespace Opm {
// compute global average
grid.comm().sum(B_avg.data(), B_avg.size());
for(auto& bval: B_avg)
bval/=nc;
bval/=global_nc_;
auto res = residual();
const int nw = res.size() / np;