MultisegmentWellSegments.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_SEGMENTS_HEADER_INCLUDED
23#define OPM_MULTISEGMENTWELL_SEGMENTS_HEADER_INCLUDED
24
27
28#include <cstddef>
29#include <vector>
30
31namespace Opm {
32
33 class AutoICD;
34 struct PhaseUsage;
35 template<class Scalar> class SegmentState;
36 class UnitSystem;
37 template<class Scalar> class WellInterfaceGeneric;
38 class SummaryState;
39
40} // namespace Opm
41
42namespace Opm {
43
44template<typename FluidSystem, typename Indices>
46{
48 using Scalar = typename FluidSystem::Scalar;
49 using EvalWell = typename PrimaryVariables::EvalWell;
50
51public:
52 MultisegmentWellSegments(const int numSegments,
53 const ParallelWellInfo<Scalar>& parallel_well_info,
55
56 void computeFluidProperties(const EvalWell& temperature,
57 const EvalWell& saltConcentration,
58 const PrimaryVariables& primary_variables,
59 int pvt_region_index,
60 DeferredLogger& deferred_logger);
61
63 void updateUpwindingSegments(const PrimaryVariables& primary_variables);
64
65 EvalWell getHydroPressureLoss(const int seg,
66 const int seg_side) const;
67
69 Scalar getPressureDiffSegLocalPerf(const int seg,
70 const int local_perf_index) const;
71
72 EvalWell getSurfaceVolume(const EvalWell& temperature,
73 const EvalWell& saltConcentration,
74 const PrimaryVariables& primary_variables,
75 const int pvt_region_index,
76 const int seg_idx) const;
77
78 EvalWell getFrictionPressureLoss(const int seg,
79 const bool extra_reverse_flow_derivatives = false) const;
80
81 // pressure drop for Spiral ICD segment (WSEGSICD)
82 EvalWell pressureDropSpiralICD(const int seg,
83 const bool extra_reverse_flow_derivatives = false) const;
84
85 // pressure drop for Autonomous ICD segment (WSEGAICD)
86 EvalWell pressureDropAutoICD(const int seg,
87 const UnitSystem& unit_system,
88 const bool extra_reverse_flow_derivatives = false) const;
89
90 // pressure drop for sub-critical valve (WSEGVALV)
91 EvalWell pressureDropValve(const int seg,
92 const SummaryState& st,
93 const bool extra_reverse_flow_derivatives = false) const;
94
95 // pressure loss contribution due to acceleration
97 const Scalar area,
98 const bool extra_reverse_flow_derivatives = false) const;
99
100 const std::vector<std::vector<int>>& inlets() const
101 {
102 return inlets_;
103 }
104
105 const std::vector<int>& inlets(const int seg) const
106 {
107 return inlets_[seg];
108 }
109
110 const std::vector<std::vector<int>>& perforations() const
111 {
112 return perforations_;
113 }
114
115 int upwinding_segment(const int seg) const
116 {
117 return upwinding_segments_[seg];
118 }
119
120 Scalar getRefDensity() const
121 {
122 return densities_[0].value();
123 }
124
125 const EvalWell& density(const int seg) const
126 {
127 return densities_[seg];
128 }
129
130 Scalar local_perforation_depth_diff(const int local_perf_index) const
131 {
132 return local_perforation_depth_diffs_[local_perf_index];
133 }
134
136 SegmentState<Scalar>& segSol) const;
137
138private:
139 // TODO: trying to use the information from the Well opm-parser as much
140 // as possible, it will possibly be re-implemented later for efficiency reason.
141
142 // the completions that is related to each segment
143 // the completions's ids are their index in the vector well_index_, well_cell_
144 // This is also assuming the order of the completions in Well is the same with
145 // the order of the completions in wells.
146 // it is for convenience reason. we can just calculate the information for segment once
147 // then using it for all the perforations belonging to this segment
148 std::vector<std::vector<int>> perforations_;
149
150 // depth difference between the segment and the perforation
151 // or in another way, the depth difference between the perforation and
152 // the segment the perforation belongs to
153 // This vector contains the depth differences for *all* perforations across all processes
154 // that this well lies on, its size is well.wellEcl().getConnections().size(),
155 // also it works with *global* perforation indices!
156 std::vector<Scalar> local_perforation_depth_diffs_;
157
158 // the inlet segments for each segment. It is for convenience and efficiency reason
159 std::vector<std::vector<int>> inlets_;
160
161 std::vector<Scalar> depth_diffs_;
162
163 // the densities of segment fluids
164 // we should not have this member variable
165 std::vector<EvalWell> densities_;
166
167 // the mass rate of the segments
168 std::vector<EvalWell> mass_rates_;
169
170 // the viscosity of the segments
171 std::vector<EvalWell> viscosities_;
172
173 // the upwinding segment for each segment based on the flow direction
174 std::vector<int> upwinding_segments_;
175
176 std::vector<std::vector<EvalWell>> phase_densities_;
177 std::vector<std::vector<EvalWell>> phase_fractions_;
178 std::vector<std::vector<EvalWell>> phase_viscosities_;
179
181
182 void copyPhaseDensities(const unsigned phaseIdx,
183 const std::size_t stride,
184 Scalar* dens) const;
185
186 Scalar mixtureDensity(const int seg) const;
187 Scalar mixtureDensityWithExponents(const int seg) const;
188 Scalar mixtureDensityWithExponents(const AutoICD& aicd, const int seg) const;
189};
190
191} // namespace Opm
192
193#endif // OPM_MULTISEGMENTWELL_SEGMENTS_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Definition: MultisegmentWellPrimaryVariables.hpp:45
DenseAd::Evaluation< Scalar, Indices::numEq+numWellEq > EvalWell
Definition: MultisegmentWellPrimaryVariables.hpp:72
Definition: MultisegmentWellSegments.hpp:46
MultisegmentWellSegments(const int numSegments, const ParallelWellInfo< Scalar > &parallel_well_info, WellInterfaceGeneric< Scalar > &well)
EvalWell pressureDropAutoICD(const int seg, const UnitSystem &unit_system, const bool extra_reverse_flow_derivatives=false) const
EvalWell pressureDropValve(const int seg, const SummaryState &st, const bool extra_reverse_flow_derivatives=false) const
EvalWell accelerationPressureLossContribution(const int seg, const Scalar area, const bool extra_reverse_flow_derivatives=false) const
const std::vector< std::vector< int > > & inlets() const
Definition: MultisegmentWellSegments.hpp:100
EvalWell getHydroPressureLoss(const int seg, const int seg_side) const
const EvalWell & density(const int seg) const
Definition: MultisegmentWellSegments.hpp:125
Scalar getPressureDiffSegLocalPerf(const int seg, const int local_perf_index) const
Pressure difference between segment and perforation.
Scalar getRefDensity() const
Definition: MultisegmentWellSegments.hpp:120
void updateUpwindingSegments(const PrimaryVariables &primary_variables)
Update upwinding segments.
EvalWell getFrictionPressureLoss(const int seg, const bool extra_reverse_flow_derivatives=false) const
const std::vector< std::vector< int > > & perforations() const
Definition: MultisegmentWellSegments.hpp:110
int upwinding_segment(const int seg) const
Definition: MultisegmentWellSegments.hpp:115
Scalar local_perforation_depth_diff(const int local_perf_index) const
Definition: MultisegmentWellSegments.hpp:130
void copyPhaseDensities(const PhaseUsage &pu, SegmentState< Scalar > &segSol) const
void computeFluidProperties(const EvalWell &temperature, const EvalWell &saltConcentration, const PrimaryVariables &primary_variables, int pvt_region_index, DeferredLogger &deferred_logger)
EvalWell getSurfaceVolume(const EvalWell &temperature, const EvalWell &saltConcentration, const PrimaryVariables &primary_variables, const int pvt_region_index, const int seg_idx) const
const std::vector< int > & inlets(const int seg) const
Definition: MultisegmentWellSegments.hpp:105
EvalWell pressureDropSpiralICD(const int seg, const bool extra_reverse_flow_derivatives=false) const
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:195
Definition: SegmentState.hpp:34
Definition: WellInterfaceGeneric.hpp:53
Definition: blackoilboundaryratevector.hh:39
Definition: BlackoilPhases.hpp:46