mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #5211 from akva2/flows_simplify_data_structure
Flows: simplify data structure
This commit is contained in:
commit
283086edeb
@ -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
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <opm/output/data/Solution.hpp>
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
|
||||
#include <opm/simulators/flow/FlowsData.hpp>
|
||||
#include <opm/simulators/flow/InterRegFlows.hpp>
|
||||
|
||||
#include <array>
|
||||
@ -82,8 +83,8 @@ public:
|
||||
const data::Aquifers& localAquiferData,
|
||||
const WellTestState& localWellTestState,
|
||||
const InterRegFlowMap& interRegFlows,
|
||||
const std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>& localFlowsn,
|
||||
const std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>& localFloresn);
|
||||
const std::array<FlowsData<double>, 3>& localFlowsn,
|
||||
const std::array<FlowsData<double>, 3>& localFloresn);
|
||||
|
||||
const std::map<std::pair<std::string, int>, double>& globalBlockData() const
|
||||
{ return globalBlockData_; }
|
||||
@ -115,10 +116,10 @@ public:
|
||||
const InterRegFlowMap& globalInterRegFlows() const
|
||||
{ return this->globalInterRegFlows_; }
|
||||
|
||||
const std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>& globalFlowsn() const
|
||||
const std::array<FlowsData<double>, 3>& globalFlowsn() const
|
||||
{ return globalFlowsn_; }
|
||||
|
||||
const std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>& globalFloresn() const
|
||||
const std::array<FlowsData<double>, 3>& globalFloresn() const
|
||||
{ return globalFloresn_; }
|
||||
|
||||
bool isIORank() const
|
||||
@ -160,8 +161,8 @@ protected:
|
||||
data::Aquifers globalAquiferData_;
|
||||
WellTestState globalWellTestState_;
|
||||
std::vector<int> localIdxToGlobalIdx_;
|
||||
std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3> globalFlowsn_;
|
||||
std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3> globalFloresn_;
|
||||
std::array<FlowsData<double>, 3> globalFlowsn_;
|
||||
std::array<FlowsData<double>, 3> globalFloresn_;
|
||||
/// \brief sorted list of cartesian indices present-
|
||||
///
|
||||
/// non-empty only when running in parallel
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <dune/grid/common/mcmgmapper.hh>
|
||||
#include <dune/grid/common/partitionset.hh>
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
@ -782,12 +781,12 @@ public:
|
||||
|
||||
class PackUnpackFlows : public P2PCommunicatorType::DataHandleInterface
|
||||
{
|
||||
const std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>& localFlows_;
|
||||
std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>& globalFlows_;
|
||||
const std::array<FlowsData<double>, 3>& localFlows_;
|
||||
std::array<FlowsData<double>, 3>& globalFlows_;
|
||||
|
||||
public:
|
||||
PackUnpackFlows(const std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3> & localFlows,
|
||||
std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>& globalFlows,
|
||||
PackUnpackFlows(const std::array<FlowsData<double>, 3> & localFlows,
|
||||
std::array<FlowsData<double>, 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::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>& localFlowsn,
|
||||
const std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>& localFloresn)
|
||||
const std::array<FlowsData<double>, 3>& localFlowsn,
|
||||
const std::array<FlowsData<double>, 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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 <opm/input/eclipse/EclipseState/Grid/FaceDir.hpp>
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
#include <opm/output/eclipse/Inplace.hpp>
|
||||
@ -194,7 +195,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
const std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>& getFlowsn() const
|
||||
const std::array<FlowsData<double>, 3>& getFlowsn() const
|
||||
{
|
||||
return this->flowsn_;
|
||||
}
|
||||
@ -219,7 +220,7 @@ public:
|
||||
return anyFlows_;
|
||||
}
|
||||
|
||||
const std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>& getFloresn() const
|
||||
const std::array<FlowsData<double>, 3>& getFloresn() const
|
||||
{
|
||||
return this->floresn_;
|
||||
}
|
||||
@ -493,8 +494,8 @@ protected:
|
||||
std::array<std::array<ScalarBuffer, numPhases>, 6> flows_;
|
||||
std::array<std::array<ScalarBuffer, numPhases>, 6> flores_;
|
||||
|
||||
std::array<std::pair<std::string, std::pair<std::vector<int>, ScalarBuffer>>, 3> floresn_;
|
||||
std::array<std::pair<std::string, std::pair<std::vector<int>, ScalarBuffer>>, 3> flowsn_;
|
||||
std::array<FlowsData<double>, 3> floresn_;
|
||||
std::array<FlowsData<double>, 3> flowsn_;
|
||||
|
||||
std::map<std::size_t, Scalar> oilConnectionPressures_;
|
||||
std::map<std::size_t, Scalar> waterConnectionSaturations_;
|
||||
|
@ -132,9 +132,9 @@ protected:
|
||||
Scalar nextStepSize,
|
||||
bool doublePrecision,
|
||||
bool isFlowsn,
|
||||
std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>&& flowsn,
|
||||
std::array<FlowsData<double>,3>&& flowsn,
|
||||
bool isFloresn,
|
||||
std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>&& floresn);
|
||||
std::array<FlowsData<double>, 3>&& floresn);
|
||||
|
||||
void evalSummary(int reportStepNum,
|
||||
Scalar curTime,
|
||||
|
@ -520,9 +520,9 @@ doWriteOutput(const int reportStepNum,
|
||||
Scalar nextStepSize,
|
||||
bool doublePrecision,
|
||||
bool isFlowsn,
|
||||
std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>&& flowsn,
|
||||
std::array<FlowsData<double>, 3>&& flowsn,
|
||||
bool isFloresn,
|
||||
std::array<std::pair<std::string, std::pair<std::vector<int>, std::vector<double>>>, 3>&& floresn)
|
||||
std::array<FlowsData<double>, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)];
|
||||
}
|
||||
}
|
||||
|
47
opm/simulators/flow/FlowsData.hpp
Normal file
47
opm/simulators/flow/FlowsData.hpp
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_FLOWS_DATA_HEADER_INCLUDED
|
||||
#define OPM_FLOWS_DATA_HEADER_INCLUDED
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
//! \brief Simple container for FLOWS data.
|
||||
template<class Scalar>
|
||||
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<int> indices; //!< Cell indices for values
|
||||
std::vector<Scalar> values; //!< Values
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_FLOWS_DATA_HEADER_INCLUDED
|
Loading…
Reference in New Issue
Block a user