diff --git a/opm/autodiff/BlackoilModel.hpp b/opm/autodiff/BlackoilModel.hpp index ff8317852..ed90eb4d9 100644 --- a/opm/autodiff/BlackoilModel.hpp +++ b/opm/autodiff/BlackoilModel.hpp @@ -23,29 +23,13 @@ #ifndef OPM_BLACKOILMODEL_HEADER_INCLUDED #define OPM_BLACKOILMODEL_HEADER_INCLUDED -#include - -#include -#include -#include -#include -#include - -#include - -struct UnstructuredGrid; -struct Wells; +#include +#include +#include +#include namespace Opm { - namespace parameter { class ParameterGroup; } - class DerivedGeology; - class RockCompressibility; - class NewtonIterationBlackoilInterface; - class BlackoilState; - class WellStateFullyImplicitBlackoil; - - /// A model implementation for three-phase black oil. /// /// The simulator is capable of handling three-phase problems @@ -56,34 +40,10 @@ namespace Opm { /// It uses automatic differentiation via the class AutoDiffBlock /// to simplify assembly of the jacobian matrix. template - class BlackoilModel + class BlackoilModel : public BlackoilModelBase > { public: - // --------- Types and enums --------- - typedef AutoDiffBlock ADB; - typedef ADB::V V; - typedef ADB::M M; - typedef BlackoilState ReservoirState; - typedef WellStateFullyImplicitBlackoil WellState; - - /// Model-specific solver parameters. - struct ModelParameters - { - double dp_max_rel_; - double ds_max_; - double dr_max_rel_; - double max_residual_allowed_; - double tolerance_mb_; - double tolerance_cnv_; - double tolerance_wells_; - - explicit ModelParameters( const parameter::ParameterGroup& param ); - ModelParameters(); - - void reset(); - }; - - // --------- Public methods --------- + typedef BlackoilModelBase > Base; /// Construct the model. It will retain references to the /// arguments of this functions, and they are expected to @@ -98,344 +58,34 @@ namespace Opm { /// \param[in] has_disgas turn on dissolved gas /// \param[in] has_vapoil turn on vaporized oil feature /// \param[in] terminal_output request output to cout/cerr - BlackoilModel(const ModelParameters& param, - const Grid& grid , - const BlackoilPropsAdInterface& fluid, - const DerivedGeology& geo , - const RockCompressibility* rock_comp_props, - const Wells* wells, + BlackoilModel(const typename Base::ModelParameters& param, + const Grid& grid, + const BlackoilPropsAdInterface& fluid, + const DerivedGeology& geo, + const RockCompressibility* rock_comp_props, + const Wells* wells, const NewtonIterationBlackoilInterface& linsolver, - const bool has_disgas, - const bool has_vapoil, - const bool terminal_output); - - /// \brief Set threshold pressures that prevent or reduce flow. - /// This prevents flow across faces if the potential - /// difference is less than the threshold. If the potential - /// difference is greater, the threshold value is subtracted - /// before calculating flow. This is treated symmetrically, so - /// flow is prevented or reduced in both directions equally. - /// \param[in] threshold_pressures_by_face array of size equal to the number of faces - /// of the grid passed in the constructor. - void setThresholdPressures(const std::vector& threshold_pressures_by_face); - - /// Called once before each time step. - /// \param[in] dt time step size - /// \param[in, out] reservoir_state reservoir state variables - /// \param[in, out] well_state well state variables - void prepareStep(const double dt, - ReservoirState& reservoir_state, - WellState& well_state); - - /// Called once after each time step. - /// In this class, this function does nothing. - /// \param[in] dt time step size - /// \param[in, out] reservoir_state reservoir state variables - /// \param[in, out] well_state well state variables - void afterStep(const double dt, - ReservoirState& reservoir_state, - WellState& well_state); - - /// Assemble the residual and Jacobian of the nonlinear system. - /// \param[in] reservoir_state reservoir state variables - /// \param[in, out] well_state well state variables - /// \param[in] initial_assembly pass true if this is the first call to assemble() in this timestep - void assemble(const BlackoilState& reservoir_state, - WellStateFullyImplicitBlackoil& well_state, - const bool initial_assembly); - - /// \brief Compute the residual norms of the mass balance for each phase, - /// the well flux, and the well equation. - /// \return a vector that contains for each phase the norm of the mass balance - /// and afterwards the norm of the residual of the well flux and the well equation. - std::vector computeResidualNorms() const; - - /// The size (number of unknowns) of the nonlinear system of equations. - int sizeNonLinear() const; - - /// Number of linear iterations used in last call to solveJacobianSystem(). - int linearIterationsLastSolve() const; - - /// Solve the Jacobian system Jx = r where J is the Jacobian and - /// r is the residual. - V solveJacobianSystem() const; - - /// Apply an update to the primary variables, chopped if appropriate. - /// \param[in] dx updates to apply to primary variables - /// \param[in, out] reservoir_state reservoir state variables - /// \param[in, out] well_state well state variables - void updateState(const V& dx, - BlackoilState& reservoir_state, - WellStateFullyImplicitBlackoil& well_state); - - /// Return true if output to cout is wanted. - bool terminalOutputEnabled() const; - - /// Compute convergence based on total mass balance (tol_mb) and maximum - /// residual mass balance (tol_cnv). - /// \param[in] dt timestep length - /// \param[in] iteration current iteration number - bool getConvergence(const double dt, const int iteration); - - /// The number of active phases in the model. - int numPhases() const; - - private: - - // --------- Types and enums --------- - - typedef Eigen::Array DataBlock; - - struct ReservoirResidualQuant { - ReservoirResidualQuant(); - std::vector accum; // Accumulations - ADB mflux; // Mass flux (surface conditions) - ADB b; // Reciprocal FVF - ADB head; // Pressure drop across int. interfaces - ADB mob; // Phase mobility (per cell) - }; - - struct SolutionState { - SolutionState(const int np); - ADB pressure; - ADB temperature; - std::vector saturation; - ADB rs; - ADB rv; - ADB qs; - ADB bhp; - // Below are quantities stored in the state for optimization purposes. - std::vector canonical_phase_pressures; // Always has 3 elements, even if only 2 phases active. - }; - - struct WellOps { - WellOps(const Wells* wells); - M w2p; // well -> perf (scatter) - M p2w; // perf -> well (gather) - }; - - enum { Water = BlackoilPropsAdInterface::Water, - Oil = BlackoilPropsAdInterface::Oil , - Gas = BlackoilPropsAdInterface::Gas , - MaxNumPhases = BlackoilPropsAdInterface::MaxNumPhases - }; - - enum PrimalVariables { Sg = 0, RS = 1, RV = 2 }; - - // --------- Data members --------- - - const Grid& grid_; - const BlackoilPropsAdInterface& fluid_; - const DerivedGeology& geo_; - const RockCompressibility* rock_comp_props_; - const Wells* wells_; - const NewtonIterationBlackoilInterface& linsolver_; - // For each canonical phase -> true if active - const std::vector active_; - // Size = # active phases. Maps active -> canonical phase indices. - const std::vector canph_; - const std::vector cells_; // All grid cells - HelperOps ops_; - const WellOps wops_; - const bool has_disgas_; - const bool has_vapoil_; - - ModelParameters param_; - bool use_threshold_pressure_; - V threshold_pressures_by_interior_face_; - - std::vector rq_; - std::vector phaseCondition_; - V well_perforation_pressure_diffs_; // Diff to bhp for each well perforation. - - LinearisedBlackoilResidual residual_; - - /// \brief Whether we print something to std::cout - bool terminal_output_; - - std::vector primalVariable_; - V pvdt_; - - // --------- Private methods --------- - - // return true if wells are available - bool wellsActive() const { return wells_ ? wells_->number_of_wells > 0 : false ; } - // return wells object - const Wells& wells () const { assert( bool(wells_ != 0) ); return *wells_; } - - SolutionState - constantState(const BlackoilState& x, - const WellStateFullyImplicitBlackoil& xw) const; - - void - makeConstantState(SolutionState& state) const; - - SolutionState - variableState(const BlackoilState& x, - const WellStateFullyImplicitBlackoil& xw) const; - - void - computeAccum(const SolutionState& state, - const int aix ); - - void computeWellConnectionPressures(const SolutionState& state, - const WellStateFullyImplicitBlackoil& xw); - - void - addWellControlEq(const SolutionState& state, - const WellStateFullyImplicitBlackoil& xw, - const V& aliveWells); - - void - addWellEq(const SolutionState& state, - WellStateFullyImplicitBlackoil& xw, - V& aliveWells); - - void updateWellControls(WellStateFullyImplicitBlackoil& xw) const; - - std::vector - computePressures(const SolutionState& state) const; - - std::vector - computePressures(const ADB& po, - const ADB& sw, - const ADB& so, - const ADB& sg) const; - - V - computeGasPressure(const V& po, - const V& sw, - const V& so, - const V& sg) const; - - std::vector - computeRelPerm(const SolutionState& state) const; - - void - computeMassFlux(const int actph , - const V& transi, - const ADB& kr , - const ADB& p , - const SolutionState& state ); - - void applyThresholdPressures(ADB& dp); - - ADB - fluidViscosity(const int phase, - const ADB& p , - const ADB& temp , - const ADB& rs , - const ADB& rv , - const std::vector& cond, - const std::vector& cells) const; - - ADB - fluidReciprocFVF(const int phase, - const ADB& p , - const ADB& temp , - const ADB& rs , - const ADB& rv , - const std::vector& cond, - const std::vector& cells) const; - - ADB - fluidDensity(const int phase, - const ADB& p , - const ADB& temp , - const ADB& rs , - const ADB& rv , - const std::vector& cond, - const std::vector& cells) const; - - V - fluidRsSat(const V& p, - const V& so, - const std::vector& cells) const; - - ADB - fluidRsSat(const ADB& p, - const ADB& so, - const std::vector& cells) const; - - V - fluidRvSat(const V& p, - const V& so, - const std::vector& cells) const; - - ADB - fluidRvSat(const ADB& p, - const ADB& so, - const std::vector& cells) const; - - ADB - poroMult(const ADB& p) const; - - ADB - transMult(const ADB& p) const; - - void - classifyCondition(const SolutionState& state, - std::vector& cond ) const; - - const std::vector - phaseCondition() const {return phaseCondition_;} - - void - classifyCondition(const BlackoilState& state); - - - /// update the primal variable for Sg, Rv or Rs. The Gas phase must - /// be active to call this method. - void - updatePrimalVariableFromState(const BlackoilState& state); - - /// Update the phaseCondition_ member based on the primalVariable_ member. - void - updatePhaseCondFromPrimalVariable(); - - /// \brief Compute the reduction within the convergence check. - /// \param[in] B A matrix with MaxNumPhases columns and the same number rows - /// as the number of cells of the grid. B.col(i) contains the values - /// for phase i. - /// \param[in] tempV A matrix with MaxNumPhases columns and the same number rows - /// as the number of cells of the grid. tempV.col(i) contains the - /// values - /// for phase i. - /// \param[in] R A matrix with MaxNumPhases columns and the same number rows - /// as the number of cells of the grid. B.col(i) contains the values - /// for phase i. - /// \param[out] R_sum An array of size MaxNumPhases where entry i contains the sum - /// of R for the phase i. - /// \param[out] maxCoeff An array of size MaxNumPhases where entry i contains the - /// maximum of tempV for the phase i. - /// \param[out] B_avg An array of size MaxNumPhases where entry i contains the average - /// of B for the phase i. - /// \param[out] maxNormWell The maximum of the well equations for each phase. - /// \param[in] nc The number of cells of the local grid. - /// \param[in] nw The number of wells on the local grid. - /// \return The total pore volume over all cells. - double - convergenceReduction(const Eigen::Array& B, - const Eigen::Array& tempV, - const Eigen::Array& R, - std::array& R_sum, - std::array& maxCoeff, - std::array& B_avg, - std::vector& maxNormWell, - int nc, - int nw) const; - - double dpMaxRel() const { return param_.dp_max_rel_; } - double dsMax() const { return param_.ds_max_; } - double drMaxRel() const { return param_.dr_max_rel_; } - double maxResidualAllowed() const { return param_.max_residual_allowed_; } - + const bool has_disgas, + const bool has_vapoil, + const bool terminal_output) + : Base(param, grid, fluid, geo, rock_comp_props, wells, linsolver, + has_disgas, has_vapoil, terminal_output) + { + } }; + + + /// Providing types by template specialisation of ModelTraits for BlackoilModel. + template + struct ModelTraits< BlackoilModel > + { + typedef BlackoilState ReservoirState; + typedef WellStateFullyImplicitBlackoil WellState; + typedef BlackoilModelBase< Grid, BlackoilModel > Base; + typedef BlackoilModelParameters ModelParameters; + }; + } // namespace Opm -#include "BlackoilModel_impl.hpp" #endif // OPM_BLACKOILMODEL_HEADER_INCLUDED diff --git a/opm/autodiff/BlackoilModelBase.hpp b/opm/autodiff/BlackoilModelBase.hpp index 46ea99683..e282ecee7 100644 --- a/opm/autodiff/BlackoilModelBase.hpp +++ b/opm/autodiff/BlackoilModelBase.hpp @@ -46,6 +46,13 @@ namespace Opm { class WellStateFullyImplicitBlackoil; + /// Traits to encapsulate the types used by classes using or + /// extending this model. Forward declared here, must be + /// specialised for each concrete model class. + template + struct ModelTraits; + + /// A model implementation for three-phase black oil. /// /// The simulator is capable of handling three-phase problems @@ -55,7 +62,9 @@ namespace Opm { /// /// It uses automatic differentiation via the class AutoDiffBlock /// to simplify assembly of the jacobian matrix. - template + /// \tparam Grid UnstructuredGrid or CpGrid. + /// \tparam Implementation Provides concrete state types. + template class BlackoilModelBase { public: @@ -63,25 +72,10 @@ namespace Opm { typedef AutoDiffBlock ADB; typedef ADB::V V; typedef ADB::M M; - typedef BlackoilState ReservoirState; - typedef WellStateFullyImplicitBlackoil WellState; - /// Model-specific solver parameters. - struct ModelParameters - { - double dp_max_rel_; - double ds_max_; - double dr_max_rel_; - double max_residual_allowed_; - double tolerance_mb_; - double tolerance_cnv_; - double tolerance_wells_; - - explicit ModelParameters( const parameter::ParameterGroup& param ); - ModelParameters(); - - void reset(); - }; + typedef typename ModelTraits::ReservoirState ReservoirState; + typedef typename ModelTraits::WellState WellState; + typedef typename ModelTraits::ModelParameters ModelParameters; // --------- Public methods --------- @@ -180,7 +174,7 @@ namespace Opm { /// The number of active phases in the model. int numPhases() const; - private: + protected: // --------- Types and enums --------- @@ -259,7 +253,7 @@ namespace Opm { std::vector primalVariable_; V pvdt_; - // --------- Private methods --------- + // --------- Protected methods --------- // return true if wells are available bool wellsActive() const { return wells_ ? wells_->number_of_wells > 0 : false ; } diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index 19ad7b421..e1ac6e7bf 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -136,48 +136,9 @@ namespace detail { } // namespace detail - template - void BlackoilModelBase::ModelParameters:: - reset() - { - // default values for the solver parameters - dp_max_rel_ = 1.0e9; - ds_max_ = 0.2; - dr_max_rel_ = 1.0e9; - max_residual_allowed_ = 1e7; - tolerance_mb_ = 1.0e-5; - tolerance_cnv_ = 1.0e-2; - tolerance_wells_ = 5.0e-1; - } - template - BlackoilModelBase::ModelParameters:: - ModelParameters() - { - // set default values - reset(); - } - - template - BlackoilModelBase::ModelParameters:: - ModelParameters( const parameter::ParameterGroup& param ) - { - // set default values - reset(); - - // overload with given parameters - dp_max_rel_ = param.getDefault("dp_max_rel", dp_max_rel_); - ds_max_ = param.getDefault("ds_max", ds_max_); - dr_max_rel_ = param.getDefault("dr_max_rel", dr_max_rel_); - max_residual_allowed_ = param.getDefault("max_residual_allowed", max_residual_allowed_); - tolerance_mb_ = param.getDefault("tolerance_mb", tolerance_mb_); - tolerance_cnv_ = param.getDefault("tolerance_cnv", tolerance_cnv_); - tolerance_wells_ = param.getDefault("tolerance_wells", tolerance_wells_ ); - } - - - template - BlackoilModelBase:: + template + BlackoilModelBase:: BlackoilModelBase(const ModelParameters& param, const Grid& grid , const BlackoilPropsAdInterface& fluid, @@ -225,9 +186,9 @@ namespace detail { - template + template void - BlackoilModelBase:: + BlackoilModelBase:: prepareStep(const double dt, ReservoirState& reservoir_state, WellState& /* well_state */) @@ -241,9 +202,9 @@ namespace detail { - template + template void - BlackoilModelBase:: + BlackoilModelBase:: afterStep(const double /* dt */, ReservoirState& /* reservoir_state */, WellState& /* well_state */) @@ -254,9 +215,9 @@ namespace detail { - template + template int - BlackoilModelBase:: + BlackoilModelBase:: sizeNonLinear() const { return residual_.sizeNonLinear(); @@ -265,9 +226,9 @@ namespace detail { - template + template int - BlackoilModelBase:: + BlackoilModelBase:: linearIterationsLastSolve() const { return linsolver_.iterations(); @@ -276,9 +237,9 @@ namespace detail { - template + template bool - BlackoilModelBase:: + BlackoilModelBase:: terminalOutputEnabled() const { return terminal_output_; @@ -287,9 +248,9 @@ namespace detail { - template + template int - BlackoilModelBase:: + BlackoilModelBase:: numPhases() const { return fluid_.numPhases(); @@ -298,9 +259,9 @@ namespace detail { - template + template void - BlackoilModelBase:: + BlackoilModelBase:: setThresholdPressures(const std::vector& threshold_pressures_by_face) { const int num_faces = AutoDiffGrid::numFaces(grid_); @@ -319,8 +280,8 @@ namespace detail { - template - BlackoilModelBase::ReservoirResidualQuant::ReservoirResidualQuant() + template + BlackoilModelBase::ReservoirResidualQuant::ReservoirResidualQuant() : accum(2, ADB::null()) , mflux( ADB::null()) , b ( ADB::null()) @@ -333,8 +294,8 @@ namespace detail { - template - BlackoilModelBase::SolutionState::SolutionState(const int np) + template + BlackoilModelBase::SolutionState::SolutionState(const int np) : pressure ( ADB::null()) , temperature( ADB::null()) , saturation(np, ADB::null()) @@ -350,8 +311,8 @@ namespace detail { - template - BlackoilModelBase:: + template + BlackoilModelBase:: WellOps::WellOps(const Wells* wells) : w2p(), p2w() @@ -386,9 +347,9 @@ namespace detail { - template - typename BlackoilModelBase::SolutionState - BlackoilModelBase::constantState(const BlackoilState& x, + template + typename BlackoilModelBase::SolutionState + BlackoilModelBase::constantState(const BlackoilState& x, const WellStateFullyImplicitBlackoil& xw) const { auto state = variableState(x, xw); @@ -400,9 +361,9 @@ namespace detail { - template + template void - BlackoilModelBase::makeConstantState(SolutionState& state) const + BlackoilModelBase::makeConstantState(SolutionState& state) const { // HACK: throw away the derivatives. this may not be the most // performant way to do things, but it will make the state @@ -429,9 +390,9 @@ namespace detail { - template - typename BlackoilModelBase::SolutionState - BlackoilModelBase::variableState(const BlackoilState& x, + template + typename BlackoilModelBase::SolutionState + BlackoilModelBase::variableState(const BlackoilState& x, const WellStateFullyImplicitBlackoil& xw) const { using namespace Opm::AutoDiffGrid; @@ -587,9 +548,9 @@ namespace detail { - template + template void - BlackoilModelBase::computeAccum(const SolutionState& state, + BlackoilModelBase::computeAccum(const SolutionState& state, const int aix ) { const Opm::PhaseUsage& pu = fluid_.phaseUsage(); @@ -634,8 +595,8 @@ namespace detail { - template - void BlackoilModelBase::computeWellConnectionPressures(const SolutionState& state, + template + void BlackoilModelBase::computeWellConnectionPressures(const SolutionState& state, const WellStateFullyImplicitBlackoil& xw) { if( ! wellsActive() ) return ; @@ -727,9 +688,9 @@ namespace detail { - template + template void - BlackoilModelBase:: + BlackoilModelBase:: assemble(const BlackoilState& reservoir_state, WellStateFullyImplicitBlackoil& well_state, const bool initial_assembly) @@ -820,8 +781,8 @@ namespace detail { - template - void BlackoilModelBase::addWellEq(const SolutionState& state, + template + void BlackoilModelBase::addWellEq(const SolutionState& state, WellStateFullyImplicitBlackoil& xw, V& aliveWells) { @@ -1062,8 +1023,8 @@ namespace detail { - template - void BlackoilModelBase::updateWellControls(WellStateFullyImplicitBlackoil& xw) const + template + void BlackoilModelBase::updateWellControls(WellStateFullyImplicitBlackoil& xw) const { if( ! wellsActive() ) return ; @@ -1138,8 +1099,8 @@ namespace detail { - template - void BlackoilModelBase::addWellControlEq(const SolutionState& state, + template + void BlackoilModelBase::addWellControlEq(const SolutionState& state, const WellStateFullyImplicitBlackoil& xw, const V& aliveWells) { @@ -1209,8 +1170,8 @@ namespace detail { - template - V BlackoilModelBase::solveJacobianSystem() const + template + V BlackoilModelBase::solveJacobianSystem() const { return linsolver_.computeNewtonIncrement(residual_); } @@ -1228,6 +1189,7 @@ namespace detail { /// \param info In a parallel this holds the information about the data distribution. double infinityNorm( const ADB& a, const boost::any& pinfo = boost::any() ) { + static_cast(pinfo); // Suppress warning in non-MPI case. #if HAVE_MPI if ( pinfo.type() == typeid(ParallelISTLInformation) ) { @@ -1254,6 +1216,7 @@ namespace detail { /// \param info In a parallel this holds the information about the data distribution. double infinityNormWell( const ADB& a, const boost::any& pinfo ) { + static_cast(pinfo); // Suppress warning in non-MPI case. double result=0; if( a.value().size() > 0 ) { result = a.value().matrix().lpNorm (); @@ -1275,8 +1238,8 @@ namespace detail { - template - void BlackoilModelBase::updateState(const V& dx, + template + void BlackoilModelBase::updateState(const V& dx, BlackoilState& reservoir_state, WellStateFullyImplicitBlackoil& well_state) { @@ -1537,9 +1500,9 @@ namespace detail { - template + template std::vector - BlackoilModelBase::computeRelPerm(const SolutionState& state) const + BlackoilModelBase::computeRelPerm(const SolutionState& state) const { using namespace Opm::AutoDiffGrid; const int nc = numCells(grid_); @@ -1566,9 +1529,9 @@ namespace detail { - template + template std::vector - BlackoilModelBase::computePressures(const SolutionState& state) const + BlackoilModelBase::computePressures(const SolutionState& state) const { using namespace Opm::AutoDiffGrid; const int nc = numCells(grid_); @@ -1596,9 +1559,9 @@ namespace detail { - template + template std::vector - BlackoilModelBase:: + BlackoilModelBase:: computePressures(const ADB& po, const ADB& sw, const ADB& so, @@ -1633,9 +1596,9 @@ namespace detail { - template + template V - BlackoilModelBase::computeGasPressure(const V& po, + BlackoilModelBase::computeGasPressure(const V& po, const V& sw, const V& so, const V& sg) const @@ -1652,9 +1615,9 @@ namespace detail { - template + template void - BlackoilModelBase::computeMassFlux(const int actph , + BlackoilModelBase::computeMassFlux(const int actph , const V& transi, const ADB& kr , const ADB& phasePressure, @@ -1698,9 +1661,9 @@ namespace detail { - template + template void - BlackoilModelBase::applyThresholdPressures(ADB& dp) + BlackoilModelBase::applyThresholdPressures(ADB& dp) { // We support reversible threshold pressures only. // Method: if the potential difference is lower (in absolute @@ -1729,9 +1692,9 @@ namespace detail { - template + template std::vector - BlackoilModelBase::computeResidualNorms() const + BlackoilModelBase::computeResidualNorms() const { std::vector residualNorms; @@ -1771,9 +1734,9 @@ namespace detail { - template + template double - BlackoilModelBase::convergenceReduction(const Eigen::Array& B, + BlackoilModelBase::convergenceReduction(const Eigen::Array& B, const Eigen::Array& tempV, const Eigen::Array& R, std::array& R_sum, @@ -1855,9 +1818,9 @@ namespace detail { - template + template bool - BlackoilModelBase::getConvergence(const double dt, const int iteration) + BlackoilModelBase::getConvergence(const double dt, const int iteration) { const double tol_mb = param_.tolerance_mb_; const double tol_cnv = param_.tolerance_cnv_; @@ -1960,9 +1923,9 @@ namespace detail { - template + template ADB - BlackoilModelBase::fluidViscosity(const int phase, + BlackoilModelBase::fluidViscosity(const int phase, const ADB& p , const ADB& temp , const ADB& rs , @@ -1987,9 +1950,9 @@ namespace detail { - template + template ADB - BlackoilModelBase::fluidReciprocFVF(const int phase, + BlackoilModelBase::fluidReciprocFVF(const int phase, const ADB& p , const ADB& temp , const ADB& rs , @@ -2014,9 +1977,9 @@ namespace detail { - template + template ADB - BlackoilModelBase::fluidDensity(const int phase, + BlackoilModelBase::fluidDensity(const int phase, const ADB& p , const ADB& temp , const ADB& rs , @@ -2042,9 +2005,9 @@ namespace detail { - template + template V - BlackoilModelBase::fluidRsSat(const V& p, + BlackoilModelBase::fluidRsSat(const V& p, const V& satOil, const std::vector& cells) const { @@ -2055,9 +2018,9 @@ namespace detail { - template + template ADB - BlackoilModelBase::fluidRsSat(const ADB& p, + BlackoilModelBase::fluidRsSat(const ADB& p, const ADB& satOil, const std::vector& cells) const { @@ -2065,9 +2028,9 @@ namespace detail { } - template + template V - BlackoilModelBase::fluidRvSat(const V& p, + BlackoilModelBase::fluidRvSat(const V& p, const V& satOil, const std::vector& cells) const { @@ -2078,9 +2041,9 @@ namespace detail { - template + template ADB - BlackoilModelBase::fluidRvSat(const ADB& p, + BlackoilModelBase::fluidRvSat(const ADB& p, const ADB& satOil, const std::vector& cells) const { @@ -2089,9 +2052,9 @@ namespace detail { - template + template ADB - BlackoilModelBase::poroMult(const ADB& p) const + BlackoilModelBase::poroMult(const ADB& p) const { const int n = p.size(); if (rock_comp_props_ && rock_comp_props_->isActive()) { @@ -2117,9 +2080,9 @@ namespace detail { - template + template ADB - BlackoilModelBase::transMult(const ADB& p) const + BlackoilModelBase::transMult(const ADB& p) const { const int n = p.size(); if (rock_comp_props_ && rock_comp_props_->isActive()) { @@ -2143,9 +2106,9 @@ namespace detail { /* - template + template void - BlackoilModelBase:: + BlackoilModelBase:: classifyCondition(const SolutionState& state, std::vector& cond ) const { @@ -2185,9 +2148,9 @@ namespace detail { } */ - template + template void - BlackoilModelBase::classifyCondition(const BlackoilState& state) + BlackoilModelBase::classifyCondition(const BlackoilState& state) { using namespace Opm::AutoDiffGrid; const int nc = numCells(grid_); @@ -2223,9 +2186,9 @@ namespace detail { } - template + template void - BlackoilModelBase::updatePrimalVariableFromState(const BlackoilState& state) + BlackoilModelBase::updatePrimalVariableFromState(const BlackoilState& state) { using namespace Opm::AutoDiffGrid; const int nc = numCells(grid_); @@ -2273,9 +2236,9 @@ namespace detail { /// Update the phaseCondition_ member based on the primalVariable_ member. - template + template void - BlackoilModelBase::updatePhaseCondFromPrimalVariable() + BlackoilModelBase::updatePhaseCondFromPrimalVariable() { if (! active_[Gas]) { OPM_THROW(std::logic_error, "updatePhaseCondFromPrimarVariable() logic requires active gas phase."); diff --git a/opm/autodiff/BlackoilModel_impl.hpp b/opm/autodiff/BlackoilModel_impl.hpp index 1f71307f3..a38441979 100644 --- a/opm/autodiff/BlackoilModel_impl.hpp +++ b/opm/autodiff/BlackoilModel_impl.hpp @@ -136,44 +136,6 @@ namespace detail { } // namespace detail - template - void BlackoilModel::ModelParameters:: - reset() - { - // default values for the solver parameters - dp_max_rel_ = 1.0e9; - ds_max_ = 0.2; - dr_max_rel_ = 1.0e9; - max_residual_allowed_ = 1e7; - tolerance_mb_ = 1.0e-5; - tolerance_cnv_ = 1.0e-2; - tolerance_wells_ = 5.0e-1; - } - - template - BlackoilModel::ModelParameters:: - ModelParameters() - { - // set default values - reset(); - } - - template - BlackoilModel::ModelParameters:: - ModelParameters( const parameter::ParameterGroup& param ) - { - // set default values - reset(); - - // overload with given parameters - dp_max_rel_ = param.getDefault("dp_max_rel", dp_max_rel_); - ds_max_ = param.getDefault("ds_max", ds_max_); - dr_max_rel_ = param.getDefault("dr_max_rel", dr_max_rel_); - max_residual_allowed_ = param.getDefault("max_residual_allowed", max_residual_allowed_); - tolerance_mb_ = param.getDefault("tolerance_mb", tolerance_mb_); - tolerance_cnv_ = param.getDefault("tolerance_cnv", tolerance_cnv_); - tolerance_wells_ = param.getDefault("tolerance_wells", tolerance_wells_ ); - } template