All Classes Functions Variables
IntegrationTest Class Reference

A class for executing a integration test for two ECLIPSE files. More...

#include <EclFilesComparator.hpp>

Inheritance diagram for IntegrationTest:
SummaryComparator ECLFilesComparator

Public Member Functions

 IntegrationTest (const std::string &basename1, const std::string &basename2, double absTolerance, double relTolerance)
 Sets up the integration test. More...
 
bool elementInWhitelist (const std::string &keyword) const
 Checks if a keyword is supported for comparison. More...
 
void equalNumKeywords () const
 Checks if the number of keywords equal in the two input cases. More...
 
void results ()
 Finds deviations for all supported keywords. More...
 
void resultsForKeyword (const std::string &keyword)
 Finds deviations for a specific keyword. More...
 
 IntegrationTest (const char *basename1, const char *basename2, double atol, double rtol)
 Constructor, creates an object of IntegrationTest class. More...
 
void setAllowSpikes (bool allowSpikesArg)
 This function sets the private member variable allowSpikes. More...
 
void setFindVolumeError (bool findVolumeErrorArg)
 This function sets the private member variable findVolumeError. More...
 
void setOneOfTheMainVariables (bool oneOfTheMainVariablesArg)
 This function sets the private member variable oneOfTheMainVariables. More...
 
void setMainVariable (std::string mainVar)
 This function sets the member variable string #mainVariable. More...
 
void setSpikeLimit (int lim)
 This function sets the private member variable spikeLimit. More...
 
void setFindVectorWithGreatestErrorRatio (bool boolean)
 This function sets the private member variable findVectorWithGreatestErrorRatio. More...
 
void setAllowDifferentAmountOfKeywords (bool boolean)
 This function sets the private member variable allowDifferentAmountsOfKeywords. More...
 
void setThrowExceptionForTooGreatErrorRatio (bool boolean)
 This function sets the private member variable throwExceptionForTooGreatErrorRatio. More...
 
void getIntegrationTest ()
 This function executes a integration test for all the keywords. If the two files do not match in amount of keywords, an exception is thrown.
Uses the boolean member variables to know which tests to execute.
 
void getIntegrationTest (const char *keyword)
 This function executes a integration test for one specific keyword. If one or both of the files do not have the keyword, an exception is thorwn.
Uses the boolean member variables to know which tests to execute.
 
- Public Member Functions inherited from SummaryComparator
 SummaryComparator (const char *basename1, const char *basename2, double absoluteTolerance, double relativeTolerance)
 Creates an SummaryComparator class object. More...
 
 ~SummaryComparator ()
 Destructor. More...
 
void setPrintKeywords (bool boolean)
 Sets the private member variable printKeywords. More...
 
void setPrintSpecificKeyword (bool boolean)
 Sets the private member variable printSpecificKeyword. More...
 
void throwOnErrors (bool dothrow)
 Set whether to throw on errors or not.
 
- Public Member Functions inherited from ECLFilesComparator
 ECLFilesComparator (int file_type, const std::string &basename1, const std::string &basename2, double absTolerance, double relTolerance)
 Open ECLIPSE files and set tolerances and keywords. More...
 
 ~ECLFilesComparator ()
 Closing the ECLIPSE files.
 
void throwOnErrors (bool dothrow)
 Set whether to throw on errors or not.
 
size_t getNoErrors () const
 Returns the number of errors encountered in the performed comparisons.
 
int getFileType () const
 Returns the ECLIPSE filetype of this.
 
double getAbsTolerance () const
 Returns the absolute tolerance stored as a private member variable in the class.
 
double getRelTolerance () const
 Returns the relative tolerance stored as a private member variable in the class.
 
void printKeywords () const
 Print all keywords and their respective Eclipse type for the two input cases.
 
void printKeywordsDifference () const
 Print common and uncommon keywords for the two input cases.
 

Static Public Member Functions

static double getRectangleArea (double height, double width)
 This function calculates the area of an rectangle of height height and width time-timePrev. More...
 
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. More...
 
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. More...
 
- Static Public Member Functions inherited from SummaryComparator
static Deviation calculateDeviations (double val1, double val2)
 Calculates the deviation between two values. More...
 
