2016-08-11 13:31:52 +02:00
|
|
|
/*
|
|
|
|
|
Copyright 2016 SINTEF ICT, Applied Mathematics.
|
2017-03-24 12:19:11 +01:00
|
|
|
Copyright 2016 - 2017 Statoil ASA.
|
|
|
|
|
Copyright 2017 Dr. Blatt - HPC-Simulation-Software & Services
|
2018-06-06 15:17:59 +02:00
|
|
|
Copyright 2016 - 2018 IRIS AS
|
2016-08-11 13:31:52 +02: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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2017-09-26 10:52:05 +02:00
|
|
|
#ifndef OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
|
|
|
|
|
#define OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
|
2016-08-11 13:31:52 +02:00
|
|
|
|
2018-08-16 11:51:36 +02:00
|
|
|
#include <ebos/eclproblem.hh>
|
2016-08-11 13:31:52 +02:00
|
|
|
#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>
|
2020-12-01 18:04:46 +01:00
|
|
|
#include <functional>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <memory>
|
2020-10-29 23:30:09 +01:00
|
|
|
#include <optional>
|
2020-12-01 18:04:46 +01:00
|
|
|
#include <string>
|
2016-08-11 13:31:52 +02:00
|
|
|
#include <tuple>
|
2020-12-01 18:04:46 +01:00
|
|
|
#include <unordered_map>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2016-08-11 13:31:52 +02:00
|
|
|
|
2020-02-19 13:00:35 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
|
|
|
|
|
2016-08-11 13:31:52 +02:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
2019-03-07 15:13:46 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp>
|
2019-09-30 12:49:36 +02:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp>
|
2020-02-19 13:00:35 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
2020-05-04 15:56:34 +02:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.hpp>
|
2016-08-11 13:31:52 +02:00
|
|
|
|
2019-06-20 10:30:16 +02:00
|
|
|
#include <opm/simulators/timestepping/SimulatorReport.hpp>
|
2019-10-23 09:09:45 +02:00
|
|
|
#include <opm/simulators/wells/PerforationData.hpp>
|
2019-05-07 13:06:02 +02:00
|
|
|
#include <opm/simulators/wells/VFPInjProperties.hpp>
|
|
|
|
|
#include <opm/simulators/wells/VFPProdProperties.hpp>
|
2019-06-20 10:15:51 +02:00
|
|
|
#include <opm/simulators/flow/countGlobalCells.hpp>
|
2019-05-07 13:06:02 +02:00
|
|
|
#include <opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp>
|
2019-06-20 09:09:19 +02:00
|
|
|
#include <opm/simulators/wells/RateConverter.hpp>
|
2019-05-07 13:06:02 +02:00
|
|
|
#include <opm/simulators/wells/WellInterface.hpp>
|
|
|
|
|
#include <opm/simulators/wells/StandardWell.hpp>
|
|
|
|
|
#include <opm/simulators/wells/MultisegmentWell.hpp>
|
2019-08-07 14:13:11 +02:00
|
|
|
#include <opm/simulators/wells/WellGroupHelpers.hpp>
|
2020-10-09 13:38:33 +02:00
|
|
|
#include <opm/simulators/wells/WellProdIndexCalculator.hpp>
|
2020-10-06 14:52:44 +02:00
|
|
|
#include <opm/simulators/wells/ParallelWellInfo.hpp>
|
2018-11-13 14:02:55 +01:00
|
|
|
#include <opm/simulators/timestepping/gatherConvergenceReport.hpp>
|
2019-05-07 13:06:02 +02:00
|
|
|
#include <dune/common/fmatrix.hh>
|
|
|
|
|
#include <dune/istl/bcrsmatrix.hh>
|
|
|
|
|
#include <dune/istl/matrixmatrix.hh>
|
2016-08-11 13:31:52 +02:00
|
|
|
|
|
|
|
|
#include <opm/material/densead/Math.hpp>
|
|
|
|
|
|
2019-05-07 13:06:02 +02:00
|
|
|
#include <opm/simulators/utils/DeferredLogger.hpp>
|
2017-01-24 15:59:41 +01:00
|
|
|
|
2020-08-21 13:42:08 +02:00
|
|
|
namespace Opm::Properties {
|
2018-08-16 11:51:36 +02:00
|
|
|
|
2020-08-27 11:38:38 +02:00
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
|
struct EnableTerminalOutput {
|
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
|
};
|
2018-08-16 11:51:36 +02:00
|
|
|
|
2020-08-21 13:42:08 +02:00
|
|
|
} // namespace Opm::Properties
|
2017-06-15 17:19:49 +02:00
|
|
|
|
2016-08-11 13:31:52 +02:00
|
|
|
namespace Opm {
|
|
|
|
|
|
2017-09-26 10:52:05 +02:00
|
|
|
/// Class for handling the blackoil well model.
|
2017-05-03 13:34:15 +02:00
|
|
|
template<typename TypeTag>
|
2019-09-05 17:04:39 +02:00
|
|
|
class BlackoilWellModel : public Opm::BaseAuxiliaryModule<TypeTag>
|
2018-08-16 11:51:36 +02:00
|
|
|
{
|
2016-08-11 13:31:52 +02:00
|
|
|
public:
|
|
|
|
|
// --------- Types ---------
|
2017-10-06 10:59:42 +02:00
|
|
|
typedef WellStateFullyImplicitBlackoil WellState;
|
2018-06-21 12:14:17 +02:00
|
|
|
typedef BlackoilModelParametersEbos<TypeTag> ModelParameters;
|
2016-08-23 09:45:37 +02:00
|
|
|
|
2020-08-26 10:49:52 +02:00
|
|
|
using Grid = GetPropType<TypeTag, Properties::Grid>;
|
|
|
|
|
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
|
|
|
|
|
using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
|
|
|
|
|
using Indices = GetPropType<TypeTag, Properties::Indices>;
|
|
|
|
|
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
|
|
|
|
|
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
|
|
|
|
|
using RateVector = GetPropType<TypeTag, Properties::RateVector>;
|
|
|
|
|
using GlobalEqVector = GetPropType<TypeTag, Properties::GlobalEqVector>;
|
|
|
|
|
using SparseMatrixAdapter = GetPropType<TypeTag, Properties::SparseMatrixAdapter>;
|
2018-08-16 11:51:36 +02:00
|
|
|
|
2019-09-05 17:04:39 +02:00
|
|
|
typedef typename Opm::BaseAuxiliaryModule<TypeTag>::NeighborSet NeighborSet;
|
2017-05-03 13:34:15 +02:00
|
|
|
|
2017-12-04 09:14:08 +01:00
|
|
|
static const int numEq = Indices::numEq;
|
|
|
|
|
static const int solventSaturationIdx = Indices::solventSaturationIdx;
|
2021-01-28 14:33:21 +01:00
|
|
|
static constexpr bool has_solvent_ = getPropValue<TypeTag, Properties::EnableSolvent>();
|
|
|
|
|
static constexpr bool has_polymer_ = getPropValue<TypeTag, Properties::EnablePolymer>();
|
2017-06-27 14:04:59 +02:00
|
|
|
|
2017-07-21 15:30:34 +02:00
|
|
|
// TODO: where we should put these types, WellInterface or Well Model?
|
|
|
|
|
// or there is some other strategy, like TypeTag
|
2017-05-03 13:34:15 +02:00
|
|
|
typedef Dune::FieldVector<Scalar, numEq > VectorBlockType;
|
2016-11-01 13:41:00 +01:00
|
|
|
typedef Dune::BlockVector<VectorBlockType> BVector;
|
2017-05-03 13:34:15 +02:00
|
|
|
|
2017-05-15 14:46:43 +02:00
|
|
|
typedef Dune::FieldMatrix<Scalar, numEq, numEq > MatrixBlockType;
|
|
|
|
|
|
2019-09-05 17:04:39 +02:00
|
|
|
typedef Opm::BlackOilPolymerModule<TypeTag> PolymerModule;
|
2016-11-18 12:43:53 +01:00
|
|
|
|
2017-01-17 13:14:32 +01:00
|
|
|
// For the conversion between the surface volume rate and resrevoir voidage rate
|
|
|
|
|
using RateConverterType = RateConverter::
|
2017-11-08 13:57:36 +01:00
|
|
|
SurfaceToReservoirVoidage<FluidSystem, std::vector<int> >;
|
2016-11-01 13:41:00 +01:00
|
|
|
|
2018-08-16 11:51:36 +02:00
|
|
|
BlackoilWellModel(Simulator& ebosSimulator);
|
|
|
|
|
|
2019-04-03 17:26:57 +02:00
|
|
|
void init();
|
2018-08-16 11:51:36 +02:00
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
|
// <eWoms auxiliary module stuff>
|
|
|
|
|
/////////////
|
|
|
|
|
unsigned numDofs() const
|
|
|
|
|
// No extra dofs are inserted for wells. (we use a Schur complement.)
|
|
|
|
|
{ return 0; }
|
2017-05-03 13:34:15 +02:00
|
|
|
|
2018-08-16 11:51:36 +02:00
|
|
|
void addNeighbors(std::vector<NeighborSet>& neighbors) const;
|
|
|
|
|
|
|
|
|
|
void applyInitial()
|
|
|
|
|
{}
|
|
|
|
|
|
2019-10-02 12:48:29 +02:00
|
|
|
void linearize(SparseMatrixAdapter& jacobian, GlobalEqVector& res);
|
2018-08-16 11:51:36 +02:00
|
|
|
|
|
|
|
|
void postSolve(GlobalEqVector& deltaX)
|
2018-06-06 10:59:41 +02:00
|
|
|
{
|
2018-08-16 11:51:36 +02:00
|
|
|
recoverWellSolutionAndUpdateWellState(deltaX);
|
2018-06-06 10:59:41 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-16 11:51:36 +02:00
|
|
|
/////////////
|
|
|
|
|
// </ eWoms auxiliary module stuff>
|
|
|
|
|
/////////////
|
|
|
|
|
|
|
|
|
|
template <class Restarter>
|
2019-04-24 17:18:44 +02:00
|
|
|
void deserialize(Restarter& /* res */)
|
2018-08-16 11:51:36 +02:00
|
|
|
{
|
|
|
|
|
// TODO (?)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief This method writes the complete state of the well
|
|
|
|
|
* to the harddisk.
|
|
|
|
|
*/
|
|
|
|
|
template <class Restarter>
|
2019-04-24 17:18:44 +02:00
|
|
|
void serialize(Restarter& /* res*/)
|
2018-08-16 11:51:36 +02:00
|
|
|
{
|
|
|
|
|
// TODO (?)
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-03 17:26:57 +02:00
|
|
|
void beginEpisode()
|
2018-08-16 11:51:36 +02:00
|
|
|
{
|
2019-04-03 17:26:57 +02:00
|
|
|
beginReportStep(ebosSimulator_.episodeIndex());
|
2018-08-16 11:51:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void beginTimeStep();
|
|
|
|
|
|
|
|
|
|
void beginIteration()
|
|
|
|
|
{
|
|
|
|
|
assemble(ebosSimulator_.model().newtonMethod().numIterations(),
|
|
|
|
|
ebosSimulator_.timeStepSize());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void endIteration()
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
void endTimeStep()
|
|
|
|
|
{
|
2018-11-30 12:15:51 +01:00
|
|
|
timeStepSucceeded(ebosSimulator_.time(), ebosSimulator_.timeStepSize());
|
2018-08-16 11:51:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void endEpisode()
|
|
|
|
|
{
|
|
|
|
|
endReportStep();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class Context>
|
|
|
|
|
void computeTotalRatesForDof(RateVector& rate,
|
|
|
|
|
const Context& context,
|
|
|
|
|
unsigned spaceIdx,
|
|
|
|
|
unsigned timeIdx) const;
|
|
|
|
|
|
2018-11-14 13:18:48 +01:00
|
|
|
|
|
|
|
|
using WellInterfacePtr = std::shared_ptr<WellInterface<TypeTag> >;
|
|
|
|
|
WellInterfacePtr well(const std::string& wellName) const;
|
|
|
|
|
|
2018-08-16 11:51:36 +02:00
|
|
|
void initFromRestartFile(const RestartValue& restartValues);
|
2016-08-25 15:25:01 +02:00
|
|
|
|
2020-09-20 22:16:07 +02:00
|
|
|
Opm::data::GroupAndNetworkValues
|
|
|
|
|
groupAndNetworkData(const int reportStepIdx, const Opm::Schedule& sched) const
|
2020-02-11 12:55:31 +01:00
|
|
|
{
|
2020-09-20 22:16:07 +02:00
|
|
|
auto grp_nwrk_values = ::Opm::data::GroupAndNetworkValues{};
|
2020-07-01 13:52:02 +02:00
|
|
|
|
2020-05-15 11:21:32 +02:00
|
|
|
this->assignGroupValues(reportStepIdx, sched, grp_nwrk_values.groupData);
|
2020-10-21 13:32:12 +02:00
|
|
|
this->assignNodeValues(grp_nwrk_values.nodeData);
|
2020-07-20 21:38:30 +02:00
|
|
|
|
2020-09-20 22:16:07 +02:00
|
|
|
return grp_nwrk_values;
|
2020-02-19 13:00:35 +01:00
|
|
|
}
|
2020-02-11 12:55:31 +01:00
|
|
|
|
2018-08-16 11:51:36 +02:00
|
|
|
Opm::data::Wells wellData() const
|
2020-02-07 19:08:14 +01:00
|
|
|
{
|
|
|
|
|
auto wsrpt = well_state_.report(phase_usage_, Opm::UgGridHelpers::globalCell(grid()));
|
|
|
|
|
|
2020-10-20 00:10:27 +02:00
|
|
|
this->assignWellGuideRates(wsrpt);
|
2020-10-29 23:16:31 +01:00
|
|
|
this->assignShutConnections(wsrpt);
|
2020-02-07 19:08:14 +01:00
|
|
|
|
|
|
|
|
return wsrpt;
|
|
|
|
|
}
|
2016-08-25 15:25:01 +02:00
|
|
|
|
2018-11-05 15:54:48 +01:00
|
|
|
// substract Binv(D)rw from r;
|
|
|
|
|
void apply( BVector& r) const;
|
|
|
|
|
|
2016-09-07 13:23:52 +02:00
|
|
|
// subtract B*inv(D)*C * x from A*x
|
2017-06-07 14:23:43 +02:00
|
|
|
void apply(const BVector& x, BVector& Ax) const;
|
2016-08-25 15:25:01 +02:00
|
|
|
|
2020-06-25 18:44:49 +02:00
|
|
|
#if HAVE_CUDA || HAVE_OPENCL
|
2020-03-13 14:21:59 +01:00
|
|
|
// accumulate the contributions of all Wells in the WellContributions object
|
|
|
|
|
void getWellContributions(WellContributions& x) const;
|
2020-03-18 17:48:28 +01:00
|
|
|
#endif
|
2020-03-13 14:21:59 +01:00
|
|
|
|
2016-11-17 13:43:39 +01:00
|
|
|
// apply well model with scaling of alpha
|
2017-06-07 14:23:43 +02:00
|
|
|
void applyScaleAdd(const Scalar alpha, const BVector& x, BVector& Ax) const;
|
2016-11-17 13:43:39 +01:00
|
|
|
|
2017-11-08 13:57:36 +01:00
|
|
|
// Check if well equations is converged.
|
2020-04-01 09:55:29 +02:00
|
|
|
ConvergenceReport getWellConvergence(const std::vector<Scalar>& B_avg, const bool checkGroupConvergence = false) const;
|
2016-08-19 13:50:27 +02:00
|
|
|
|
2017-11-08 13:57:36 +01:00
|
|
|
// return the internal well state, ignore the passed one.
|
|
|
|
|
// Used by the legacy code to make it compatible with the legacy well models.
|
2017-11-08 15:48:30 +01:00
|
|
|
const WellState& wellState(const WellState& well_state OPM_UNUSED) const;
|
2017-02-13 17:07:34 +01:00
|
|
|
|
2017-11-08 13:57:36 +01:00
|
|
|
// return the internal well state
|
2017-11-08 15:48:30 +01:00
|
|
|
const WellState& wellState() const;
|
2016-08-11 13:31:52 +02:00
|
|
|
|
2020-05-07 16:13:39 +02:00
|
|
|
const SimulatorReportSingle& lastReport() const;
|
2017-08-08 10:44:10 +02:00
|
|
|
|
2019-10-02 12:48:29 +02:00
|
|
|
void addWellContributions(SparseMatrixAdapter& jacobian) const
|
2018-11-05 15:54:48 +01:00
|
|
|
{
|
|
|
|
|
for ( const auto& well: well_container_ ) {
|
2019-10-02 12:48:29 +02:00
|
|
|
well->addWellContributions(jacobian);
|
2018-11-05 15:54:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-08 13:57:36 +01:00
|
|
|
// called at the beginning of a report step
|
|
|
|
|
void beginReportStep(const int time_step);
|
|
|
|
|
|
2018-11-22 11:01:58 +01:00
|
|
|
/// Return true if any well has a THP constraint.
|
|
|
|
|
bool hasTHPConstraints() const;
|
|
|
|
|
|
2018-11-23 12:51:13 +01:00
|
|
|
/// Shut down any single well, but only if it is in prediction mode.
|
2018-12-03 13:24:34 +01:00
|
|
|
/// Returns true if the well was actually found and shut.
|
|
|
|
|
bool forceShutWellByNameIfPredictionMode(const std::string& wellname, const double simulation_time);
|
2018-11-22 16:24:17 +01:00
|
|
|
|
2021-02-12 12:35:53 +01:00
|
|
|
void updateEclWell(int timeStepIdx, int well_index);
|
|
|
|
|
void updateEclWell(int timeStepIdx, const std::string& wname);
|
2021-02-12 11:26:14 +01:00
|
|
|
bool hasWell(const std::string& wname);
|
2021-02-12 12:35:53 +01:00
|
|
|
double wellPI(int well_index) const;
|
|
|
|
|
double wellPI(const std::string& well_name) const;
|
2017-11-08 13:57:36 +01:00
|
|
|
protected:
|
|
|
|
|
Simulator& ebosSimulator_;
|
2019-10-23 09:09:45 +02:00
|
|
|
|
2019-11-13 23:16:11 +01:00
|
|
|
std::vector< Well > wells_ecl_;
|
2019-10-23 09:09:45 +02:00
|
|
|
std::vector< std::vector<PerforationData> > well_perf_data_;
|
2020-10-09 13:38:33 +02:00
|
|
|
std::vector< WellProdIndexCalculator > prod_index_calc_;
|
2017-11-08 13:57:36 +01:00
|
|
|
|
2020-10-06 14:52:44 +02:00
|
|
|
std::vector< ParallelWellInfo > parallel_well_info_;
|
2020-10-09 15:09:28 +02:00
|
|
|
std::vector< ParallelWellInfo* > local_parallel_well_info_;
|
2020-10-06 14:52:44 +02:00
|
|
|
|
2017-11-08 13:57:36 +01:00
|
|
|
bool wells_active_;
|
2017-10-16 16:46:28 +02:00
|
|
|
|
2017-06-15 17:19:49 +02:00
|
|
|
// a vector of all the wells.
|
2017-08-21 10:23:42 +02:00
|
|
|
std::vector<WellInterfacePtr > well_container_;
|
2017-06-15 17:19:49 +02:00
|
|
|
|
2018-08-16 11:51:36 +02:00
|
|
|
// map from logically cartesian cell indices to compressed ones
|
2020-11-10 11:54:19 +01:00
|
|
|
// cells not in the interior are not mapped. This deactivates
|
|
|
|
|
// these for distributed wells and make the distribution non-overlapping.
|
2018-08-16 11:51:36 +02:00
|
|
|
std::vector<int> cartesian_to_compressed_;
|
|
|
|
|
|
2018-11-15 14:37:01 +01:00
|
|
|
std::vector<bool> is_cell_perforated_;
|
|
|
|
|
|
2020-09-22 14:12:15 +02:00
|
|
|
std::function<bool(const Well&)> is_shut_or_defunct_;
|
|
|
|
|
|
2020-10-09 13:38:33 +02:00
|
|
|
void initializeWellProdIndCalculators();
|
2019-10-23 09:09:45 +02:00
|
|
|
void initializeWellPerfData();
|
2020-10-20 00:16:52 +02:00
|
|
|
void initializeWellState(const int timeStepIdx,
|
|
|
|
|
const int globalNumWells,
|
|
|
|
|
const SummaryState& summaryState);
|
2019-10-23 09:09:45 +02:00
|
|
|
|
2017-08-21 10:23:42 +02:00
|
|
|
// create the well container
|
2019-10-23 09:09:45 +02:00
|
|
|
std::vector<WellInterfacePtr > createWellContainer(const int time_step);
|
2017-06-15 17:19:49 +02:00
|
|
|
|
2020-12-01 18:04:46 +01:00
|
|
|
WellInterfacePtr
|
|
|
|
|
createWellPointer(const int wellID,
|
|
|
|
|
const int time_step) const;
|
|
|
|
|
|
|
|
|
|
template <typename WellType>
|
|
|
|
|
std::unique_ptr<WellType>
|
|
|
|
|
createTypedWellPointer(const int wellID,
|
|
|
|
|
const int time_step) const;
|
|
|
|
|
|
2019-02-07 14:43:17 +01:00
|
|
|
WellInterfacePtr createWellForWellTest(const std::string& well_name, const int report_step, Opm::DeferredLogger& deferred_logger) const;
|
2018-10-31 14:56:56 +01:00
|
|
|
|
2017-11-08 13:57:36 +01:00
|
|
|
WellState well_state_;
|
|
|
|
|
WellState previous_well_state_;
|
2019-12-17 08:49:47 +01:00
|
|
|
WellState well_state_nupcol_;
|
2017-01-09 10:36:17 +01:00
|
|
|
|
2017-11-08 13:57:36 +01:00
|
|
|
const ModelParameters param_;
|
2016-08-23 09:45:37 +02:00
|
|
|
bool terminal_output_;
|
2017-11-08 13:57:36 +01:00
|
|
|
std::vector<int> pvt_region_idx_;
|
2017-01-11 17:02:20 +01:00
|
|
|
PhaseUsage phase_usage_;
|
2020-10-05 20:02:13 +02:00
|
|
|
size_t global_num_cells_;
|
2017-08-11 14:51:29 +02:00
|
|
|
// the number of the cells in the local grid
|
2020-10-05 20:02:13 +02:00
|
|
|
size_t local_num_cells_;
|
2017-11-08 13:57:36 +01:00
|
|
|
double gravity_;
|
|
|
|
|
std::vector<double> depth_;
|
2018-03-23 12:56:19 +01:00
|
|
|
bool initial_step_;
|
2020-01-29 08:41:41 +01:00
|
|
|
bool report_step_starts_;
|
2020-10-01 18:27:57 +02:00
|
|
|
bool glift_debug = false;
|
2020-10-15 17:56:11 +02:00
|
|
|
bool alternative_well_rate_init_;
|
2020-10-29 23:30:09 +01:00
|
|
|
|
|
|
|
|
std::optional<int> last_run_wellpi_{};
|
|
|
|
|
|
2017-11-08 13:57:36 +01:00
|
|
|
std::unique_ptr<RateConverterType> rateConverter_;
|
2021-01-14 19:22:34 +01:00
|
|
|
std::unique_ptr<VFPProperties> vfp_properties_;
|
2016-08-11 13:31:52 +02:00
|
|
|
|
2020-05-07 16:13:39 +02:00
|
|
|
SimulatorReportSingle last_report_;
|
2017-03-24 15:12:42 +01:00
|
|
|
|
2018-06-06 15:17:59 +02:00
|
|
|
WellTestState wellTestState_;
|
2019-09-30 12:49:36 +02:00
|
|
|
std::unique_ptr<GuideRate> guideRate_;
|
2018-06-06 15:17:59 +02:00
|
|
|
|
2020-05-15 11:21:32 +02:00
|
|
|
std::map<std::string, double> node_pressures_; // Storing network pressures for output.
|
|
|
|
|
|
2017-08-21 10:23:42 +02:00
|
|
|
// used to better efficiency of calcuation
|
2016-11-17 13:43:39 +01:00
|
|
|
mutable BVector scaleAddRes_;
|
2016-11-02 10:43:55 +01:00
|
|
|
|
2018-06-06 10:59:41 +02:00
|
|
|
const Grid& grid() const
|
|
|
|
|
{ return ebosSimulator_.vanguard().grid(); }
|
|
|
|
|
|
|
|
|
|
const EclipseState& eclState() const
|
|
|
|
|
{ return ebosSimulator_.vanguard().eclState(); }
|
|
|
|
|
|
2017-11-08 13:57:36 +01:00
|
|
|
const Schedule& schedule() const
|
2018-02-01 16:27:42 +01:00
|
|
|
{ return ebosSimulator_.vanguard().schedule(); }
|
2017-08-10 15:27:05 +02:00
|
|
|
|
2020-09-30 10:04:39 +02:00
|
|
|
void gliftDebug(
|
|
|
|
|
const std::string &msg,
|
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
|
|
|
|
|
2020-10-09 15:09:28 +02:00
|
|
|
/// \brief Get the wells of our partition that are not shut.
|
|
|
|
|
/// \param timeStepIdx The index of the time step.
|
|
|
|
|
/// \param[out] globalNumWells the number of wells globally.
|
|
|
|
|
std::vector< Well > getLocalNonshutWells(const int timeStepIdx,
|
2020-12-04 10:06:14 +01:00
|
|
|
int& globalNumWells) const;
|
|
|
|
|
|
|
|
|
|
/// \brief Create the parallel well information
|
|
|
|
|
/// \param localWells The local wells from ECL schedule
|
|
|
|
|
std::vector< ParallelWellInfo* >
|
|
|
|
|
createLocalParallelWellInfo(const std::vector<Well>& localWells);
|
2020-10-09 15:09:28 +02:00
|
|
|
|
2018-08-16 11:51:36 +02:00
|
|
|
// compute the well fluxes and assemble them in to the reservoir equations as source terms
|
|
|
|
|
// and in the well equations.
|
|
|
|
|
void assemble(const int iterationIdx,
|
|
|
|
|
const double dt);
|
|
|
|
|
|
|
|
|
|
// called at the end of a time step
|
2018-11-30 12:15:51 +01:00
|
|
|
void timeStepSucceeded(const double& simulationTime, const double dt);
|
2018-08-16 11:51:36 +02:00
|
|
|
|
|
|
|
|
// called at the end of a report step
|
|
|
|
|
void endReportStep();
|
|
|
|
|
|
|
|
|
|
// using the solution x to recover the solution xw for wells and applying
|
|
|
|
|
// xw to update Well State
|
|
|
|
|
void recoverWellSolutionAndUpdateWellState(const BVector& x);
|
|
|
|
|
|
2020-02-10 15:16:09 +01:00
|
|
|
void updateWellControls(Opm::DeferredLogger& deferred_logger, const bool checkGroupControls);
|
|
|
|
|
|
|
|
|
|
void updateAndCommunicateGroupData();
|
2020-05-15 11:21:32 +02:00
|
|
|
void updateNetworkPressures();
|
2017-08-10 15:27:05 +02:00
|
|
|
|
|
|
|
|
// setting the well_solutions_ based on well_state.
|
2019-02-07 14:43:17 +01:00
|
|
|
void updatePrimaryVariables(Opm::DeferredLogger& deferred_logger);
|
2017-08-10 15:27:05 +02:00
|
|
|
|
2020-10-05 20:02:13 +02:00
|
|
|
void setupCartesianToCompressed_(const int* global_cell, int local_num__cells);
|
2017-06-07 09:29:31 +02:00
|
|
|
|
2021-01-28 12:52:19 +01:00
|
|
|
void setRepRadiusPerfLength();
|
2017-06-07 09:29:31 +02:00
|
|
|
|
|
|
|
|
|
2019-02-27 14:47:31 +01:00
|
|
|
void computeAverageFormationFactor(std::vector<Scalar>& B_avg) const;
|
2017-08-10 15:27:05 +02:00
|
|
|
|
|
|
|
|
// Calculating well potentials for each well
|
2019-08-07 14:13:11 +02:00
|
|
|
void computeWellPotentials(std::vector<double>& well_potentials, const int reportStepIdx, Opm::DeferredLogger& deferred_logger);
|
2017-08-10 15:27:05 +02:00
|
|
|
|
|
|
|
|
const std::vector<double>& wellPerfEfficiencyFactors() const;
|
|
|
|
|
|
2019-08-07 14:13:11 +02:00
|
|
|
void calculateEfficiencyFactors(const int reportStepIdx);
|
2017-08-10 15:27:05 +02:00
|
|
|
|
2020-10-09 13:38:33 +02:00
|
|
|
void calculateProductivityIndexValues(DeferredLogger& deferred_logger);
|
|
|
|
|
|
2017-09-05 11:09:58 +02: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
|
2019-02-07 14:43:17 +01:00
|
|
|
void calculateExplicitQuantities(Opm::DeferredLogger& deferred_logger) const;
|
2017-08-10 15:27:05 +02:00
|
|
|
|
2017-08-21 15:41:25 +02:00
|
|
|
void initPrimaryVariablesEvaluation() const;
|
2017-08-10 15:27:05 +02:00
|
|
|
|
2017-08-11 14:51:29 +02:00
|
|
|
// The number of components in the model.
|
2017-11-08 15:48:30 +01:00
|
|
|
int numComponents() const;
|
|
|
|
|
|
2019-11-01 15:11:21 +01:00
|
|
|
int numLocalWells() const;
|
2017-11-08 15:48:30 +01:00
|
|
|
|
|
|
|
|
int numPhases() const;
|
2017-11-08 13:57:36 +01:00
|
|
|
|
2019-03-04 11:24:52 +01:00
|
|
|
void assembleWellEq(const std::vector<Scalar>& B_avg, const double dt, Opm::DeferredLogger& deferred_logger);
|
2017-08-14 14:11:58 +02:00
|
|
|
|
|
|
|
|
// some preparation work, mostly related to group control and RESV,
|
|
|
|
|
// at the beginning of each time step (Not report step)
|
2019-05-24 16:45:27 +02:00
|
|
|
void prepareTimeStep(Opm::DeferredLogger& deferred_logger);
|
2017-11-08 13:57:36 +01:00
|
|
|
|
2017-11-08 15:48:30 +01:00
|
|
|
void extractLegacyCellPvtRegionIndex_();
|
|
|
|
|
|
|
|
|
|
void extractLegacyDepth_();
|
2017-11-08 13:57:36 +01:00
|
|
|
|
|
|
|
|
/// return true if wells are available in the reservoir
|
|
|
|
|
bool wellsActive() const;
|
|
|
|
|
|
|
|
|
|
void setWellsActive(const bool wells_active);
|
2017-09-04 13:54:41 +02:00
|
|
|
|
2017-11-08 13:57:36 +01:00
|
|
|
/// return true if wells are available on this process
|
|
|
|
|
bool localWellsActive() const;
|
|
|
|
|
|
2018-06-28 13:47:10 +02:00
|
|
|
/// upate the wellTestState related to economic limits
|
|
|
|
|
void updateWellTestState(const double& simulationTime, WellTestState& wellTestState) const;
|
2017-11-08 13:57:36 +01:00
|
|
|
|
2017-11-08 15:48:30 +01:00
|
|
|
void updatePerforationIntensiveQuantities();
|
2017-09-04 13:54:41 +02:00
|
|
|
|
2019-02-07 14:43:17 +01:00
|
|
|
void wellTesting(const int timeStepIdx, const double simulationTime, Opm::DeferredLogger& deferred_logger);
|
2018-06-06 15:17:59 +02:00
|
|
|
|
2018-11-26 12:09:04 +01:00
|
|
|
// convert well data from opm-common to well state from opm-core
|
|
|
|
|
void wellsToState( const data::Wells& wells,
|
2020-09-20 22:16:07 +02:00
|
|
|
const data::GroupAndNetworkValues& grpNwrkValues,
|
2019-03-22 09:41:29 +01:00
|
|
|
const PhaseUsage& phases,
|
|
|
|
|
const bool handle_ms_well,
|
|
|
|
|
WellStateFullyImplicitBlackoil& state ) const;
|
2018-11-26 12:09:04 +01:00
|
|
|
|
2019-04-04 15:36:35 +02:00
|
|
|
// whether there exists any multisegment well open on this process
|
2019-10-23 09:09:45 +02:00
|
|
|
bool anyMSWellOpenLocal() const;
|
2019-03-22 09:41:29 +01:00
|
|
|
|
2019-11-13 23:16:11 +01:00
|
|
|
const Well& getWellEcl(const std::string& well_name) const;
|
2019-08-07 14:13:11 +02:00
|
|
|
|
2020-02-10 15:16:09 +01:00
|
|
|
void updateGroupIndividualControls(Opm::DeferredLogger& deferred_logger, std::set<std::string>& switched_groups);
|
2020-03-24 09:24:45 +01:00
|
|
|
void updateGroupIndividualControl(const Group& group, Opm::DeferredLogger& deferred_logger, std::set<std::string>& switched_groups);
|
|
|
|
|
bool checkGroupConstraints(const Group& group, Opm::DeferredLogger& deferred_logger) const;
|
2020-04-08 10:41:20 +02:00
|
|
|
Group::ProductionCMode checkGroupProductionConstraints(const Group& group, Opm::DeferredLogger& deferred_logger) const;
|
|
|
|
|
Group::InjectionCMode checkGroupInjectionConstraints(const Group& group, const Phase& phase) const;
|
2020-05-04 15:56:34 +02:00
|
|
|
void checkGconsaleLimits(const Group& group, WellState& well_state, Opm::DeferredLogger& deferred_logger ) const;
|
2020-03-24 09:24:45 +01:00
|
|
|
|
2020-02-10 15:16:09 +01:00
|
|
|
void updateGroupHigherControls(Opm::DeferredLogger& deferred_logger, std::set<std::string>& switched_groups);
|
|
|
|
|
void checkGroupHigherConstraints(const Group& group, Opm::DeferredLogger& deferred_logger, std::set<std::string>& switched_groups);
|
2019-08-07 14:13:11 +02:00
|
|
|
|
2020-04-08 10:41:20 +02:00
|
|
|
void actionOnBrokenConstraints(const Group& group, const Group::ExceedAction& exceed_action, const Group::ProductionCMode& newControl, Opm::DeferredLogger& deferred_logger);
|
2019-08-07 14:13:11 +02:00
|
|
|
|
2020-04-08 10:41:20 +02:00
|
|
|
void actionOnBrokenConstraints(const Group& group, const Group::InjectionCMode& newControl, const Phase& topUpPhase, Opm::DeferredLogger& deferred_logger);
|
2019-08-07 14:13:11 +02:00
|
|
|
|
2019-09-23 15:15:55 +02:00
|
|
|
WellInterfacePtr getWell(const std::string& well_name) const;
|
|
|
|
|
|
2019-11-13 23:16:11 +01:00
|
|
|
void updateWsolvent(const Group& group, const Schedule& schedule, const int reportStepIdx, const WellStateFullyImplicitBlackoil& wellState);
|
2019-09-23 15:15:55 +02:00
|
|
|
|
2019-11-13 23:16:11 +01:00
|
|
|
void setWsolvent(const Group& group, const Schedule& schedule, const int reportStepIdx, double wsolvent);
|
2019-09-23 15:15:55 +02:00
|
|
|
|
2020-10-29 23:30:09 +01:00
|
|
|
void runWellPIScaling(const int timeStepIdx, DeferredLogger& local_deferredLogger);
|
|
|
|
|
|
2020-10-20 00:10:27 +02:00
|
|
|
void assignWellGuideRates(data::Wells& wsrpt) const;
|
2020-10-29 23:16:31 +01:00
|
|
|
void assignShutConnections(data::Wells& wsrpt) const;
|
2020-09-20 22:16:07 +02:00
|
|
|
void assignGroupValues(const int reportStepIdx,
|
|
|
|
|
const Schedule& sched,
|
|
|
|
|
std::map<std::string, data::GroupData>& gvalues) const;
|
|
|
|
|
|
2020-10-21 13:32:12 +02:00
|
|
|
void assignNodeValues(std::map<std::string, data::NodeData>& gvalues) const;
|
2020-05-15 11:21:32 +02:00
|
|
|
|
2020-07-20 21:38:30 +02:00
|
|
|
std::unordered_map<std::string, data::GroupGuideRates>
|
|
|
|
|
calculateAllGroupGuiderates(const int reportStepIdx, const Schedule& sched) const;
|
|
|
|
|
|
2020-07-01 13:52:02 +02:00
|
|
|
void assignGroupControl(const Group& group, data::GroupData& gdata) const;
|
2020-07-20 21:38:30 +02:00
|
|
|
data::GuideRateValue getGuideRateValues(const Well& well) const;
|
|
|
|
|
data::GuideRateValue getGuideRateValues(const Group& group) const;
|
|
|
|
|
void getGuideRateValues(const GuideRate::RateVector& qs,
|
|
|
|
|
const bool is_inj,
|
|
|
|
|
const std::string& wgname,
|
|
|
|
|
data::GuideRateValue& grval) const;
|
|
|
|
|
|
|
|
|
|
void assignGroupGuideRates(const Group& group,
|
|
|
|
|
const std::unordered_map<std::string, data::GroupGuideRates>& groupGuideRates,
|
|
|
|
|
data::GroupData& gdata) const;
|
2016-08-11 13:31:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Opm
|
2017-02-13 16:45:06 +01:00
|
|
|
|
2017-09-26 10:52:05 +02:00
|
|
|
#include "BlackoilWellModel_impl.hpp"
|
2016-08-11 13:31:52 +02:00
|
|
|
#endif
|