adding WellModel as template class for BlackoilModelBase

the compilation and running of flow are recovered.

Conflicts:
	opm/autodiff/BlackoilModelBase_impl.hpp
This commit is contained in:
Kai Bao 2016-04-18 12:14:01 +02:00
parent 586f2cc962
commit b464e4fb4a
3 changed files with 232 additions and 187 deletions

View File

@ -26,6 +26,7 @@
#include <opm/autodiff/BlackoilModelBase.hpp> #include <opm/autodiff/BlackoilModelBase.hpp>
#include <opm/core/simulator/BlackoilState.hpp> #include <opm/core/simulator/BlackoilState.hpp>
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp> #include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
#include <opm/autodiff/StandardWells.hpp>
#include <opm/autodiff/BlackoilModelParameters.hpp> #include <opm/autodiff/BlackoilModelParameters.hpp>
namespace Opm { namespace Opm {
@ -40,10 +41,10 @@ namespace Opm {
/// It uses automatic differentiation via the class AutoDiffBlock /// It uses automatic differentiation via the class AutoDiffBlock
/// to simplify assembly of the jacobian matrix. /// to simplify assembly of the jacobian matrix.
template<class Grid> template<class Grid>
class BlackoilModel : public BlackoilModelBase<Grid, BlackoilModel<Grid> > class BlackoilModel : public BlackoilModelBase<Grid, BlackoilModel<Grid>, StandardWells>
{ {
public: public:
typedef BlackoilModelBase<Grid, BlackoilModel<Grid> > Base; typedef BlackoilModelBase<Grid, BlackoilModel<Grid>, StandardWells> Base;
/// Construct the model. It will retain references to the /// Construct the model. It will retain references to the
/// arguments of this functions, and they are expected to /// arguments of this functions, and they are expected to

View File

@ -32,7 +32,6 @@
#include <opm/autodiff/NewtonIterationBlackoilInterface.hpp> #include <opm/autodiff/NewtonIterationBlackoilInterface.hpp>
#include <opm/autodiff/BlackoilModelEnums.hpp> #include <opm/autodiff/BlackoilModelEnums.hpp>
#include <opm/autodiff/VFPProperties.hpp> #include <opm/autodiff/VFPProperties.hpp>
#include <opm/autodiff/StandardWells.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp> #include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
#include <array> #include <array>
@ -106,7 +105,7 @@ namespace Opm {
/// to simplify assembly of the jacobian matrix. /// to simplify assembly of the jacobian matrix.
/// \tparam Grid UnstructuredGrid or CpGrid. /// \tparam Grid UnstructuredGrid or CpGrid.
/// \tparam Implementation Provides concrete state types. /// \tparam Implementation Provides concrete state types.
template<class Grid, class Implementation> template<class Grid, class Implementation, class WellModel>
class BlackoilModelBase class BlackoilModelBase
{ {
public: public:
@ -276,7 +275,7 @@ namespace Opm {
const BlackoilPropsAdInterface& fluid_; const BlackoilPropsAdInterface& fluid_;
const DerivedGeology& geo_; const DerivedGeology& geo_;
const RockCompressibility* rock_comp_props_; const RockCompressibility* rock_comp_props_;
StandardWells std_wells_; WellModel std_wells_;
VFPProperties vfp_properties_; VFPProperties vfp_properties_;
const NewtonIterationBlackoilInterface& linsolver_; const NewtonIterationBlackoilInterface& linsolver_;
// For each canonical phase -> true if active // For each canonical phase -> true if active
@ -328,11 +327,11 @@ namespace Opm {
return static_cast<const Implementation&>(*this); return static_cast<const Implementation&>(*this);
} }
/// return the StandardWells object /// return the WellModel object
StandardWells& stdWells() { return std_wells_; } WellModel& stdWells() { return std_wells_; }
const StandardWells& stdWells() const { return std_wells_; } const WellModel& stdWells() const { return std_wells_; }
/// return the Well struct in the StandardWells /// return the Well struct in the WellModel
const Wells& wells() const { return std_wells_.wells(); } const Wells& wells() const { return std_wells_.wells(); }
/// return true if wells are available in the reservoir /// return true if wells are available in the reservoir

View File

@ -143,8 +143,8 @@ namespace detail {
} // namespace detail } // namespace detail
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
BlackoilModelBase(const ModelParameters& param, BlackoilModelBase(const ModelParameters& param,
const Grid& grid , const Grid& grid ,
const BlackoilPropsAdInterface& fluid, const BlackoilPropsAdInterface& fluid,
@ -217,9 +217,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
prepareStep(const double dt, prepareStep(const double dt,
ReservoirState& reservoir_state, ReservoirState& reservoir_state,
WellState& /* well_state */) WellState& /* well_state */)
@ -234,10 +234,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
template <class NonlinearSolverType> template <class NonlinearSolverType>
IterationReport IterationReport
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
nonlinearIteration(const int iteration, nonlinearIteration(const int iteration,
const double dt, const double dt,
NonlinearSolverType& nonlinear_solver, NonlinearSolverType& nonlinear_solver,
@ -289,9 +289,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
afterStep(const double /* dt */, afterStep(const double /* dt */,
ReservoirState& /* reservoir_state */, ReservoirState& /* reservoir_state */,
WellState& /* well_state */) WellState& /* well_state */)
@ -303,9 +303,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
int int
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
sizeNonLinear() const sizeNonLinear() const
{ {
return residual_.sizeNonLinear(); return residual_.sizeNonLinear();
@ -315,9 +315,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
int int
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
linearIterationsLastSolve() const linearIterationsLastSolve() const
{ {
return linsolver_.iterations(); return linsolver_.iterations();
@ -327,9 +327,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
bool bool
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
terminalOutputEnabled() const terminalOutputEnabled() const
{ {
return terminal_output_; return terminal_output_;
@ -339,9 +339,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
int int
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
numPhases() const numPhases() const
{ {
return fluid_.numPhases(); return fluid_.numPhases();
@ -351,9 +351,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
int int
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
numMaterials() const numMaterials() const
{ {
return material_name_.size(); return material_name_.size();
@ -363,9 +363,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
const std::string& const std::string&
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
materialName(int material_index) const materialName(int material_index) const
{ {
assert(material_index < numMaterials()); assert(material_index < numMaterials());
@ -376,9 +376,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
setThresholdPressures(const std::vector<double>& threshold_pressures) setThresholdPressures(const std::vector<double>& threshold_pressures)
{ {
const int num_faces = AutoDiffGrid::numFaces(grid_); const int num_faces = AutoDiffGrid::numFaces(grid_);
@ -407,8 +407,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
BlackoilModelBase<Grid, Implementation>::ReservoirResidualQuant::ReservoirResidualQuant() BlackoilModelBase<Grid, Implementation, WellModel>::
ReservoirResidualQuant::ReservoirResidualQuant()
: accum(2, ADB::null()) : accum(2, ADB::null())
, mflux( ADB::null()) , mflux( ADB::null())
, b ( ADB::null()) , b ( ADB::null())
@ -421,9 +422,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
int int
BlackoilModelBase<Grid, Implementation>::numWellVars() const BlackoilModelBase<Grid, Implementation, WellModel>::numWellVars() const
{ {
// For each well, we have a bhp variable, and one flux per phase. // For each well, we have a bhp variable, and one flux per phase.
const int nw = stdWells().localWellsActive() ? wells().number_of_wells : 0; const int nw = stdWells().localWellsActive() ? wells().number_of_wells : 0;
@ -434,9 +435,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::makeConstantState(SolutionState& state) const BlackoilModelBase<Grid, Implementation, WellModel>::
makeConstantState(SolutionState& state) const
{ {
// HACK: throw away the derivatives. this may not be the most // HACK: throw away the derivatives. this may not be the most
// performant way to do things, but it will make the state // performant way to do things, but it will make the state
@ -463,10 +465,11 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
typename BlackoilModelBase<Grid, Implementation>::SolutionState typename BlackoilModelBase<Grid, Implementation, WellModel>::SolutionState
BlackoilModelBase<Grid, Implementation>::variableState(const ReservoirState& x, BlackoilModelBase<Grid, Implementation, WellModel>::
const WellState& xw) const variableState(const ReservoirState& x,
const WellState& xw) const
{ {
std::vector<V> vars0 = asImpl().variableStateInitials(x, xw); std::vector<V> vars0 = asImpl().variableStateInitials(x, xw);
std::vector<ADB> vars = ADB::variables(vars0); std::vector<ADB> vars = ADB::variables(vars0);
@ -477,10 +480,11 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
std::vector<V> std::vector<V>
BlackoilModelBase<Grid, Implementation>::variableStateInitials(const ReservoirState& x, BlackoilModelBase<Grid, Implementation, WellModel>::
const WellState& xw) const variableStateInitials(const ReservoirState& x,
const WellState& xw) const
{ {
assert(active_[ Oil ]); assert(active_[ Oil ]);
@ -499,9 +503,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::variableReservoirStateInitials(const ReservoirState& x, std::vector<V>& vars0) const BlackoilModelBase<Grid, Implementation, WellModel>::
variableReservoirStateInitials(const ReservoirState& x, std::vector<V>& vars0) const
{ {
using namespace Opm::AutoDiffGrid; using namespace Opm::AutoDiffGrid;
const int nc = numCells(grid_); const int nc = numCells(grid_);
@ -537,9 +542,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::variableWellStateInitials(const WellState& xw, std::vector<V>& vars0) const BlackoilModelBase<Grid, Implementation, WellModel>::
variableWellStateInitials(const WellState& xw, std::vector<V>& vars0) const
{ {
// Initial well rates. // Initial well rates.
if ( stdWells().localWellsActive() ) if ( stdWells().localWellsActive() )
@ -571,9 +577,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
std::vector<int> std::vector<int>
BlackoilModelBase<Grid, Implementation>::variableStateIndices() const BlackoilModelBase<Grid, Implementation, WellModel>::
variableStateIndices() const
{ {
assert(active_[Oil]); assert(active_[Oil]);
std::vector<int> indices(5, -1); std::vector<int> indices(5, -1);
@ -594,9 +601,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
std::vector<int> std::vector<int>
BlackoilModelBase<Grid, Implementation>::variableWellStateIndices() const BlackoilModelBase<Grid, Implementation, WellModel>::
variableWellStateIndices() const
{ {
// Black oil model standard is 5 equation. // Black oil model standard is 5 equation.
// For the pure well solve, only the well equations are picked. // For the pure well solve, only the well equations are picked.
@ -612,11 +620,12 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
typename BlackoilModelBase<Grid, Implementation>::SolutionState typename BlackoilModelBase<Grid, Implementation, WellModel>::SolutionState
BlackoilModelBase<Grid, Implementation>::variableStateExtractVars(const ReservoirState& x, BlackoilModelBase<Grid, Implementation, WellModel>::
const std::vector<int>& indices, variableStateExtractVars(const ReservoirState& x,
std::vector<ADB>& vars) const const std::vector<int>& indices,
std::vector<ADB>& vars) const
{ {
//using namespace Opm::AutoDiffGrid; //using namespace Opm::AutoDiffGrid;
const int nc = Opm::AutoDiffGrid::numCells(grid_); const int nc = Opm::AutoDiffGrid::numCells(grid_);
@ -684,11 +693,12 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::variableStateExtractWellsVars(const std::vector<int>& indices, BlackoilModelBase<Grid, Implementation, WellModel>::
std::vector<ADB>& vars, variableStateExtractWellsVars(const std::vector<int>& indices,
SolutionState& state) const std::vector<ADB>& vars,
SolutionState& state) const
{ {
// Qs. // Qs.
state.qs = std::move(vars[indices[Qs]]); state.qs = std::move(vars[indices[Qs]]);
@ -701,10 +711,11 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::computeAccum(const SolutionState& state, BlackoilModelBase<Grid, Implementation, WellModel>::
const int aix ) computeAccum(const SolutionState& state,
const int aix )
{ {
const Opm::PhaseUsage& pu = fluid_.phaseUsage(); const Opm::PhaseUsage& pu = fluid_.phaseUsage();
@ -763,9 +774,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void BlackoilModelBase<Grid, Implementation>::computeWellConnectionPressures(const SolutionState& state, void BlackoilModelBase<Grid, Implementation, WellModel>::
const WellState& xw) computeWellConnectionPressures(const SolutionState& state,
const WellState& xw)
{ {
if( ! localWellsActive() ) return ; if( ! localWellsActive() ) return ;
@ -780,8 +792,8 @@ namespace detail {
asImpl().stdWells().computePropertiesForWellConnectionPressures(state, xw, fluid_, active_, phaseCondition_, b_perf, rsmax_perf, rvmax_perf, surf_dens_perf); asImpl().stdWells().computePropertiesForWellConnectionPressures(state, xw, fluid_, active_, phaseCondition_, b_perf, rsmax_perf, rvmax_perf, surf_dens_perf);
// Extract well connection depths. // Extract well connection depths.
const StandardWells::Vector depth = cellCentroidsZToEigen(grid_); const typename WellModel::Vector depth = cellCentroidsZToEigen(grid_);
const StandardWells::Vector pdepth = subset(depth, asImpl().stdWells().wellOps().well_cells); const typename WellModel::Vector pdepth = subset(depth, asImpl().stdWells().wellOps().well_cells);
const int nperf = wells().well_connpos[wells().number_of_wells]; const int nperf = wells().well_connpos[wells().number_of_wells];
const std::vector<double> depth_perf(pdepth.data(), pdepth.data() + nperf); const std::vector<double> depth_perf(pdepth.data(), pdepth.data() + nperf);
@ -796,9 +808,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
assemble(const ReservoirState& reservoir_state, assemble(const ReservoirState& reservoir_state,
WellState& well_state, WellState& well_state,
const bool initial_assembly) const bool initial_assembly)
@ -874,9 +886,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
assembleMassBalanceEq(const SolutionState& state) assembleMassBalanceEq(const SolutionState& state)
{ {
// Compute b_p and the accumulation term b_p*s_p for each phase, // Compute b_p and the accumulation term b_p*s_p for each phase,
@ -942,9 +954,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::updateEquationsScaling() { BlackoilModelBase<Grid, Implementation, WellModel>::
updateEquationsScaling() {
ADB::V B; ADB::V B;
const Opm::PhaseUsage& pu = fluid_.phaseUsage(); const Opm::PhaseUsage& pu = fluid_.phaseUsage();
for ( int idx=0; idx<MaxNumPhases; ++idx ) for ( int idx=0; idx<MaxNumPhases; ++idx )
@ -975,11 +988,12 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::addWellContributionToMassBalanceEq(const std::vector<ADB>& cq_s, BlackoilModelBase<Grid, Implementation, WellModel>::
const SolutionState&, addWellContributionToMassBalanceEq(const std::vector<ADB>& cq_s,
const WellState&) const SolutionState&,
const WellState&)
{ {
if ( !asImpl().localWellsActive() ) if ( !asImpl().localWellsActive() )
{ {
@ -1001,11 +1015,12 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::extractWellPerfProperties(const SolutionState&, BlackoilModelBase<Grid, Implementation, WellModel>::
std::vector<ADB>& mob_perfcells, extractWellPerfProperties(const SolutionState&,
std::vector<ADB>& b_perfcells) const std::vector<ADB>& mob_perfcells,
std::vector<ADB>& b_perfcells) const
{ {
// If we have wells, extract the mobilities and b-factors for // If we have wells, extract the mobilities and b-factors for
// the well-perforated cells. // the well-perforated cells.
@ -1029,9 +1044,11 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void BlackoilModelBase<Grid, Implementation>::addWellFluxEq(const std::vector<ADB>& cq_s, void
const SolutionState& state) BlackoilModelBase<Grid, Implementation, WellModel>::
addWellFluxEq(const std::vector<ADB>& cq_s,
const SolutionState& state)
{ {
if( !asImpl().localWellsActive() ) if( !asImpl().localWellsActive() )
{ {
@ -1055,8 +1072,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
bool BlackoilModelBase<Grid, Implementation>::isVFPActive() const bool BlackoilModelBase<Grid, Implementation, WellModel>::
isVFPActive() const
{ {
if( ! localWellsActive() ) { if( ! localWellsActive() ) {
return false; return false;
@ -1089,11 +1107,12 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
bool BlackoilModelBase<Grid, Implementation>::solveWellEq(const std::vector<ADB>& mob_perfcells, bool BlackoilModelBase<Grid, Implementation, WellModel>::
const std::vector<ADB>& b_perfcells, solveWellEq(const std::vector<ADB>& mob_perfcells,
SolutionState& state, const std::vector<ADB>& b_perfcells,
WellState& well_state) SolutionState& state,
WellState& well_state)
{ {
V aliveWells; V aliveWells;
const int np = wells().number_of_phases; const int np = wells().number_of_phases;
@ -1196,10 +1215,11 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void BlackoilModelBase<Grid, Implementation>::addWellControlEq(const SolutionState& state, void BlackoilModelBase<Grid, Implementation, WellModel>::
const WellState& xw, addWellControlEq(const SolutionState& state,
const V& aliveWells) const WellState& xw,
const V& aliveWells)
{ {
if( ! localWellsActive() ) return; if( ! localWellsActive() ) return;
@ -1362,8 +1382,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
V BlackoilModelBase<Grid, Implementation>::solveJacobianSystem() const V
BlackoilModelBase<Grid, Implementation, WellModel>::
solveJacobianSystem() const
{ {
return linsolver_.computeNewtonIncrement(residual_); return linsolver_.computeNewtonIncrement(residual_);
} }
@ -1473,10 +1495,12 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void BlackoilModelBase<Grid, Implementation>::updateState(const V& dx, void
ReservoirState& reservoir_state, BlackoilModelBase<Grid, Implementation, WellModel>::
WellState& well_state) updateState(const V& dx,
ReservoirState& reservoir_state,
WellState& well_state)
{ {
using namespace Opm::AutoDiffGrid; using namespace Opm::AutoDiffGrid;
const int np = fluid_.numPhases(); const int np = fluid_.numPhases();
@ -1800,9 +1824,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
std::vector<ADB> std::vector<ADB>
BlackoilModelBase<Grid, Implementation>::computeRelPerm(const SolutionState& state) const BlackoilModelBase<Grid, Implementation, WellModel>::
computeRelPerm(const SolutionState& state) const
{ {
using namespace Opm::AutoDiffGrid; using namespace Opm::AutoDiffGrid;
const int nc = numCells(grid_); const int nc = numCells(grid_);
@ -1829,9 +1854,9 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
std::vector<ADB> std::vector<ADB>
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
computePressures(const ADB& po, computePressures(const ADB& po,
const ADB& sw, const ADB& sw,
const ADB& so, const ADB& so,
@ -1866,12 +1891,13 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
V V
BlackoilModelBase<Grid, Implementation>::computeGasPressure(const V& po, BlackoilModelBase<Grid, Implementation, WellModel>::
const V& sw, computeGasPressure(const V& po,
const V& so, const V& sw,
const V& sg) const const V& so,
const V& sg) const
{ {
assert (active_[Gas]); assert (active_[Gas]);
std::vector<ADB> cp = fluid_.capPress(ADB::constant(sw), std::vector<ADB> cp = fluid_.capPress(ADB::constant(sw),
@ -1883,15 +1909,16 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::computeMassFlux(const int actph , BlackoilModelBase<Grid, Implementation, WellModel>::
const V& transi, computeMassFlux(const int actph ,
const ADB& kr , const V& transi,
const ADB& mu , const ADB& kr ,
const ADB& rho , const ADB& mu ,
const ADB& phasePressure, const ADB& rho ,
const SolutionState& state) const ADB& phasePressure,
const SolutionState& state)
{ {
// Compute and store mobilities. // Compute and store mobilities.
const ADB tr_mult = transMult(state.pressure); const ADB tr_mult = transMult(state.pressure);
@ -1916,9 +1943,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::applyThresholdPressures(ADB& dp) BlackoilModelBase<Grid, Implementation, WellModel>::
applyThresholdPressures(ADB& dp)
{ {
// We support reversible threshold pressures only. // We support reversible threshold pressures only.
// Method: if the potential difference is lower (in absolute // Method: if the potential difference is lower (in absolute
@ -1948,9 +1976,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
std::vector<double> std::vector<double>
BlackoilModelBase<Grid, Implementation>::computeResidualNorms() const BlackoilModelBase<Grid, Implementation, WellModel>::
computeResidualNorms() const
{ {
std::vector<double> residualNorms; std::vector<double> residualNorms;
@ -1988,9 +2017,9 @@ namespace detail {
} }
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
double double
BlackoilModelBase<Grid, Implementation>:: BlackoilModelBase<Grid, Implementation, WellModel>::
relativeChange(const SimulationDataContainer& previous, relativeChange(const SimulationDataContainer& previous,
const SimulationDataContainer& current ) const const SimulationDataContainer& current ) const
{ {
@ -2029,16 +2058,17 @@ namespace detail {
} }
} }
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
double double
BlackoilModelBase<Grid, Implementation>::convergenceReduction(const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic>& B, BlackoilModelBase<Grid, Implementation, WellModel>::
const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic>& tempV, convergenceReduction(const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic>& B,
const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic>& R, const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic>& tempV,
std::vector<double>& R_sum, const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic>& R,
std::vector<double>& maxCoeff, std::vector<double>& R_sum,
std::vector<double>& B_avg, std::vector<double>& maxCoeff,
std::vector<double>& maxNormWell, std::vector<double>& B_avg,
int nc) const std::vector<double>& maxNormWell,
int nc) const
{ {
const int np = asImpl().numPhases(); const int np = asImpl().numPhases();
const int nm = asImpl().numMaterials(); const int nm = asImpl().numMaterials();
@ -2115,9 +2145,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
bool bool
BlackoilModelBase<Grid, Implementation>::getConvergence(const double dt, const int iteration) BlackoilModelBase<Grid, Implementation, WellModel>::
getConvergence(const double dt, const int iteration)
{ {
const double tol_mb = param_.tolerance_mb_; const double tol_mb = param_.tolerance_mb_;
const double tol_cnv = param_.tolerance_cnv_; const double tol_cnv = param_.tolerance_cnv_;
@ -2239,9 +2270,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
bool bool
BlackoilModelBase<Grid, Implementation>::getWellConvergence(const int iteration) BlackoilModelBase<Grid, Implementation, WellModel>::
getWellConvergence(const int iteration)
{ {
const double tol_wells = param_.tolerance_wells_; const double tol_wells = param_.tolerance_wells_;
@ -2318,14 +2350,15 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
ADB ADB
BlackoilModelBase<Grid, Implementation>::fluidViscosity(const int phase, BlackoilModelBase<Grid, Implementation, WellModel>::
const ADB& p , fluidViscosity(const int phase,
const ADB& temp , const ADB& p ,
const ADB& rs , const ADB& temp ,
const ADB& rv , const ADB& rs ,
const std::vector<PhasePresence>& cond) const const ADB& rv ,
const std::vector<PhasePresence>& cond) const
{ {
switch (phase) { switch (phase) {
case Water: case Water:
@ -2343,14 +2376,15 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
ADB ADB
BlackoilModelBase<Grid, Implementation>::fluidReciprocFVF(const int phase, BlackoilModelBase<Grid, Implementation, WellModel>::
const ADB& p , fluidReciprocFVF(const int phase,
const ADB& temp , const ADB& p ,
const ADB& rs , const ADB& temp ,
const ADB& rv , const ADB& rs ,
const std::vector<PhasePresence>& cond) const const ADB& rv ,
const std::vector<PhasePresence>& cond) const
{ {
switch (phase) { switch (phase) {
case Water: case Water:
@ -2368,12 +2402,13 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
ADB ADB
BlackoilModelBase<Grid, Implementation>::fluidDensity(const int phase, BlackoilModelBase<Grid, Implementation, WellModel>::
const ADB& b, fluidDensity(const int phase,
const ADB& rs, const ADB& b,
const ADB& rv) const const ADB& rs,
const ADB& rv) const
{ {
const V& rhos = fluid_.surfaceDensity(phase, cells_); const V& rhos = fluid_.surfaceDensity(phase, cells_);
const Opm::PhaseUsage& pu = fluid_.phaseUsage(); const Opm::PhaseUsage& pu = fluid_.phaseUsage();
@ -2391,11 +2426,12 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
V V
BlackoilModelBase<Grid, Implementation>::fluidRsSat(const V& p, BlackoilModelBase<Grid, Implementation, WellModel>::
const V& satOil, fluidRsSat(const V& p,
const std::vector<int>& cells) const const V& satOil,
const std::vector<int>& cells) const
{ {
return fluid_.rsSat(ADB::constant(p), ADB::constant(satOil), cells).value(); return fluid_.rsSat(ADB::constant(p), ADB::constant(satOil), cells).value();
} }
@ -2404,11 +2440,12 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
ADB ADB
BlackoilModelBase<Grid, Implementation>::fluidRsSat(const ADB& p, BlackoilModelBase<Grid, Implementation, WellModel>::
const ADB& satOil, fluidRsSat(const ADB& p,
const std::vector<int>& cells) const const ADB& satOil,
const std::vector<int>& cells) const
{ {
return fluid_.rsSat(p, satOil, cells); return fluid_.rsSat(p, satOil, cells);
} }
@ -2417,11 +2454,12 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
V V
BlackoilModelBase<Grid, Implementation>::fluidRvSat(const V& p, BlackoilModelBase<Grid, Implementation, WellModel>::
const V& satOil, fluidRvSat(const V& p,
const std::vector<int>& cells) const const V& satOil,
const std::vector<int>& cells) const
{ {
return fluid_.rvSat(ADB::constant(p), ADB::constant(satOil), cells).value(); return fluid_.rvSat(ADB::constant(p), ADB::constant(satOil), cells).value();
} }
@ -2430,11 +2468,12 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
ADB ADB
BlackoilModelBase<Grid, Implementation>::fluidRvSat(const ADB& p, BlackoilModelBase<Grid, Implementation, WellModel>::
const ADB& satOil, fluidRvSat(const ADB& p,
const std::vector<int>& cells) const const ADB& satOil,
const std::vector<int>& cells) const
{ {
return fluid_.rvSat(p, satOil, cells); return fluid_.rvSat(p, satOil, cells);
} }
@ -2443,9 +2482,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
ADB ADB
BlackoilModelBase<Grid, Implementation>::poroMult(const ADB& p) const BlackoilModelBase<Grid, Implementation, WellModel>::
poroMult(const ADB& p) const
{ {
const int n = p.size(); const int n = p.size();
if (rock_comp_props_ && rock_comp_props_->isActive()) { if (rock_comp_props_ && rock_comp_props_->isActive()) {
@ -2473,9 +2513,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
ADB ADB
BlackoilModelBase<Grid, Implementation>::transMult(const ADB& p) const BlackoilModelBase<Grid, Implementation, WellModel>::
transMult(const ADB& p) const
{ {
const int n = p.size(); const int n = p.size();
if (rock_comp_props_ && rock_comp_props_->isActive()) { if (rock_comp_props_ && rock_comp_props_->isActive()) {
@ -2503,9 +2544,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::classifyCondition(const ReservoirState& state) BlackoilModelBase<Grid, Implementation, WellModel>::
classifyCondition(const ReservoirState& state)
{ {
using namespace Opm::AutoDiffGrid; using namespace Opm::AutoDiffGrid;
const int nc = numCells(grid_); const int nc = numCells(grid_);
@ -2543,9 +2585,10 @@ namespace detail {
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::updatePrimalVariableFromState(const ReservoirState& state) BlackoilModelBase<Grid, Implementation, WellModel>::
updatePrimalVariableFromState(const ReservoirState& state)
{ {
using namespace Opm::AutoDiffGrid; using namespace Opm::AutoDiffGrid;
const int nc = numCells(grid_); const int nc = numCells(grid_);
@ -2593,9 +2636,10 @@ namespace detail {
/// Update the phaseCondition_ member based on the primalVariable_ member. /// Update the phaseCondition_ member based on the primalVariable_ member.
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::updatePhaseCondFromPrimalVariable() BlackoilModelBase<Grid, Implementation, WellModel>::
updatePhaseCondFromPrimalVariable()
{ {
if (! active_[Gas]) { if (! active_[Gas]) {
OPM_THROW(std::logic_error, "updatePhaseCondFromPrimarVariable() logic requires active gas phase."); OPM_THROW(std::logic_error, "updatePhaseCondFromPrimarVariable() logic requires active gas phase.");
@ -2633,10 +2677,11 @@ namespace detail {
// TODO: only kept for now due to flow_multisegment // TODO: only kept for now due to flow_multisegment
// will be removed soon // will be removed soon
template <class Grid, class Implementation> template <class Grid, class Implementation, class WellModel>
void void
BlackoilModelBase<Grid, Implementation>::updateWellState(const V& dwells, BlackoilModelBase<Grid, Implementation, WellModel>::
WellState& well_state) updateWellState(const V& dwells,
WellState& well_state)
{ {
const double gravity = detail::getGravity(geo_.gravity(), UgGridHelpers::dimensions(grid_)); const double gravity = detail::getGravity(geo_.gravity(), UgGridHelpers::dimensions(grid_));
asImpl().stdWells().updateWellState(dwells, gravity, dpMaxRel(), fluid_.phaseUsage(), asImpl().stdWells().updateWellState(dwells, gravity, dpMaxRel(), fluid_.phaseUsage(),