diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index dec5706b6..b4887ec52 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -472,6 +472,8 @@ private: summaryConfig_, nullptr, python, std::move(parseContext), init_from_restart_file, outputCout_, outputInterval); + verifyValidCellGeometry(EclGenericVanguard::comm(), *this->eclipseState_); + setupTime_ = externalSetupTimer.elapsed(); outputFiles_ = (outputMode != FileOutputMode::OUTPUT_NONE); } diff --git a/opm/simulators/utils/readDeck.cpp b/opm/simulators/utils/readDeck.cpp index e48e5685a..85fc1c83a 100644 --- a/opm/simulators/utils/readDeck.cpp +++ b/opm/simulators/utils/readDeck.cpp @@ -54,6 +54,8 @@ #include #include +#include + #include #include #include @@ -332,6 +334,44 @@ namespace { } } #endif + + bool gridHasValidCellGeometry(const Opm::EclipseGrid& inputGrid, + const Opm::UnitSystem& usys) + { + const auto numActive = inputGrid.getNumActive(); + + for (auto activeCell = 0*numActive; activeCell < numActive; ++activeCell) { + if (inputGrid.isValidCellGeomtry(inputGrid.getGlobalIndex(activeCell), usys)) { + return true; + } + } + + return false; + } + + bool gridHasValidCellGeometry(Opm::Parallel::Communication comm, + const Opm::EclipseState& eclipseState) + { + bool hasValidCells = false; + + if (comm.rank() == 0) { + hasValidCells = + gridHasValidCellGeometry(eclipseState.getInputGrid(), + eclipseState.getDeckUnitSystem()); + } + +#if HAVE_MPI + const auto status = comm.broadcast(&hasValidCells, 1, 0); + + if (status != MPI_SUCCESS) { + throw std::invalid_argument { + "Unable to establish cell geomtry validity across MPI ranks" + }; + } +#endif // HAVE_MPI + + return hasValidCells; + } } // --------------------------------------------------------------------------- @@ -518,3 +558,16 @@ void Opm::readDeck(Opm::Parallel::Communication comm, std::exit(EXIT_FAILURE); } } + +void Opm::verifyValidCellGeometry(Parallel::Communication comm, + const EclipseState& eclipseState) +{ + if (gridHasValidCellGeometry(comm, eclipseState)) { + return; + } + + throw std::invalid_argument { + R"(No active cell in input grid has valid/finite cell geometry +Please check geometry keywords, especially if grid is imported through GDFILE)" + }; +} diff --git a/opm/simulators/utils/readDeck.hpp b/opm/simulators/utils/readDeck.hpp index 850843b5e..b5ed3d49b 100644 --- a/opm/simulators/utils/readDeck.hpp +++ b/opm/simulators/utils/readDeck.hpp @@ -86,6 +86,9 @@ void readDeck(Parallel::Communication comm, bool initFromRestart, bool checkDeck, const std::optional& outputInterval); + +void verifyValidCellGeometry(Parallel::Communication comm, + const EclipseState& eclipseState); } // end namespace Opm #endif // OPM_READDECK_HEADER_INCLUDED