static double unitStep (double value)
 Unit step function. More...
 
- Static Public Member Functions inherited from ECLFilesComparator
static Deviation calculateDeviations (double val1, double val2)
 Calculate deviations for two values. More...
 
static double median (std::vector< double > vec)
 Calculate median of a vector. More...
 
static double average (const std::vector< double > &vec)
 Calculate average of a vector. More...
 

Additional Inherited Members

- Protected Member Functions inherited from SummaryComparator
void getDeviation (size_t refIndex, size_t &checkIndex, Deviation &dev)
 Calculate deviation between two data values and stores it in a Deviation struct. More...
 
void setDataSets (const std::vector< double > &timeVec1, const std::vector< double > &timeVec2)
 Figure out which data file contains the most / less timesteps and assign member variable pointers accordingly. More...
 
void setTimeVecs (std::vector< double > &timeVec1, std::vector< double > &timeVec2)
 Reads in the time values of each time step. More...
 
void getDataVecs (std::vector< double > &dataVec1, std::vector< double > &dataVec2, const char *keyword)
 Read the data for one specific keyword into two separate vectors. More...
 
void chooseReference (const std::vector< double > &timeVec1, const std::vector< double > &timeVec2, const std::vector< double > &dataVec1, const std::vector< double > &dataVec2)
 Sets one data set as a basis and the other as values to check against. More...
 
double getRelTolerance ()
 Returns the relative tolerance.
 
double getAbsTolerance ()
 Returns the absolute tolerance.
 
const char * getUnit (const char *keyword)
 Returns the unit of the values of a keyword. More...
 
void printUnits ()
 Prints the units of the files.
 
void printKeywords ()
 Prints the keywords of the files. More...
 
void printDataOfSpecificKeyword (const std::vector< double > &timeVec1, const std::vector< double > &timeVec2, const char *keyword)
 Prints the summary vectors from the two files. More...
 
- Protected Member Functions inherited from ECLFilesComparator
void keywordValidForComparing (const std::string &keyword) const
 Checks if the keyword exists in both cases. More...
 
unsigned int getEclKeywordData (ecl_kw_type *&ecl_kw1, ecl_kw_type *&ecl_kw2, const std::string &keyword, int occurrence1, int occurrence2) const
 Stores keyword data for a given occurrence. More...
 
template<typename T >
void printValuesForCell (const std::string &keyword, int occurrence1, int occurrence2, size_t cell, const T &value1, const T &value2) const
 Prints values for a given keyword, occurrence and cell. More...
 
- Protected Attributes inherited from SummaryComparator
ecl_sum_type * ecl_sum1 = nullptr
 Struct that contains file1.
 
ecl_sum_type * ecl_sum2 = nullptr
 Struct that contains file2.
 
ecl_sum_type * ecl_sum_fileShort = nullptr
 For keeping track of the file with most/fewest timesteps.
 
ecl_sum_type * ecl_sum_fileLong = nullptr
 For keeping track of the file with most/fewest timesteps.
 
stringlist_type * keys1 = nullptr
 For storing all the keywords of file1.
 
stringlist_type * keys2 = nullptr
 For storing all the keywords of file2.
 
stringlist_type * keysShort = nullptr
 For keeping track of the file with most/fewest keywords.
 
stringlist_type * keysLong = nullptr
 For keeping track of the file with most/fewest keywords.
 
const std::vector< double > * referenceVec = nullptr
 For storing the values of each time step for the file containing the fewer time steps. More...
 
const std::vector< double > * referenceDataVec = nullptr
 For storing the data corresponding to each time step for the file containing the fewer time steps. More...
 
const std::vector< double > * checkVec = nullptr
 For storing the values of each time step for the file containing the more time steps. More...
 
const std::vector< double > * checkDataVec = nullptr
 For storing the data values corresponding to each time step for the file containing the more time steps. More...
 
bool printKeyword = false
 Boolean value for choosing whether to print the keywords or not.
 
bool printSpecificKeyword = false
 Boolean value for choosing whether to print the vectors of a keyword or not.
 
bool throwOnError = true
 Throw on first error.
 
- Protected Attributes inherited from ECLFilesComparator
ecl_file_type * ecl_file1 = nullptr
 
