#include namespace Opm { template BlackoilAquiferModel::BlackoilAquiferModel(Simulator& simulator) : simulator_(simulator) { init(); } template void BlackoilAquiferModel::initialSolutionApplied() { if (aquiferCarterTracyActive()) { for (auto& aquifer : aquifers_CarterTracy) { aquifer.initialSolutionApplied(); } } if (aquiferFetkovichActive()) { for (auto& aquifer : aquifers_Fetkovich) { aquifer.initialSolutionApplied(); } } } template void BlackoilAquiferModel::initFromRestart(const std::vector& aquiferSoln) { if (aquiferCarterTracyActive()) { for (auto& aquifer : aquifers_CarterTracy) { aquifer.initFromRestart(aquiferSoln); } } if (aquiferFetkovichActive()) { for (auto& aquifer : aquifers_Fetkovich) { aquifer.initFromRestart(aquiferSoln); } } } template void BlackoilAquiferModel::beginEpisode() { } template void BlackoilAquiferModel::beginIteration() { } template void BlackoilAquiferModel::beginTimeStep() { if (aquiferCarterTracyActive()) { for (auto& aquifer : aquifers_CarterTracy) { aquifer.beginTimeStep(); } } if (aquiferFetkovichActive()) { for (auto& aquifer : aquifers_Fetkovich) { aquifer.beginTimeStep(); } } } template template void BlackoilAquiferModel::addToSource(RateVector& rates, const Context& context, unsigned spaceIdx, unsigned timeIdx) const { if (aquiferCarterTracyActive()) { for (auto& aquifer : aquifers_CarterTracy) { aquifer.addToSource(rates, context, spaceIdx, timeIdx); } } if (aquiferFetkovichActive()) { for (auto& aquifer : aquifers_Fetkovich) { aquifer.addToSource(rates, context, spaceIdx, timeIdx); } } } template void BlackoilAquiferModel::endIteration() { } template void BlackoilAquiferModel::endTimeStep() { if (aquiferCarterTracyActive()) { for (auto& aquifer : aquifers_CarterTracy) { aquifer.endTimeStep(); } } if (aquiferFetkovichActive()) { for (auto& aquifer : aquifers_Fetkovich) { aquifer.endTimeStep(); } } } template void BlackoilAquiferModel::endEpisode() { } template template void BlackoilAquiferModel::serialize(Restarter& /* res */) { // TODO (?) throw std::logic_error("BlackoilAquiferModel::serialize() is not yet implemented"); } template template void BlackoilAquiferModel::deserialize(Restarter& /* res */) { // TODO (?) throw std::logic_error("BlackoilAquiferModel::deserialize() is not yet implemented"); } // Initialize the aquifers in the deck template void BlackoilAquiferModel::init() { const auto& deck = this->simulator_.vanguard().deck(); 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."); // updateConnectionIntensiveQuantities(); const auto& eclState = this->simulator_.vanguard().eclState(); // Get all the carter tracy aquifer properties data and put it in aquifers vector const AquiferCT aquiferct = AquiferCT(eclState.getTableManager(), deck); const Aquancon aquifer_connect = Aquancon(eclState.getInputGrid(), deck); std::vector aquifersData = aquiferct.data(); std::vector 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( aquifer_connection[i], cartesian_to_compressed_, this->simulator_, aquifersData[i])); } } 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."); // 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); std::vector aquifersData = aquifetp.data(); std::vector 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( aquifer_connection[i], cartesian_to_compressed_, this->simulator_, aquifersData[i])); } } } template bool BlackoilAquiferModel::aquiferActive() const { return (aquiferCarterTracyActive() || aquiferFetkovichActive()); } template bool BlackoilAquiferModel::aquiferCarterTracyActive() const { return !aquifers_CarterTracy.empty(); } template bool BlackoilAquiferModel::aquiferFetkovichActive() const { return !aquifers_Fetkovich.empty(); } } // namespace Opm