Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: The eclipse gride preprocessing is not allowed to deactivate cells #393

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion opm/grid/CpGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ namespace Dune
/// \param poreVolume pore volumes for use in MINPV processing, if asked for in deck
void processEclipseFormat(const Opm::EclipseGrid& ecl_grid, bool periodic_extension, bool turn_normals = false, bool clip_z = false,
const std::vector<double>& poreVolume = std::vector<double>(),
const Opm::NNC& = Opm::NNC());
const Opm::NNC& = Opm::NNC(),
bool allow_deactivate_cells = false);
#endif

/// Read the Eclipse grid format ('grdecl').
Expand Down
5 changes: 3 additions & 2 deletions opm/grid/cpgrid/CpGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,12 @@ CpGrid::scatterGrid(EdgeWeightMethod method, const std::vector<cpgrid::OpmWellTy
bool periodic_extension,
bool turn_normals, bool clip_z,
const std::vector<double>& poreVolume,
const Opm::NNC& nncs)
const Opm::NNC& nncs,
bool allow_deactivate_cells)
{
current_view_data_->processEclipseFormat(ecl_grid, periodic_extension,
turn_normals, clip_z,
poreVolume, nncs);
poreVolume, nncs, allow_deactivate_cells);
}
#endif

Expand Down
5 changes: 4 additions & 1 deletion opm/grid/cpgrid/CpGridData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ class CpGridData
/// \param turn_normals if true, all normals will be turned. This is intended for handling inputs with wrong orientations.
/// \param clip_z if true, the grid will be clipped so that the top and bottom will be planar.
/// \param poreVolume pore volumes for use in MINPV processing, if asked for in deck
/// \param allow_deactivate_cells By default the active/inactive cells should be fully initialized in the EclipseGrid,
/// but if this parameter is set to true the function is allowed to deactivate cells.
void processEclipseFormat(const Opm::EclipseGrid& ecl_grid, bool periodic_extension, bool turn_normals = false, bool clip_z = false,
const std::vector<double>& poreVolume = std::vector<double>(), const Opm::NNC& nncs = Opm::NNC());
const std::vector<double>& poreVolume = std::vector<double>(), const Opm::NNC& nncs = Opm::NNC(),
bool allow_deactivate_cells = false);
#endif

/// Read the Eclipse grid format ('grdecl').
Expand Down
24 changes: 23 additions & 1 deletion opm/grid/cpgrid/processEclipseFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,24 @@ namespace Dune
namespace cpgrid
{

namespace {

void assert_active_cells(const grdecl& grdecl_grid, const Opm::EclipseGrid& ecl_grid) {
// #ifndef NDEBUG
const auto& ecl_actnum = ecl_grid.getACTNUM();
for (std::size_t g = 0; g < ecl_grid.getCartesianSize(); g++) {
if (ecl_actnum[g] != grdecl_grid.actnum[g])
throw std::logic_error("Cells have been deactivated in the grid processing - should not happen");
}
// #endif
}

}


#if HAVE_ECL_INPUT
void CpGridData::processEclipseFormat(const Opm::EclipseGrid& ecl_grid, bool periodic_extension, bool turn_normals, bool clip_z,
const std::vector<double>& poreVolume, const Opm::NNC& nncs)
const std::vector<double>& poreVolume, const Opm::NNC& nncs, bool allow_deactivate_cells)
{
std::vector<double> coordData = ecl_grid.getCOORD();

Expand Down Expand Up @@ -227,10 +242,17 @@ namespace cpgrid
addOuterCellLayer(g, new_coord, new_zcorn, new_actnum, new_g);
// Make the grid.
processEclipseFormat(new_g, nnc_cells, z_tolerance, true, turn_normals);
if (!allow_deactivate_cells) {
assert_active_cells(new_g, ecl_grid);
}
} else {
// Make the grid.
processEclipseFormat(g, nnc_cells, z_tolerance, false, turn_normals);
if (!allow_deactivate_cells) {
assert_active_cells(g, ecl_grid);
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we maybe deactivate this test in production by #ifndef NDEDUG

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better safe than sorry - I would prefer to leave that test in - even in release mode; can add a commented of #ifndef NDEBUG - which can be activated at some point in the future.

}
#endif // #if HAVE_ECL_INPUT

Expand Down