BlackoilSolventModel.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2015 IRIS AS
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef OPM_BLACKOILSOLVENTMODEL_HEADER_INCLUDED
21 #define OPM_BLACKOILSOLVENTMODEL_HEADER_INCLUDED
22 
28 
29 namespace Opm {
30 
37  template<class Grid>
38  class BlackoilSolventModel : public BlackoilModelBase<Grid, BlackoilSolventModel<Grid> >
39  {
40  public:
41 
42  // --------- Types and enums ---------
43 
46  typedef typename Base::WellState WellState;
47  // The next line requires C++11 support available in g++ 4.7.
48  // friend Base;
49  friend class BlackoilModelBase<Grid, BlackoilSolventModel<Grid> >;
50 
66  BlackoilSolventModel(const typename Base::ModelParameters& param,
67  const Grid& grid,
68  const BlackoilPropsAdInterface& fluid,
69  const DerivedGeology& geo,
70  const RockCompressibility* rock_comp_props,
71  const SolventPropsAdFromDeck& solvent_props,
72  const Wells* wells,
73  const NewtonIterationBlackoilInterface& linsolver,
74  const EclipseStateConstPtr eclState,
75  const bool has_disgas,
76  const bool has_vapoil,
77  const bool terminal_output,
78  const bool has_solvent);
79 
84  void updateState(const V& dx,
85  ReservoirState& reservoir_state,
86  WellState& well_state);
87 
92  void assemble(const ReservoirState& reservoir_state,
93  WellState& well_state,
94  const bool initial_assembly);
95 
96 
97  protected:
98 
99  // --------- Types and enums ---------
100 
102  typedef typename Base::DataBlock DataBlock;
104 
105  // --------- Data members ---------
106  const bool has_solvent_;
107  const int solvent_pos_;
109 
110  // Need to declare Base members we want to use here.
111  using Base::grid_;
112  using Base::fluid_;
113  using Base::geo_;
115  using Base::wells_;
116  using Base::linsolver_;
117  using Base::active_;
118  using Base::canph_;
119  using Base::cells_;
120  using Base::ops_;
121  using Base::wops_;
122  using Base::has_disgas_;
123  using Base::has_vapoil_;
124  using Base::param_;
127  using Base::rq_;
128  using Base::phaseCondition_;
130  using Base::residual_;
132  using Base::primalVariable_;
133  using Base::pvdt_;
134 
135  // --------- Protected methods ---------
136 
137  // Need to declare Base members we want to use here.
138  using Base::wellsActive;
139  using Base::wells;
140  using Base::variableState;
144  using Base::fluidViscosity;
146  using Base::fluidDensity;
147  using Base::fluidRsSat;
148  using Base::fluidRvSat;
149  using Base::poroMult;
150  using Base::transMult;
153  using Base::dpMaxRel;
154  using Base::dsMax;
155  using Base::drMaxRel;
157 
161 
162  std::vector<ADB>
163  computeRelPerm(const SolutionState& state) const;
164 
165  void
166  makeConstantState(SolutionState& state) const;
167 
168  std::vector<V>
169  variableStateInitials(const ReservoirState& x,
170  const WellState& xw) const;
171 
172  std::vector<int>
173  variableStateIndices() const;
174 
175  SolutionState
176  variableStateExtractVars(const ReservoirState& x,
177  const std::vector<int>& indices,
178  std::vector<ADB>& vars) const;
179 
180  void
181  computeAccum(const SolutionState& state,
182  const int aix );
183 
184  void
185  assembleMassBalanceEq(const SolutionState& state);
186 
187  void
188  addWellContributionToMassBalanceEq(const std::vector<ADB>& cq_s,
189  const SolutionState& state,
190  WellState& xw);
191 
192  void computeWellConnectionPressures(const SolutionState& state,
193  const WellState& xw);
194 
195  void updateEquationsScaling();
196 
197  void
198  computeMassFlux(const int actph ,
199  const V& transi,
200  const ADB& kr ,
201  const ADB& p ,
202  const SolutionState& state );
203 
204  const std::vector<PhasePresence>
205  phaseCondition() const {return this->phaseCondition_;}
206 
207 
208  };
209 
210 
211 
215  {
216  explicit BlackoilSolventSolutionState(const int np)
218  solvent_saturation( ADB::null())
219  {
220  }
222  };
223 
224 
225 
227  template <class Grid>
229  {
234  };
235 
236 } // namespace Opm
237 
239 
240 #endif // OPM_BLACKOILSOLVENTMODEL_HEADER_INCLUDED
Definition: GeoProps.hpp:53
Base::SolutionState SolutionState
Definition: BlackoilSolventModel.hpp:101
double drMaxRel() const
Definition: BlackoilModelBase.hpp:518
LinearisedBlackoilResidual residual_
Definition: BlackoilModelBase.hpp:279
Definition: BlackoilPropsAdInterface.hpp:38
std::vector< int > primalVariable_
Definition: BlackoilModelBase.hpp:284
const DerivedGeology & geo_
Definition: BlackoilModelBase.hpp:251
V fluidRvSat(const V &p, const V &so, const std::vector< int > &cells) const
Definition: BlackoilModelEnums.hpp:48
Definition: AdditionalObjectDeleter.hpp:22
const Wells * wells_
Definition: BlackoilModelBase.hpp:253
ModelTraits< BlackoilSolventModel< Grid > >::ModelParameters ModelParameters
Definition: BlackoilModelBase.hpp:108
const std::vector< PhasePresence > phaseCondition() const
Definition: BlackoilSolventModel.hpp:205
const Wells & wells() const
Definition: BlackoilModelBase.hpp:309
BlackoilModelParameters ModelParameters
Definition: BlackoilSolventModel.hpp:232
const std::vector< bool > active_
Definition: BlackoilModelBase.hpp:257
void computeAccum(const SolutionState &state, const int aix)
Definition: BlackoilSolventModel_impl.hpp:193
std::vector< V > variableStateInitials(const ReservoirState &x, const WellState &xw) const
Definition: BlackoilSolventModel_impl.hpp:126
const RockCompressibility * rock_comp_props_
Definition: BlackoilModelBase.hpp:252
void computeWellConnectionPressures(const SolutionState &state, const WellState &xw)
void makeConstantState(SolutionState &state) const
Definition: BlackoilSolventModel_impl.hpp:114
ModelTraits< BlackoilSolventModel< Grid > >::ReservoirState ReservoirState
Definition: BlackoilModelBase.hpp:106
const std::vector< int > canph_
Definition: BlackoilModelBase.hpp:259
bool wellsActive() const
Definition: BlackoilModelBase.hpp:305
const int solvent_pos_
Definition: BlackoilSolventModel.hpp:107
double maxResidualAllowed() const
Definition: BlackoilModelBase.hpp:519
Definition: BlackoilModelBase.hpp:98
const SolventPropsAdFromDeck & solvent_props_
Definition: BlackoilSolventModel.hpp:108
BlackoilSolventSolutionState(const int np)
Definition: BlackoilSolventModel.hpp:216
Definition: BlackoilSolventState.hpp:33
V well_perforation_pressure_diffs_
Definition: BlackoilModelBase.hpp:277
const WellOps wops_
Definition: BlackoilModelBase.hpp:262
const BlackoilPropsAdInterface & fluid_
Definition: BlackoilModelBase.hpp:250
ModelTraits< Implementation >::SolutionState SolutionState
Definition: BlackoilModelBase.hpp:109
V threshold_pressures_by_interior_face_
Definition: BlackoilModelBase.hpp:269
void assemble(const ReservoirState &reservoir_state, WellState &well_state, const bool initial_assembly)
Definition: BlackoilSolventModel_impl.hpp:580
ModelParameters param_
Definition: BlackoilModelBase.hpp:266
Struct for containing iteration variables.
Definition: BlackoilModelBase.hpp:51
void addWellContributionToMassBalanceEq(const std::vector< ADB > &cq_s, const SolutionState &state, WellState &xw)
Definition: BlackoilSolventModel_impl.hpp:245
Definition: BlackoilSolventModel.hpp:38
WellStateFullyImplicitBlackoilSolvent WellState
Definition: BlackoilSolventModel.hpp:231
const std::vector< int > cells_
Definition: BlackoilModelBase.hpp:260
SolutionState variableStateExtractVars(const ReservoirState &x, const std::vector< int > &indices, std::vector< ADB > &vars) const
Definition: BlackoilSolventModel_impl.hpp:171
Base::WellState WellState
Definition: BlackoilSolventModel.hpp:46
SolutionState variableState(const ReservoirState &x, const WellState &xw) const
Solver parameters for the BlackoilModel.
Definition: BlackoilModelParameters.hpp:29
void computeMassFlux(const int actph, const V &transi, const ADB &kr, const ADB &p, const SolutionState &state)
Definition: BlackoilSolventModel_impl.hpp:496
bool use_threshold_pressure_
Definition: BlackoilModelBase.hpp:267
const Grid & grid_
Definition: BlackoilModelBase.hpp:249
Interface class for (linear) solvers for the fully implicit black-oil system.
Definition: NewtonIterationBlackoilInterface.hpp:31
const bool has_vapoil_
Definition: BlackoilModelBase.hpp:264
ADB fluidDensity(const int phase, const ADB &b, const ADB &rs, const ADB &rv) const
std::vector< PhasePresence > phaseCondition_
Definition: BlackoilModelBase.hpp:272
HelperOps ops_
Definition: BlackoilModelBase.hpp:261
double dsMax() const
Definition: BlackoilModelBase.hpp:517
void updateState(const V &dx, ReservoirState &reservoir_state, WellState &well_state)
Definition: BlackoilSolventModel_impl.hpp:442
const bool has_disgas_
Definition: BlackoilModelBase.hpp:263
void computeWellConnectionPressures(const SolutionState &state, const WellState &xw)
Definition: BlackoilSolventModel_impl.hpp:303
Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > DataBlock
Definition: BlackoilModelBase.hpp:230
void updateEquationsScaling()
Definition: BlackoilSolventModel_impl.hpp:233
Definition: BlackoilSolventModel.hpp:214
std::vector< ReservoirResidualQuant > rq_
Definition: BlackoilModelBase.hpp:271
BlackoilSolventModel(const typename Base::ModelParameters &param, const Grid &grid, const BlackoilPropsAdInterface &fluid, const DerivedGeology &geo, const RockCompressibility *rock_comp_props, const SolventPropsAdFromDeck &solvent_props, const Wells *wells, const NewtonIterationBlackoilInterface &linsolver, const EclipseStateConstPtr eclState, const bool has_disgas, const bool has_vapoil, const bool terminal_output, const bool has_solvent)
Definition: BlackoilSolventModel_impl.hpp:73
bool terminal_output_
Whether we print something to std::cout.
Definition: BlackoilModelBase.hpp:282
Definition: SolventPropsAdFromDeck.hpp:38
V fluidRsSat(const V &p, const V &so, const std::vector< int > &cells) const
void updatePrimalVariableFromState(const ReservoirState &state)
double dpMaxRel() const
Definition: BlackoilModelBase.hpp:516
void assembleMassBalanceEq(const SolutionState &state)
Definition: BlackoilSolventModel_impl.hpp:218
ADB fluidReciprocFVF(const int phase, const ADB &p, const ADB &temp, const ADB &rs, const ADB &rv, const std::vector< PhasePresence > &cond) const
ADB solvent_saturation
Definition: BlackoilSolventModel.hpp:221
BlackoilModelBase< Grid, BlackoilSolventModel< Grid > > Base
Definition: BlackoilSolventModel.hpp:44
const bool has_solvent_
Definition: BlackoilSolventModel.hpp:106
V computeGasPressure(const V &po, const V &sw, const V &so, const V &sg) const
Base::ReservoirState ReservoirState
Definition: BlackoilSolventModel.hpp:45
ADB fluidViscosity(const int phase, const ADB &p, const ADB &temp, const ADB &rs, const ADB &rv, const std::vector< PhasePresence > &cond) const
std::vector< ADB > computeRelPerm(const SolutionState &state) const
Definition: BlackoilSolventModel_impl.hpp:548
std::vector< int > variableStateIndices() const
Definition: BlackoilSolventModel_impl.hpp:151
ADB::V V
Definition: BlackoilModelBase.hpp:103
BlackoilSolventSolutionState SolutionState
Definition: BlackoilSolventModel.hpp:233
Definition: BlackoilSolventModel.hpp:103
Definition: BlackoilModelBase.hpp:83
Definition: WellStateFullyImplicitBlackoilSolvent.hpp:28
Base::DataBlock DataBlock
Definition: BlackoilSolventModel.hpp:102
void addWellControlEq(const SolutionState &state, const WellState &xw, const V &aliveWells)
ModelTraits< BlackoilSolventModel< Grid > >::WellState WellState
Definition: BlackoilModelBase.hpp:107
const NewtonIterationBlackoilInterface & linsolver_
Definition: BlackoilModelBase.hpp:255
std::vector< ADB > computePressures(const ADB &po, const ADB &sw, const ADB &so, const ADB &sg) const
BlackoilSolventState ReservoirState
Definition: BlackoilSolventModel.hpp:230