opm-common
EclFilesComparator.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
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 
30 namespace Opm { namespace EclIO {
31  class EGrid;
32 }} // namespace Opm::ecl
33 
35 public:
36  ECLFilesComparator(const std::string& basename1,
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 
71 protected:
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 
77  std::string rootName1, rootName2;
78 
79  template <typename T>
80  void printValuesForCell(const std::string& keyword,
81  const std::string& reference,
82  size_t kw_size,
83  size_t cell,
84  const Opm::EclIO::EGrid *grid,
85  const T& value1,
86  const T& value2) const;
87 
88 private:
89  double absTolerance = 0;
90  double relTolerance = 0;
91 };
92 
93 #endif
bool analysis
Perform full error analysis.
Definition: EclFilesComparator.hpp:73
static Deviation calculateDeviations(double val1, double val2)
Calculate deviations for two values.
Definition: EclFilesComparator.cpp:120
Deviation struct.
Definition: Deviation.hpp:27
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
static double average(const std::vector< double > &vec)
Calculate average of a vector.
Definition: EclFilesComparator.cpp:149
static double median(std::vector< double > vec)
Calculate median of a vector.
Definition: EclFilesComparator.cpp:132
Definition: EGrid.hpp:32
double getRelTolerance() const
Returns the relative tolerance stored as a private member variable in the class.
Definition: EclFilesComparator.hpp:57
bool throwOnError
Throw on first error.
Definition: EclFilesComparator.hpp:72
double getAbsTolerance() const
Returns the absolute tolerance stored as a private member variable in the class.
Definition: EclFilesComparator.hpp:53
Definition: EclFilesComparator.hpp:34