mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #5965 from akva2/fix_output_move
Fixed: Data output should use move semantics
This commit is contained in:
commit
71a70c57eb
@ -412,7 +412,7 @@ outputRestart(data::Solution& sol)
|
||||
if (! this->fip_[phase].empty()) {
|
||||
sol.insert(Inplace::EclString(phase),
|
||||
UnitSystem::measure::volume,
|
||||
this->fip_[phase],
|
||||
std::move(this->fip_[phase]),
|
||||
data::TargetType::SUMMARY);
|
||||
}
|
||||
}
|
||||
|
@ -410,9 +410,9 @@ void GenericOutputBlackoilModule<FluidSystem>::
|
||||
assignToSolution(data::Solution& sol)
|
||||
{
|
||||
using DataEntry =
|
||||
std::tuple<std::string, UnitSystem::measure, const std::vector<Scalar>&>;
|
||||
std::tuple<std::string, UnitSystem::measure, std::vector<Scalar>&>;
|
||||
|
||||
auto doInsert = [&sol](const DataEntry& entry,
|
||||
auto doInsert = [&sol](DataEntry& entry,
|
||||
const data::TargetType target)
|
||||
{
|
||||
if (std::get<2>(entry).empty()) {
|
||||
@ -426,13 +426,16 @@ assignToSolution(data::Solution& sol)
|
||||
};
|
||||
|
||||
// if index not specified, we treat it as valid (>= 0)
|
||||
auto addEntry = [](std::vector<DataEntry>& container, const std::string& name, UnitSystem::measure measure, const auto& flowArray, int index = 1) {
|
||||
auto addEntry = [](std::vector<DataEntry>& container,
|
||||
const std::string& name,
|
||||
UnitSystem::measure measure,
|
||||
auto& flowArray, int index = 1)
|
||||
{
|
||||
if (index >= 0) { // Only add if index is valid
|
||||
container.emplace_back(name, measure, flowArray);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
std::vector<DataEntry> baseSolutionVector;
|
||||
addEntry(baseSolutionVector, "1OVERBG", UnitSystem::measure::gas_inverse_formation_volume_factor, invB_[gasPhaseIdx], gasPhaseIdx);
|
||||
addEntry(baseSolutionVector, "1OVERBO", UnitSystem::measure::oil_inverse_formation_volume_factor, invB_[oilPhaseIdx], oilPhaseIdx);
|
||||
@ -510,7 +513,7 @@ assignToSolution(data::Solution& sol)
|
||||
addEntry(flowsSolutionVector, "FLRWATJ-", UnitSystem::measure::rate, flores_[FaceDir::ToIntersectionIndex(Dir::YMinus)][waterCompIdx], waterCompIdx);
|
||||
addEntry(flowsSolutionVector, "FLRWATK-", UnitSystem::measure::rate, flores_[FaceDir::ToIntersectionIndex(Dir::ZMinus)][waterCompIdx], waterCompIdx);
|
||||
|
||||
const auto extendedSolutionArrays = std::array {
|
||||
auto extendedSolutionArrays = std::array {
|
||||
DataEntry{"BIOFILM", UnitSystem::measure::identity, cBiofilm_},
|
||||
DataEntry{"CALCITE", UnitSystem::measure::identity, cCalcite_},
|
||||
DataEntry{"DRSDTCON", UnitSystem::measure::gas_oil_ratio_rate, drsdtcon_},
|
||||
@ -562,22 +565,22 @@ assignToSolution(data::Solution& sol)
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& array: compositionalEntries) {
|
||||
for (auto& array: compositionalEntries) {
|
||||
doInsert(array, data::TargetType::RESTART_SOLUTION);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& array : baseSolutionVector) {
|
||||
for (auto& array : baseSolutionVector) {
|
||||
doInsert(array, data::TargetType::RESTART_SOLUTION);
|
||||
}
|
||||
|
||||
if (this->enableFlows_) {
|
||||
for (const auto& array : flowsSolutionVector) {
|
||||
for (auto& array : flowsSolutionVector) {
|
||||
doInsert(array, data::TargetType::RESTART_SOLUTION);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& array : extendedSolutionArrays) {
|
||||
for (auto& array : extendedSolutionArrays) {
|
||||
doInsert(array, data::TargetType::RESTART_OPM_EXTENDED);
|
||||
}
|
||||
|
||||
|
@ -139,23 +139,23 @@ assignStress(const unsigned globalDofIdx,
|
||||
|
||||
template<class Scalar>
|
||||
void MechContainer<Scalar>::
|
||||
outputRestart(data::Solution& sol) const
|
||||
outputRestart(data::Solution& sol)
|
||||
{
|
||||
if (!allocated_) {
|
||||
return;
|
||||
}
|
||||
using DataEntry = std::tuple<std::string,
|
||||
UnitSystem::measure,
|
||||
std::variant<const std::vector<Scalar>*,
|
||||
const std::array<std::vector<Scalar>,3>*,
|
||||
const VoigtArray<Scalar>*>>;
|
||||
std::variant<std::vector<Scalar>*,
|
||||
std::array<std::vector<Scalar>,3>*,
|
||||
VoigtArray<Scalar>*>>;
|
||||
|
||||
auto doInsert = [&sol](const std::string& name,
|
||||
const UnitSystem::measure& measure,
|
||||
const std::vector<Scalar>& entry)
|
||||
std::vector<Scalar>& entry)
|
||||
{
|
||||
if (!entry.empty()) {
|
||||
sol.insert(name, measure, entry, data::TargetType::RESTART_OPM_EXTENDED);
|
||||
sol.insert(name, measure, std::move(entry), data::TargetType::RESTART_OPM_EXTENDED);
|
||||
}
|
||||
};
|
||||
|
||||
@ -172,25 +172,25 @@ outputRestart(data::Solution& sol) const
|
||||
};
|
||||
|
||||
std::for_each(solutionVectors.begin(), solutionVectors.end(),
|
||||
[&doInsert](const auto& array)
|
||||
[&doInsert](auto& array)
|
||||
{
|
||||
std::visit(VisitorOverloadSet{
|
||||
[&array, &doInsert](const std::vector<Scalar>* v)
|
||||
[&array, &doInsert](std::vector<Scalar>* v)
|
||||
{
|
||||
doInsert(std::get<0>(array), std::get<1>(array), *v);
|
||||
},
|
||||
[&array, &doInsert](const std::array<std::vector<Scalar>,3>* V)
|
||||
[&array, &doInsert](std::array<std::vector<Scalar>,3>* V)
|
||||
{
|
||||
const auto& v = *V;
|
||||
auto& v = *V;
|
||||
const auto& name = std::get<0>(array);
|
||||
const auto& measure = std::get<1>(array);
|
||||
doInsert(name + "X", measure, v[0]);
|
||||
doInsert(name + "Y", measure, v[1]);
|
||||
doInsert(name + "Z", measure, v[2]);
|
||||
},
|
||||
[&array, &doInsert](const VoigtArray<Scalar>* V)
|
||||
[&array, &doInsert](VoigtArray<Scalar>* V)
|
||||
{
|
||||
const auto& v = *V;
|
||||
auto& v = *V;
|
||||
const auto& name = std::get<0>(array);
|
||||
const auto& measure = std::get<1>(array);
|
||||
doInsert(name + "XX", measure, v[VoigtIndex::XX]);
|
||||
@ -203,6 +203,8 @@ outputRestart(data::Solution& sol) const
|
||||
}, std::get<2>(array));
|
||||
}
|
||||
);
|
||||
|
||||
allocated_ = false;
|
||||
}
|
||||
|
||||
template class MechContainer<double>;
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
void assignStress(const unsigned globalDofIdx,
|
||||
const Dune::FieldVector<Scalar,6>& stress);
|
||||
|
||||
void outputRestart(data::Solution& sol) const;
|
||||
void outputRestart(data::Solution& sol);
|
||||
|
||||
bool allocated() const
|
||||
{ return allocated_; }
|
||||
|
Loading…
Reference in New Issue
Block a user