diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 1f90106ae..c8a30f400 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -453,6 +453,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/flow/ConvergenceOutputConfiguration.hpp opm/simulators/flow/ExtraConvergenceOutputThread.hpp opm/simulators/flow/FlowMain.hpp + opm/simulators/flow/FlowsData.hpp opm/simulators/flow/InterRegFlows.hpp opm/simulators/flow/Main.hpp opm/simulators/flow/NonlinearSolver.hpp diff --git a/ebos/collecttoiorank.hh b/ebos/collecttoiorank.hh index 692b2abae..6ef7434eb 100644 --- a/ebos/collecttoiorank.hh +++ b/ebos/collecttoiorank.hh @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -82,8 +83,8 @@ public: const data::Aquifers& localAquiferData, const WellTestState& localWellTestState, const InterRegFlowMap& interRegFlows, - const std::array, std::vector>>, 3>& localFlowsn, - const std::array, std::vector>>, 3>& localFloresn); + const std::array, 3>& localFlowsn, + const std::array, 3>& localFloresn); const std::map, double>& globalBlockData() const { return globalBlockData_; } @@ -115,10 +116,10 @@ public: const InterRegFlowMap& globalInterRegFlows() const { return this->globalInterRegFlows_; } - const std::array, std::vector>>, 3>& globalFlowsn() const + const std::array, 3>& globalFlowsn() const { return globalFlowsn_; } - const std::array, std::vector>>, 3>& globalFloresn() const + const std::array, 3>& globalFloresn() const { return globalFloresn_; } bool isIORank() const @@ -160,8 +161,8 @@ protected: data::Aquifers globalAquiferData_; WellTestState globalWellTestState_; std::vector localIdxToGlobalIdx_; - std::array, std::vector>>, 3> globalFlowsn_; - std::array, std::vector>>, 3> globalFloresn_; + std::array, 3> globalFlowsn_; + std::array, 3> globalFloresn_; /// \brief sorted list of cartesian indices present- /// /// non-empty only when running in parallel diff --git a/ebos/collecttoiorank_impl.hh b/ebos/collecttoiorank_impl.hh index ab2454515..72e853d13 100644 --- a/ebos/collecttoiorank_impl.hh +++ b/ebos/collecttoiorank_impl.hh @@ -33,7 +33,6 @@ #include #include - #include #include #include @@ -782,13 +781,13 @@ public: class PackUnpackFlows : public P2PCommunicatorType::DataHandleInterface { - const std::array, std::vector>>, 3>& localFlows_; - std::array, std::vector>>, 3>& globalFlows_; + const std::array, 3>& localFlows_; + std::array, 3>& globalFlows_; public: - PackUnpackFlows(const std::array, std::vector>>, 3> & localFlows, - std::array, std::vector>>, 3>& globalFlows, - const bool isIORank) + PackUnpackFlows(const std::array, 3> & localFlows, + std::array, 3>& globalFlows, + const bool isIORank) : localFlows_(localFlows) , globalFlows_(globalFlows) { @@ -807,14 +806,14 @@ public: if (link != 0) throw std::logic_error("link in method pack is not 0 as expected"); for (int i = 0; i < 3; ++i) { - const auto& name = localFlows_[i].first; + const auto& name = localFlows_[i].name; buffer.write(name); - unsigned int size = localFlows_[i].second.first.size(); + const std::size_t size = localFlows_[i].indices.size(); buffer.write(size); - for (unsigned int j = 0; j < size; ++j) { - const auto& nncIdx = localFlows_[i].second.first[j]; + for (std::size_t j = 0; j < size; ++j) { + const auto& nncIdx = localFlows_[i].indices[j]; buffer.write(nncIdx); - const auto& flows = localFlows_[i].second.second[j]; + const auto& flows = localFlows_[i].values[j]; buffer.write(flows); } } @@ -825,7 +824,7 @@ public: for (int i = 0; i < 3; ++i) { std::string name; buffer.read(name); - globalFlows_[i].first = name; + globalFlows_[i].name = name; unsigned int size = 0; buffer.read(size); for (unsigned int j = 0; j < size; ++j) { @@ -836,7 +835,7 @@ public: if (nncIdx < 0) continue; // This array is initialized in the collect(...) method below - globalFlows_[i].second.second[nncIdx] = data; + globalFlows_[i].values[nncIdx] = data; } } } @@ -975,8 +974,8 @@ collect(const data::Solution& localCellData, const data::Aquifers& localAquiferData, const WellTestState& localWellTestState, const InterRegFlowMap& localInterRegFlows, - const std::array, std::vector>>, 3>& localFlowsn, - const std::array, std::vector>>, 3>& localFloresn) + const std::array, 3>& localFlowsn, + const std::array, 3>& localFloresn) { globalCellData_ = {}; globalBlockData_.clear(); @@ -1010,12 +1009,10 @@ collect(const data::Solution& localCellData, // Set the right sizes for Flowsn and Floresn for (int i = 0; i < 3; ++i) { - unsigned int sizeFlr = localFloresn[i].second.first.size(); - globalFloresn_[i].second.first.resize(sizeFlr, 0); - globalFloresn_[i].second.second.resize(sizeFlr, 0.0); - unsigned int sizeFlo = localFlowsn[i].second.first.size(); - globalFlowsn_[i].second.first.resize(sizeFlo, 0); - globalFlowsn_[i].second.second.resize(sizeFlo, 0.0); + const std::size_t sizeFlr = localFloresn[i].indices.size(); + globalFloresn_[i].resize(sizeFlr); + const std::size_t sizeFlo = localFlowsn[i].indices.size(); + globalFlowsn_[i].resize(sizeFlo); } PackUnPackWellData packUnpackWellData { diff --git a/ebos/eclgenericoutputblackoilmodule.cc b/ebos/eclgenericoutputblackoilmodule.cc index 06fb98184..f51be45a4 100644 --- a/ebos/eclgenericoutputblackoilmodule.cc +++ b/ebos/eclgenericoutputblackoilmodule.cc @@ -1137,9 +1137,9 @@ doAllocBuffers(const unsigned bufferSize, if (numOutputNnc > 0) { enableFlowsn_ = true; - flowsn_[compIdxs[ii]].first = rstName[ii]; - flowsn_[compIdxs[ii]].second.first.resize(numOutputNnc, -1); - flowsn_[compIdxs[ii]].second.second.resize(numOutputNnc, 0.0); + flowsn_[compIdxs[ii]].name = rstName[ii]; + flowsn_[compIdxs[ii]].indices.resize(numOutputNnc, -1); + flowsn_[compIdxs[ii]].values.resize(numOutputNnc, 0.0); } } } @@ -1173,9 +1173,9 @@ doAllocBuffers(const unsigned bufferSize, if (numOutputNnc > 0) { enableFloresn_ = true; - floresn_[compIdxs[ii]].first = rstName[ii]; - floresn_[compIdxs[ii]].second.first.resize(numOutputNnc, -1); - floresn_[compIdxs[ii]].second.second.resize(numOutputNnc, 0.0); + floresn_[compIdxs[ii]].name = rstName[ii]; + floresn_[compIdxs[ii]].indices.resize(numOutputNnc, -1); + floresn_[compIdxs[ii]].values.resize(numOutputNnc, 0.0); } } } diff --git a/ebos/eclgenericoutputblackoilmodule.hh b/ebos/eclgenericoutputblackoilmodule.hh index 7f4439728..e3fbc7f1a 100644 --- a/ebos/eclgenericoutputblackoilmodule.hh +++ b/ebos/eclgenericoutputblackoilmodule.hh @@ -23,6 +23,7 @@ #ifndef EWOMS_ECL_GENERIC_OUTPUT_BLACK_OIL_MODULE_HH #define EWOMS_ECL_GENERIC_OUTPUT_BLACK_OIL_MODULE_HH +#include "opm/simulators/flow/FlowsData.hpp" #include #include #include @@ -194,7 +195,7 @@ public: return 0; } - const std::array, std::vector>>, 3>& getFlowsn() const + const std::array, 3>& getFlowsn() const { return this->flowsn_; } @@ -219,7 +220,7 @@ public: return anyFlows_; } - const std::array, std::vector>>, 3>& getFloresn() const + const std::array, 3>& getFloresn() const { return this->floresn_; } @@ -493,8 +494,8 @@ protected: std::array, 6> flows_; std::array, 6> flores_; - std::array, ScalarBuffer>>, 3> floresn_; - std::array, ScalarBuffer>>, 3> flowsn_; + std::array, 3> floresn_; + std::array, 3> flowsn_; std::map oilConnectionPressures_; std::map waterConnectionSaturations_; diff --git a/ebos/eclgenericwriter.hh b/ebos/eclgenericwriter.hh index 889262502..29d2cd58c 100644 --- a/ebos/eclgenericwriter.hh +++ b/ebos/eclgenericwriter.hh @@ -117,24 +117,24 @@ protected: const TransmissibilityType& globalTrans() const; unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const; - void doWriteOutput(const int reportStepNum, - const bool isSubStep, - data::Solution&& localCellData, - data::Wells&& localWellData, - data::GroupAndNetworkValues&& localGroupAndNetworkData, - data::Aquifers&& localAquiferData, - WellTestState&& localWTestState, - const Action::State& actionState, - const UDQState& udqState, - const SummaryState& summaryState, - const std::vector& thresholdPressure, - Scalar curTime, - Scalar nextStepSize, - bool doublePrecision, - bool isFlowsn, - std::array, std::vector>>, 3>&& flowsn, - bool isFloresn, - std::array, std::vector>>, 3>&& floresn); + void doWriteOutput(const int reportStepNum, + const bool isSubStep, + data::Solution&& localCellData, + data::Wells&& localWellData, + data::GroupAndNetworkValues&& localGroupAndNetworkData, + data::Aquifers&& localAquiferData, + WellTestState&& localWTestState, + const Action::State& actionState, + const UDQState& udqState, + const SummaryState& summaryState, + const std::vector& thresholdPressure, + Scalar curTime, + Scalar nextStepSize, + bool doublePrecision, + bool isFlowsn, + std::array,3>&& flowsn, + bool isFloresn, + std::array, 3>&& floresn); void evalSummary(int reportStepNum, Scalar curTime, diff --git a/ebos/eclgenericwriter_impl.hh b/ebos/eclgenericwriter_impl.hh index 4ca18d694..c4503f83a 100644 --- a/ebos/eclgenericwriter_impl.hh +++ b/ebos/eclgenericwriter_impl.hh @@ -505,24 +505,24 @@ exportNncStructure_(const std::unordered_map& cartesianToActive, template void EclGenericWriter:: -doWriteOutput(const int reportStepNum, - const bool isSubStep, - data::Solution&& localCellData, - data::Wells&& localWellData, - data::GroupAndNetworkValues&& localGroupAndNetworkData, - data::Aquifers&& localAquiferData, - WellTestState&& localWTestState, - const Action::State& actionState, - const UDQState& udqState, - const SummaryState& summaryState, - const std::vector& thresholdPressure, - Scalar curTime, - Scalar nextStepSize, - bool doublePrecision, - bool isFlowsn, - std::array, std::vector>>, 3>&& flowsn, - bool isFloresn, - std::array, std::vector>>, 3>&& floresn) +doWriteOutput(const int reportStepNum, + const bool isSubStep, + data::Solution&& localCellData, + data::Wells&& localWellData, + data::GroupAndNetworkValues&& localGroupAndNetworkData, + data::Aquifers&& localAquiferData, + WellTestState&& localWTestState, + const Action::State& actionState, + const UDQState& udqState, + const SummaryState& summaryState, + const std::vector& thresholdPressure, + Scalar curTime, + Scalar nextStepSize, + bool doublePrecision, + bool isFlowsn, + std::array, 3>&& flowsn, + bool isFloresn, + std::array, 3>&& floresn) { const auto isParallel = this->collectToIORank_.isParallel(); const bool needsReordering = this->collectToIORank_.doesNeedReordering(); @@ -556,22 +556,22 @@ doWriteOutput(const int reportStepNum, if (isFlowsn) { const auto flowsn_global = isParallel ? this->collectToIORank_.globalFlowsn() : std::move(flowsn); for (const auto& flows : flowsn_global) { - if (flows.first.empty()) + if (flows.name.empty()) continue; - if (flows.first == "FLOGASN+") { - restartValue.addExtra(flows.first, UnitSystem::measure::gas_surface_rate, flows.second.second); - } - else { - restartValue.addExtra(flows.first, UnitSystem::measure::liquid_surface_rate, flows.second.second); + if (flows.name == "FLOGASN+") { + restartValue.addExtra(flows.name, UnitSystem::measure::gas_surface_rate, flows.values); + } else { + restartValue.addExtra(flows.name, UnitSystem::measure::liquid_surface_rate, flows.values); } } } if (isFloresn) { const auto floresn_global = isParallel ? this->collectToIORank_.globalFloresn() : std::move(floresn); for (const auto& flores : floresn_global) { - if (flores.first.empty()) + if (flores.name.empty()) { continue; - restartValue.addExtra(flores.first, UnitSystem::measure::rate, flores.second.second); + } + restartValue.addExtra(flores.name, UnitSystem::measure::rate, flores.values); } } diff --git a/ebos/ecloutputblackoilmodule.hh b/ebos/ecloutputblackoilmodule.hh index 3a1d5aa35..5735ea91c 100644 --- a/ebos/ecloutputblackoilmodule.hh +++ b/ebos/ecloutputblackoilmodule.hh @@ -688,19 +688,19 @@ public: } } if (flowsInfo.faceId == -2) { - if (!this->flowsn_[gasCompIdx].second.first.empty()) { - this->flowsn_[gasCompIdx].second.first[flowsInfo.nncId] = flowsInfo.nncId; - this->flowsn_[gasCompIdx].second.second[flowsInfo.nncId] + if (!this->flowsn_[gasCompIdx].indices.empty()) { + this->flowsn_[gasCompIdx].indices[flowsInfo.nncId] = flowsInfo.nncId; + this->flowsn_[gasCompIdx].values[flowsInfo.nncId] = flowsInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(gasCompIdx)]; } - if (!this->flowsn_[oilCompIdx].second.first.empty()) { - this->flowsn_[oilCompIdx].second.first[flowsInfo.nncId] = flowsInfo.nncId; - this->flowsn_[oilCompIdx].second.second[flowsInfo.nncId] + if (!this->flowsn_[oilCompIdx].indices.empty()) { + this->flowsn_[oilCompIdx].indices[flowsInfo.nncId] = flowsInfo.nncId; + this->flowsn_[oilCompIdx].values[flowsInfo.nncId] = flowsInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(oilCompIdx)]; } - if (!this->flowsn_[waterCompIdx].second.first.empty()) { - this->flowsn_[waterCompIdx].second.first[flowsInfo.nncId] = flowsInfo.nncId; - this->flowsn_[waterCompIdx].second.second[flowsInfo.nncId] + if (!this->flowsn_[waterCompIdx].indices.empty()) { + this->flowsn_[waterCompIdx].indices[flowsInfo.nncId] = flowsInfo.nncId; + this->flowsn_[waterCompIdx].values[flowsInfo.nncId] = flowsInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(waterCompIdx)]; } } @@ -728,19 +728,19 @@ public: } if (floresInfo.faceId == -2) { - if (!this->floresn_[gasCompIdx].second.first.empty()) { - this->floresn_[gasCompIdx].second.first[floresInfo.nncId] = floresInfo.nncId; - this->floresn_[gasCompIdx].second.second[floresInfo.nncId] + if (!this->floresn_[gasCompIdx].indices.empty()) { + this->floresn_[gasCompIdx].indices[floresInfo.nncId] = floresInfo.nncId; + this->floresn_[gasCompIdx].values[floresInfo.nncId] = floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(gasCompIdx)]; } - if (!this->floresn_[oilCompIdx].second.first.empty()) { - this->floresn_[oilCompIdx].second.first[floresInfo.nncId] = floresInfo.nncId; - this->floresn_[oilCompIdx].second.second[floresInfo.nncId] + if (!this->floresn_[oilCompIdx].indices.empty()) { + this->floresn_[oilCompIdx].indices[floresInfo.nncId] = floresInfo.nncId; + this->floresn_[oilCompIdx].values[floresInfo.nncId] = floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(oilCompIdx)]; } - if (!this->floresn_[waterCompIdx].second.first.empty()) { - this->floresn_[waterCompIdx].second.first[floresInfo.nncId] = floresInfo.nncId; - this->floresn_[waterCompIdx].second.second[floresInfo.nncId] + if (!this->floresn_[waterCompIdx].indices.empty()) { + this->floresn_[waterCompIdx].indices[floresInfo.nncId] = floresInfo.nncId; + this->floresn_[waterCompIdx].values[floresInfo.nncId] = floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(waterCompIdx)]; } } diff --git a/opm/simulators/flow/FlowsData.hpp b/opm/simulators/flow/FlowsData.hpp new file mode 100644 index 000000000..adc5a2e6b --- /dev/null +++ b/opm/simulators/flow/FlowsData.hpp @@ -0,0 +1,47 @@ +/* + Copyright 2023 SINTEF Digital + + 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 . +*/ + +#ifndef OPM_FLOWS_DATA_HEADER_INCLUDED +#define OPM_FLOWS_DATA_HEADER_INCLUDED + +#include +#include +#include + +namespace Opm { + +//! \brief Simple container for FLOWS data. +template +struct FlowsData +{ + //! \brief Resize data vectors. + void resize(const std::size_t size) + { + indices.resize(size); + values.resize(size); + } + + std::string name; //!< Associated name + std::vector indices; //!< Cell indices for values + std::vector values; //!< Values +}; + +} // namespace Opm + +#endif // OPM_FLOWS_DATA_HEADER_INCLUDED