Don't Process Corner-Point Data If No Valid Cell Geometry

If no cell has a valid corner-point geometry, typically caused by
using GDFILE to read non-finite data such as all ZCORN = -1.0E+20,
then we must not attempt to generate a grid structure.  If we do, we
will typically just fail somewhere deep down in the corner-point
processing code and generate a diagnostic message that's hard to
decipher.

With this commit we instead output a diagnostic message of the form

    Failed to create valid EclipseState object.
    Exception caught: No active cell in input grid has valid/finite cell geometry
    Please check geometry keywords, especially if grid is imported through GDFILE

This may not be a lot better than the original diagnostic

    Processing grid
    flow: ${ROOT}/opm-grid/opm/grid/cpgpreprocess/preprocess.c:768: is_lefthanded: Assertion `! searching' failed.
    Aborted (core dumped)

but does at least suggest that the grid data may be faulty.
This commit is contained in:
Bård Skaflestad
2022-03-25 11:08:32 +01:00
parent 0cd2ce6589
commit dfdfbbd7d7
3 changed files with 58 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -54,6 +54,8 @@
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Units/UnitSystem.hpp>
#include <opm/simulators/flow/KeywordValidation.hpp>
#include <opm/simulators/flow/ValidationFunctions.hpp>
#include <opm/simulators/utils/ParallelEclipseState.hpp>
@@ -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)"
};
}

View File

@@ -86,6 +86,9 @@ void readDeck(Parallel::Communication comm,
bool initFromRestart,
bool checkDeck,
const std::optional<int>& outputInterval);
void verifyValidCellGeometry(Parallel::Communication comm,
const EclipseState& eclipseState);
} // end namespace Opm
#endif // OPM_READDECK_HEADER_INCLUDED