MSWellHelpers.hpp
Go to the documentation of this file.
1/*
2 Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
3 Copyright 2017 Statoil ASA.
4 Copyright 2020 Equinor ASA.
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_MSWELLHELPERS_HEADER_INCLUDED
24#define OPM_MSWELLHELPERS_HEADER_INCLUDED
25
26#include <dune/istl/matrix.hh>
27
28#include <algorithm>
29#include <cassert>
30#include <cstddef>
31
32namespace Dune {
33template<class Matrix> class UMFPack;
34}
35
36namespace Opm {
37
38template<class Scalar> class ParallelWellInfo;
39class DeferredLogger;
40class SICD;
41
42namespace mswellhelpers
43{
44
56 template<class MatrixType>
58 {
59 public:
60 using Scalar = typename MatrixType::field_type;
61 ParallellMSWellB(const MatrixType& B,
62 const ParallelWellInfo<Scalar>& parallel_well_info);
63
65 template<class X, class Y>
66 void mv (const X& x, Y& y) const;
67
69 template<class X, class Y>
70 void mmv (const X& x, Y& y) const;
71
72 private:
73 const MatrixType& B_;
74 const ParallelWellInfo<Scalar>& parallel_well_info_;
75 };
76
78 template <typename MatrixType, typename VectorType>
79 VectorType
81 VectorType x);
82
104 template <class DiagMatWell, class WellWeight>
105 typename DiagMatWell::field_type
106 contractCprWellDiagonal(const DiagMatWell& D,
107 const WellWeight& lambda,
108 const int pressureColumn)
109 {
110 using Scalar = typename DiagMatWell::field_type;
111 using Block = typename DiagMatWell::block_type;
112
113 // Conservation rows come first and the segment pressure is last; a
114 // reordering of the well variables must update this. Extra reservoir
115 // weights (e.g. EXTBO) have no well row, as in StandardWellEquations.
116 assert(pressureColumn == Block::cols - 1);
117 const std::size_t numConservationRows =
118 std::min(lambda.size(), static_cast<std::size_t>(Block::rows - 1));
119
120 Scalar diag = 0.0;
121 for (std::size_t row = 0; row < D.N(); ++row) {
122 for (auto col = D[row].begin(), end = D[row].end(); col != end; ++col) {
123 for (std::size_t i = 0; i < numConservationRows; ++i) {
124 diag += lambda[i] * (*col)[i][pressureColumn];
125 }
126 }
127 }
128 return (diag == 0.0) ? Scalar{1.0} : diag;
129 }
130
131
132
134 template <typename VectorType, typename MatrixType>
135 Dune::Matrix<typename MatrixType::block_type>
136 invertWithUMFPack(const int size,
137 const int bsize,
138 Dune::UMFPack<MatrixType>& linsolver);
139
140
141
142 // obtain y = D^-1 * x with a BICSSTAB iterative solver
143 template <typename MatrixType, typename VectorType>
144 VectorType
145 invDX(const MatrixType& D, VectorType x, DeferredLogger& deferred_logger);
146
147 // calculating the friction pressure loss
148 // l is the segment length
149 // area is the segment cross area
150 // diameter is the segment inner diameter
151 // w is mass flow rate through the segment
152 // density is density
153 // roughness is the absolute roughness
154 // mu is the average phase viscosity
155 template <typename ValueType, typename Scalar>
156 ValueType frictionPressureLoss(const Scalar l, const Scalar diameter,
157 const Scalar area, const Scalar roughness,
158 const ValueType& density,
159 const ValueType& w, const ValueType& mu);
160
161
162 template <typename ValueType, typename Scalar>
163 ValueType valveContrictionPressureLoss(const ValueType& mass_rate,
164 const ValueType& density,
165 const Scalar area_con, const Scalar cv);
166
167
168 template <typename ValueType, typename Scalar>
169 ValueType velocityHead(const Scalar area, const ValueType& mass_rate,
170 const ValueType& density);
171
172
173 // calculating the viscosity of oil-water emulsion at local conditons
174 template <typename ValueType, typename Scalar>
175 ValueType emulsionViscosity(const ValueType& water_fraction,
176 const ValueType& water_viscosity,
177 const ValueType& oil_fraction,
178 const ValueType& oil_viscosity,
179 const SICD& sicd);
180
181} // namespace mswellhelpers
182} // namespace Opm
183
184#endif
Definition: MSWellHelpers.hpp:33
Definition: DeferredLogger.hpp:57
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:217
A wrapper around the B matrix for distributed MS wells.
Definition: MSWellHelpers.hpp:58
typename MatrixType::field_type Scalar
Definition: MSWellHelpers.hpp:60
void mv(const X &x, Y &y) const
y = A x
ParallellMSWellB(const MatrixType &B, const ParallelWellInfo< Scalar > &parallel_well_info)
void mmv(const X &x, Y &y) const
y = A x
Definition: fvbaseprimaryvariables.hh:161
ValueType velocityHead(const Scalar area, const ValueType &mass_rate, const ValueType &density)
ValueType valveContrictionPressureLoss(const ValueType &mass_rate, const ValueType &density, const Scalar area_con, const Scalar cv)
VectorType applyUMFPack(Dune::UMFPack< MatrixType > &linsolver, VectorType x)
Applies umfpack and checks for singularity.
ValueType frictionPressureLoss(const Scalar l, const Scalar diameter, const Scalar area, const Scalar roughness, const ValueType &density, const ValueType &w, const ValueType &mu)
Dune::Matrix< typename MatrixType::block_type > invertWithUMFPack(const int size, const int bsize, Dune::UMFPack< MatrixType > &linsolver)
Applies umfpack and checks for singularity.
DiagMatWell::field_type contractCprWellDiagonal(const DiagMatWell &D, const WellWeight &lambda, const int pressureColumn)
Definition: MSWellHelpers.hpp:106
ValueType emulsionViscosity(const ValueType &water_fraction, const ValueType &water_viscosity, const ValueType &oil_fraction, const ValueType &oil_viscosity, const SICD &sicd)
VectorType invDX(const MatrixType &D, VectorType x, DeferredLogger &deferred_logger)
Definition: blackoilbioeffectsmodules.hh:45