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
|
2018-06-06 08:17:59 -05:00
|
|
|
Copyright 2016 - 2018 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2017-09-26 03:52:05 -05:00
|
|
|
#ifndef OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
|
|
|
|
#define OPM_BLACKOILWELLMODEL_HEADER_INCLUDED
|
2016-08-11 06:31:52 -05:00
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
#include <ebos/eclproblem.hh>
|
2016-08-11 06:31:52 -05: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 11:04:46 -06:00
|
|
|
#include <functional>
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
2020-10-29 17:30:09 -05:00
|
|
|
#include <optional>
|
2020-12-01 11:04:46 -06:00
|
|
|
#include <string>
|
2016-08-11 06:31:52 -05:00
|
|
|
#include <tuple>
|
2020-12-01 11:04:46 -06:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2016-08-11 06:31:52 -05:00
|
|
|
|
2020-02-19 06:00:35 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
|
|
|
|
2016-08-11 06:31:52 -05:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
2019-03-07 08:13:46 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp>
|
2019-09-30 05:49:36 -05:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp>
|
2020-02-19 06:00:35 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
2020-05-04 08:56:34 -05:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.hpp>
|
2016-08-11 06:31:52 -05:00
|
|
|
|
2019-06-20 03:30:16 -05:00
|
|
|
#include <opm/simulators/timestepping/SimulatorReport.hpp>
|
2019-10-23 02:09:45 -05:00
|
|
|
#include <opm/simulators/wells/PerforationData.hpp>
|
2019-05-07 06:06:02 -05:00
|
|
|
#include <opm/simulators/wells/VFPInjProperties.hpp>
|
|
|
|
#include <opm/simulators/wells/VFPProdProperties.hpp>
|
2019-06-20 03:15:51 -05:00
|
|
|
#include <opm/simulators/flow/countGlobalCells.hpp>
|
2019-05-07 06:06:02 -05:00
|
|
|
#include <opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp>
|
2019-06-20 02:09:19 -05:00
|
|
|
#include <opm/simulators/wells/RateConverter.hpp>
|
2019-05-07 06:06:02 -05:00
|
|
|
#include <opm/simulators/wells/WellInterface.hpp>
|
|
|
|
#include <opm/simulators/wells/StandardWell.hpp>
|
|
|
|
#include <opm/simulators/wells/MultisegmentWell.hpp>
|
2019-08-07 07:13:11 -05:00
|
|
|
#include <opm/simulators/wells/WellGroupHelpers.hpp>
|
2020-10-09 06:38:33 -05:00
|
|
|
#include <opm/simulators/wells/WellProdIndexCalculator.hpp>
|
2020-10-06 07:52:44 -05:00
|
|
|
#include <opm/simulators/wells/ParallelWellInfo.hpp>
|
2018-11-13 07:02:55 -06:00
|
|
|
#include <opm/simulators/timestepping/gatherConvergenceReport.hpp>
|
2019-05-07 06:06:02 -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>
|
|
|
|
|
2019-05-07 06:06:02 -05:00
|
|
|
#include <opm/simulators/utils/DeferredLogger.hpp>
|
2017-01-24 08:59:41 -06:00
|
|
|
|
2020-08-21 06:42:08 -05:00
|
|
|
namespace Opm::Properties {
|
2018-08-16 04:51:36 -05:00
|
|
|
|
2020-08-27 04:38:38 -05:00
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct EnableTerminalOutput {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
2018-08-16 04:51:36 -05:00
|
|
|
|
2020-08-21 06:42:08 -05:00
|
|
|
} // namespace Opm::Properties
|
2017-06-15 10:19:49 -05:00
|
|
|
|
2016-08-11 06:31:52 -05:00
|
|
|
namespace Opm {
|
|
|
|
|
2017-09-26 03:52:05 -05:00
|
|
|
/// Class for handling the blackoil well model.
|
2017-05-03 06:34:15 -05:00
|
|
|
template<typename TypeTag>
|
2019-09-05 10:04:39 -05:00
|
|
|
class BlackoilWellModel : public Opm::BaseAuxiliaryModule<TypeTag>
|
2018-08-16 04:51:36 -05:00
|
|
|
{
|
2016-08-11 06:31:52 -05:00
|
|
|
public:
|
|
|
|
// --------- Types ---------
|
2017-10-06 03:59:42 -05:00
|
|
|
typedef WellStateFullyImplicitBlackoil WellState;
|
2018-06-21 05:14:17 -05:00
|
|
|
typedef BlackoilModelParametersEbos<TypeTag> ModelParameters;
|
2016-08-23 02:45:37 -05:00
|
|
|
|
2020-08-26 03:49:52 -05: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 04:51:36 -05:00
|
|
|
|
2019-09-05 10:04:39 -05:00
|
|
|
typedef typename Opm::BaseAuxiliaryModule<TypeTag>::NeighborSet NeighborSet;
|
2017-05-03 06:34:15 -05:00
|
|
|
|
2017-12-04 02:14:08 -06:00
|
|
|
static const int numEq = Indices::numEq;
|
|
|
|
static const int solventSaturationIdx = Indices::solventSaturationIdx;
|
2021-01-28 07:33:21 -06:00
|
|
|
static constexpr bool has_solvent_ = getPropValue<TypeTag, Properties::EnableSolvent>();
|
|
|
|
static constexpr bool has_polymer_ = getPropValue<TypeTag, Properties::EnablePolymer>();
|
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-05-15 07:46:43 -05:00
|
|
|
typedef Dune::FieldMatrix<Scalar, numEq, numEq > MatrixBlockType;
|
|
|
|
|
2019-09-05 10:04:39 -05:00
|
|
|
typedef Opm::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::
|
2017-11-08 06:57:36 -06:00
|
|
|
SurfaceToReservoirVoidage<FluidSystem, std::vector<int> >;
|
2016-11-01 07:41:00 -05:00
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
BlackoilWellModel(Simulator& ebosSimulator);
|
|
|
|
|
2019-04-03 10:26:57 -05:00
|
|
|
void init();
|
2018-08-16 04:51:36 -05: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 06:34:15 -05:00
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
void addNeighbors(std::vector<NeighborSet>& neighbors) const;
|
|
|
|
|
|
|
|
void applyInitial()
|
|
|
|
{}
|
|
|
|
|
2019-10-02 05:48:29 -05:00
|
|
|
void linearize(SparseMatrixAdapter& jacobian, GlobalEqVector& res);
|
2018-08-16 04:51:36 -05:00
|
|
|
|
|
|
|
void postSolve(GlobalEqVector& deltaX)
|
2018-06-06 03:59:41 -05:00
|
|
|
{
|
2018-08-16 04:51:36 -05:00
|
|
|
recoverWellSolutionAndUpdateWellState(deltaX);
|
2018-06-06 03:59:41 -05:00
|
|
|
}
|
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
/////////////
|
|
|
|
// </ eWoms auxiliary module stuff>
|
|
|
|
/////////////
|
|
|
|
|
|
|
|
template <class Restarter>
|
2019-04-24 10:18:44 -05:00
|
|
|
void deserialize(Restarter& /* res */)
|
2018-08-16 04:51:36 -05:00
|
|
|
{
|
|
|
|
// TODO (?)
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief This method writes the complete state of the well
|
|
|
|
* to the harddisk.
|
|
|
|
*/
|
|
|
|
template <class Restarter>
|
2019-04-24 10:18:44 -05:00
|
|
|
void serialize(Restarter& /* res*/)
|
2018-08-16 04:51:36 -05:00
|
|
|
{
|
|
|
|
// TODO (?)
|
|
|
|
}
|
|
|
|
|
2019-04-03 10:26:57 -05:00
|
|
|
void beginEpisode()
|
2018-08-16 04:51:36 -05:00
|
|
|
{
|
2019-04-03 10:26:57 -05:00
|
|
|
beginReportStep(ebosSimulator_.episodeIndex());
|
2018-08-16 04:51:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void beginTimeStep();
|
|
|
|
|
|
|
|
void beginIteration()
|
|
|
|
{
|
|
|
|
assemble(ebosSimulator_.model().newtonMethod().numIterations(),
|
|
|
|
ebosSimulator_.timeStepSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
void endIteration()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void endTimeStep()
|
|
|
|
{
|
2018-11-30 05:15:51 -06:00
|
|
|
timeStepSucceeded(ebosSimulator_.time(), ebosSimulator_.timeStepSize());
|
2018-08-16 04:51:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void endEpisode()
|
|
|
|
{
|
|
|
|
endReportStep();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Context>
|
|
|
|
void computeTotalRatesForDof(RateVector& rate,
|
|
|
|
const Context& context,
|
|
|
|
unsigned spaceIdx,
|
|
|
|
unsigned timeIdx) const;
|
|
|
|
|
2018-11-14 06:18:48 -06:00
|
|
|
|
|
|
|
using WellInterfacePtr = std::shared_ptr<WellInterface<TypeTag> >;
|
|
|
|
WellInterfacePtr well(const std::string& wellName) const;
|
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
void initFromRestartFile(const RestartValue& restartValues);
|
2016-08-25 08:25:01 -05:00
|
|
|
|
2020-09-20 15:16:07 -05:00
|
|
|
Opm::data::GroupAndNetworkValues
|
|
|
|
groupAndNetworkData(const int reportStepIdx, const Opm::Schedule& sched) const
|
2020-02-11 05:55:31 -06:00
|
|
|
{
|
2020-09-20 15:16:07 -05:00
|
|
|
auto grp_nwrk_values = ::Opm::data::GroupAndNetworkValues{};
|
2020-07-01 06:52:02 -05:00
|
|
|
|
2020-05-15 04:21:32 -05:00
|
|
|
this->assignGroupValues(reportStepIdx, sched, grp_nwrk_values.groupData);
|
2020-10-21 06:32:12 -05:00
|
|
|
this->assignNodeValues(grp_nwrk_values.nodeData);
|
2020-07-20 14:38:30 -05:00
|
|
|
|
2020-09-20 15:16:07 -05:00
|
|
|
return grp_nwrk_values;
|
2020-02-19 06:00:35 -06:00
|
|
|
}
|
2020-02-11 05:55:31 -06:00
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
Opm::data::Wells wellData() const
|
2020-02-07 12:08:14 -06:00
|
|
|
{
|
|
|
|
auto wsrpt = well_state_.report(phase_usage_, Opm::UgGridHelpers::globalCell(grid()));
|
|
|
|
|
2020-10-19 17:10:27 -05:00
|
|
|
this->assignWellGuideRates(wsrpt);
|
2020-10-29 17:16:31 -05:00
|
|
|
this->assignShutConnections(wsrpt);
|
2020-02-07 12:08:14 -06:00
|
|
|
|
|
|
|
return wsrpt;
|
|
|
|
}
|
2016-08-25 08:25:01 -05:00
|
|
|
|
2018-11-05 08:54:48 -06:00
|
|
|
// substract Binv(D)rw from r;
|
|
|
|
void apply( BVector& r) const;
|
|
|
|
|
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
|
|
|
|
2020-06-25 11:44:49 -05:00
|
|
|
#if HAVE_CUDA || HAVE_OPENCL
|
2020-03-13 08:21:59 -05:00
|
|
|
// accumulate the contributions of all Wells in the WellContributions object
|
|
|
|
void getWellContributions(WellContributions& x) const;
|
2020-03-18 11:48:28 -05:00
|
|
|
#endif
|
2020-03-13 08:21:59 -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-11-08 06:57:36 -06:00
|
|
|
// Check if well equations is converged.
|
2020-04-01 02:55:29 -05:00
|
|
|
ConvergenceReport getWellConvergence(const std::vector<Scalar>& B_avg, const bool checkGroupConvergence = false) const;
|
2016-08-19 06:50:27 -05:00
|
|
|
|
2017-11-08 06:57:36 -06: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 08:48:30 -06:00
|
|
|
const WellState& wellState(const WellState& well_state OPM_UNUSED) const;
|
2017-02-13 10:07:34 -06:00
|
|
|
|
2017-11-08 06:57:36 -06:00
|
|
|
// return the internal well state
|
2017-11-08 08:48:30 -06:00
|
|
|
const WellState& wellState() const;
|
2016-08-11 06:31:52 -05:00
|
|
|
|
2020-05-07 09:13:39 -05:00
|
|
|
const SimulatorReportSingle& lastReport() const;
|
2017-08-08 03:44:10 -05:00
|
|
|
|
2019-10-02 05:48:29 -05:00
|
|
|
void addWellContributions(SparseMatrixAdapter& jacobian) const
|
2018-11-05 08:54:48 -06:00
|
|
|
{
|
|
|
|
for ( const auto& well: well_container_ ) {
|
2019-10-02 05:48:29 -05:00
|
|
|
well->addWellContributions(jacobian);
|
2018-11-05 08:54:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-08 06:57:36 -06:00
|
|
|
// called at the beginning of a report step
|
|
|
|
void beginReportStep(const int time_step);
|
|
|
|
|
2018-11-22 04:01:58 -06:00
|
|
|
/// Return true if any well has a THP constraint.
|
|
|
|
bool hasTHPConstraints() const;
|
|
|
|
|
2018-11-23 05:51:13 -06:00
|
|
|
/// Shut down any single well, but only if it is in prediction mode.
|
2018-12-03 06:24:34 -06:00
|
|
|
/// Returns true if the well was actually found and shut.
|
|
|
|
bool forceShutWellByNameIfPredictionMode(const std::string& wellname, const double simulation_time);
|
2018-11-22 09:24:17 -06:00
|
|
|
|
2021-02-12 05:35:53 -06:00
|
|
|
void updateEclWell(int timeStepIdx, int well_index);
|
|
|
|
void updateEclWell(int timeStepIdx, const std::string& wname);
|
2021-02-12 04:26:14 -06:00
|
|
|
bool hasWell(const std::string& wname);
|
2021-02-12 05:35:53 -06:00
|
|
|
double wellPI(int well_index) const;
|
|
|
|
double wellPI(const std::string& well_name) const;
|
2017-11-08 06:57:36 -06:00
|
|
|
protected:
|
|
|
|
Simulator& ebosSimulator_;
|
2019-10-23 02:09:45 -05:00
|
|
|
|
2019-11-13 16:16:11 -06:00
|
|
|
std::vector< Well > wells_ecl_;
|
2019-10-23 02:09:45 -05:00
|
|
|
std::vector< std::vector<PerforationData> > well_perf_data_;
|
2020-10-09 06:38:33 -05:00
|
|
|
std::vector< WellProdIndexCalculator > prod_index_calc_;
|
2017-11-08 06:57:36 -06:00
|
|
|
|
2020-10-06 07:52:44 -05:00
|
|
|
std::vector< ParallelWellInfo > parallel_well_info_;
|
2020-10-09 08:09:28 -05:00
|
|
|
std::vector< ParallelWellInfo* > local_parallel_well_info_;
|
2020-10-06 07:52:44 -05:00
|
|
|
|
2017-11-08 06:57:36 -06:00
|
|
|
bool wells_active_;
|
2017-10-16 09:46:28 -05:00
|
|
|
|
2017-06-15 10:19:49 -05:00
|
|
|
// a vector of all the wells.
|
2017-08-21 03:23:42 -05:00
|
|
|
std::vector<WellInterfacePtr > well_container_;
|
2017-06-15 10:19:49 -05:00
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
// map from logically cartesian cell indices to compressed ones
|
2020-11-10 04:54:19 -06:00
|
|
|
// cells not in the interior are not mapped. This deactivates
|
|
|
|
// these for distributed wells and make the distribution non-overlapping.
|
2018-08-16 04:51:36 -05:00
|
|
|
std::vector<int> cartesian_to_compressed_;
|
|
|
|
|
2018-11-15 07:37:01 -06:00
|
|
|
std::vector<bool> is_cell_perforated_;
|
|
|
|
|
2020-09-22 07:12:15 -05:00
|
|
|
std::function<bool(const Well&)> is_shut_or_defunct_;
|
|
|
|
|
2020-10-09 06:38:33 -05:00
|
|
|
void initializeWellProdIndCalculators();
|
2019-10-23 02:09:45 -05:00
|
|
|
void initializeWellPerfData();
|
2020-10-19 17:16:52 -05:00
|
|
|
void initializeWellState(const int timeStepIdx,
|
|
|
|
const int globalNumWells,
|
|
|
|
const SummaryState& summaryState);
|
2019-10-23 02:09:45 -05:00
|
|
|
|
2017-08-21 03:23:42 -05:00
|
|
|
// create the well container
|
2019-10-23 02:09:45 -05:00
|
|
|
std::vector<WellInterfacePtr > createWellContainer(const int time_step);
|
2017-06-15 10:19:49 -05:00
|
|
|
|
2020-12-01 11:04:46 -06: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 07:43:17 -06:00
|
|
|
WellInterfacePtr createWellForWellTest(const std::string& well_name, const int report_step, Opm::DeferredLogger& deferred_logger) const;
|
2018-10-31 08:56:56 -05:00
|
|
|
|
2017-11-08 06:57:36 -06:00
|
|
|
WellState well_state_;
|
|
|
|
WellState previous_well_state_;
|
2019-12-17 01:49:47 -06:00
|
|
|
WellState well_state_nupcol_;
|
2017-01-09 03:36:17 -06:00
|
|
|
|
2017-11-08 06:57:36 -06:00
|
|
|
const ModelParameters param_;
|
2016-08-23 02:45:37 -05:00
|
|
|
bool terminal_output_;
|
2017-11-08 06:57:36 -06:00
|
|
|
std::vector<int> pvt_region_idx_;
|
2017-01-11 10:02:20 -06:00
|
|
|
PhaseUsage phase_usage_;
|
2020-10-05 13:02:13 -05:00
|
|
|
size_t global_num_cells_;
|
2017-08-11 07:51:29 -05:00
|
|
|
// the number of the cells in the local grid
|
2020-10-05 13:02:13 -05:00
|
|
|
size_t local_num_cells_;
|
2017-11-08 06:57:36 -06:00
|
|
|
double gravity_;
|
|
|
|
std::vector<double> depth_;
|
2018-03-23 06:56:19 -05:00
|
|
|
bool initial_step_;
|
2020-01-29 01:41:41 -06:00
|
|
|
bool report_step_starts_;
|
2020-10-01 11:27:57 -05:00
|
|
|
bool glift_debug = false;
|
2020-10-15 10:56:11 -05:00
|
|
|
bool alternative_well_rate_init_;
|
2020-10-29 17:30:09 -05:00
|
|
|
|
|
|
|
std::optional<int> last_run_wellpi_{};
|
|
|
|
|
2017-11-08 06:57:36 -06:00
|
|
|
std::unique_ptr<RateConverterType> rateConverter_;
|
2021-01-14 12:22:34 -06:00
|
|
|
std::unique_ptr<VFPProperties> vfp_properties_;
|
2016-08-11 06:31:52 -05:00
|
|
|
|
2020-05-07 09:13:39 -05:00
|
|
|
SimulatorReportSingle last_report_;
|
2017-03-24 09:12:42 -05:00
|
|
|
|
2018-06-06 08:17:59 -05:00
|
|
|
WellTestState wellTestState_;
|
2019-09-30 05:49:36 -05:00
|
|
|
std::unique_ptr<GuideRate> guideRate_;
|
2018-06-06 08:17:59 -05:00
|
|
|
|
2020-05-15 04:21:32 -05:00
|
|
|
std::map<std::string, double> node_pressures_; // Storing network pressures for output.
|
|
|
|
|
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
|
|
|
|
2018-06-06 03:59:41 -05:00
|
|
|
const Grid& grid() const
|
|
|
|
{ return ebosSimulator_.vanguard().grid(); }
|
|
|
|
|
|
|
|
const EclipseState& eclState() const
|
|
|
|
{ return ebosSimulator_.vanguard().eclState(); }
|
|
|
|
|
2017-11-08 06:57:36 -06:00
|
|
|
const Schedule& schedule() const
|
2018-02-01 09:27:42 -06:00
|
|
|
{ return ebosSimulator_.vanguard().schedule(); }
|
2017-08-10 08:27:05 -05:00
|
|
|
|
2020-09-30 03:04:39 -05:00
|
|
|
void gliftDebug(
|
|
|
|
const std::string &msg,
|
|
|
|
Opm::DeferredLogger& deferred_logger) const;
|
|
|
|
|
2020-10-09 08:09:28 -05: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 03:06:14 -06: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 08:09:28 -05:00
|
|
|
|
2018-08-16 04:51:36 -05: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 05:15:51 -06:00
|
|
|
void timeStepSucceeded(const double& simulationTime, const double dt);
|
2018-08-16 04:51:36 -05: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 08:16:09 -06:00
|
|
|
void updateWellControls(Opm::DeferredLogger& deferred_logger, const bool checkGroupControls);
|
|
|
|
|
|
|
|
void updateAndCommunicateGroupData();
|
2020-05-15 04:21:32 -05:00
|
|
|
void updateNetworkPressures();
|
2017-08-10 08:27:05 -05:00
|
|
|
|
|
|
|
// setting the well_solutions_ based on well_state.
|
2019-02-07 07:43:17 -06:00
|
|
|
void updatePrimaryVariables(Opm::DeferredLogger& deferred_logger);
|
2017-08-10 08:27:05 -05:00
|
|
|
|
2020-10-05 13:02:13 -05:00
|
|
|
void setupCartesianToCompressed_(const int* global_cell, int local_num__cells);
|
2017-06-07 02:29:31 -05:00
|
|
|
|
2021-01-28 05:52:19 -06:00
|
|
|
void setRepRadiusPerfLength();
|
2017-06-07 02:29:31 -05:00
|
|
|
|
|
|
|
|
2019-02-27 07:47:31 -06:00
|
|
|
void computeAverageFormationFactor(std::vector<Scalar>& B_avg) const;
|
2017-08-10 08:27:05 -05:00
|
|
|
|
|
|
|
// Calculating well potentials for each well
|
2019-08-07 07:13:11 -05:00
|
|
|
void computeWellPotentials(std::vector<double>& well_potentials, const int reportStepIdx, Opm::DeferredLogger& deferred_logger);
|
2017-08-10 08:27:05 -05:00
|
|
|
|
|
|
|
const std::vector<double>& wellPerfEfficiencyFactors() const;
|
|
|
|
|
2019-08-07 07:13:11 -05:00
|
|
|
void calculateEfficiencyFactors(const int reportStepIdx);
|
2017-08-10 08:27:05 -05:00
|
|
|
|
2020-10-09 06:38:33 -05:00
|
|
|
void calculateProductivityIndexValues(DeferredLogger& deferred_logger);
|
|
|
|
|
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
|
2019-02-07 07:43:17 -06:00
|
|
|
void calculateExplicitQuantities(Opm::DeferredLogger& deferred_logger) const;
|
2017-08-10 08:27:05 -05:00
|
|
|
|
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.
|
2017-11-08 08:48:30 -06:00
|
|
|
int numComponents() const;
|
|
|
|
|
2019-11-01 09:11:21 -05:00
|
|
|
int numLocalWells() const;
|
2017-11-08 08:48:30 -06:00
|
|
|
|
|
|
|
int numPhases() const;
|
2017-11-08 06:57:36 -06:00
|
|
|
|
2019-03-04 04:24:52 -06:00
|
|
|
void assembleWellEq(const std::vector<Scalar>& B_avg, const double dt, Opm::DeferredLogger& deferred_logger);
|
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)
|
2019-05-24 09:45:27 -05:00
|
|
|
void prepareTimeStep(Opm::DeferredLogger& deferred_logger);
|
2017-11-08 06:57:36 -06:00
|
|
|
|
2017-11-08 08:48:30 -06:00
|
|
|
void extractLegacyCellPvtRegionIndex_();
|
|
|
|
|
|
|
|
void extractLegacyDepth_();
|
2017-11-08 06:57:36 -06:00
|
|
|
|
|
|
|
/// return true if wells are available in the reservoir
|
|
|
|
bool wellsActive() const;
|
|
|
|
|
|
|
|
void setWellsActive(const bool wells_active);
|
2017-09-04 06:54:41 -05:00
|
|
|
|
2017-11-08 06:57:36 -06:00
|
|
|
/// return true if wells are available on this process
|
|
|
|
bool localWellsActive() const;
|
|
|
|
|
2018-06-28 06:47:10 -05:00
|
|
|
/// upate the wellTestState related to economic limits
|
|
|
|
void updateWellTestState(const double& simulationTime, WellTestState& wellTestState) const;
|
2017-11-08 06:57:36 -06:00
|
|
|
|
2017-11-08 08:48:30 -06:00
|
|
|
void updatePerforationIntensiveQuantities();
|
2017-09-04 06:54:41 -05:00
|
|
|
|
2019-02-07 07:43:17 -06:00
|
|
|
void wellTesting(const int timeStepIdx, const double simulationTime, Opm::DeferredLogger& deferred_logger);
|
2018-06-06 08:17:59 -05:00
|
|
|
|
2018-11-26 05:09:04 -06:00
|
|
|
// convert well data from opm-common to well state from opm-core
|
|
|
|
void wellsToState( const data::Wells& wells,
|
2020-09-20 15:16:07 -05:00
|
|
|
const data::GroupAndNetworkValues& grpNwrkValues,
|
2019-03-22 03:41:29 -05:00
|
|
|
const PhaseUsage& phases,
|
|
|
|
const bool handle_ms_well,
|
|
|
|
WellStateFullyImplicitBlackoil& state ) const;
|
2018-11-26 05:09:04 -06:00
|
|
|
|
2019-04-04 08:36:35 -05:00
|
|
|
// whether there exists any multisegment well open on this process
|
2019-10-23 02:09:45 -05:00
|
|
|
bool anyMSWellOpenLocal() const;
|
2019-03-22 03:41:29 -05:00
|
|
|
|
2019-11-13 16:16:11 -06:00
|
|
|
const Well& getWellEcl(const std::string& well_name) const;
|
2019-08-07 07:13:11 -05:00
|
|
|
|
2020-02-10 08:16:09 -06:00
|
|
|
void updateGroupIndividualControls(Opm::DeferredLogger& deferred_logger, std::set<std::string>& switched_groups);
|
2020-03-24 03:24:45 -05: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 03:41:20 -05: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 08:56:34 -05:00
|
|
|
void checkGconsaleLimits(const Group& group, WellState& well_state, Opm::DeferredLogger& deferred_logger ) const;
|
2020-03-24 03:24:45 -05:00
|
|
|
|
2020-02-10 08:16:09 -06: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 07:13:11 -05:00
|
|
|
|
2020-04-08 03:41:20 -05:00
|
|
|
void actionOnBrokenConstraints(const Group& group, const Group::ExceedAction& exceed_action, const Group::ProductionCMode& newControl, Opm::DeferredLogger& deferred_logger);
|
2019-08-07 07:13:11 -05:00
|
|
|
|
2020-04-08 03:41:20 -05:00
|
|
|
void actionOnBrokenConstraints(const Group& group, const Group::InjectionCMode& newControl, const Phase& topUpPhase, Opm::DeferredLogger& deferred_logger);
|
2019-08-07 07:13:11 -05:00
|
|
|
|
2019-09-23 08:15:55 -05:00
|
|
|
WellInterfacePtr getWell(const std::string& well_name) const;
|
|
|
|
|
2019-11-13 16:16:11 -06:00
|
|
|
void updateWsolvent(const Group& group, const Schedule& schedule, const int reportStepIdx, const WellStateFullyImplicitBlackoil& wellState);
|
2019-09-23 08:15:55 -05:00
|
|
|
|
2019-11-13 16:16:11 -06:00
|
|
|
void setWsolvent(const Group& group, const Schedule& schedule, const int reportStepIdx, double wsolvent);
|
2019-09-23 08:15:55 -05:00
|
|
|
|
2020-10-29 17:30:09 -05:00
|
|
|
void runWellPIScaling(const int timeStepIdx, DeferredLogger& local_deferredLogger);
|
|
|
|
|
2020-10-19 17:10:27 -05:00
|
|
|
void assignWellGuideRates(data::Wells& wsrpt) const;
|
2020-10-29 17:16:31 -05:00
|
|
|
void assignShutConnections(data::Wells& wsrpt) const;
|
2020-09-20 15:16:07 -05:00
|
|
|
void assignGroupValues(const int reportStepIdx,
|
|
|
|
const Schedule& sched,
|
|
|
|
std::map<std::string, data::GroupData>& gvalues) const;
|
|
|
|
|
2020-10-21 06:32:12 -05:00
|
|
|
void assignNodeValues(std::map<std::string, data::NodeData>& gvalues) const;
|
2020-05-15 04:21:32 -05:00
|
|
|
|
2020-07-20 14:38:30 -05:00
|
|
|
std::unordered_map<std::string, data::GroupGuideRates>
|
|
|
|
calculateAllGroupGuiderates(const int reportStepIdx, const Schedule& sched) const;
|
|
|
|
|
2020-07-01 06:52:02 -05:00
|
|
|
void assignGroupControl(const Group& group, data::GroupData& gdata) const;
|
2020-07-20 14:38:30 -05: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 06:31:52 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Opm
|
2017-02-13 09:45:06 -06:00
|
|
|
|
2017-09-26 03:52:05 -05:00
|
|
|
#include "BlackoilWellModel_impl.hpp"
|
2016-08-11 06:31:52 -05:00
|
|
|
#endif
|