My Project
MultisegmentWellEval.hpp
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
25#include <opm/simulators/wells/MultisegmentWellEquations.hpp>
26#include <opm/simulators/wells/MultisegmentWellGeneric.hpp>
27#include <opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp>
28#include <opm/simulators/wells/MultisegmentWellSegments.hpp>
29
30#include <opm/material/densead/Evaluation.hpp>
31
32#include <array>
33#include <memory>
34#include <utility>
35#include <vector>
36
37namespace Opm
38{
39
40class ConvergenceReport;
41class GroupState;
42class Schedule;
43class WellContributions;
44template<class FluidSystem, class Indices, class Scalar> class WellInterfaceIndices;
45class WellState;
46
47template<typename FluidSystem, typename Indices, typename Scalar>
49{
50protected:
52 static constexpr int numWellEq = PrimaryVariables::numWellEq;
53 static constexpr int SPres = PrimaryVariables::SPres;
54 static constexpr int WQTotal = PrimaryVariables::WQTotal;
55
58
59 using BVector = typename Equations::BVector;
60 using BVectorWell = typename Equations::BVectorWell;
61
62 // TODO: for more efficient implementation, we should have EvalReservoir, EvalWell, and EvalRerservoirAndWell
63 // EvalR (Eval), EvalW, EvalRW
64 // TODO: for now, we only use one type to save some implementation efforts, while improve later.
65 using EvalWell = typename PrimaryVariables::EvalWell;
66 using Eval = DenseAd::Evaluation<Scalar, /*size=*/Indices::numEq>;
67
68public:
70 const Equations& linSys() const
71 { return linSys_; }
72
73protected:
75
76 void initMatrixAndVectors(const int num_cells);
77
78 void assembleDefaultPressureEq(const int seg,
79 WellState& well_state);
80
81 // assemble pressure equation for ICD segments
82 void assembleICDPressureEq(const int seg,
83 const UnitSystem& unit_system,
84 WellState& well_state,
85 DeferredLogger& deferred_logger);
86
87
88 void assemblePressureEq(const int seg,
89 const UnitSystem& unit_system,
90 WellState& well_state,
91 DeferredLogger& deferred_logger);
92
95 const std::vector<double>& B_avg,
96 DeferredLogger& deferred_logger,
97 const double max_residual_allowed,
98 const double tolerance_wells,
99 const double relaxed_inner_tolerance_flow_ms_well,
100 const double tolerance_pressure_ms_wells,
101 const double relaxed_inner_tolerance_pressure_ms_well,
102 const bool relax_tolerance) const;
103
104 std::pair<bool, std::vector<Scalar> >
105 getFiniteWellResiduals(const std::vector<Scalar>& B_avg,
106 DeferredLogger& deferred_logger) const;
107
108 double getControlTolerance(const WellState& well_state,
109 const double tolerance_wells,
110 const double tolerance_pressure_ms_wells,
111 DeferredLogger& deferred_logger) const;
112
113 double getResidualMeasureValue(const WellState& well_state,
114 const std::vector<double>& residuals,
115 const double tolerance_wells,
116 const double tolerance_pressure_ms_wells,
117 DeferredLogger& deferred_logger) const;
118
119 void handleAccelerationPressureLoss(const int seg,
120 WellState& well_state);
121
122 EvalWell pressureDropAutoICD(const int seg,
123 const UnitSystem& unit_system) const;
124
125 // convert a Eval from reservoir to contain the derivative related to wells
126 EvalWell extendEval(const Eval& in) const;
127
129
133
134 // depth difference between perforations and the perforated grid cells
135 std::vector<double> cell_perforation_depth_diffs_;
136 // pressure correction due to the different depth of the perforation and
137 // center depth of the grid block
138 std::vector<double> cell_perforation_pressure_diffs_;
139};
140
141}
142
143#endif // OPM_MULTISEGMENTWELL_GENERIC_HEADER_INCLUDED
Represents the convergence status of the whole simulator, to make it possible to query and store the ...
Definition: ConvergenceReport.hpp:38
Definition: DeferredLogger.hpp:57
Definition: MultisegmentWellEval.hpp:49
Equations linSys_
The equation system.
Definition: MultisegmentWellEval.hpp:130
PrimaryVariables primary_variables_
The primary variables.
Definition: MultisegmentWellEval.hpp:131
ConvergenceReport getWellConvergence(const WellState &well_state, const std::vector< double > &B_avg, DeferredLogger &deferred_logger, const double max_residual_allowed, const double tolerance_wells, const double relaxed_inner_tolerance_flow_ms_well, const double tolerance_pressure_ms_wells, const double relaxed_inner_tolerance_pressure_ms_well, const bool relax_tolerance) const
check whether the well equations get converged for this well
Definition: MultisegmentWellEval.cpp:81
const Equations & linSys() const
Returns a const reference to equation system.
Definition: MultisegmentWellEval.hpp:70
MSWSegments segments_
Segment properties.
Definition: MultisegmentWellEval.hpp:132
Definition: MultisegmentWellGeneric.hpp:42
Definition: MultisegmentWellPrimaryVariables.hpp:42
Definition: MultisegmentWellSegments.hpp:37
Definition: WellInterfaceIndices.hpp:33
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition: WellState.hpp:60
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27