Merge pull request #1107 from blattms/fix-ebos-global-cell

[Ebos,bugfix] Correctly compute the global number of cells.
This commit is contained in:
Atgeirr Flø Rasmussen 2017-04-04 10:33:22 +02:00 committed by GitHub
commit 81dbfc8205
2 changed files with 43 additions and 2 deletions

View File

@ -156,6 +156,48 @@ namespace detail {
}
}
/// \brief Get the number of local interior cells in a grid.
/// \tparam The type of the DUNE grid.
/// \param grid The grid which cells we count
/// \return The number of interior cell in the partition of the
/// grid stored on this process.
template<class Grid>
std::size_t countLocalInteriorCells(const Grid& grid)
{
if ( grid.comm().size() == 1)
{
return grid.size(0);
}
std::size_t count = 0;
const auto& gridView = grid.leafGridView();
for(auto cell = gridView.template begin<0, Dune::Interior_Partition>(),
endCell = gridView.template end<0, Dune::Interior_Partition>();
cell != endCell; ++cell)
{
++count;
}
return count;
}
/// \brief Get the number of cells of a global grid.
///
/// In a parallel run this is the number of cells that a grid would
/// have if the whole grid was stored on one process only.
/// \tparam The type of the DUNE grid.
/// \param grid The grid which cells we count
/// \return The global number of cells.
template<class Grid>
std::size_t countGlobalCells(const Grid& grid)
{
if ( grid.comm().size() == 1)
{
return grid.size(0);
}
std::size_t count = countLocalInteriorCells(grid);
return grid.comm().sum(count);
}
template <class Scalar>
inline
double

View File

@ -190,9 +190,8 @@ namespace Opm {
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_);
wellModel().setWellsActive( localWellsActive() );
global_nc_ = Opm::AutoDiffGrid::numCells(grid_);
// compute global sum of number of cells
global_nc_ = grid_.comm().sum( global_nc_ );
global_nc_ = detail::countGlobalCells(grid_);
if (!istlSolver_)
{