Merge pull request #3845 from bska/detect-invalid-cpdata

Don't Process Corner-Point Data If No Valid Cell Geometry
This commit is contained in:
Bård Skaflestad 2022-03-25 15:33:27 +01:00 committed by GitHub
commit 6b74ba512a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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