All Classes Functions Variables
summaryIntegrationTest.hpp
1 /*
2  Copyright 2016 Statoil 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 it under
7  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 #include <opm/test_util/summaryComparator.hpp>
21 
25  double total=0;
26  double error=0;
27 
31  this->total += rhs.total;
32  this->error += rhs.error;
33  return *this;
34  }
35 };
36 
38 class IntegrationTest: public SummaryComparator {
39  private:
40  bool allowSpikes = false;
41  bool findVolumeError = false;
42  bool allowDifferentAmountOfKeywords = true;
43  bool findVectorWithGreatestErrorRatio = false;
44  bool oneOfTheMainVariables = false;
45  bool throwExceptionForTooGreatErrorRatio = true;
46  std::string mainVariable;
47  int spikeLimit = 13370;
48 
53 
54 
60  void checkForKeyword(const std::vector<double>& timeVec1,
61  const std::vector<double>& timeVec2, const char* keyword);
62 
66  void volumeErrorCheck(const char* keyword);
67 
74  WellProductionVolume getSpecificWellVolume(const std::vector<double>& timeVec1,
75  const std::vector<double>& timeVec2,
76  const char* keyword);
77 
81  void checkWithSpikes(const char* keyword);
82 
87  int checkDeviation(const Deviation& deviation);
88 
93  WellProductionVolume getWellProductionVolume(const char* keyword);
94 
96  void evaluateWellProductionVolume();
97 
101  void updateVolumeError(const char* keyword);
102 
109  void findGreatestErrorRatio(const WellProductionVolume& volume,
110  double &greatestRatio,
111  const char* currentKeyword,
112  std::string &greatestErrorRatio);
113 
114 #if 0
115  bool checkUnits(const char* keyword);
119 #endif
120  public:
127  IntegrationTest(const char* basename1, const char* basename2,
128  double atol, double rtol) :
129  SummaryComparator(basename1, basename2, atol, rtol) {}
130 
134  void setAllowSpikes(bool allowSpikesArg){this->allowSpikes = allowSpikesArg;}
135 
139  void setFindVolumeError(bool findVolumeErrorArg){this->findVolumeError = findVolumeErrorArg;}
140 
144  void setOneOfTheMainVariables(bool oneOfTheMainVariablesArg){this->oneOfTheMainVariables = oneOfTheMainVariablesArg;}
145 
148  void setMainVariable(std::string mainVar){this->mainVariable = mainVar;}
149 
152  void setSpikeLimit(int lim){this->spikeLimit = lim;}
153 
157  void setFindVectorWithGreatestErrorRatio(bool boolean){this->findVectorWithGreatestErrorRatio = boolean;}
158 
162  void setAllowDifferentAmountOfKeywords(bool boolean){this->allowDifferentAmountOfKeywords = boolean;}
163 
167  void setThrowExceptionForTooGreatErrorRatio(bool boolean){this->throwExceptionForTooGreatErrorRatio = boolean;}
168 
170  void getIntegrationTest();
171 
173  void getIntegrationTest(const char* keyword);
174 
180  static double getRectangleArea(double height, double width){return height*width;}
181 
194  static double integrate(const std::vector<double>& timeVec,
195  const std::vector<double>& dataVec);
196 
212  static double integrateError(const std::vector<double>& timeVec1,
213  const std::vector<double>& dataVec1,
214  const std::vector<double>& timeVec2,
215  const std::vector<double>& dataVec2);
216 };
Struct for storing the total area under a graph.
Definition: summaryIntegrationTest.hpp:24
IntegrationTest(const char *basename1, const char *basename2, double atol, double rtol)
Constructor, creates an object of IntegrationTest class.
Definition: summaryIntegrationTest.hpp:127
void setSpikeLimit(int lim)
This function sets the private member variable spikeLimit.
Definition: summaryIntegrationTest.hpp:152
void setOneOfTheMainVariables(bool oneOfTheMainVariablesArg)
This function sets the private member variable oneOfTheMainVariables.
Definition: summaryIntegrationTest.hpp:144
Deviation struct.
Definition: EclFilesComparator.hpp:39
double total
The total area under the graph when plotting the summary vector against time.
Definition: summaryIntegrationTest.hpp:25
static double integrate(const std::vector< double > &timeVec, const std::vector< double > &dataVec)
This function calculates the area under a graph by doing a Riemann sum.
Definition: summaryIntegrationTest.cpp:320
void setMainVariable(std::string mainVar)
This function sets the member variable string #mainVariable.
Definition: summaryIntegrationTest.hpp:148
Definition: summaryComparator.hpp:56
void setAllowSpikes(bool allowSpikesArg)
This function sets the private member variable allowSpikes.
Definition: summaryIntegrationTest.hpp:134
void setFindVolumeError(bool findVolumeErrorArg)
This function sets the private member variable findVolumeError.
Definition: summaryIntegrationTest.hpp:139
void getIntegrationTest()
This function executes a integration test for all the keywords. If the two files do not match in amou...
Definition: summaryIntegrationTest.cpp:27
double error
The total area under the graph when plotting the deviation vector against time.
Definition: summaryIntegrationTest.hpp:26
void setThrowExceptionForTooGreatErrorRatio(bool boolean)
This function sets the private member variable throwExceptionForTooGreatErrorRatio.
Definition: summaryIntegrationTest.hpp:167
A class for executing a integration test for two ECLIPSE files.
Definition: EclFilesComparator.hpp:199
static double integrateError(const std::vector< double > &timeVec1, const std::vector< double > &dataVec1, const std::vector< double > &timeVec2, const std::vector< double > &dataVec2)
This function calculates the Riemann sum of the error between two graphs.
Definition: summaryIntegrationTest.cpp:335
WellProductionVolume & operator+=(const WellProductionVolume &rhs)
Overloaded operator.
Definition: summaryIntegrationTest.hpp:30
void setAllowDifferentAmountOfKeywords(bool boolean)
This function sets the private member variable allowDifferentAmountsOfKeywords.
Definition: summaryIntegrationTest.hpp:162
static double getRectangleArea(double height, double width)
This function calculates the area of an rectangle of height height and width time-timePrev.
Definition: summaryIntegrationTest.hpp:180
void setFindVectorWithGreatestErrorRatio(bool boolean)
This function sets the private member variable findVectorWithGreatestErrorRatio.
Definition: summaryIntegrationTest.hpp:157