ecl_grid_type * ecl_grid1 = nullptr
 
ecl_file_type * ecl_file2 = nullptr
 
ecl_grid_type * ecl_grid2 = nullptr
 
std::vector< std::string > keywords1
 
std::vector< std::string > keywords2
 
bool throwOnError = true
 Throw on first error.
 
size_t num_errors = 0
 

Detailed Description

A class for executing a integration test for two ECLIPSE files.

This class inherits from ECLFilesComparator, which opens and closes the input cases and stores keywordnames. The three public functions equalNumKeywords(), results() and resultsForKeyword() can be invoked to compare griddata or keyworddata for all keywords or a given keyword (resultsForKeyword()).

The class inherits from the SummaryComparator class, which takes care of all file reading.
The IntegrationTest class compares values from the two different files and throws exceptions when the deviation is unsatisfying.

Constructor & Destructor Documentation

IntegrationTest::IntegrationTest ( const std::string &  basename1,
const std::string &  basename2,
double  absTolerance,
double  relTolerance 
)

Sets up the integration test.

Parameters
[in]basename1Full path without file extension to the first case.
[in]basename2Full path without file extension to the second case.
[in]absToleranceTolerance for absolute deviation.
[in]relToleranceTolerance for relative deviation.

This constructor calls the constructor of the superclass, with input filetype unified restart. See the docs for ECLFilesComparator for more information.

IntegrationTest::IntegrationTest ( const char *  basename1,
const char *  basename2,
double  atol,
double  rtol 
)
inline

Constructor, creates an object of IntegrationTest class.

Parameters
[in]basename1Path to file1 without extension.
[in]basename1Path to file2 without extension.
[in]atolThe absolute tolerance which is to be used in the test.
[in]rtolThe relative tolerance which is to be used in the test.

The constructor calls the constructor of the super class.

Member Function Documentation

bool IntegrationTest::elementInWhitelist ( const std::string &  keyword) const

Checks if a keyword is supported for comparison.

Parameters
[in]keywordKeyword to check.
void IntegrationTest::equalNumKeywords ( ) const

Checks if the number of keywords equal in the two input cases.

Parameters
[in]keywordKeyword to check.
static double IntegrationTest::getRectangleArea ( double  height,
double  width 
)
inlinestatic

This function calculates the area of an rectangle of height height and width time-timePrev.

Parameters
[in]heightThe height of the rectangle. See important statement of use below.
[in]widthThe width of the rectangle
[out]areaReturns the area of the rectangle

This function is simple. When using it on a summary vector (data values plotted againt time), calculating the area between the two points i and i+1 note this: width is time_of_i+1 - time_of_i, the height is data_of_i+1 NOT data_of_i. The upper limit must be used.

double IntegrationTest::integrate ( const std::vector< double > &  timeVec,
const std::vector< double > &  dataVec 
)
static

This function calculates the area under a graph by doing a Riemann sum.

Parameters
[in]timeVecContains the time values
[in]dataVecContains the data values

The function does a Riemann sum integration of the graph formed by the points (timeVec[i] , dataVec[i]). In the case of a summary vector, the summary vector of quantity corresponding to a rate, is a piecewise continus function consisting of unit step functions. Thus the Riemann sum will become an exact expression for the integral of the graph. Important: For the data values correspoding to time i and i-1, the fixed value of the height of the rectangles in the Riemann sum is set by the data value i. The upper limit must be used.

double IntegrationTest::integrateError ( const std::vector< double > &  timeVec1,
const std::vector< double > &  dataVec1,
const std::vector< double > &  timeVec2,
const std::vector< double > &  dataVec2 
)
static

This function calculates the Riemann sum of the error between two graphs.

Parameters
[in]timeVec1Contains the time values of graph 1
[in]dataVec1Contains the data values of graph 1
[in]timeVec2Contains the time values of graph 2
[in]dataVec2Contains the data values of graph 2

This function takes in two graphs and returns the integrated error. In case of ecl summary vectors: if the vectors correspond to a quantity which is a rate, the vectors will be piecewise continous unit step functions. In this case the error will also be a piecewise continous unit step function. The function uses a Riemann sum when calculating the integral. Thus the integral will become exact. Important: For the data values corresponding to time i and i-1, the fixed value of the height of the rectangles in the Riemann sum is set by the data value i. The upper limit must be used.

