My Project
Loading...
Searching...
No Matches
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 <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>
59VFPEvaluation<Scalar> operator*(Scalar lhs, const VFPEvaluation<Scalar>& rhs);
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:
148 const std::vector<double>& values);
149
159
167
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
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>
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>>
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 std::pair< Scalar, Scalar > getMinimumBHPCoordinate(const VFPProdTable &table, const Scalar thp, const Scalar wfr, const Scalar gfr, const Scalar alq)
Get (flo, bhp) at minimum bhp for given thp,wfr,gfr,alq.
Definition VFPHelpers.cpp:511
static Scalar findTHP(const std::vector< Scalar > &bhp_array, const std::vector< double > &thp_array, Scalar bhp, const bool find_largest=true)
This function finds the value of THP given a specific BHP.
Definition VFPHelpers.cpp:364
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)
Get (flo, bhp) at largest occuring stable vfp/ipr-intersection if it exists.
Definition VFPHelpers.cpp:544
static detail::InterpData< Scalar > findInterpData(const Scalar value_in, const std::vector< double > &values)
Helper function to find indices etc.
Definition VFPHelpers.cpp:83
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)
Helper function which interpolates data using the indices etc.
Definition VFPHelpers.cpp:145
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
Helper struct for linear interpolation.
Definition VFPHelpers.hpp:66
An "ADB-like" structure with a single value and a set of derivatives.
Definition VFPHelpers.hpp:44