2016-08-11 06:31:52 -05:00
|
|
|
/*
|
|
|
|
Copyright 2016 SINTEF ICT, Applied Mathematics.
|
2017-03-24 06:19:11 -05:00
|
|
|
Copyright 2016 - 2017 Statoil ASA.
|
|
|
|
Copyright 2017 Dr. Blatt - HPC-Simulation-Software & Services
|
2017-05-03 06:34:15 -05:00
|
|
|
Copyright 2016 - 2017 IRIS AS
|
2016-08-11 06:31:52 -05:00
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OPM_STANDARDWELLSDENSE_HEADER_INCLUDED
|
|
|
|
#define OPM_STANDARDWELLSDENSE_HEADER_INCLUDED
|
|
|
|
|
|
|
|
#include <opm/common/OpmLog/OpmLog.hpp>
|
|
|
|
|
|
|
|
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
|
|
|
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
#include <tuple>
|
|
|
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
|
|
|
|
|
|
|
#include <opm/core/wells.h>
|
|
|
|
#include <opm/core/wells/DynamicListEconLimited.hpp>
|
2017-01-09 03:36:17 -06:00
|
|
|
#include <opm/core/wells/WellCollection.hpp>
|
2017-05-22 12:35:38 -05:00
|
|
|
#include <opm/core/simulator/SimulatorReport.hpp>
|
2016-08-11 06:31:52 -05:00
|
|
|
#include <opm/autodiff/VFPProperties.hpp>
|
2016-08-23 02:45:37 -05:00
|
|
|
#include <opm/autodiff/WellHelpers.hpp>
|
|
|
|
#include <opm/autodiff/BlackoilModelEnums.hpp>
|
|
|
|
#include <opm/autodiff/WellDensitySegmented.hpp>
|
2016-12-29 09:35:24 -06:00
|
|
|
#include <opm/autodiff/BlackoilPropsAdFromDeck.hpp>
|
2016-08-23 02:45:37 -05:00
|
|
|
#include <opm/autodiff/BlackoilDetails.hpp>
|
|
|
|
#include <opm/autodiff/BlackoilModelParameters.hpp>
|
2017-10-06 03:59:42 -05:00
|
|
|
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
|
2017-01-17 06:14:32 -06:00
|
|
|
#include <opm/autodiff/RateConverter.hpp>
|
2017-06-15 10:19:49 -05:00
|
|
|
#include <opm/autodiff/WellInterface.hpp>
|
2017-06-27 09:04:04 -05:00
|
|
|
#include <opm/autodiff/StandardWell.hpp>
|
2017-09-01 10:37:51 -05:00
|
|
|
#include <opm/autodiff/MultisegmentWell.hpp>
|
2016-08-25 08:25:01 -05:00
|
|
|
#include<dune/common/fmatrix.hh>
|
|
|
|
#include<dune/istl/bcrsmatrix.hh>
|
|
|
|
#include<dune/istl/matrixmatrix.hh>
|
2016-08-11 06:31:52 -05:00
|
|
|
|
|
|
|
#include <opm/material/densead/Math.hpp>
|
|
|
|
|
2017-01-24 08:59:41 -06:00
|
|
|
#include <opm/simulators/WellSwitchingLogger.hpp>
|
|
|
|
|
2017-06-15 10:19:49 -05:00
|
|
|
|
2016-08-11 06:31:52 -05:00
|
|
|
namespace Opm {
|
|
|
|
|
|
|
|
/// Class for handling the standard well model.
|
2017-05-03 06:34:15 -05:00
|
|
|
template<typename TypeTag>
|
2016-08-11 06:31:52 -05:00
|
|
|
class StandardWellsDense {
|
|
|
|
public:
|
|
|
|
// --------- Types ---------
|
2017-10-06 03:59:42 -05:00
|
|
|
typedef WellStateFullyImplicitBlackoil WellState;
|
2016-08-23 02:45:37 -05:00
|
|
|
typedef BlackoilModelParameters ModelParameters;
|
|
|
|
|
2017-06-27 09:51:11 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
|
2017-05-03 06:34:15 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Indices) BlackoilIndices;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
|
2017-06-27 07:04:59 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
|
2017-05-03 06:34:15 -05:00
|
|
|
|
|
|
|
static const int numEq = BlackoilIndices::numEq;
|
2017-06-07 02:29:31 -05:00
|
|
|
static const int solventSaturationIdx = BlackoilIndices::solventSaturationIdx;
|
2017-06-27 07:04:59 -05:00
|
|
|
|
2017-07-21 08:30:34 -05:00
|
|
|
// TODO: where we should put these types, WellInterface or Well Model?
|
|
|
|
// or there is some other strategy, like TypeTag
|
2017-05-03 06:34:15 -05:00
|
|
|
typedef Dune::FieldVector<Scalar, numEq > VectorBlockType;
|
2016-11-01 07:41:00 -05:00
|
|
|
typedef Dune::BlockVector<VectorBlockType> BVector;
|
2017-05-03 06:34:15 -05:00
|
|
|
|
2017-06-07 02:29:31 -05:00
|
|
|
typedef Ewoms::BlackOilPolymerModule<TypeTag> PolymerModule;
|
2016-11-18 05:43:53 -06:00
|
|
|
|
2017-01-17 06:14:32 -06:00
|
|
|
// For the conversion between the surface volume rate and resrevoir voidage rate
|
|
|
|
using RateConverterType = RateConverter::
|
|
|
|
SurfaceToReservoirVoidage<BlackoilPropsAdFromDeck::FluidSystem, std::vector<int> >;
|
2016-11-01 07:41:00 -05:00
|
|
|
|
2016-08-11 06:31:52 -05:00
|
|
|
// --------- Public methods ---------
|
2016-08-23 02:45:37 -05:00
|
|
|
StandardWellsDense(const Wells* wells_arg,
|
2017-01-09 03:36:17 -06:00
|
|
|
WellCollection* well_collection,
|
2017-05-09 01:21:51 -05:00
|
|
|
const std::vector< const Well* >& wells_ecl,
|
2016-08-23 02:45:37 -05:00
|
|
|
const ModelParameters& param,
|
2017-08-10 04:20:09 -05:00
|
|
|
const RateConverterType& rate_converter,
|
2017-05-09 01:21:51 -05:00
|
|
|
const bool terminal_output,
|
2017-10-02 07:18:33 -05:00
|
|
|
const int current_index,
|
|
|
|
std::vector<int>& pvt_region_idx);
|
2016-08-23 02:45:37 -05:00
|
|
|
|
2017-01-11 10:02:20 -06:00
|
|
|
void init(const PhaseUsage phase_usage_arg,
|
|
|
|
const std::vector<bool>& active_arg,
|
2016-09-09 07:58:54 -05:00
|
|
|
const double gravity_arg,
|
|
|
|
const std::vector<double>& depth_arg,
|
2017-06-07 02:29:31 -05:00
|
|
|
long int global_nc,
|
2017-06-27 09:51:11 -05:00
|
|
|
const Grid& grid);
|
2016-09-09 07:58:54 -05:00
|
|
|
|
2017-08-07 04:35:59 -05:00
|
|
|
void setVFPProperties(const VFPProperties* vfp_properties_arg);
|
2016-08-23 02:45:37 -05:00
|
|
|
|
2017-05-03 06:34:15 -05:00
|
|
|
|
2016-11-23 14:44:33 -06:00
|
|
|
SimulatorReport assemble(Simulator& ebosSimulator,
|
2016-08-23 02:45:37 -05:00
|
|
|
const int iterationIdx,
|
|
|
|
const double dt,
|
2017-02-13 09:45:06 -06:00
|
|
|
WellState& well_state);
|
2016-08-25 08:25:01 -05:00
|
|
|
|
2016-09-07 06:23:52 -05:00
|
|
|
// substract Binv(D)rw from r;
|
2017-02-13 10:07:34 -06:00
|
|
|
void apply( BVector& r) const;
|
2016-08-25 08:25:01 -05:00
|
|
|
|
2016-09-07 06:23:52 -05:00
|
|
|
// subtract B*inv(D)*C * x from A*x
|
2017-06-07 07:23:43 -05:00
|
|
|
void apply(const BVector& x, BVector& Ax) const;
|
2016-08-25 08:25:01 -05:00
|
|
|
|
2016-11-17 06:43:39 -06:00
|
|
|
// apply well model with scaling of alpha
|
2017-06-07 07:23:43 -05:00
|
|
|
void applyScaleAdd(const Scalar alpha, const BVector& x, BVector& Ax) const;
|
2016-11-17 06:43:39 -06:00
|
|
|
|
2017-07-21 08:30:34 -05:00
|
|
|
// using the solution x to recover the solution xw for wells and applying
|
|
|
|
// xw to update Well State
|
2017-08-21 07:16:24 -05:00
|
|
|
void recoverWellSolutionAndUpdateWellState(const BVector& x, WellState& well_state) const;
|
2016-08-25 08:25:01 -05:00
|
|
|
|
2017-08-10 08:27:05 -05:00
|
|
|
int numWells() const;
|
2016-08-19 06:50:27 -05:00
|
|
|
|
2016-08-11 06:31:52 -05:00
|
|
|
/// return true if wells are available in the reservoir
|
2017-02-13 10:07:34 -06:00
|
|
|
bool wellsActive() const;
|
2016-08-23 02:45:37 -05:00
|
|
|
|
2017-02-13 10:07:34 -06:00
|
|
|
void setWellsActive(const bool wells_active);
|
|
|
|
|
|
|
|
/// return true if wells are available on this process
|
|
|
|
bool localWellsActive() const;
|
2016-08-11 06:31:52 -05:00
|
|
|
|
2016-08-23 02:45:37 -05:00
|
|
|
bool getWellConvergence(Simulator& ebosSimulator,
|
2017-07-21 09:01:32 -05:00
|
|
|
const std::vector<Scalar>& B_avg) const;
|
2016-08-23 02:45:37 -05:00
|
|
|
|
2016-08-11 06:31:52 -05:00
|
|
|
/// upate the dynamic lists related to economic limits
|
2017-05-03 06:34:15 -05:00
|
|
|
void updateListEconLimited(const Schedule& schedule,
|
|
|
|
const int current_step,
|
|
|
|
const Wells* wells_struct,
|
|
|
|
const WellState& well_state,
|
|
|
|
DynamicListEconLimited& list_econ_limited) const;
|
2016-08-11 06:31:52 -05:00
|
|
|
|
2017-02-14 08:06:57 -06:00
|
|
|
WellCollection* wellCollection() const;
|
2017-01-09 04:29:00 -06:00
|
|
|
|
2017-08-08 03:44:10 -05:00
|
|
|
|
2016-08-11 06:31:52 -05:00
|
|
|
protected:
|
|
|
|
bool wells_active_;
|
|
|
|
const Wells* wells_;
|
2017-05-09 01:21:51 -05:00
|
|
|
const std::vector< const Well* > wells_ecl_;
|
2017-01-09 03:36:17 -06:00
|
|
|
|
2017-06-27 05:17:36 -05:00
|
|
|
// the number of wells in this process
|
2017-06-28 04:15:04 -05:00
|
|
|
// trying not to use things from Wells struct
|
|
|
|
// TODO: maybe a better name to emphasize it is local?
|
2017-06-27 05:17:36 -05:00
|
|
|
const int number_of_wells_;
|
|
|
|
|
2017-07-25 03:15:27 -05:00
|
|
|
const int number_of_phases_;
|
|
|
|
|
2017-08-21 03:23:42 -05:00
|
|
|
using WellInterfacePtr = std::unique_ptr<WellInterface<TypeTag> >;
|
2017-06-15 10:19:49 -05:00
|
|
|
// a vector of all the wells.
|
|
|
|
// eventually, the wells_ above should be gone.
|
|
|
|
// the name is just temporary
|
|
|
|
// later, might make share_ptr const later.
|
2017-08-21 03:23:42 -05:00
|
|
|
std::vector<WellInterfacePtr > well_container_;
|
2017-06-15 10:19:49 -05:00
|
|
|
|
2017-08-22 07:49:30 -05:00
|
|
|
using ConvergenceReport = typename WellInterface<TypeTag>::ConvergenceReport;
|
|
|
|
|
2017-08-21 03:23:42 -05:00
|
|
|
// create the well container
|
|
|
|
static std::vector<WellInterfacePtr > createWellContainer(const Wells* wells,
|
|
|
|
const std::vector<const Well*>& wells_ecl,
|
2017-09-25 08:09:34 -05:00
|
|
|
const bool use_multisegment_well,
|
2017-08-21 03:23:42 -05:00
|
|
|
const int time_step);
|
2017-06-15 10:19:49 -05:00
|
|
|
|
2017-01-09 03:36:17 -06:00
|
|
|
// Well collection is used to enforce the group control
|
|
|
|
WellCollection* well_collection_;
|
|
|
|
|
2016-08-23 02:45:37 -05:00
|
|
|
ModelParameters param_;
|
|
|
|
bool terminal_output_;
|
2017-05-09 01:21:51 -05:00
|
|
|
bool has_solvent_;
|
2017-06-07 02:29:31 -05:00
|
|
|
bool has_polymer_;
|
2017-05-09 01:21:51 -05:00
|
|
|
int current_timeIdx_;
|
2016-08-11 06:31:52 -05:00
|
|
|
|
2017-01-11 10:02:20 -06:00
|
|
|
PhaseUsage phase_usage_;
|
|
|
|
std::vector<bool> active_;
|
2017-08-10 04:20:09 -05:00
|
|
|
const RateConverterType& rate_converter_;
|
2017-10-02 07:18:33 -05:00
|
|
|
std::vector<int> pvt_region_idx_;
|
2017-01-09 04:29:00 -06:00
|
|
|
|
2017-08-11 07:51:29 -05:00
|
|
|
// the number of the cells in the local grid
|
|
|
|
int number_of_cells_;
|
2016-08-11 06:31:52 -05:00
|
|
|
|
2017-03-24 09:12:42 -05:00
|
|
|
long int global_nc_;
|
|
|
|
|
2017-08-21 03:23:42 -05:00
|
|
|
// used to better efficiency of calcuation
|
2016-11-17 06:43:39 -06:00
|
|
|
mutable BVector scaleAddRes_;
|
2016-11-02 04:43:55 -05:00
|
|
|
|
2017-08-10 08:27:05 -05:00
|
|
|
void updateWellControls(WellState& xw) const;
|
|
|
|
|
|
|
|
void updateGroupControls(WellState& well_state) const;
|
|
|
|
|
|
|
|
// setting the well_solutions_ based on well_state.
|
2017-08-21 08:41:25 -05:00
|
|
|
void updatePrimaryVariables(const WellState& well_state) const;
|
2017-08-10 08:27:05 -05:00
|
|
|
|
2017-06-07 02:29:31 -05:00
|
|
|
void setupCompressedToCartesian(const int* global_cell, int number_of_cells, std::map<int,int>& cartesian_to_compressed ) const;
|
|
|
|
|
2017-06-27 13:06:44 -05:00
|
|
|
void computeRepRadiusPerfLength(const Grid& grid);
|
2017-06-07 02:29:31 -05:00
|
|
|
|
|
|
|
|
2017-06-23 05:24:50 -05:00
|
|
|
void computeAverageFormationFactor(Simulator& ebosSimulator,
|
|
|
|
std::vector<double>& B_avg) const;
|
2017-08-10 08:27:05 -05:00
|
|
|
|
|
|
|
void applyVREPGroupControl(WellState& well_state) const;
|
|
|
|
|
|
|
|
void computeWellVoidageRates(const WellState& well_state,
|
|
|
|
std::vector<double>& well_voidage_rates,
|
|
|
|
std::vector<double>& voidage_conversion_coeffs) const;
|
|
|
|
|
|
|
|
// Calculating well potentials for each well
|
|
|
|
// TODO: getBhp() will be refactored to reduce the duplication of the code calculating the bhp from THP.
|
|
|
|
void computeWellPotentials(const Simulator& ebosSimulator,
|
|
|
|
const WellState& well_state,
|
|
|
|
std::vector<double>& well_potentials) const;
|
|
|
|
|
|
|
|
const std::vector<double>& wellPerfEfficiencyFactors() const;
|
|
|
|
|
|
|
|
void calculateEfficiencyFactors();
|
|
|
|
|
2017-09-05 04:09:58 -05:00
|
|
|
// it should be able to go to prepareTimeStep(), however, the updateWellControls() and initPrimaryVariablesEvaluation()
|
|
|
|
// makes it a little more difficult. unless we introduce if (iterationIdx != 0) to avoid doing the above functions
|
|
|
|
// twice at the beginning of the time step
|
|
|
|
/// Calculating the explict quantities used in the well calculation. By explicit, we mean they are cacluated
|
|
|
|
/// at the beginning of the time step and no derivatives are included in these quantities
|
2017-09-05 04:20:43 -05:00
|
|
|
void calculateExplicitQuantities(const Simulator& ebosSimulator,
|
2017-09-05 04:09:58 -05:00
|
|
|
const WellState& xw) const;
|
2017-08-10 08:27:05 -05:00
|
|
|
|
|
|
|
SimulatorReport solveWellEq(Simulator& ebosSimulator,
|
|
|
|
const double dt,
|
|
|
|
WellState& well_state) const;
|
|
|
|
|
2017-08-21 08:41:25 -05:00
|
|
|
void initPrimaryVariablesEvaluation() const;
|
2017-08-10 08:27:05 -05:00
|
|
|
|
2017-08-11 07:51:29 -05:00
|
|
|
// The number of components in the model.
|
|
|
|
int numComponents() const
|
|
|
|
{
|
|
|
|
if (numPhases() == 2) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
int numComp = FluidSystem::numComponents;
|
|
|
|
if (has_solvent_) {
|
|
|
|
numComp ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return numComp;
|
|
|
|
}
|
|
|
|
|
|
|
|
int numPhases() const;
|
|
|
|
|
|
|
|
int flowPhaseToEbosPhaseIdx( const int phaseIdx ) const;
|
|
|
|
|
|
|
|
void resetWellControlFromState(const WellState& xw) const;
|
|
|
|
|
|
|
|
void assembleWellEq(Simulator& ebosSimulator,
|
|
|
|
const double dt,
|
|
|
|
WellState& well_state,
|
|
|
|
bool only_wells) const;
|
2017-08-14 07:11:58 -05:00
|
|
|
|
|
|
|
// some preparation work, mostly related to group control and RESV,
|
|
|
|
// at the beginning of each time step (Not report step)
|
|
|
|
void prepareTimeStep(const Simulator& ebos_simulator,
|
2017-09-04 06:54:41 -05:00
|
|
|
WellState& well_state) const;
|
|
|
|
|
|
|
|
void prepareGroupControl(const Simulator& ebos_simulator,
|
|
|
|
WellState& well_state) const;
|
|
|
|
|
2016-08-11 06:31:52 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Opm
|
2017-02-13 09:45:06 -06:00
|
|
|
|
|
|
|
#include "StandardWellsDense_impl.hpp"
|
2016-08-11 06:31:52 -05:00
|
|
|
#endif
|