VFPHelpers.hpp
Go to the documentation of this file.
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#include <optional>
29
33namespace Opm {
34
35class VFPInjTable;
36class VFPProdTable;
37
38namespace detail {
39
45template <typename T>
46T getFlo(const VFPProdTable& table,
47 const T& aqua,
48 const T& liquid,
49 const T& vapour);
50
56template <typename T>
57T getFlo(const VFPInjTable& table,
58 const T& aqua,
59 const T& liquid,
60 const T& vapour);
61
66template <typename T>
67T getWFR(const VFPProdTable& table,
68 const T& aqua,
69 const T& liquid,
70 const T& vapour);
71
76template <typename T>
77T getGFR(const VFPProdTable& table,
78 const T& aqua,
79 const T& liquid,
80 const T& vapour);
81
85struct InterpData {
86 InterpData() : ind_{0, 0}, inv_dist_(0.0), factor_(0.0) {}
87 int ind_[2]; //[First element greater than or equal to value, Last element smaller than or equal to value]
88 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
89 double factor_; // Interpolation factor
90};
91
98InterpData findInterpData(const double value_in, const std::vector<double>& values);
99
104 VFPEvaluation() : value(0.0), dthp(0.0), dwfr(0.0), dgfr(0.0), dalq(0.0), dflo(0.0) {};
105 double value;
106 double dthp;
107 double dwfr;
108 double dgfr;
109 double dalq;
110 double dflo;
111};
112
115VFPEvaluation operator*(double lhs, const VFPEvaluation& rhs);
116
120VFPEvaluation interpolate(const VFPProdTable& table,
121 const InterpData& flo_i,
122 const InterpData& thp_i,
123 const InterpData& wfr_i,
124 const InterpData& gfr_i,
125 const InterpData& alq_i);
126
131VFPEvaluation interpolate(const VFPInjTable& table,
132 const InterpData& flo_i,
133 const InterpData& thp_i);
134
135VFPEvaluation bhp(const VFPProdTable& table,
136 const double aqua,
137 const double liquid,
138 const double vapour,
139 const double thp,
140 const double alq,
141 const double explicit_wfr,
142 const double explicit_gfr,
143 const bool use_vfpexplicit);
144
145VFPEvaluation bhp(const VFPInjTable& table,
146 const double aqua,
147 const double liquid,
148 const double vapour,
149 const double thp);
150
151
155template <typename T>
156const T& getTable(const std::map<int, std::reference_wrapper<const T>>& tables, int table_id);
157
161template <typename T>
162bool hasTable(const std::map<int, std::reference_wrapper<const T>>& tables, int table_id) {
163 const auto entry = tables.find(table_id);
164 return (entry != tables.end() );
165}
166
167
171template <typename TYPE, typename TABLE>
172TYPE getType(const TABLE& table);
173
174
181double findTHP(const std::vector<double>& bhp_array,
182 const std::vector<double>& thp_array,
183 double bhp);
184
188std::pair<double, double>
189getMinimumBHPCoordinate(const VFPProdTable& table,
190 const double thp,
191 const double wfr,
192 const double gfr,
193 const double alq);
194
199std::optional<std::pair<double, double>>
200intersectWithIPR(const VFPProdTable& table,
201 const double thp,
202 const double wfr,
203 const double gfr,
204 const double alq,
205 const double ipr_a,
206 const double ipr_b,
207 const std::function<double(const double)>& adjust_bhp);
208
209} // namespace detail
210
211
212} // namespace
213
214
215
216
217#endif /* OPM_AUTODIFF_VFPHELPERS_HPP_ */
T getWFR(const VFPProdTable &table, const T &aqua, const T &liquid, const T &vapour)
VFPEvaluation interpolate(const VFPProdTable &table, const InterpData &flo_i, const InterpData &thp_i, const InterpData &wfr_i, const InterpData &gfr_i, const InterpData &alq_i)
VFPEvaluation bhp(const VFPProdTable &table, const double aqua, const double liquid, const double vapour, const double thp, const double alq, const double explicit_wfr, const double explicit_gfr, const bool use_vfpexplicit)
VFPEvaluation operator*(double lhs, const VFPEvaluation &rhs)
std::optional< std::pair< double, double > > intersectWithIPR(const VFPProdTable &table, const double thp, const double wfr, const double gfr, const double alq, const double ipr_a, const double ipr_b, const std::function< double(const double)> &adjust_bhp)
std::pair< double, double > getMinimumBHPCoordinate(const VFPProdTable &table, const double thp, const double wfr, const double gfr, const double alq)
TYPE getType(const TABLE &table)
bool hasTable(const std::map< int, std::reference_wrapper< const T > > &tables, int table_id)
Definition: VFPHelpers.hpp:162
T getGFR(const VFPProdTable &table, const T &aqua, const T &liquid, const T &vapour)
double findTHP(const std::vector< double > &bhp_array, const std::vector< double > &thp_array, double bhp)
InterpData findInterpData(const double value_in, const std::vector< double > &values)
T getFlo(const VFPProdTable &table, const T &aqua, const T &liquid, const T &vapour)
const T & getTable(const std::map< int, std::reference_wrapper< const T > > &tables, int table_id)
VFPEvaluation operator-(VFPEvaluation lhs, const VFPEvaluation &rhs)
VFPEvaluation operator+(VFPEvaluation lhs, const VFPEvaluation &rhs)
Definition: BlackoilPhases.hpp:27
Definition: VFPHelpers.hpp:85
double factor_
Definition: VFPHelpers.hpp:89
InterpData()
Definition: VFPHelpers.hpp:86
double inv_dist_
Definition: VFPHelpers.hpp:88
int ind_[2]
Definition: VFPHelpers.hpp:87
Definition: VFPHelpers.hpp:103
double dalq
Definition: VFPHelpers.hpp:109
double dflo
Definition: VFPHelpers.hpp:110
double dgfr
Definition: VFPHelpers.hpp:108
VFPEvaluation()
Definition: VFPHelpers.hpp:104
double value
Definition: VFPHelpers.hpp:105
double dthp
Definition: VFPHelpers.hpp:106
double dwfr
Definition: VFPHelpers.hpp:107