00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OPM_BLACKOILSOLVENTMODEL_HEADER_INCLUDED
00021 #define OPM_BLACKOILSOLVENTMODEL_HEADER_INCLUDED
00022
00023 #include <opm/autodiff/BlackoilModelBase.hpp>
00024 #include <opm/autodiff/BlackoilModelParameters.hpp>
00025 #include <opm/autodiff/WellStateFullyImplicitBlackoilSolvent.hpp>
00026 #include <opm/autodiff/SolventPropsAdFromDeck.hpp>
00027 #include <opm/autodiff/StandardWellsSolvent.hpp>
00028
00029 namespace Opm {
00030
00037 template<class Grid>
00038 class BlackoilSolventModel : public BlackoilModelBase<Grid, StandardWellsSolvent, BlackoilSolventModel<Grid> >
00039 {
00040 public:
00041
00042
00043
00044 typedef BlackoilModelBase<Grid, StandardWellsSolvent, BlackoilSolventModel<Grid> > Base;
00045 typedef typename Base::ReservoirState ReservoirState;
00046 typedef typename Base::WellState WellState;
00047
00048
00049 friend class BlackoilModelBase<Grid, StandardWellsSolvent, BlackoilSolventModel<Grid> >;
00050
00067 BlackoilSolventModel(const typename Base::ModelParameters& param,
00068 const Grid& grid,
00069 const BlackoilPropsAdFromDeck& fluid,
00070 const DerivedGeology& geo,
00071 const RockCompressibility* rock_comp_props,
00072 const SolventPropsAdFromDeck& solvent_props,
00073 const StandardWellsSolvent& well_model,
00074 const NewtonIterationBlackoilInterface& linsolver,
00075 std::shared_ptr< const EclipseState > eclState,
00076 const bool has_disgas,
00077 const bool has_vapoil,
00078 const bool terminal_output,
00079 const bool has_solvent,
00080 const bool is_miscible);
00081
00086 void updateState(const V& dx,
00087 ReservoirState& reservoir_state,
00088 WellState& well_state);
00089
00090 using Base::wellModel;
00091
00092
00093 std::vector<std::vector<double> >
00094 computeFluidInPlace(const ReservoirState& x,
00095 const std::vector<int>& fipnum);
00096
00097 protected:
00098
00099
00100
00101 typedef typename Base::SolutionState SolutionState;
00102 typedef typename Base::DataBlock DataBlock;
00103 enum { Solvent = CanonicalVariablePositions::Next };
00104
00105
00106 const bool has_solvent_;
00107 const int solvent_pos_;
00108 const SolventPropsAdFromDeck& solvent_props_;
00109 const bool is_miscible_;
00110 std::vector<ADB> mu_eff_;
00111 std::vector<ADB> b_eff_;
00112
00113
00114 using Base::grid_;
00115 using Base::fluid_;
00116 using Base::geo_;
00117 using Base::rock_comp_props_;
00118 using Base::linsolver_;
00119 using Base::active_;
00120 using Base::canph_;
00121 using Base::cells_;
00122 using Base::ops_;
00123 using Base::has_disgas_;
00124 using Base::has_vapoil_;
00125 using Base::param_;
00126 using Base::use_threshold_pressure_;
00127 using Base::threshold_pressures_by_connection_;
00128 using Base::sd_;
00129 using Base::phaseCondition_;
00130 using Base::residual_;
00131 using Base::terminal_output_;
00132 using Base::pvdt_;
00133
00134
00135
00136
00137 using Base::wells;
00138 using Base::variableState;
00139 using Base::computeGasPressure;
00140 using Base::applyThresholdPressures;
00141 using Base::fluidRsSat;
00142 using Base::fluidRvSat;
00143 using Base::poroMult;
00144 using Base::transMult;
00145 using Base::updatePrimalVariableFromState;
00146 using Base::updatePhaseCondFromPrimalVariable;
00147 using Base::dpMaxRel;
00148 using Base::dsMax;
00149 using Base::drMaxRel;
00150 using Base::maxResidualAllowed;
00151
00152
00153
00154
00155
00156 std::vector<ADB>
00157 computeRelPerm(const SolutionState& state) const;
00158
00159 ADB
00160 fluidViscosity(const int phase,
00161 const ADB& p ,
00162 const ADB& temp ,
00163 const ADB& rs ,
00164 const ADB& rv ,
00165 const std::vector<PhasePresence>& cond) const;
00166
00167 ADB
00168 fluidReciprocFVF(const int phase,
00169 const ADB& p ,
00170 const ADB& temp ,
00171 const ADB& rs ,
00172 const ADB& rv ,
00173 const std::vector<PhasePresence>& cond) const;
00174
00175 ADB
00176 fluidDensity(const int phase,
00177 const ADB& b,
00178 const ADB& rs,
00179 const ADB& rv) const;
00180
00181 void
00182 makeConstantState(SolutionState& state) const;
00183
00184 std::vector<V>
00185 variableStateInitials(const ReservoirState& x,
00186 const WellState& xw) const;
00187
00188 std::vector<int>
00189 variableStateIndices() const;
00190
00191 SolutionState
00192 variableStateExtractVars(const ReservoirState& x,
00193 const std::vector<int>& indices,
00194 std::vector<ADB>& vars) const;
00195
00196 void
00197 computeAccum(const SolutionState& state,
00198 const int aix );
00199
00200 void
00201 assembleMassBalanceEq(const SolutionState& state);
00202
00203 void
00204 addWellContributionToMassBalanceEq(const std::vector<ADB>& cq_s,
00205 const SolutionState& state,
00206 WellState& xw);
00207
00208 void updateEquationsScaling();
00209
00210 void
00211 computeMassFlux(const int actph ,
00212 const V& transi,
00213 const ADB& kr ,
00214 const ADB& mu ,
00215 const ADB& rho ,
00216 const ADB& p ,
00217 const SolutionState& state );
00218
00219 const std::vector<PhasePresence>
00220 phaseCondition() const {return this->phaseCondition_;}
00221
00222
00223 void computeEffectiveProperties(const SolutionState& state);
00224
00225
00226 void computeToddLongstaffMixing(std::vector<ADB>& viscosity, std::vector<ADB>& density, const std::vector<ADB>& saturations, const ADB po, const Opm::PhaseUsage pu);
00227
00228
00229 std::vector<ADB>
00230 computePressures(const ADB& po,
00231 const ADB& sw,
00232 const ADB& so,
00233 const ADB& sg,
00234 const ADB& ss) const;
00235 };
00236
00237
00238
00241 struct BlackoilSolventSolutionState : public DefaultBlackoilSolutionState
00242 {
00243 explicit BlackoilSolventSolutionState(const int np)
00244 : DefaultBlackoilSolutionState(np),
00245 solvent_saturation( ADB::null())
00246 {
00247 }
00248 ADB solvent_saturation;
00249 };
00250
00251
00252
00254 template <class Grid>
00255 struct ModelTraits< BlackoilSolventModel<Grid> >
00256 {
00257 typedef BlackoilState ReservoirState;
00258 typedef WellStateFullyImplicitBlackoilSolvent WellState;
00259 typedef BlackoilModelParameters ModelParameters;
00260 typedef BlackoilSolventSolutionState SolutionState;
00261 };
00262
00263 }
00264
00265 #include "BlackoilSolventModel_impl.hpp"
00266
00267 #endif // OPM_BLACKOILSOLVENTMODEL_HEADER_INCLUDED