void IntegrationTest::results ( )

Finds deviations for all supported keywords.

results() loops through all supported keywords for integration test (defined in keywordWhitelist – this is SGAS, SWAT and PRESSURE) and calls resultsForKeyword() for each keyword.

void IntegrationTest::resultsForKeyword ( const std::string &  keyword)

Finds deviations for a specific keyword.

Parameters
[in]keywordKeyword to check.

First, resultsForKeyword() checks if the keyword exits in both cases, and if the number of keyword occurrences in the two cases differ. If these tests fail, an exception is thrown. Then deviaitons are calculated as described below for each occurrence, and an exception is thrown if the relative error ratio $E$ is larger than the relative tolerance. Calculation:
Let the keyword values for occurrence $n$ and cell $i$ be $p_{n,i}$ and $q_{n,i}$ for input case 1 and 2, respectively. Consider first the initial occurrence ( $n=0$). The function uses the second cases as reference, and calculates the volume weighted sum of $q_{0,i}$ over all cells $i$:

\[ S_0 = \sum_{i} q_{0,i} v_i \]

where $v_{i}$ is the volume of cell $i$ in case 2. Then, the deviations between the cases for each cell are calculated:

\[ \Delta = \sum_{i} |p_{0,i} - q_{0,i}| v_i.\]

The error ratio is then $E = \Delta/S_0$.
For all other occurrences $n$, the deviation value $\Delta$ is calculated the same way, but the total value $S$ is calculated relative to the initial occurrence total $S_0$:

\[ S = \sum_{i} |q_{n,i} - q_{0,i}| v_i. \]

The error ratio is $ E = \Delta/S$.

void IntegrationTest::setAllowDifferentAmountOfKeywords ( bool  boolean)
inline

This function sets the private member variable allowDifferentAmountsOfKeywords.

Parameters
[in]booleanBoolean value

When allowDifferentAmountOfKeywords is false, the amount of kewyord in the two files will be compared. the number of keywords are different an exception will be thrown.

void IntegrationTest::setAllowSpikes ( bool  allowSpikesArg)
inline

This function sets the private member variable allowSpikes.

Parameters
[in]allowSpikesBoolean value

When allowSpikes is true, the integration test checkWithSpikes is excecuted.

void IntegrationTest::setFindVectorWithGreatestErrorRatio ( bool  boolean)
inline

This function sets the private member variable findVectorWithGreatestErrorRatio.

Parameters
[in]findVolumeErrorBoolean value

When findVectorWithGreatestErrorRatio is true, the integration test will print the vector with the greatest error ratio.

void IntegrationTest::setFindVolumeError ( bool  findVolumeErrorArg)
inline

This function sets the private member variable findVolumeError.

Parameters
[in]findVolumeErrorBoolean value

When findVolumeError is true, the integration test volumeErrorCheck and the function evaluateWellProductionVolume are excecuted.

void IntegrationTest::setMainVariable ( std::string  mainVar)
inline

This function sets the member variable string #mainVariable.

Parameters
[in]mainVarThis is the string should contain one of the main variables. e.g. WOPR
void IntegrationTest::setOneOfTheMainVariables ( bool  oneOfTheMainVariablesArg)
inline

This function sets the private member variable oneOfTheMainVariables.

Parameters
[in]oneOfTheMainVariablesBoolean value

When oneOfTheMainVariables is true, the integration test runs the substest volumeErrorCheckForOneSpecificVariable.

void IntegrationTest::setSpikeLimit ( int  lim)
inline

This function sets the private member variable spikeLimit.

Parameters
[in]limThe value which the spike limit is to be given.
void IntegrationTest::setThrowExceptionForTooGreatErrorRatio ( bool  boolean)
inline

This function sets the private member variable throwExceptionForTooGreatErrorRatio.

Parameters
[in]booleanBoolean value

When throwExceptionForTooGreatErrorRatio is false, the function getWellProductionVolume will throw an exception.


The documentation for this class was generated from the following files: