EclRegressionTest.hpp
Go to the documentation of this file.
1/*
2 Copyright 2019 Equinor ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef ECLREGRESSIONTEST_HPP
21#define ECLREGRESSIONTEST_HPP
22
24
26
27namespace Opm { namespace EclIO {
28 class EGrid;
29}}
30
31namespace EIOD = Opm::EclIO;
32
33
42public:
49 ECLRegressionTest(const std::string& basename1, const std::string& basename2,
50 double absToleranceArg, double relToleranceArg):
51 ECLFilesComparator(basename1, basename2, absToleranceArg, relToleranceArg) {}
52
54
56 void setOnlyLastReportNumber(bool onlyLastSequenceArg) {
57 this->onlyLastSequence = onlyLastSequenceArg;
58 }
59
60 int countDev() { return deviations.size(); }
61
62 // Accept extra keywords: If this switch is set to true the comparison
63 // will ignore extra keywords which are only present
64 // in the new simulation.
65
66 void setReportStepOnly(bool reportStepOnlyArg) {
67 this->reportStepOnly = reportStepOnlyArg;
68 }
69
70 void setAcceptExtraKeywords(bool acceptExtraKeywordsArg) {
71 this->acceptExtraKeywords = acceptExtraKeywordsArg;
72 }
73
74 void setIntegrationTest(bool inregrationTestArg) {
75 this->integrationTest = inregrationTestArg;
76 }
77
78 void setPrintKeywordOnly(bool printArg) {
79 this->printKeywordOnly = printArg;
80 }
81
83 this->spesificKeyword = std::move(keyword);
84 }
86 this->spesificSequence = seqn;
87 }
88
89 void setLoadBaseRunData(bool loadArg) {
90 this->loadBaseRunData = loadArg;
91 }
92
93 void loadGrids();
95
97
102
103private:
104 bool checkFileName(const std::string& rootName, const std::string& extension, std::string& filename);
105
106 // Prints results stored in absDeviation and relDeviation.
107 void printResultsForKeyword(const std::string& keyword) const;
108 void printComparisonForKeywordLists(const std::vector<std::string>& arrayList1,
109 const std::vector<std::string>& arrayList2) const;
110
111 void printComparisonForKeywordLists(const std::vector<std::string>& arrayList1,
112 const std::vector<std::string>& arrayList2,
113 const std::vector<EIOD::eclArrType>& arrayType1,
114 const std::vector<EIOD::eclArrType>& arrayType2) const;
115
116 void printMissingKeywords(const std::vector<std::string>& arrayList1,
117 const std::vector<std::string>& arrayList2) const;
118
119 void compareKeywords(const std::vector<std::string>& keywords1,
120 const std::vector<std::string>& keywords2,
121 const std::string& reference);
122
123 void checkSpesificKeyword(std::vector<std::string>& keywords1,
124 std::vector<std::string>& keywords2,
125 std::vector<EIOD::eclArrType>& arrayType1,
126 std::vector<EIOD::eclArrType>& arrayType2,
127 const std::string& reference);
128
129 template <typename T>
130 void compareVectors(const std::vector<T>& t1, const std::vector<T>& t2,
131 const std::string& keyword, const std::string& reference);
132
133 template <typename T>
134 void compareFloatingPointVectors(const std::vector<T>& t1, const std::vector<T> &t2,
135 const std::string& keyword, const std::string& reference);
136
137 // deviationsForCell throws an exception if both the absolute deviation AND the relative deviation
138 // are larger than absTolerance and relTolerance, respectively. In addition,
139 // if allowNegativeValues is passed as false, an exception will be thrown when the absolute value
140 // of a negative value exceeds absTolerance. If no exceptions are thrown, the absolute and relative deviations are added to absDeviation and relDeviation.
141 // void deviationsForCell(double val1, double val2, const std::string& keyword, const std::string reference, size_t kw_size, size_t cell, bool allowNegativeValues = true);
142
143 void deviationsForCell(double val1, double val2, const std::string& keyword,
144 const std::string& reference, size_t kw_size, size_t cell,
145 bool allowNegativeValues, bool useStrictTol);
146
147 template <typename T>
148 void deviationsForNonFloatingPoints(T val1, T val2, const std::string& keyword,
149 const std::string& reference,
150 size_t kw_size, size_t cell);
151
152 // These vectors store absolute and relative deviations, respecively. Note that they are whiped clean for every new keyword comparison.
153 std::vector<double> absDeviation, relDeviation;
154
155 // Keywords which should not contain negative values, i.e. uses allowNegativeValues = false in deviationsForCell():
156 const std::vector<std::string> keywordDisallowNegatives = {"SGAS", "SWAT", "PRESSURE"};
157
158 double strictAbsTol = 1e-6;
159 double strictRelTol = 1e-6;
160
161 // keywords that triggers strict tolerances
162 const std::vector<std::string> keywordsStrictTol = {"COORD", "ZCORN", "PORV", "DEPTH", "DX", "DY", "DZ", "PERMX", "PERMY", "PERMZ", "NTG",
163 "TRANX", "TRANY", "TRANZ", "TRANNNC", "SGRP", "SCON", "DOUBHEAD"
164 };
165 // keywords that should not be compared
166 const std::vector<std::string> keywordsBlackList = {"TCPU"};
167
168 bool reportStepOnly = false;
169
170 // Only compare last occurrence
171 bool onlyLastSequence = false;
172
173 bool integrationTest = false;
174
175 bool printKeywordOnly = false;
176
177 bool loadBaseRunData = false;
178
179 // spesific keyword to be compared
180 std::string spesificKeyword;
181
182 // spesific restart sequence to be compared
183 int spesificSequence = -1;
184
185 // Accept extra keywords in the restart file of the 'new' simulation.
186 bool acceptExtraKeywords = false;
187
188 Opm::EclIO::EGrid* grid1 = nullptr;
189 Opm::EclIO::EGrid* grid2 = nullptr;
190};
191
192#endif
const char *const string
Definition: cJSON.h:170
Definition: EclFilesComparator.hpp:34
std::map< std::string, std::vector< Deviation > > deviations
Definition: EclFilesComparator.hpp:74
A class for executing a regression test for two ECLIPSE files.
Definition: EclRegressionTest.hpp:41
void setPrintKeywordOnly(bool printArg)
Definition: EclRegressionTest.hpp:78
void printDeviationReport()
void setAcceptExtraKeywords(bool acceptExtraKeywordsArg)
Definition: EclRegressionTest.hpp:70
int countDev()
Definition: EclRegressionTest.hpp:60
void compareSpesificRstReportStepNumber(int seqn)
Definition: EclRegressionTest.hpp:85
void compareSpesificKeyword(std::string keyword)
Definition: EclRegressionTest.hpp:82
void setReportStepOnly(bool reportStepOnlyArg)
Definition: EclRegressionTest.hpp:66
void setLoadBaseRunData(bool loadArg)
Definition: EclRegressionTest.hpp:89
void setOnlyLastReportNumber(bool onlyLastSequenceArg)
Option to only compare last occurrence.
Definition: EclRegressionTest.hpp:56
void setIntegrationTest(bool inregrationTestArg)
Definition: EclRegressionTest.hpp:74
ECLRegressionTest(const std::string &basename1, const std::string &basename2, double absToleranceArg, double relToleranceArg)
Sets up the regression test.
Definition: EclRegressionTest.hpp:49
Definition: EGrid.hpp:36
Definition: EclFile.hpp:33
UDAKeyword keyword(UDAControl control)
Definition: A.hpp:4
std::string extension(const std::string &fname)
static const double e
Definition: exprtk.hpp:758