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 <functional>
25#include <map>
26#include <vector>
27#include <optional>
28
32namespace Opm {
33
34class VFPInjTable;
35class VFPProdTable;
36
37namespace detail {
38
42template<class Scalar>
44{
45 VFPEvaluation() : value(0.0), dthp(0.0), dwfr(0.0), dgfr(0.0), dalq(0.0), dflo(0.0) {};
46 Scalar value;
47 Scalar dthp;
48 Scalar dwfr;
49 Scalar dgfr;
50 Scalar dalq;
51 Scalar dflo;
52};
53
54template<class Scalar>
56template<class Scalar>
58template<class Scalar>
60
64template<class Scalar>
66{
67 InterpData() : ind_{0, 0}, inv_dist_(0.0), factor_(0.0) {}
68 int ind_[2]; //[First element greater than or equal to value, Last element smaller than or equal to value]
69 Scalar 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
70 Scalar factor_; // Interpolation factor
71};
72
78template <typename T>
79T getFlo(const VFPProdTable& table,
80 const T& aqua,
81 const T& liquid,
82 const T& vapour);
83
89template <typename T>
90T getFlo(const VFPInjTable& table,
91 const T& aqua,
92 const T& liquid,
93 const T& vapour);
94
99template <typename T>
100T getWFR(const VFPProdTable& table,
101 const T& aqua,
102 const T& liquid,
103 const T& vapour);
104
109template <typename T>
110T getGFR(const VFPProdTable& table,
111 const T& aqua,
112 const T& liquid,
113 const T& vapour);
114
118template <typename T>
119const T& getTable(const std::map<int, std::reference_wrapper<const T>>& tables, int table_id);
120
124template <typename T>
125bool hasTable(const std::map<int, std::reference_wrapper<const T>>& tables, int table_id) {
126 const auto entry = tables.find(table_id);
127 return (entry != tables.end() );
128}
129
133template <typename TYPE, typename TABLE>
134TYPE getType(const TABLE& table);
135
136}
137
138template<class Scalar>
140public:
147 static detail::InterpData<Scalar> findInterpData(const Scalar value_in,
148 const std::vector<double>& values);
149
153 static detail::VFPEvaluation<Scalar> interpolate(const VFPProdTable& table,
154 const detail::InterpData<Scalar>& flo_i,
155 const detail::InterpData<Scalar>& thp_i,
156 const detail::InterpData<Scalar>& wfr_i,
157 const detail::InterpData<Scalar>& gfr_i,
158 const detail::InterpData<Scalar>& alq_i);
159
164 static detail::VFPEvaluation<Scalar> interpolate(const VFPInjTable& table,
165 const detail::InterpData<Scalar>& flo_i,
166 const detail::InterpData<Scalar>& thp_i);
167
168 static detail::VFPEvaluation<Scalar> bhp(const VFPProdTable& table,
169 const Scalar aqua,
170 const Scalar liquid,
171 const Scalar vapour,
172 const Scalar thp,
173 const Scalar alq,
174 const Scalar explicit_wfr,
175 const Scalar explicit_gfr,
176 const bool use_vfpexplicit);
177
178 static detail::VFPEvaluation<Scalar> bhp(const VFPInjTable& table,
179 const Scalar aqua,
180 const Scalar liquid,
181 const Scalar vapour,
182 const Scalar thp);
183
190 static Scalar findTHP(const std::vector<Scalar>& bhp_array,
191 const std::vector<double>& thp_array,
192 Scalar bhp,
193 const bool find_largest = true);
194
198 static std::pair<Scalar, Scalar>
199 getMinimumBHPCoordinate(const VFPProdTable& table,
200 const Scalar thp,
201 const Scalar wfr,
202 const Scalar gfr,
203 const Scalar alq);
204
209 static std::optional<std::pair<Scalar, Scalar>>
210 intersectWithIPR(const VFPProdTable& table,
211 const Scalar thp,
212 const Scalar wfr,
213 const Scalar gfr,
214 const Scalar alq,
215 const Scalar ipr_a,
216 const Scalar ipr_b,
217 const std::function<Scalar(const Scalar)>& adjust_bhp);
218};
219
220} // namespace
221
222#endif /* OPM_AUTODIFF_VFPHELPERS_HPP_ */
Definition: VFPHelpers.hpp:139
static Scalar findTHP(const std::vector< Scalar > &bhp_array, const std::vector< double > &thp_array, Scalar bhp, const bool find_largest=true)
static std::optional< std::pair< Scalar, Scalar > > intersectWithIPR(const VFPProdTable &table, const Scalar thp, const Scalar wfr, const Scalar gfr, const Scalar alq, const Scalar ipr_a, const Scalar ipr_b, const std::function< Scalar(const Scalar)> &adjust_bhp)
static detail::VFPEvaluation< Scalar > interpolate(const VFPInjTable &table, const detail::InterpData< Scalar > &flo_i, const detail::InterpData< Scalar > &thp_i)
static detail::InterpData< Scalar > findInterpData(const Scalar value_in, const std::vector< double > &values)
static detail::VFPEvaluation< Scalar > bhp(const VFPInjTable &table, const Scalar aqua, const Scalar liquid, const Scalar vapour, const Scalar thp)
static detail::VFPEvaluation< Scalar > bhp(const VFPProdTable &table, const Scalar aqua, const Scalar liquid, const Scalar vapour, const Scalar thp, const Scalar alq, const Scalar explicit_wfr, const Scalar explicit_gfr, const bool use_vfpexplicit)
static detail::VFPEvaluation< Scalar > interpolate(const VFPProdTable &table, const detail::InterpData< Scalar > &flo_i, const detail::InterpData< Scalar > &thp_i, const detail::InterpData< Scalar > &wfr_i, const detail::InterpData< Scalar > &gfr_i, const detail::InterpData< Scalar > &alq_i)
static std::pair< Scalar, Scalar > getMinimumBHPCoordinate(const VFPProdTable &table, const Scalar thp, const Scalar wfr, const Scalar gfr, const Scalar alq)
T getWFR(const VFPProdTable &table, const T &aqua, const T &liquid, const T &vapour)
VFPEvaluation< Scalar > operator+(VFPEvaluation< Scalar > lhs, const VFPEvaluation< Scalar > &rhs)
VFPEvaluation< Scalar > operator-(VFPEvaluation< Scalar > lhs, const VFPEvaluation< Scalar > &rhs)
VFPEvaluation< Scalar > operator*(Scalar lhs, const VFPEvaluation< Scalar > &rhs)
TYPE getType(const TABLE &table)
bool hasTable(const std::map< int, std::reference_wrapper< const T > > &tables, int table_id)
Definition: VFPHelpers.hpp:125
T getGFR(const VFPProdTable &table, const T &aqua, const T &liquid, const T &vapour)
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)
Definition: blackoilboundaryratevector.hh:37
Definition: VFPHelpers.hpp:66
Scalar inv_dist_
Definition: VFPHelpers.hpp:69
Scalar factor_
Definition: VFPHelpers.hpp:70
InterpData()
Definition: VFPHelpers.hpp:67
int ind_[2]
Definition: VFPHelpers.hpp:68
Definition: VFPHelpers.hpp:44
Scalar dwfr
Definition: VFPHelpers.hpp:48
Scalar dthp
Definition: VFPHelpers.hpp:47
VFPEvaluation()
Definition: VFPHelpers.hpp:45
Scalar dalq
Definition: VFPHelpers.hpp:50
Scalar value
Definition: VFPHelpers.hpp:46
Scalar dflo
Definition: VFPHelpers.hpp:51
Scalar dgfr
Definition: VFPHelpers.hpp:49