EclFilesComparator.hpp
Go to the documentation of this file.
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
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 ECLFILESCOMPARATOR_HPP
21#define ECLFILESCOMPARATOR_HPP
22
23#include "Deviation.hpp"
24
25#include <map>
26#include <stddef.h>
27#include <string>
28#include <vector>
29
30namespace Opm { namespace EclIO {
31 class EGrid;
32}} // namespace Opm::ecl
33
35public:
37 const std::string& basename2,
38 double absTolerance, double relTolerance);
39
40 void throwOnErrors(bool dothrow) {
41 throwOnError = dothrow;
42 }
43
44 void doAnalysis(bool analize) {
45 analysis = analize;
46 }
47
48 size_t getNoErrors() const {
49 return num_errors;
50 }
51
53 double getAbsTolerance() const {
54 return absTolerance;
55 }
57 double getRelTolerance() const {
58 return relTolerance;
59 }
60
63 static Deviation calculateDeviations(double val1, double val2);
66 static double median(std::vector<double> vec);
69 static double average(const std::vector<double>& vec);
70
71protected:
72 bool throwOnError = true;
73 bool analysis = false;
74 std::map<std::string, std::vector<Deviation>> deviations;
75 mutable size_t num_errors = 0;
76
78
79 template <typename T>
81 const std::string& reference,
82 size_t kw_size,
83 size_t cell,
85 const T& value1,
86 const T& value2) const;
87
88private:
89 double absTolerance = 0;
90 double relTolerance = 0;
91};
92
93#endif
const char *const string
Definition: cJSON.h:170
Definition: EclFilesComparator.hpp:34
size_t num_errors
Definition: EclFilesComparator.hpp:75
bool throwOnError
Throw on first error.
Definition: EclFilesComparator.hpp:72
std::string rootName1
Definition: EclFilesComparator.hpp:77
void throwOnErrors(bool dothrow)
Definition: EclFilesComparator.hpp:40
bool analysis
Perform full error analysis.
Definition: EclFilesComparator.hpp:73
std::map< std::string, std::vector< Deviation > > deviations
Definition: EclFilesComparator.hpp:74
double getAbsTolerance() const
Returns the absolute tolerance stored as a private member variable in the class.
Definition: EclFilesComparator.hpp:53
double getRelTolerance() const
Returns the relative tolerance stored as a private member variable in the class.
Definition: EclFilesComparator.hpp:57
static double average(const std::vector< double > &vec)
Calculate average of a vector.
void printValuesForCell(const std::string &keyword, const std::string &reference, size_t kw_size, size_t cell, Opm::EclIO::EGrid *grid, const T &value1, const T &value2) const
static Deviation calculateDeviations(double val1, double val2)
Calculate deviations for two values.
ECLFilesComparator(const std::string &basename1, const std::string &basename2, double absTolerance, double relTolerance)
void doAnalysis(bool analize)
Definition: EclFilesComparator.hpp:44
std::string rootName2
Definition: EclFilesComparator.hpp:77
static double median(std::vector< double > vec)
Calculate median of a vector.
size_t getNoErrors() const
Definition: EclFilesComparator.hpp:48
Definition: EGrid.hpp:36
UDAKeyword keyword(UDAControl control)
Definition: A.hpp:4
Deviation struct.
Definition: Deviation.hpp:27