2019-10-19 13:53:35 -05:00
|
|
|
#include <opm/grid/utility/cartesianToCompressed.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)
|
|
|
|
{
|
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
|
|
|
}
|
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
|
|
|
}
|
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()
|
|
|
|
{
|
2019-10-19 13:53:35 -05:00
|
|
|
const auto& deck = this->simulator_.vanguard().deck();
|
2020-01-22 08:32:04 -06:00
|
|
|
const auto& comm = this->simulator_.vanguard().gridView().comm();
|
|
|
|
|
|
|
|
bool has;
|
|
|
|
if (comm.rank() == 0)
|
|
|
|
has = deck.hasKeyword("AQUCT");
|
|
|
|
comm.broadcast(&has, 1, 0);
|
|
|
|
|
|
|
|
if (has) {
|
|
|
|
if (comm.size() > 1)
|
|
|
|
throw std::runtime_error("Aquifers currently do not work in parallel.");
|
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
// updateConnectionIntensiveQuantities();
|
|
|
|
const auto& eclState = this->simulator_.vanguard().eclState();
|
|
|
|
|
|
|
|
// Get all the carter tracy aquifer properties data and put it in aquifers vector
|
2020-02-05 15:58:05 -06:00
|
|
|
const AquiferCT aquiferct = AquiferCT(eclState.getTableManager(), deck);
|
2019-12-20 07:30:13 -06:00
|
|
|
const Aquancon aquifer_connect = Aquancon(eclState.getInputGrid(), deck);
|
|
|
|
|
2020-02-05 15:51:35 -06:00
|
|
|
std::vector<AquiferCT::AQUCT_data> aquifersData = aquiferct.data();
|
2019-12-20 07:30:13 -06:00
|
|
|
std::vector<Aquancon::AquanconOutput> aquifer_connection = aquifer_connect.getAquOutput();
|
|
|
|
|
|
|
|
assert(aquifersData.size() == aquifer_connection.size());
|
|
|
|
const auto& ugrid = simulator_.vanguard().grid();
|
|
|
|
const auto& gridView = simulator_.gridView();
|
|
|
|
const int number_of_cells = gridView.size(0);
|
|
|
|
|
|
|
|
cartesian_to_compressed_ = cartesianToCompressed(number_of_cells, Opm::UgGridHelpers::globalCell(ugrid));
|
|
|
|
|
|
|
|
for (size_t i = 0; i < aquifersData.size(); ++i) {
|
|
|
|
aquifers_CarterTracy.push_back(AquiferCarterTracy<TypeTag>(
|
2020-02-05 15:50:28 -06:00
|
|
|
aquifer_connection[i], cartesian_to_compressed_, this->simulator_, aquifersData[i]));
|
2019-12-20 07:30:13 -06:00
|
|
|
}
|
2019-10-19 13:53:35 -05:00
|
|
|
}
|
2020-01-22 08:32:04 -06:00
|
|
|
if (comm.rank() == 0)
|
|
|
|
has = deck.hasKeyword("AQUFETP");
|
|
|
|
comm.broadcast(&has, 1, 0);
|
|
|
|
|
|
|
|
if (has) {
|
|
|
|
if (comm.size() > 1)
|
|
|
|
throw std::runtime_error("Aquifers currently do not work in parallel.");
|
|
|
|
|
2019-12-20 07:30:13 -06:00
|
|
|
// updateConnectionIntensiveQuantities();
|
|
|
|
const auto& eclState = this->simulator_.vanguard().eclState();
|
|
|
|
|
|
|
|
// Get all the carter tracy aquifer properties data and put it in aquifers vector
|
|
|
|
const Aquifetp aquifetp = Aquifetp(deck);
|
|
|
|
const Aquancon aquifer_connect = Aquancon(eclState.getInputGrid(), deck);
|
|
|
|
|
2020-02-05 15:51:35 -06:00
|
|
|
std::vector<Aquifetp::AQUFETP_data> aquifersData = aquifetp.data();
|
2019-12-20 07:30:13 -06:00
|
|
|
std::vector<Aquancon::AquanconOutput> aquifer_connection = aquifer_connect.getAquOutput();
|
|
|
|
|
|
|
|
assert(aquifersData.size() == aquifer_connection.size());
|
|
|
|
const auto& ugrid = simulator_.vanguard().grid();
|
|
|
|
const auto& gridView = simulator_.gridView();
|
|
|
|
const int number_of_cells = gridView.size(0);
|
|
|
|
|
|
|
|
cartesian_to_compressed_ = cartesianToCompressed(number_of_cells, Opm::UgGridHelpers::globalCell(ugrid));
|
|
|
|
|
|
|
|
for (size_t i = 0; i < aquifersData.size(); ++i) {
|
|
|
|
aquifers_Fetkovich.push_back(AquiferFetkovich<TypeTag>(
|
2020-02-05 15:50:28 -06:00
|
|
|
aquifer_connection[i], cartesian_to_compressed_, this->simulator_, aquifersData[i]));
|
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>
|
|
|
|
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
|
|
|
}
|
2019-10-19 13:53:35 -05:00
|
|
|
} // namespace Opm
|