mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
move output of restart data to CompositionalContainer
This commit is contained in:
@@ -27,6 +27,13 @@
|
||||
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
|
||||
#include <opm/material/fluidsystems/GenericOilGasFluidSystem.hpp>
|
||||
|
||||
#include <opm/output/data/Solution.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <tuple>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
template<class FluidSystem>
|
||||
@@ -59,6 +66,61 @@ allocate(const unsigned bufferSize,
|
||||
}
|
||||
}
|
||||
|
||||
template<class FluidSystem>
|
||||
void CompositionalContainer<FluidSystem>::
|
||||
outputRestart(data::Solution& sol)
|
||||
{
|
||||
using DataEntry =
|
||||
std::tuple<std::string, UnitSystem::measure, std::vector<Scalar>&>;
|
||||
|
||||
auto doInsert = [&sol](DataEntry& entry,
|
||||
const data::TargetType target)
|
||||
{
|
||||
if (std::get<2>(entry).empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
sol.insert(std::get<std::string>(entry),
|
||||
std::get<UnitSystem::measure>(entry),
|
||||
std::move(std::get<2>(entry)),
|
||||
target);
|
||||
};
|
||||
|
||||
auto entries = std::vector<DataEntry>{};
|
||||
|
||||
// ZMF
|
||||
if (!moleFractions_[0].empty()) {
|
||||
for (int i = 0; i < numComponents; ++i) {
|
||||
const auto name = fmt::format("ZMF{}", i + 1); // Generate ZMF1, ZMF2, ...
|
||||
entries.emplace_back(name, UnitSystem::measure::identity, moleFractions_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// XMF
|
||||
if (!phaseMoleFractions_[oilPhaseIdx][0].empty()) {
|
||||
for (int i = 0; i < numComponents; ++i) {
|
||||
const auto name = fmt::format("XMF{}", i + 1); // Generate XMF1, XMF2, ...
|
||||
entries.emplace_back(name, UnitSystem::measure::identity,
|
||||
phaseMoleFractions_[oilPhaseIdx][i]);
|
||||
}
|
||||
}
|
||||
|
||||
// YMF
|
||||
if (!phaseMoleFractions_[gasPhaseIdx][0].empty()) {
|
||||
for (int i = 0; i < numComponents; ++i) {
|
||||
const auto name = fmt::format("YMF{}", i + 1); // Generate YMF1, YMF2, ...
|
||||
entries.emplace_back(name, UnitSystem::measure::identity,
|
||||
phaseMoleFractions_[gasPhaseIdx][i]);
|
||||
}
|
||||
}
|
||||
|
||||
std::for_each(entries.begin(), entries.end(),
|
||||
[&doInsert](auto& array)
|
||||
{ doInsert(array, data::TargetType::RESTART_SOLUTION); });
|
||||
|
||||
this->allocated_ = false;
|
||||
}
|
||||
|
||||
template<class T> using FS = BlackOilFluidSystem<T,BlackOilDefaultIndexTraits>;
|
||||
|
||||
#define INSTANTIATE_TYPE(T) \
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
namespace data { class Solution; }
|
||||
|
||||
template<class FluidSystem>
|
||||
class CompositionalContainer
|
||||
{
|
||||
@@ -50,6 +52,8 @@ public:
|
||||
void allocate(const unsigned bufferSize,
|
||||
std::map<std::string, int>& rstKeywords);
|
||||
|
||||
void outputRestart(data::Solution& sol);
|
||||
|
||||
bool allocated_ = false;
|
||||
// total mole fractions for each component
|
||||
std::array<ScalarBuffer, numComponents> moleFractions_;
|
||||
|
||||
@@ -527,36 +527,8 @@ assignToSolution(data::Solution& sol)
|
||||
DataEntry{"TMULT_RC", UnitSystem::measure::identity, rockCompTransMultiplier_},
|
||||
};
|
||||
|
||||
// basically, for compositional, we can not use std::array for this. We need to generate the ZMF1, ZMF2, and so on
|
||||
// and also, we need to map these values.
|
||||
// TODO: the following should go to a function
|
||||
if (this->isCompositional_) {
|
||||
auto compositionalEntries = std::vector<DataEntry>{};
|
||||
{
|
||||
// ZMF
|
||||
for (int i = 0; i < numComponents; ++i) {
|
||||
const auto name = fmt::format("ZMF{}", i + 1); // Generate ZMF1, ZMF2, ...
|
||||
compositionalEntries.emplace_back(name, UnitSystem::measure::identity, compC_.moleFractions_[i]);
|
||||
}
|
||||
|
||||
// XMF
|
||||
for (int i = 0; i < numComponents; ++i) {
|
||||
const auto name = fmt::format("XMF{}", i + 1); // Generate XMF1, XMF2, ...
|
||||
compositionalEntries.emplace_back(name, UnitSystem::measure::identity,
|
||||
compC_.phaseMoleFractions_[oilPhaseIdx][i]);
|
||||
}
|
||||
|
||||
// YMF
|
||||
for (int i = 0; i < numComponents; ++i) {
|
||||
const auto name = fmt::format("YMF{}", i + 1); // Generate YMF1, YMF2, ...
|
||||
compositionalEntries.emplace_back(name, UnitSystem::measure::identity,
|
||||
compC_.phaseMoleFractions_[gasPhaseIdx][i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& array: compositionalEntries) {
|
||||
doInsert(array, data::TargetType::RESTART_SOLUTION);
|
||||
}
|
||||
this->compC_.outputRestart(sol);
|
||||
}
|
||||
|
||||
for (auto& array : baseSolutionVector) {
|
||||
|
||||
Reference in New Issue
Block a user