My Project
VFPHelpers.hpp
1/*
2 Copyright 2015 SINTEF ICT, Applied Mathematics.
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
21#ifndef OPM_AUTODIFF_VFPHELPERS_HPP_
22#define OPM_AUTODIFF_VFPHELPERS_HPP_
23
24#include <array>
25#include <functional>
26#include <map>
27#include <vector>
28
32namespace Opm {
33
34class VFPInjTable;
35class VFPProdTable;
36
37namespace detail {
38
44template <typename T>
45T getFlo(const VFPProdTable& table,
46 const T& aqua,
47 const T& liquid,
48 const T& vapour);
49
55template <typename T>
56T getFlo(const VFPInjTable& table,
57 const T& aqua,
58 const T& liquid,
59 const T& vapour);
60
65template <typename T>
66T getWFR(const VFPProdTable& table,
67 const T& aqua,
68 const T& liquid,
69 const T& vapour);
70
75template <typename T>
76T getGFR(const VFPProdTable& table,
77 const T& aqua,
78 const T& liquid,
79 const T& vapour);
80
84struct InterpData {
85 InterpData() : ind_{0, 0}, inv_dist_(0.0), factor_(0.0) {}
86 int ind_[2]; //[First element greater than or equal to value, Last element smaller than or equal to value]
87 double inv_dist_; // 1 / distance between the two end points of the segment. Used to calculate derivatives and uses 1.0 / 0.0 = 0.0 as a convention
88 double factor_; // Interpolation factor
89};
90
97InterpData findInterpData(const double value_in, const std::vector<double>& values);
98
103 VFPEvaluation() : value(0.0), dthp(0.0), dwfr(0.0), dgfr(0.0), dalq(0.0), dflo(0.0) {};
104 double value;
105 double dthp;
106 double dwfr;
107 double dgfr;
108 double dalq;
109 double dflo;
110};
111
112VFPEvaluation operator+(VFPEvaluation lhs, const VFPEvaluation& rhs);
113VFPEvaluation operator-(VFPEvaluation lhs, const VFPEvaluation& rhs);
114VFPEvaluation operator*(double lhs, const VFPEvaluation& rhs);
115
119VFPEvaluation interpolate(const VFPProdTable& table,
120 const InterpData& flo_i,
121 const InterpData& thp_i,
122 const InterpData& wfr_i,
123 const InterpData& gfr_i,
124 const InterpData& alq_i);
125
130VFPEvaluation interpolate(const VFPInjTable& table,
131 const InterpData& flo_i,
132 const InterpData& thp_i);
133
134VFPEvaluation bhp(const VFPProdTable& table,
135 const double aqua,
136 const double liquid,
137 const double vapour,
138 const double thp,
139 const double alq,
140 const double explicit_wfr,
141 const double explicit_gfr,
142 const bool use_vfpexplicit);
143
144VFPEvaluation bhp(const VFPInjTable& table,
145 const double aqua,
146 const double liquid,
147 const double vapour,
148 const double thp);
149
150
154template <typename T>
155const T& getTable(const std::map<int, std::reference_wrapper<const T>>& tables, int table_id);
156
160template <typename T>
161bool hasTable(const std::map<int, std::reference_wrapper<const T>>& tables, int table_id) {
162 const auto entry = tables.find(table_id);
163 return (entry != tables.end() );
164}
165
166
170template <typename TYPE, typename TABLE>
171TYPE getType(const TABLE& table);
172
173
180double findTHP(const std::vector<double>& bhp_array,
181 const std::vector<double>& thp_array,
182 double bhp);
183
184
185} // namespace detail
186
187
188} // namespace
189
190
191
192
193#endif /* OPM_AUTODIFF_VFPHELPERS_HPP_ */
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27
Helper struct for linear interpolation.
Definition: VFPHelpers.hpp:84
An "ADB-like" structure with a single value and a set of derivatives.
Definition: VFPHelpers.hpp:102