2019-03-14 07:35:59 -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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OPM_AQUIFETP_HEADER_INCLUDED
|
|
|
|
#define OPM_AQUIFETP_HEADER_INCLUDED
|
|
|
|
|
2019-05-07 06:06:02 -05:00
|
|
|
#include <opm/simulators/aquifers/AquiferInterface.hpp>
|
2019-03-14 07:35:59 -05:00
|
|
|
|
2019-11-28 10:26:58 -06:00
|
|
|
#include <opm/output/data/Aquifer.hpp>
|
|
|
|
|
|
|
|
#include <exception>
|
|
|
|
#include <stdexcept>
|
|
|
|
|
2019-03-14 07:35:59 -05:00
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
template <typename TypeTag>
|
|
|
|
class AquiferFetkovich : public AquiferInterface<TypeTag>
|
|
|
|
{
|
2019-03-14 07:35:59 -05:00
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
public:
|
2019-03-14 07:35:59 -05:00
|
|
|
typedef AquiferInterface<TypeTag> Base;
|
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
using typename Base::BlackoilIndices;
|
2019-03-14 07:35:59 -05:00
|
|
|
using typename Base::ElementContext;
|
2019-12-20 07:30:13 -06:00
|
|
|
using typename Base::Eval;
|
|
|
|
using typename Base::FluidState;
|
2019-03-14 07:35:59 -05:00
|
|
|
using typename Base::FluidSystem;
|
|
|
|
using typename Base::IntensiveQuantities;
|
2019-12-20 07:30:13 -06:00
|
|
|
using typename Base::RateVector;
|
2019-03-14 07:35:59 -05:00
|
|
|
using typename Base::Scalar;
|
2019-12-20 07:30:13 -06:00
|
|
|
using typename Base::Simulator;
|
2020-11-24 07:58:15 -06:00
|
|
|
using typename Base::ElementMapper;
|
2019-03-14 07:35:59 -05:00
|
|
|
|
|
|
|
using Base::waterCompIdx;
|
|
|
|
using Base::waterPhaseIdx;
|
|
|
|
|
2020-02-10 10:39:04 -06:00
|
|
|
AquiferFetkovich(const std::vector<Aquancon::AquancCell>& connections,
|
2019-12-20 07:30:13 -06:00
|
|
|
const Simulator& ebosSimulator,
|
|
|
|
const Aquifetp::AQUFETP_data& aqufetp_data)
|
2020-12-08 09:09:01 -06:00
|
|
|
: Base(aqufetp_data.aquiferID, connections, ebosSimulator)
|
2019-12-20 07:30:13 -06:00
|
|
|
, aqufetp_data_(aqufetp_data)
|
|
|
|
{
|
|
|
|
}
|
2019-03-14 07:35:59 -05:00
|
|
|
|
2019-12-10 04:29:27 -06:00
|
|
|
void endTimeStep() override
|
2019-03-14 07:35:59 -05:00
|
|
|
{
|
2020-02-10 10:39:04 -06:00
|
|
|
for (const auto& q : this->Qai_) {
|
|
|
|
this->W_flux_ += q * this->ebos_simulator_.timeStepSize();
|
2019-12-20 07:30:13 -06:00
|
|
|
aquifer_pressure_ = aquiferPressure();
|
|
|
|
}
|
2019-03-14 07:35:59 -05:00
|
|
|
}
|
|
|
|
|
2020-10-01 16:30:07 -05:00
|
|
|
Opm::data::AquiferData aquiferData() const
|
|
|
|
{
|
|
|
|
// TODO: how to unify the two functions?
|
|
|
|
data::AquiferData data;
|
|
|
|
data.aquiferID = this->aquiferID;
|
|
|
|
data.pressure = this->aquifer_pressure_;
|
|
|
|
data.fluxRate = 0.;
|
|
|
|
for (const auto& q : this->Qai_) {
|
|
|
|
data.fluxRate += q.value();
|
|
|
|
}
|
|
|
|
data.volume = this->W_flux_.value();
|
|
|
|
data.initPressure = this->pa0_;
|
|
|
|
data.type = Opm::data::AquiferType::Fetkovich;
|
|
|
|
// Not handling std::shared_ptr<FetkovichData> aquFet for now,
|
|
|
|
// because we do not need it yet
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
protected:
|
2019-03-14 07:35:59 -05:00
|
|
|
// Aquifer Fetkovich Specific Variables
|
2019-11-08 06:24:34 -06:00
|
|
|
// TODO: using const reference here will cause segmentation fault, which is very strange
|
2019-03-14 07:35:59 -05:00
|
|
|
const Aquifetp::AQUFETP_data aqufetp_data_;
|
|
|
|
Scalar aquifer_pressure_; // aquifer
|
|
|
|
|
2020-02-09 00:43:43 -06:00
|
|
|
inline void initializeConnections() override
|
2019-03-14 07:35:59 -05:00
|
|
|
{
|
2020-09-24 09:09:56 -05:00
|
|
|
this->cell_depth_.resize(this->size(), this->aquiferDepth());
|
2020-02-10 10:39:04 -06:00
|
|
|
this->alphai_.resize(this->size(), 1.0);
|
|
|
|
this->faceArea_connected_.resize(this->size(), 0.0);
|
2019-12-20 07:30:13 -06:00
|
|
|
|
|
|
|
// Translate the C face tag into the enum used by opm-parser's TransMult class
|
|
|
|
Opm::FaceDir::DirEnum faceDirection;
|
|
|
|
|
|
|
|
// denom_face_areas is the sum of the areas connected to an aquifer
|
|
|
|
Scalar denom_face_areas = 0.;
|
2020-02-10 10:39:04 -06:00
|
|
|
this->cellToConnectionIdx_.resize(this->ebos_simulator_.gridView().size(/*codim=*/0), -1);
|
|
|
|
for (size_t idx = 0; idx < this->size(); ++idx) {
|
|
|
|
const auto global_index = this->connections_[idx].global_index;
|
2020-12-08 09:09:01 -06:00
|
|
|
const int cell_index = this->ebos_simulator_.vanguard().compressedIndex(global_index);
|
|
|
|
if (cell_index < 0) //the global_index is not part of this grid
|
|
|
|
continue;
|
|
|
|
|
2020-02-10 10:39:04 -06:00
|
|
|
this->cellToConnectionIdx_[cell_index] = idx;
|
2020-12-08 09:09:01 -06:00
|
|
|
this->cell_depth_.at(idx) = this->ebos_simulator_.vanguard().cellCenterDepth(cell_index);
|
2020-11-24 07:58:15 -06:00
|
|
|
}
|
|
|
|
// get areas for all connections
|
|
|
|
const auto& gridView = this->ebos_simulator_.vanguard().gridView();
|
|
|
|
ElementMapper elemMapper(gridView, Dune::mcmgElementLayout());
|
|
|
|
auto elemIt = gridView.template begin</*codim=*/ 0>();
|
|
|
|
const auto& elemEndIt = gridView.template end</*codim=*/ 0>();
|
|
|
|
for (; elemIt != elemEndIt; ++elemIt) {
|
|
|
|
const auto& elem = *elemIt;
|
2020-12-15 01:47:29 -06:00
|
|
|
if (elem.partitionType() != Dune::InteriorEntity)
|
|
|
|
continue;
|
2020-11-24 07:58:15 -06:00
|
|
|
unsigned cell_index = elemMapper.index(elem);
|
|
|
|
int idx = this->cellToConnectionIdx_[cell_index];
|
|
|
|
|
|
|
|
// only deal with connections given by the aquifer
|
|
|
|
if( idx < 0)
|
|
|
|
continue;
|
2020-02-10 10:39:04 -06:00
|
|
|
|
|
|
|
if (!this->connections_[idx].influx_coeff.first) { // influx_coeff is defaulted
|
2020-11-24 07:58:15 -06:00
|
|
|
auto isIt = gridView.ibegin(elem);
|
|
|
|
const auto& isEndIt = gridView.iend(elem);
|
|
|
|
for (; isIt != isEndIt; ++ isIt) {
|
|
|
|
// store intersection, this might be costly
|
|
|
|
const auto& intersection = *isIt;
|
|
|
|
|
|
|
|
// only deal with grid boundaries
|
|
|
|
if (!intersection.boundary())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
int insideFaceIdx = intersection.indexInInside();
|
|
|
|
switch (insideFaceIdx) {
|
2019-12-18 07:54:04 -06:00
|
|
|
case 0:
|
|
|
|
faceDirection = Opm::FaceDir::XMinus;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
faceDirection = Opm::FaceDir::XPlus;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
faceDirection = Opm::FaceDir::YMinus;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
faceDirection = Opm::FaceDir::YPlus;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
faceDirection = Opm::FaceDir::ZMinus;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
faceDirection = Opm::FaceDir::ZPlus;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
OPM_THROW(Opm::NumericalIssue,
|
2020-11-24 07:58:15 -06:00
|
|
|
"Initialization of Aquifer Fetkovich problem. Make sure faceTag is correctly defined"); }
|
|
|
|
|
2019-12-18 07:54:04 -06:00
|
|
|
|
2020-02-10 10:39:04 -06:00
|
|
|
if (faceDirection == this->connections_[idx].face_dir) {
|
2020-11-24 07:58:15 -06:00
|
|
|
this->faceArea_connected_[idx] = this->getFaceArea(intersection, idx);
|
2019-12-18 07:54:04 -06:00
|
|
|
break;
|
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2019-12-18 07:54:04 -06:00
|
|
|
} else {
|
2020-02-10 10:39:04 -06:00
|
|
|
this->faceArea_connected_.at(idx) = this->connections_[idx].influx_coeff.second;
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2020-02-10 10:39:04 -06:00
|
|
|
denom_face_areas += (this->connections_[idx].influx_mult * this->faceArea_connected_.at(idx));
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
const double eps_sqrt = std::sqrt(std::numeric_limits<double>::epsilon());
|
2020-02-10 10:39:04 -06:00
|
|
|
for (size_t idx = 0; idx < this->size(); ++idx) {
|
|
|
|
this->alphai_.at(idx) = (denom_face_areas < eps_sqrt)
|
2019-12-20 07:30:13 -06:00
|
|
|
? // Prevent no connection NaNs due to division by zero
|
|
|
|
0.
|
2020-02-10 10:39:04 -06:00
|
|
|
: (this->connections_[idx].influx_mult * this->faceArea_connected_.at(idx)) / denom_face_areas;
|
2019-03-14 07:35:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-28 10:26:58 -06:00
|
|
|
void assignRestartData(const data::AquiferData& xaq) override
|
|
|
|
{
|
2019-12-20 07:30:13 -06:00
|
|
|
if (xaq.type != data::AquiferType::Fetkovich) {
|
|
|
|
throw std::invalid_argument {"Analytic aquifer data for unexpected aquifer type "
|
|
|
|
"passed to Fetkovich aquifer"};
|
|
|
|
}
|
|
|
|
|
|
|
|
this->aquifer_pressure_ = xaq.pressure;
|
2019-11-28 10:26:58 -06:00
|
|
|
}
|
|
|
|
|
2019-11-08 06:24:16 -06:00
|
|
|
inline Eval dpai(int idx)
|
2019-03-14 07:35:59 -05:00
|
|
|
{
|
2020-02-10 10:39:04 -06:00
|
|
|
const Eval dp = aquifer_pressure_ - this->pressure_current_.at(idx)
|
2020-09-24 09:09:56 -05:00
|
|
|
+ this->rhow_[idx] * this->gravity_() * (this->cell_depth_[idx] - this->aquiferDepth());
|
2019-12-20 07:30:13 -06:00
|
|
|
return dp;
|
2019-03-14 07:35:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// This function implements Eq 5.12 of the EclipseTechnicalDescription
|
|
|
|
inline Scalar aquiferPressure()
|
|
|
|
{
|
2020-02-10 10:39:04 -06:00
|
|
|
Scalar Flux = this->W_flux_.value();
|
|
|
|
Scalar pa_ = this->pa0_ - Flux / (aqufetp_data_.C_t * aqufetp_data_.V0);
|
2019-12-20 07:30:13 -06:00
|
|
|
return pa_;
|
2019-03-14 07:35:59 -05:00
|
|
|
}
|
|
|
|
|
2019-12-10 04:29:27 -06:00
|
|
|
inline void calculateAquiferConstants() override
|
2019-03-14 07:35:59 -05:00
|
|
|
{
|
2020-02-10 10:39:04 -06:00
|
|
|
this->Tc_ = (aqufetp_data_.C_t * aqufetp_data_.V0) / aqufetp_data_.J;
|
2019-03-14 07:35:59 -05:00
|
|
|
}
|
|
|
|
// This function implements Eq 5.14 of the EclipseTechnicalDescription
|
2019-12-10 04:29:27 -06:00
|
|
|
inline void calculateInflowRate(int idx, const Simulator& simulator) override
|
2019-03-14 07:35:59 -05:00
|
|
|
{
|
2020-02-10 10:39:04 -06:00
|
|
|
const Scalar td_Tc_ = simulator.timeStepSize() / this->Tc_;
|
2019-12-20 07:30:13 -06:00
|
|
|
const Scalar coef = (1 - exp(-td_Tc_)) / td_Tc_;
|
2020-02-10 10:39:04 -06:00
|
|
|
this->Qai_.at(idx) = this->alphai_[idx] * aqufetp_data_.J * dpai(idx) * coef;
|
2019-03-14 07:35:59 -05:00
|
|
|
}
|
|
|
|
|
2019-12-10 04:29:27 -06:00
|
|
|
inline void calculateAquiferCondition() override
|
2019-03-14 07:35:59 -05:00
|
|
|
{
|
2020-02-10 10:39:04 -06:00
|
|
|
this->rhow_.resize(this->size(), 0.);
|
2019-12-20 07:30:13 -06:00
|
|
|
|
|
|
|
if (this->solution_set_from_restart_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-05 15:51:54 -06:00
|
|
|
if (!aqufetp_data_.p0.first) {
|
2020-09-24 09:09:56 -05:00
|
|
|
this->pa0_ = this->calculateReservoirEquilibrium();
|
2019-12-20 07:30:13 -06:00
|
|
|
} else {
|
2020-02-10 10:39:04 -06:00
|
|
|
this->pa0_ = aqufetp_data_.p0.second;
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2020-02-10 10:39:04 -06:00
|
|
|
aquifer_pressure_ = this->pa0_;
|
2019-03-14 07:35:59 -05:00
|
|
|
}
|
|
|
|
|
2020-09-24 09:09:56 -05:00
|
|
|
virtual Scalar aquiferDepth() const override
|
2019-03-14 07:35:59 -05:00
|
|
|
{
|
2020-09-24 09:09:56 -05:00
|
|
|
return aqufetp_data_.d0;
|
2019-03-14 07:35:59 -05:00
|
|
|
}
|
2019-12-20 07:30:13 -06:00
|
|
|
}; // Class AquiferFetkovich
|
2019-01-07 04:44:33 -06:00
|
|
|
} // namespace Opm
|
2019-03-14 07:35:59 -05:00
|
|
|
#endif
|