My Project
Loading...
Searching...
No Matches
MultisegmentWellEquations.hpp
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#ifndef OPM_MULTISEGMENTWELL_EQUATIONS_HEADER_INCLUDED
23#define OPM_MULTISEGMENTWELL_EQUATIONS_HEADER_INCLUDED
24
25#include <dune/common/fmatrix.hh>
26#include <dune/common/fvector.hh>
27#include <dune/istl/bcrsmatrix.hh>
28#include <dune/istl/bvector.hh>
29
30#include <memory>
31
32namespace Dune {
33template<class M> class UMFPack;
34}
35
36namespace Opm
37{
38
39template<class Scalar, int numWellEq, int numEq> class MultisegmentWellEquationAccess;
40template<class Scalar> class MultisegmentWellGeneric;
41#if COMPILE_BDA_BRIDGE
42template<class Scalar> class WellContributions;
43#endif
44template<class Scalar> class WellInterfaceGeneric;
45template<class Scalar> class WellState;
46
47template<class Scalar, int numWellEq, int numEq>
49{
50public:
51 // sparsity pattern for the matrices
52 // [A C^T [x = [ res
53 // B D ] x_well] res_well]
54
55 // the vector type for the res_well and x_well
56 using VectorBlockWellType = Dune::FieldVector<Scalar,numWellEq>;
57 using BVectorWell = Dune::BlockVector<VectorBlockWellType>;
58
59 using VectorBlockType = Dune::FieldVector<Scalar,numEq>;
60 using BVector = Dune::BlockVector<VectorBlockType>;
61
62 // the matrix type for the diagonal matrix D
63 using DiagMatrixBlockWellType = Dune::FieldMatrix<Scalar,numWellEq,numWellEq>;
64 using DiagMatWell = Dune::BCRSMatrix<DiagMatrixBlockWellType>;
65
66 // the matrix type for the non-diagonal matrix B and C^T
67 using OffDiagMatrixBlockWellType = Dune::FieldMatrix<Scalar,numWellEq,numEq>;
68 using OffDiagMatWell = Dune::BCRSMatrix<OffDiagMatrixBlockWellType>;
69
71
77 void init(const int numPerfs,
78 const std::vector<int>& cells,
79 const std::vector<std::vector<int>>& segment_inlets,
80 const std::vector<std::vector<int>>& segment_perforations);
81
83 void clear();
84
86 void apply(const BVector& x, BVector& Ax) const;
87
89 void apply(BVector& r) const;
90
92 void createSolver();
93
95 BVectorWell solve() const;
96
98 BVectorWell solve(const BVectorWell& rhs) const;
99
102 void recoverSolutionWell(const BVector& x, BVectorWell& xw) const;
103
104#if COMPILE_BDA_BRIDGE
106 void extract(WellContributions<Scalar>& wellContribs) const;
107#endif
108
110 template<class SparseMatrixAdapter>
111 void extract(SparseMatrixAdapter& jacobian) const;
112
114 template<class PressureMatrix>
115 void extractCPRPressureMatrix(PressureMatrix& jacobian,
116 const BVector& weights,
117 const int pressureVarIndex,
118 const bool /*use_well_weights*/,
120 const int seg_pressure_var_ind,
121 const WellState<Scalar>& well_state) const;
122
124 const BVectorWell& residual() const
125 {
126 return resWell_;
127 }
128
129 private:
130 friend class MultisegmentWellEquationAccess<Scalar,numWellEq,numEq>;
131 // two off-diagonal matrices
132 OffDiagMatWell duneB_;
133 OffDiagMatWell duneC_;
134 // "diagonal" matrix for the well. It has offdiagonal entries for inlets and outlets.
135 DiagMatWell duneD_;
136
140 mutable std::shared_ptr<Dune::UMFPack<DiagMatWell>> duneDSolver_;
141
142 // residuals of the well equations
143 BVectorWell resWell_;
144
146
147 // Store the global index of well perforated cells
148 std::vector<int> cells_;
149};
150
151}
152
153#endif // OPM_MULTISEGMENTWELLWELL_EQUATIONS_HEADER_INCLUDED
Definition MultisegmentWellEquations.hpp:33
Class administering assembler access to equation system.
Definition MultisegmentWellEquations.hpp:39
Definition MultisegmentWellEquations.hpp:49
void extractCPRPressureMatrix(PressureMatrix &jacobian, const BVector &weights, const int pressureVarIndex, const bool, const WellInterfaceGeneric< Scalar > &well, const int seg_pressure_var_ind, const WellState< Scalar > &well_state) const
Extract CPR pressure matrix.
Definition MultisegmentWellEquations.cpp:322
void clear()
Set all coefficients to 0.
Definition MultisegmentWellEquations.cpp:130
void apply(const BVector &x, BVector &Ax) const
Apply linear operator to vector.
Definition MultisegmentWellEquations.cpp:141
void extract(SparseMatrixAdapter &jacobian) const
Add the matrices of this well to the sparse matrix adapter.
Definition MultisegmentWellEquations.cpp:285
void recoverSolutionWell(const BVector &x, BVectorWell &xw) const
Recover well solution.
Definition MultisegmentWellEquations.cpp:200
void createSolver()
Compute the LU-decomposition of D matrix.
Definition MultisegmentWellEquations.cpp:165
void init(const int numPerfs, const std::vector< int > &cells, const std::vector< std::vector< int > > &segment_inlets, const std::vector< std::vector< int > > &segment_perforations)
Setup sparsity pattern for the matrices.
Definition MultisegmentWellEquations.cpp:58
BVectorWell solve() const
Apply inverted D matrix to residual and return result.
Definition MultisegmentWellEquations.cpp:186
const BVectorWell & residual() const
Returns a const reference to the residual.
Definition MultisegmentWellEquations.hpp:124
Definition MultisegmentWellPrimaryVariables.hpp:39
This class serves to eliminate the need to include the WellContributions into the matrix (with –matri...
Definition StandardWellEval.hpp:41
Definition WellTest.hpp:37
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition WellState.hpp:62
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37