2020-06-22 02:31:54 -05:00
|
|
|
/*
|
|
|
|
Copyright 2017 TNO - Heat Transfer & Fluid Dynamics, Modelling & Optimization of the Subsurface
|
|
|
|
Copyright 2017 Statoil ASA.
|
|
|
|
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
2020-11-13 08:08:45 -06:00
|
|
|
#include <opm/grid/utility/cartesianToCompressed.hpp>
|
|
|
|
#include "BlackoilAquiferModel.hpp"
|
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
namespace Opm
|
|
|
|
{
|
2019-10-19 13:53:35 -05:00
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
template <typename TypeTag>
|
|
|
|
BlackoilAquiferModel<TypeTag>::BlackoilAquiferModel(Simulator& simulator)
|
|
|
|
: simulator_(simulator)
|
|
|
|
{
|
2020-12-11 08:33:25 -06:00
|
|
|
// Grid needs to support Facetag
|
2020-12-11 10:38:00 -06:00
|
|
|
using Grid = std::remove_const_t<std::remove_reference_t<decltype(simulator.vanguard().grid())>>;
|
|
|
|
static_assert(SupportsFaceTag<Grid>::value, "Grid has to support assumptions about face tag.");
|
2020-12-11 08:33:25 -06:00
|
|
|
|
2019-10-19 13:53:35 -05:00
|
|
|
init();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename TypeTag>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::initialSolutionApplied()
|
|
|
|
{
|
|
|
|
if (aquiferCarterTracyActive()) {
|
2019-12-20 08:10:36 -06:00
|
|
|
for (auto& aquifer : aquifers_CarterTracy) {
|
|
|
|
aquifer.initialSolutionApplied();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2019-10-19 13:53:35 -05:00
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
if (aquiferFetkovichActive()) {
|
2019-12-20 08:10:36 -06:00
|
|
|
for (auto& aquifer : aquifers_Fetkovich) {
|
|
|
|
aquifer.initialSolutionApplied();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2019-10-19 13:53:35 -05:00
|
|
|
}
|
2020-11-16 17:18:16 -06:00
|
|
|
|
|
|
|
if (this->aquiferNumericalActive()) {
|
|
|
|
for (auto& aquifer : this->aquifers_numerical) {
|
|
|
|
aquifer.initialSolutionApplied();
|
|
|
|
}
|
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename TypeTag>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::initFromRestart(const std::vector<data::AquiferData>& aquiferSoln)
|
|
|
|
{
|
|
|
|
if (aquiferCarterTracyActive()) {
|
|
|
|
for (auto& aquifer : aquifers_CarterTracy) {
|
|
|
|
aquifer.initFromRestart(aquiferSoln);
|
|
|
|
}
|
2019-11-28 11:21:45 -06:00
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
if (aquiferFetkovichActive()) {
|
|
|
|
for (auto& aquifer : aquifers_Fetkovich) {
|
|
|
|
aquifer.initFromRestart(aquiferSoln);
|
|
|
|
}
|
2019-11-28 11:21:45 -06:00
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename TypeTag>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::beginEpisode()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename TypeTag>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::beginIteration()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename TypeTag>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::beginTimeStep()
|
|
|
|
{
|
|
|
|
if (aquiferCarterTracyActive()) {
|
2019-12-20 08:10:36 -06:00
|
|
|
for (auto& aquifer : aquifers_CarterTracy) {
|
|
|
|
aquifer.beginTimeStep();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2019-10-19 13:53:35 -05:00
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
if (aquiferFetkovichActive()) {
|
2019-12-20 08:10:36 -06:00
|
|
|
for (auto& aquifer : aquifers_Fetkovich) {
|
|
|
|
aquifer.beginTimeStep();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2019-10-19 13:53:35 -05:00
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename TypeTag>
|
|
|
|
template <class Context>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::addToSource(RateVector& rates,
|
|
|
|
const Context& context,
|
|
|
|
unsigned spaceIdx,
|
|
|
|
unsigned timeIdx) const
|
|
|
|
{
|
|
|
|
if (aquiferCarterTracyActive()) {
|
|
|
|
for (auto& aquifer : aquifers_CarterTracy) {
|
|
|
|
aquifer.addToSource(rates, context, spaceIdx, timeIdx);
|
|
|
|
}
|
2019-10-19 13:53:35 -05:00
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
if (aquiferFetkovichActive()) {
|
|
|
|
for (auto& aquifer : aquifers_Fetkovich) {
|
|
|
|
aquifer.addToSource(rates, context, spaceIdx, timeIdx);
|
|
|
|
}
|
2019-10-19 13:53:35 -05:00
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename TypeTag>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::endIteration()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename TypeTag>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::endTimeStep()
|
|
|
|
{
|
|
|
|
if (aquiferCarterTracyActive()) {
|
2019-12-20 08:10:36 -06:00
|
|
|
for (auto& aquifer : aquifers_CarterTracy) {
|
|
|
|
aquifer.endTimeStep();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2019-10-19 13:53:35 -05:00
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
if (aquiferFetkovichActive()) {
|
2019-12-20 08:10:36 -06:00
|
|
|
for (auto& aquifer : aquifers_Fetkovich) {
|
|
|
|
aquifer.endTimeStep();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2019-10-19 13:53:35 -05:00
|
|
|
}
|
2020-11-16 17:18:16 -06:00
|
|
|
if (aquiferNumericalActive()) {
|
|
|
|
for (auto& aquifer : this->aquifers_numerical) {
|
|
|
|
aquifer.endTimeStep();
|
|
|
|
}
|
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
template <typename TypeTag>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::endEpisode()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename TypeTag>
|
|
|
|
template <class Restarter>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::serialize(Restarter& /* res */)
|
|
|
|
{
|
|
|
|
// TODO (?)
|
|
|
|
throw std::logic_error("BlackoilAquiferModel::serialize() is not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename TypeTag>
|
|
|
|
template <class Restarter>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::deserialize(Restarter& /* res */)
|
|
|
|
{
|
|
|
|
// TODO (?)
|
|
|
|
throw std::logic_error("BlackoilAquiferModel::deserialize() is not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize the aquifers in the deck
|
|
|
|
template <typename TypeTag>
|
|
|
|
void
|
|
|
|
BlackoilAquiferModel<TypeTag>::init()
|
|
|
|
{
|
2020-02-18 09:19:25 -06:00
|
|
|
const auto& aquifer = this->simulator_.vanguard().eclState().aquifer();
|
|
|
|
|
2020-03-23 07:49:51 -05:00
|
|
|
if (!aquifer.active()) {
|
|
|
|
return;
|
|
|
|
}
|
2020-02-18 09:19:25 -06:00
|
|
|
|
2020-03-23 07:49:51 -05:00
|
|
|
// Get all the carter tracy aquifer properties data and put it in aquifers vector
|
|
|
|
const auto& connections = aquifer.connections();
|
|
|
|
for (const auto& aq : aquifer.ct()) {
|
|
|
|
aquifers_CarterTracy.emplace_back(connections[aq.aquiferID],
|
2020-12-08 09:09:01 -06:00
|
|
|
this->simulator_, aq);
|
2019-10-19 13:53:35 -05:00
|
|
|
}
|
2020-02-10 10:39:04 -06:00
|
|
|
|
2020-03-23 07:49:51 -05:00
|
|
|
for (const auto& aq : aquifer.fetp()) {
|
|
|
|
aquifers_Fetkovich.emplace_back(connections[aq.aquiferID],
|
2020-12-08 09:09:01 -06:00
|
|
|
this->simulator_, aq);
|
2019-10-19 13:53:35 -05:00
|
|
|
}
|
2020-11-13 08:08:45 -06:00
|
|
|
|
|
|
|
if (aquifer.hasNumericalAquifer()) {
|
|
|
|
for (const auto& elem : aquifer.numericalAquifers().aquifers()) {
|
2020-11-16 17:18:16 -06:00
|
|
|
this->aquifers_numerical.emplace_back(elem.second,
|
|
|
|
this->cartesian_to_compressed_, this->simulator_);
|
2020-11-13 08:08:45 -06:00
|
|
|
}
|
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
template <typename TypeTag>
|
|
|
|
bool
|
|
|
|
BlackoilAquiferModel<TypeTag>::aquiferActive() const
|
|
|
|
{
|
2018-10-16 08:59:16 -05:00
|
|
|
return (aquiferCarterTracyActive() || aquiferFetkovichActive());
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
template <typename TypeTag>
|
|
|
|
bool
|
|
|
|
BlackoilAquiferModel<TypeTag>::aquiferCarterTracyActive() const
|
|
|
|
{
|
2019-10-19 13:53:35 -05:00
|
|
|
return !aquifers_CarterTracy.empty();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
template <typename TypeTag>
|
|
|
|
bool
|
|
|
|
BlackoilAquiferModel<TypeTag>::aquiferFetkovichActive() const
|
|
|
|
{
|
2019-10-19 13:53:35 -05:00
|
|
|
return !aquifers_Fetkovich.empty();
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2020-10-01 16:30:07 -05:00
|
|
|
|
2020-11-13 08:08:45 -06:00
|
|
|
template<typename TypeTag>
|
|
|
|
bool
|
|
|
|
BlackoilAquiferModel<TypeTag>::aquiferNumericalActive() const
|
|
|
|
{
|
|
|
|
return !(this->aquifers_numerical.empty());
|
|
|
|
}
|
|
|
|
|
2020-10-01 16:30:07 -05:00
|
|
|
template<typename TypeTag>
|
|
|
|
Opm::data::Aquifers BlackoilAquiferModel<TypeTag>::aquiferData() const {
|
|
|
|
Opm::data::Aquifers data;
|
|
|
|
if (this->aquiferCarterTracyActive()) {
|
|
|
|
for (const auto& aqu : aquifers_CarterTracy) {
|
|
|
|
Opm::data::AquiferData aqu_data = aqu.aquiferData();
|
|
|
|
data[aqu_data.aquiferID] = aqu_data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->aquiferFetkovichActive()) {
|
|
|
|
for (const auto& aqu : aquifers_Fetkovich) {
|
|
|
|
Opm::data::AquiferData aqu_data = aqu.aquiferData();
|
|
|
|
data[aqu_data.aquiferID] = aqu_data;
|
|
|
|
}
|
|
|
|
}
|
2020-11-13 08:08:45 -06:00
|
|
|
|
|
|
|
if (this->aquiferNumericalActive()) {
|
|
|
|
for (const auto& aqu : this->aquifers_numerical) {
|
|
|
|
Opm::data::AquiferData aqu_data = aqu.aquiferData();
|
|
|
|
data[aqu_data.aquiferID] = aqu_data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 16:30:07 -05:00
|
|
|
return data;
|
|
|
|
}
|
2019-10-19 13:53:35 -05:00
|
|
|
} // namespace Opm
|