assert if Alugrid can initialized from Deck: check format and geometry

This commit is contained in:
Elyes Ahmed 2022-06-21 14:30:47 +02:00
parent 4d76351111
commit d0a1101bc8
2 changed files with 47 additions and 2 deletions

View File

@ -209,6 +209,18 @@ namespace Opm {
void resetACTNUM( const std::vector<int>& actnum);
bool equal(const EclipseGrid& other) const;
static bool hasDVDEPTHZKeywords(const Deck&);
/*
For ALugrid we can *only* use the keyword <DXV, DXYV, DZV, DEPTHZ> so to
initialize a Regular Cartesian Grid; further we need equidistant mesh
spacing in each direction to initialize ALuGrid (mandatory for
mesh refinement!).
*/
static bool hasEqualDVDEPTHZ(const Deck&);
static bool allEqual(const std::vector<double> &v);
static void assertALuGridFormat(const Deck&);
private:
std::vector<double> m_minpvVector;
@ -265,7 +277,6 @@ namespace Opm {
void initCornerPointGrid(const Deck&);
void assertCornerPointKeywords(const Deck&);
static bool hasDVDEPTHZKeywords(const Deck&);
static bool hasDTOPSKeywords(const Deck&);
static void assertVectorSize(const std::vector<double>& vector, size_t expectedSize, const std::string& msg);

View File

@ -1252,7 +1252,36 @@ EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum)
else
return false;
}
bool EclipseGrid::hasEqualDVDEPTHZ(const Deck& deck) {
const std::vector<double>& DXV = deck.get<ParserKeywords::DXV>().back().getSIDoubleData();
const std::vector<double>& DYV = deck.get<ParserKeywords::DYV>().back().getSIDoubleData();
const std::vector<double>& DZV = deck.get<ParserKeywords::DZV>().back().getSIDoubleData();
const std::vector<double>& DEPTHZ = deck.get<ParserKeywords::DEPTHZ>().back().getSIDoubleData();
if (EclipseGrid::allEqual(DXV) &&
EclipseGrid::allEqual(DYV)&&
EclipseGrid::allEqual(DZV)&&
EclipseGrid::allEqual(DEPTHZ))
return true;
else
return false;
}
void EclipseGrid::assertALuGridFormat(const Deck& deck) {
if (EclipseGrid::hasDVDEPTHZKeywords(deck) &&
EclipseGrid::hasEqualDVDEPTHZ(deck)) {
}
else if (!EclipseGrid::hasDVDEPTHZKeywords(deck)) {
throw std::invalid_argument("Tried to initialize ALuGrid without all required keywords <DXV, DXY, DXZ, DEPTHZ>: Only Cartesian Regular Grid is supported for ALuGrid");
}
else if (EclipseGrid::hasDVDEPTHZKeywords(deck) &&
!EclipseGrid::hasEqualDVDEPTHZ(deck)) {
throw std::invalid_argument("Tried to initialize ALuGrid on non-equidistant DXV, and or DXY, and or DXZ, and or DEPTHZ: Only cell dimensions that are equal in each direction are used to initialize ALUGrid");
}
else
throw std::invalid_argument("Tried to initialize ALuGrid using unknown Grid format");
}
bool EclipseGrid::hasDTOPSKeywords(const Deck& deck) {
if ((deck.hasKeyword<ParserKeywords::DX>() || deck.hasKeyword<ParserKeywords::DXV>()) &&
(deck.hasKeyword<ParserKeywords::DY>() || deck.hasKeyword<ParserKeywords::DYV>()) &&
@ -1383,7 +1412,12 @@ std::vector<double> EclipseGrid::createDVector(const std::array<int,3>& dims, st
}
}
}
bool EclipseGrid::allEqual(const std::vector<double> &v) {
auto comp = [](double x, double y) { return std::fabs(x - y) < 1e-12; };
return std::equal(v.begin() + 1, v.end(), v.begin(), comp);
}
bool EclipseGrid::equal(const EclipseGrid& other) const {
//double reltol = 1.0e-6;