Add option to ignore extra keywords in the regresstion testing
This commit is contained in:
parent
c870172a30
commit
7cd29ea7d7
@ -231,20 +231,23 @@ void ECLRegressionTest::gridCompare(const bool volumecheck) const {
|
|||||||
|
|
||||||
|
|
||||||
void ECLRegressionTest::results() {
|
void ECLRegressionTest::results() {
|
||||||
if (keywords1.size() != keywords2.size()) {
|
if (!this->acceptExtraKeywords) {
|
||||||
std::set<std::string> keys(keywords1.begin() , keywords1.end());
|
if (keywords1.size() != keywords2.size()) {
|
||||||
for (const auto& key2: keywords2)
|
std::set<std::string> keys(keywords1.begin() , keywords1.end());
|
||||||
keys.insert( key2 );
|
for (const auto& key2: keywords2)
|
||||||
|
keys.insert( key2 );
|
||||||
|
|
||||||
for (const auto& key : keys)
|
for (const auto& key : keys)
|
||||||
fprintf(stderr," %8s:%3d %8s:%3d \n",key.c_str() , ecl_file_get_num_named_kw( ecl_file1 , key.c_str()),
|
fprintf(stderr," %8s:%3d %8s:%3d \n",key.c_str() , ecl_file_get_num_named_kw( ecl_file1 , key.c_str()),
|
||||||
key.c_str() , ecl_file_get_num_named_kw( ecl_file2 , key.c_str()));
|
key.c_str() , ecl_file_get_num_named_kw( ecl_file2 , key.c_str()));
|
||||||
|
|
||||||
|
|
||||||
OPM_THROW(std::runtime_error, "\nKeywords in first file: " << keywords1.size()
|
OPM_THROW(std::runtime_error, "\nKeywords in first file: " << keywords1.size()
|
||||||
<< "\nKeywords in second file: " << keywords2.size()
|
<< "\nKeywords in second file: " << keywords2.size()
|
||||||
<< "\nThe number of keywords differ.");
|
<< "\nThe number of keywords differ.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& it : keywords1)
|
for (const auto& it : keywords1)
|
||||||
resultsForKeyword(it);
|
resultsForKeyword(it);
|
||||||
|
|
||||||
|
@ -40,6 +40,10 @@ class ECLRegressionTest: public ECLFilesComparator {
|
|||||||
// Only compare last occurrence
|
// Only compare last occurrence
|
||||||
bool onlyLastOccurrence = false;
|
bool onlyLastOccurrence = false;
|
||||||
|
|
||||||
|
// Accept extra keywords in the restart file of the 'new' simulation.
|
||||||
|
bool acceptExtraKeywords = false;
|
||||||
|
|
||||||
|
|
||||||
// Prints results stored in absDeviation and relDeviation.
|
// Prints results stored in absDeviation and relDeviation.
|
||||||
void printResultsForKeyword(const std::string& keyword) const;
|
void printResultsForKeyword(const std::string& keyword) const;
|
||||||
|
|
||||||
@ -69,6 +73,11 @@ class ECLRegressionTest: public ECLFilesComparator {
|
|||||||
//! \brief Option to only compare last occurrence
|
//! \brief Option to only compare last occurrence
|
||||||
void setOnlyLastOccurrence(bool onlyLastOccurrenceArg) {this->onlyLastOccurrence = onlyLastOccurrenceArg;}
|
void setOnlyLastOccurrence(bool onlyLastOccurrenceArg) {this->onlyLastOccurrence = onlyLastOccurrenceArg;}
|
||||||
|
|
||||||
|
// Accept extra keywords: If this switch is set to true the comparison
|
||||||
|
// of restart files will ignore extra keywords which are only present
|
||||||
|
// in the new simulation.
|
||||||
|
void setAcceptExtraKeywords(bool acceptExtraKeywords) { this->acceptExtraKeywords = acceptExtraKeywords; }
|
||||||
|
|
||||||
//! \brief Compares grid properties of the two cases.
|
//! \brief Compares grid properties of the two cases.
|
||||||
// gridCompare() checks if both the number of active and global cells in the two cases are the same. If they are, and volumecheck is true, all cells are looped over to calculate the cell volume deviation for the two cases. If the both the relative and absolute deviation exceeds the tolerances, an exception is thrown.
|
// gridCompare() checks if both the number of active and global cells in the two cases are the same. If they are, and volumecheck is true, all cells are looped over to calculate the cell volume deviation for the two cases. If the both the relative and absolute deviation exceeds the tolerances, an exception is thrown.
|
||||||
void gridCompare(const bool volumecheck) const;
|
void gridCompare(const bool volumecheck) const;
|
||||||
|
@ -132,6 +132,7 @@ int main(int argc, char** argv) {
|
|||||||
bool allowSpikes = false;
|
bool allowSpikes = false;
|
||||||
bool throwOnError = true;
|
bool throwOnError = true;
|
||||||
bool throwTooGreatErrorRatio = true;
|
bool throwTooGreatErrorRatio = true;
|
||||||
|
bool acceptExtraKeywords = false;
|
||||||
bool analysis = false;
|
bool analysis = false;
|
||||||
bool volumecheck = true;
|
bool volumecheck = true;
|
||||||
char* keyword = nullptr;
|
char* keyword = nullptr;
|
||||||
@ -140,7 +141,7 @@ int main(int argc, char** argv) {
|
|||||||
int c = 0;
|
int c = 0;
|
||||||
int spikeLimit = -1;
|
int spikeLimit = -1;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "hiIk:alnpPt:VRgs:m:vK")) != -1) {
|
while ((c = getopt(argc, argv, "hiIk:alnpPt:VRgs:m:vKx")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a':
|
case 'a':
|
||||||
analysis = true;
|
analysis = true;
|
||||||
@ -198,6 +199,9 @@ int main(int argc, char** argv) {
|
|||||||
case 'V':
|
case 'V':
|
||||||
volumecheck = false;
|
volumecheck = false;
|
||||||
break;
|
break;
|
||||||
|
case 'x':
|
||||||
|
acceptExtraKeywords = true;
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
if (optopt == 'k' || optopt == 'm' || optopt == 's') {
|
if (optopt == 'k' || optopt == 'm' || optopt == 's') {
|
||||||
std::cerr << "Option " << optopt << " requires a keyword as argument, see manual (-h) for more information." << std::endl;
|
std::cerr << "Option " << optopt << " requires a keyword as argument, see manual (-h) for more information." << std::endl;
|
||||||
@ -344,6 +348,7 @@ int main(int argc, char** argv) {
|
|||||||
ECLRegressionTest comparator(file_type, basename1, basename2, absTolerance, relTolerance);
|
ECLRegressionTest comparator(file_type, basename1, basename2, absTolerance, relTolerance);
|
||||||
comparator.throwOnErrors(throwOnError);
|
comparator.throwOnErrors(throwOnError);
|
||||||
comparator.doAnalysis(analysis);
|
comparator.doAnalysis(analysis);
|
||||||
|
comparator.setAcceptExtraKeywords(acceptExtraKeywords);
|
||||||
if (printKeywords) {
|
if (printKeywords) {
|
||||||
comparator.printKeywords();
|
comparator.printKeywords();
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user