StandardWellPrimaryVariables.hpp
Go to the documentation of this file.
1/*
2 Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
3 Copyright 2017 Statoil ASA.
4 Copyright 2016 - 2017 IRIS AS.
5
6 This file is part of the Open Porous Media project (OPM).
7
8 OPM is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 OPM is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with OPM. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22
23#ifndef OPM_STANDARDWELL_PRIMARY_VARIABLES_HEADER_INCLUDED
24#define OPM_STANDARDWELL_PRIMARY_VARIABLES_HEADER_INCLUDED
25
26#include <opm/material/densead/Evaluation.hpp>
27
29
30#include <vector>
31
32namespace Opm
33{
34
35class DeferredLogger;
36template<class FluidSystem, class Indices> class WellInterfaceIndices;
37template<typename Scalar, typename IndexTraits> class WellState;
38
40template<class FluidSystem, class Indices>
42protected:
43 // the positions of the primary variables for StandardWell
44 // the first one is the weighted total rate (WQ_t), the second and the third ones are F_w and F_g,
45 // which represent the fraction of Water and Gas based on the weighted total rate, the last one is BHP.
46 // correspondingly, we have four well equations for blackoil model, the first three are mass
47 // converstation equations, and the last one is the well control equation.
48 // primary variables related to other components, will be before the Bhp and after F_g.
49 // well control equation is always the last well equation.
50 // TODO: in the current implementation, we use the well rate as the first primary variables for injectors,
51 // instead of G_t.
52
53 // Table showing the primary variable indices, depending on what phases are present:
54 //
55 // WOG OG WG WO W/O/G (single phase)
56 // WQTotal 0 0 0 0 0
57 // WFrac 1 -1000 -1000 1 -1000
58 // GFrac 2 1 1 -1000 -1000
59 // Spres 3 2 2 2 1
60
62 static constexpr int numWellControlEq = 1;
63
64public:
66 static constexpr int numWellConservationEq = Indices::numPhases + Indices::numSolvents;
67
71
72 static constexpr int WQTotal = 0;
73
77 static constexpr int Bhp = numStaticWellEq - numWellControlEq;
78
79 static constexpr bool has_wfrac_variable = Indices::waterEnabled && Indices::oilEnabled;
80 static constexpr bool has_gfrac_variable = Indices::gasEnabled && Indices::numPhases > 1;
81 static constexpr int WFrac = has_wfrac_variable ? 1 : -1000;
82 static constexpr int GFrac = has_gfrac_variable ? has_wfrac_variable + 1 : -1000;
83 static constexpr int SFrac = !Indices::enableSolvent ? -1000 : has_wfrac_variable+has_gfrac_variable+1;
84
85 using Scalar = typename FluidSystem::Scalar;
86 using IndexTraits = typename FluidSystem::IndexTraitsType;
88 using EvalWell = DenseAd::DynamicEvaluation<Scalar, numStaticWellEq + Indices::numEq + 1>;
90
93 : well_(well)
94 {}
95
97 void resize(const int numWellEq);
98
100 int numWellEq() const { return numWellEq_; }
101
104 const bool stop_or_zero_rate_target,
105 DeferredLogger& deferred_logger);
106
109
111 void updateNewton(const BVectorWell& dwells,
112 const bool stop_or_zero_rate_target,
113 const Scalar dFLimit,
114 const Scalar dBHPLimit,
115 DeferredLogger& deferred_logger);
116
118 void updateNewtonPolyMW(const BVectorWell& dwells);
119
121 void checkFinite(DeferredLogger& deferred_logger) const;
122
125 DeferredLogger& deferred_logger) const;
126
129
131 EvalWell volumeFractionScaled(const int compIdx) const;
132
134 EvalWell surfaceVolumeFraction(const int compIdx) const;
135
137 EvalWell getQs(const int compIdx) const;
138
140 Scalar value(const int idx) const
141 { return value_[idx]; }
142
144 const EvalWell& eval(const int idx) const
145 { return evaluation_[idx]; }
146
148 void setValue(const int idx, const Scalar val)
149 { value_[idx] = val; }
150
151private:
153 void setEvaluationsFromValues();
154
157 Scalar relaxationFactorFractionsProducer(const BVectorWell& dwells,
158 DeferredLogger& deferred_logger) const;
159
161 EvalWell volumeFraction(const int compIdx) const;
162
164 void processFractions();
165
168 std::vector<Scalar> value_;
169
172 std::vector<EvalWell> evaluation_;
173
175
178 int numWellEq_ = numStaticWellEq;
179};
180
181}
182
183#endif // OPM_STANDARDWELL_PRIMARY_VARIABLES_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Definition: StandardWellEquations.hpp:47
Class holding primary variables for StandardWell.
Definition: StandardWellPrimaryVariables.hpp:41
void checkFinite(DeferredLogger &deferred_logger) const
Check that all values are finite.
void updateNewtonPolyMW(const BVectorWell &dwells)
Update polymer molecular weight values from newton update vector.
EvalWell volumeFractionScaled(const int compIdx) const
Returns scaled volume fraction for a component.
static constexpr int SFrac
Definition: StandardWellPrimaryVariables.hpp:83
int numWellEq() const
Returns number of well equations.
Definition: StandardWellPrimaryVariables.hpp:100
static constexpr bool has_gfrac_variable
Definition: StandardWellPrimaryVariables.hpp:80
void resize(const int numWellEq)
Resize values and evaluations.
DenseAd::DynamicEvaluation< Scalar, numStaticWellEq+Indices::numEq+1 > EvalWell
Evaluation for the well equations.
Definition: StandardWellPrimaryVariables.hpp:88
Scalar value(const int idx) const
Returns a value.
Definition: StandardWellPrimaryVariables.hpp:140
void updateNewton(const BVectorWell &dwells, const bool stop_or_zero_rate_target, const Scalar dFLimit, const Scalar dBHPLimit, DeferredLogger &deferred_logger)
Update values from newton update vector.
static constexpr int numWellControlEq
Number of the well control equations.
Definition: StandardWellPrimaryVariables.hpp:62
static constexpr bool has_wfrac_variable
Definition: StandardWellPrimaryVariables.hpp:79
typename StandardWellEquations< Scalar, IndexTraits, Indices::numEq >::BVectorWell BVectorWell
Definition: StandardWellPrimaryVariables.hpp:89
void update(const WellState< Scalar, IndexTraits > &well_state, const bool stop_or_zero_rate_target, DeferredLogger &deferred_logger)
Copy values from well state.
static constexpr int WQTotal
The index for the weighted total rate.
Definition: StandardWellPrimaryVariables.hpp:72
void updatePolyMW(const WellState< Scalar, IndexTraits > &well_state)
Copy polymer molecular weigt values from well state.
const EvalWell & eval(const int idx) const
Returns a const ref to an evaluation.
Definition: StandardWellPrimaryVariables.hpp:144
static constexpr int numStaticWellEq
Number of the well equations that will always be used.
Definition: StandardWellPrimaryVariables.hpp:70
static constexpr int GFrac
Definition: StandardWellPrimaryVariables.hpp:82
EvalWell surfaceVolumeFraction(const int compIdx) const
Returns surface volume fraction for a component.
typename FluidSystem::Scalar Scalar
Definition: StandardWellPrimaryVariables.hpp:85
void setValue(const int idx, const Scalar val)
Set a value. Note that this does not also set the corresponding evaluation.
Definition: StandardWellPrimaryVariables.hpp:148
void copyToWellState(WellState< Scalar, IndexTraits > &well_state, DeferredLogger &deferred_logger) const
Copy values to well state.
typename FluidSystem::IndexTraitsType IndexTraits
Definition: StandardWellPrimaryVariables.hpp:86
EvalWell getQs(const int compIdx) const
Returns scaled rate for a component.
static constexpr int numWellConservationEq
Number of the conservation equations.
Definition: StandardWellPrimaryVariables.hpp:66
static constexpr int WFrac
Definition: StandardWellPrimaryVariables.hpp:81
StandardWellPrimaryVariables(const WellInterfaceIndices< FluidSystem, Indices > &well)
Constructor initializes reference to well interface.
Definition: StandardWellPrimaryVariables.hpp:92
static constexpr int Bhp
The index for Bhp in primary variables and the index of well control equation.
Definition: StandardWellPrimaryVariables.hpp:77
void copyToWellStatePolyMW(WellState< Scalar, IndexTraits > &well_state) const
Copy polymer molecular weight values to well state.
Definition: WellInterfaceIndices.hpp:34
Definition: WellState.hpp:66
Definition: blackoilboundaryratevector.hh:39