All Classes Functions Variables
SummaryComparator Class Reference
Inheritance diagram for SummaryComparator:
IntegrationTest RegressionTest

Public Member Functions

 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.
 

Static Public Member Functions

static Deviation calculateDeviations (double val1, double val2)
 Calculates the deviation between two values. More...
 
static double unitStep (double value)
 Unit step function. More...
 

Protected Member Functions

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 Attributes

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.
 

Constructor & Destructor Documentation

SummaryComparator::SummaryComparator ( const char *  basename1,
const char *  basename2,
double  absoluteTolerance,
double  relativeTolerance 
)

Creates an SummaryComparator class object.

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

The constructor creates an object of the class, and openes the files, an exception is thrown if the opening of the files fails.
It creates stringlists, in which keywords are to be stored, and figures out which keylist that contains the more/less keywords.
Also the private member variables aboluteTolerance and relativeTolerance are set.

SummaryComparator::~SummaryComparator ( )

Destructor.

The destructor takes care of the allocated memory in which data has been stored.

Member Function Documentation

Deviation SummaryComparator::calculateDeviations ( double  val1,
double  val2 
)
static

Calculates the deviation between two values.

Parameters
[in]val1The first value of interest.
[in]val2The second value if interest.
[out]retReturns a Deviation struct.

The function takes two values, calculates the absolute and relative deviation and returns the result as a Deviation struct.

void SummaryComparator::chooseReference ( const std::vector< double > &  timeVec1,
const std::vector< double > &  timeVec2,
const std::vector< double > &  dataVec1,
const std::vector< double > &  dataVec2 
)
protected

Sets one data set as a basis and the other as values to check against.

Parameters
[in]timeVec1Used to figure out which dataset that have the more/fewer time steps.
[in]timeVec2Used to figure out which dataset that have the more/fewer time steps.
[in]dataVec1For assiging the the correct pointer to the data vector.
[in]dataVec2For assiging the the correct pointer to the data vector.

Figures out which time vector that contains the fewer elements. Sets this as referenceVec and its corresponding data as referenceDataVec.
The remaining data set is set as checkVec (the time vector) and checkDataVec.

void SummaryComparator::getDataVecs ( std::vector< double > &  dataVec1,
std::vector< double > &  dataVec2,
const char *  keyword 
)
protected

Read the data for one specific keyword into two separate vectors.

Parameters
[in]dataVec1Vector for storing the data for one specific keyword from file1
[in]dataVec2Vector for storing the data for one specific keyword from file2

The two data files do not necessarily have the same amount of data values, but the values must correspond to the same interval in time. Thus possible to interpolate values.

void SummaryComparator::getDeviation ( size_t  refIndex,
size_t &  checkIndex,
Deviation dev 
)
protected

Calculate deviation between two data values and stores it in a Deviation struct.

Parameters
[in]refIndexIndex in reference data
[in]checkindexIndex in data to be checked.
[out]devHolds the result from the comparison on return.

Uses the referenceVec as basis, and checks its values against the values in checkDataVec. The function is reccursive, and will update the iterative index j of the checkVec until checkVec[j] >= referenceVec[i].
When referenceVec and checkVec have the same time value (i.e. referenceVec[i] == checkVec[j]) a direct comparison is used,
when this is not the case, when referenceVec[i] do not excist as an element in checkVec, a value is generated, either by the principle of unit step or by interpolation.

const char * SummaryComparator::getUnit ( const char *  keyword)
protected

Returns the unit of the values of a keyword.

Parameters
[in]keywordThe keyword of interest.
[out]retThe unit of the keyword as a const char*.
void SummaryComparator::printDataOfSpecificKeyword ( const std::vector< double > &  timeVec1,
const std::vector< double > &  timeVec2,
const char *  keyword 
)
protected

Prints the summary vectors from the two files.

The function requires that the summary vectors of the specific file have been read into the member variables referenceVec etc.

void SummaryComparator::printKeywords ( )
protected

Prints the keywords of the files.

The function prints first the common keywords, than the keywords that are different.

void SummaryComparator::setDataSets ( const std::vector< double > &  timeVec1,
const std::vector< double > &  timeVec2 
)
protected

Figure out which data file contains the most / less timesteps and assign member variable pointers accordingly.

Parameters
[in]timeVec1Data from first file
[in]timeVec2Data from second file

Figure out which data file that contains the more/fewer time steps and assigns the private member variable pointers ecl_sum_fileShort / ecl_sum_fileLong to the correct data sets ecl_sum1 / ecl_sum2.

void SummaryComparator::setPrintKeywords ( bool  boolean)
inline

Sets the private member variable printKeywords.

Parameters
[in]booleanBoolean value

The function sets the private member variable printKeywords. When it is true the function printKeywords will be called.

void SummaryComparator::setPrintSpecificKeyword ( bool  boolean)
inline

Sets the private member variable printSpecificKeyword.

Parameters
[in]booleanBoolean value

The function sets the private member variable printSpecificKeyword. When true, the summary vector of the keyword for both files will be printed.

void SummaryComparator::setTimeVecs ( std::vector< double > &  timeVec1,
std::vector< double > &  timeVec2 
)
protected

Reads in the time values of each time step.

Parameters
[in]timeVec1Vector for storing the time steps from file1
[in]timeVec2Vector for storing the time steps from file2
static double SummaryComparator::unitStep ( double  value)
inlinestatic

Unit step function.

Parameters
[in]valueThe input value should be the last know value
[out]retReturn the unit-step-function value.

In this case: The unit step function is used when the data from the two data set, which is to be compared, don't match in time.
The unit step function is then to be called on the checkDataVec 's value at the last time step which is before the time of comparison. Returns a value based on the unit step principle.

Member Data Documentation

const std::vector<double>* SummaryComparator::checkDataVec = nullptr
protected

For storing the data values corresponding to each time step for the file containing the more time steps.

const std::vector<double>* SummaryComparator::checkVec = nullptr
protected

For storing the values of each time step for the file containing the more time steps.

const std::vector<double>* SummaryComparator::referenceDataVec = nullptr
protected

For storing the data corresponding to each time step for the file containing the fewer time steps.

const std::vector<double>* SummaryComparator::referenceVec = nullptr
protected

For storing the values of each time step for the file containing the fewer time steps.


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