MultisegmentWellEval.hpp
Go to the documentation of this file.
1/*
2 Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
3 Copyright 2017 Statoil ASA.
4
5 This file is part of the Open Porous Media project (OPM).
6
7 OPM is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 OPM is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with OPM. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21
22#ifndef OPM_MULTISEGMENTWELL_EVAL_HEADER_INCLUDED
23#define OPM_MULTISEGMENTWELL_EVAL_HEADER_INCLUDED
24
30
31#include <opm/grid/utility/SparseTable.hpp>
32
33#include <opm/material/densead/Evaluation.hpp>
34
35#include <utility>
36#include <vector>
37
38namespace Opm {
39
40class ConvergenceReport;
41class Schedule;
42class SummaryState;
43
44template<class FluidSystem, class Indices> class WellInterfaceIndices;
45template<typename Scalar, typename IndexTraits> class WellState;
46
47template<typename FluidSystem, typename Indices>
48class MultisegmentWellEval : public MultisegmentWellGeneric<typename FluidSystem::Scalar,
49 typename FluidSystem::IndexTraitsType>
50{
51public:
52 using Scalar = typename FluidSystem::Scalar;
54
55protected:
56 using IndexTraits = typename FluidSystem::IndexTraitsType;
57 static constexpr int numWellEq = PrimaryVariables::numWellEq;
58 static constexpr int SPres = PrimaryVariables::SPres;
59 static constexpr int WQTotal = PrimaryVariables::WQTotal;
60
63
66
67 using BVector = typename Equations::BVector;
69
70 // TODO: for more efficient implementation, we should have EvalReservoir, EvalWell, and EvalRerservoirAndWell
71 // EvalR (Eval), EvalW, EvalRW
72 // TODO: for now, we only use one type to save some implementation efforts, while improve later.
74 using Eval = DenseAd::Evaluation<Scalar, /*size=*/Indices::numDerivatives>;
75
76public:
78 const Equations& linSys() const
79 { return linSys_; }
80
81 static constexpr int numResDofs = Indices::numEq;
82 static constexpr int numWellDofs = PrimaryVariables::numWellEq;// numResDofs + 1; // NB will fail for for thermal for now
83 using BMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numWellDofs, numResDofs>>;
84 using CMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numResDofs, numWellDofs>>;
85 using DMatrix = Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, numWellDofs, numWellDofs>>;
86 using WVector = Dune::BlockVector<Dune::FieldVector<Scalar, numWellDofs>>;
87
88 void addBCDMatrix(std::vector<BMatrix>& b_matrices,
89 std::vector<CMatrix>& c_matrices,
90 std::vector<DMatrix>& d_matrices,
91 Opm::SparseTable<int>& wcells) const;
92protected:
94
95 void initMatrixAndVectors(const ParallelWellInfo<Scalar>& parallel_well_info);
96
97 void assembleDefaultPressureEq(const int seg,
99 const bool use_average_density);
100
101 // assemble pressure equation for ICD segments
102 void assembleICDPressureEq(const int seg,
103 const UnitSystem& unit_system,
105 const SummaryState& summary_state,
106 const bool use_average_density,
107 DeferredLogger& deferred_logger);
108
111 const bool use_average_density);
112
113
114 void assemblePressureEq(const int seg,
115 const UnitSystem& unit_system,
117 const SummaryState& summary_state,
118 const bool use_average_density,
119 DeferredLogger& deferred_logger);
120
123 const std::vector<Scalar>& B_avg,
124 DeferredLogger& deferred_logger,
125 const Scalar max_residual_allowed,
126 const Scalar tolerance_wells,
127 const Scalar relaxed_inner_tolerance_flow_ms_well,
128 const Scalar tolerance_pressure_ms_wells,
129 const Scalar relaxed_inner_tolerance_pressure_ms_well,
130 const bool relax_tolerance,
131 const bool well_is_stopped) const;
132
133 std::pair<bool, std::vector<Scalar> >
134 getFiniteWellResiduals(const std::vector<Scalar>& B_avg,
135 DeferredLogger& deferred_logger) const;
136
138 const Scalar tolerance_wells,
139 const Scalar tolerance_pressure_ms_wells,
140 DeferredLogger& deferred_logger) const;
141
143 const std::vector<Scalar>& residuals,
144 const Scalar tolerance_wells,
145 const Scalar tolerance_pressure_ms_wells,
146 DeferredLogger& deferred_logger) const;
147
150
151 // convert a Eval from reservoir to contain the derivative related to wells
152 EvalWell extendEval(const Eval& in) const;
153
155
159
160 // depth difference between perforations and the perforated grid cells
161 std::vector<Scalar> cell_perforation_depth_diffs_;
162 // pressure correction due to the different depth of the perforation and
163 // center depth of the grid block
165};
166
167}
168
169#endif // OPM_MULTISEGMENTWELL_GENERIC_HEADER_INCLUDED
Definition: ConvergenceReport.hpp:38
Definition: DeferredLogger.hpp:57
Dune::BlockVector< VectorBlockWellType > BVectorWell
Definition: MultisegmentWellEquations.hpp:61
Dune::BlockVector< VectorBlockType > BVector
Definition: MultisegmentWellEquations.hpp:64
Definition: MultisegmentWellEval.hpp:50
Dune::BCRSMatrix< Dune::FieldMatrix< Scalar, numResDofs, numWellDofs > > CMatrix
Definition: MultisegmentWellEval.hpp:84
Dune::BlockVector< Dune::FieldVector< Scalar, numWellDofs > > WVector
Definition: MultisegmentWellEval.hpp:86
static constexpr int numWellEq
Definition: MultisegmentWellEval.hpp:57
EvalWell extendEval(const Eval &in) const
static constexpr int SPres
Definition: MultisegmentWellEval.hpp:58
static constexpr int WQTotal
Definition: MultisegmentWellEval.hpp:59
const WellInterfaceIndices< FluidSystem, Indices > & baseif_
Definition: MultisegmentWellEval.hpp:154
static constexpr int numWellDofs
Definition: MultisegmentWellEval.hpp:82
Scalar getControlTolerance(const WellState< Scalar, IndexTraits > &well_state, const Scalar tolerance_wells, const Scalar tolerance_pressure_ms_wells, DeferredLogger &deferred_logger) const
void addBCDMatrix(std::vector< BMatrix > &b_matrices, std::vector< CMatrix > &c_matrices, std::vector< DMatrix > &d_matrices, Opm::SparseTable< int > &wcells) const
std::pair< bool, std::vector< Scalar > > getFiniteWellResiduals(const std::vector< Scalar > &B_avg, DeferredLogger &deferred_logger) const
Equations linSys_
The equation system.
Definition: MultisegmentWellEval.hpp:156
void assembleDefaultPressureEq(const int seg, WellState< Scalar, IndexTraits > &well_state, const bool use_average_density)
typename PrimaryVariables::EvalWell EvalWell
Definition: MultisegmentWellEval.hpp:73
static constexpr bool enable_energy
Definition: MultisegmentWellEval.hpp:61
std::vector< Scalar > cell_perforation_depth_diffs_
Definition: MultisegmentWellEval.hpp:161
void assembleICDPressureEq(const int seg, const UnitSystem &unit_system, WellState< Scalar, IndexTraits > &well_state, const SummaryState &summary_state, const bool use_average_density, DeferredLogger &deferred_logger)
typename Equations::BVectorWell BVectorWell
Definition: MultisegmentWellEval.hpp:68
const Equations & linSys() const
Returns a const reference to equation system.
Definition: MultisegmentWellEval.hpp:78
PrimaryVariables primary_variables_
The primary variables.
Definition: MultisegmentWellEval.hpp:157
std::vector< Scalar > cell_perforation_pressure_diffs_
Definition: MultisegmentWellEval.hpp:164
typename FluidSystem::IndexTraitsType IndexTraits
Definition: MultisegmentWellEval.hpp:56
void assemblePressureEq(const int seg, const UnitSystem &unit_system, WellState< Scalar, IndexTraits > &well_state, const SummaryState &summary_state, const bool use_average_density, DeferredLogger &deferred_logger)
MultisegmentWellEval(WellInterfaceIndices< FluidSystem, Indices > &baseif, const ParallelWellInfo< Scalar > &parallel_well_info)
MSWSegments segments_
Segment properties.
Definition: MultisegmentWellEval.hpp:158
Dune::BCRSMatrix< Dune::FieldMatrix< Scalar, numWellDofs, numWellDofs > > DMatrix
Definition: MultisegmentWellEval.hpp:85
ConvergenceReport getWellConvergence(const WellState< Scalar, IndexTraits > &well_state, const std::vector< Scalar > &B_avg, DeferredLogger &deferred_logger, const Scalar max_residual_allowed, const Scalar tolerance_wells, const Scalar relaxed_inner_tolerance_flow_ms_well, const Scalar tolerance_pressure_ms_wells, const Scalar relaxed_inner_tolerance_pressure_ms_well, const bool relax_tolerance, const bool well_is_stopped) const
check whether the well equations get converged for this well
DenseAd::Evaluation< Scalar, Indices::numDerivatives > Eval
Definition: MultisegmentWellEval.hpp:74
void initMatrixAndVectors(const ParallelWellInfo< Scalar > &parallel_well_info)
Dune::BCRSMatrix< Dune::FieldMatrix< Scalar, numWellDofs, numResDofs > > BMatrix
Definition: MultisegmentWellEval.hpp:83
Scalar getResidualMeasureValue(const WellState< Scalar, IndexTraits > &well_state, const std::vector< Scalar > &residuals, const Scalar tolerance_wells, const Scalar tolerance_pressure_ms_wells, DeferredLogger &deferred_logger) const
static constexpr int numResDofs
Definition: MultisegmentWellEval.hpp:81
void assembleAccelerationPressureLoss(const int seg, WellState< Scalar, IndexTraits > &well_state)
void assembleAccelerationAndHydroPressureLosses(const int seg, WellState< Scalar, IndexTraits > &well_state, const bool use_average_density)
typename FluidSystem::Scalar Scalar
Definition: MultisegmentWellEval.hpp:52
static constexpr int Temperature
Definition: MultisegmentWellEval.hpp:62
typename Equations::BVector BVector
Definition: MultisegmentWellEval.hpp:67
Definition: MultisegmentWellGeneric.hpp:39
Definition: MultisegmentWellPrimaryVariables.hpp:45
DenseAd::Evaluation< Scalar, Indices::numEq+numWellEq > EvalWell
Definition: MultisegmentWellPrimaryVariables.hpp:79
static constexpr int numWellEq
Definition: MultisegmentWellPrimaryVariables.hpp:75
static constexpr int Temperature
Definition: MultisegmentWellPrimaryVariables.hpp:71
static constexpr int SPres
Definition: MultisegmentWellPrimaryVariables.hpp:72
static constexpr bool enable_energy
Definition: MultisegmentWellPrimaryVariables.hpp:64
static constexpr int WQTotal
Definition: MultisegmentWellPrimaryVariables.hpp:66
Definition: MultisegmentWellSegments.hpp:45
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:198
Definition: WellInterfaceIndices.hpp:34
Definition: WellState.hpp:66
Definition: blackoilbioeffectsmodules.hh:45