My Project
Loading...
Searching...
No Matches
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 const bool use_average_density);
81
82 // assemble pressure equation for ICD segments
83 void assembleICDPressureEq(const int seg,
85 WellState& well_state,
86 const bool use_average_density,
88
89 void assembleAccelerationAndHydroPressureLosses(const int seg,
90 WellState& well_state,
91 const bool use_average_density);
92
93
94 void assemblePressureEq(const int seg,
96 WellState& well_state,
97 const bool use_average_density,
99
102 const std::vector<double>& B_avg,
104 const double max_residual_allowed,
105 const double tolerance_wells,
107 const double tolerance_pressure_ms_wells,
109 const bool relax_tolerance) const;
110
111 std::pair<bool, std::vector<Scalar> >
112 getFiniteWellResiduals(const std::vector<Scalar>& B_avg,
114
115 double getControlTolerance(const WellState& well_state,
116 const double tolerance_wells,
117 const double tolerance_pressure_ms_wells,
119
120 double getResidualMeasureValue(const WellState& well_state,
121 const std::vector<double>& residuals,
122 const double tolerance_wells,
123 const double tolerance_pressure_ms_wells,
125
126 void handleAccelerationPressureLoss(const int seg,
127 WellState& well_state);
128
129 EvalWell pressureDropAutoICD(const int seg,
130 const UnitSystem& unit_system) const;
131
132 // convert a Eval from reservoir to contain the derivative related to wells
133 EvalWell extendEval(const Eval& in) const;
134
136
140
141 // depth difference between perforations and the perforated grid cells
142 std::vector<double> cell_perforation_depth_diffs_;
143 // pressure correction due to the different depth of the perforation and
144 // center depth of the grid block
145 std::vector<double> cell_perforation_pressure_diffs_;
146};
147
148}
149
150#endif // OPM_MULTISEGMENTWELL_GENERIC_HEADER_INCLUDED
Definition AquiferInterface.hpp:35
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:137
PrimaryVariables primary_variables_
The primary variables.
Definition MultisegmentWellEval.hpp:138
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:139
Definition MultisegmentWellGeneric.hpp:42
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