move output of tracer data into TracerContainer

This commit is contained in:
Arne Morten Kvarving 2025-02-13 15:02:36 +01:00
parent 7f4e3624f7
commit 7386655b65
3 changed files with 36 additions and 35 deletions

View File

@ -632,41 +632,7 @@ assignToSolution(data::Solution& sol)
this->fipC_.outputRestart(sol);
// Tracers
if (! this->tracerC_.freeConcentrations_.empty()) {
const auto& tracers = this->eclState_.tracer();
for (auto tracerIdx = 0*tracers.size();
tracerIdx < tracers.size(); ++tracerIdx)
{
sol.insert(tracers[tracerIdx].fname(),
UnitSystem::measure::identity,
std::move(this->tracerC_.freeConcentrations_[tracerIdx]),
data::TargetType::RESTART_TRACER_SOLUTION);
}
// Put freeTracerConcentrations container into a valid state. Otherwise
// we'll move from vectors that have already been moved from if we
// get here and it's not a restart step.
this->tracerC_.freeConcentrations_.clear();
}
if (! this->tracerC_.solConcentrations_.empty()) {
const auto& tracers = this->eclState_.tracer();
for (auto tracerIdx = 0*tracers.size();
tracerIdx < tracers.size(); ++tracerIdx)
{
if (this->tracerC_.solConcentrations_[tracerIdx].empty())
continue;
sol.insert(tracers[tracerIdx].sname(),
UnitSystem::measure::identity,
std::move(this->tracerC_.solConcentrations_[tracerIdx]),
data::TargetType::RESTART_TRACER_SOLUTION);
}
// Put solTracerConcentrations container into a valid state. Otherwise
// we'll move from vectors that have already been moved from if we
// get here and it's not a restart step.
this->tracerC_.solConcentrations_.clear();
}
this->tracerC_.outputRestart(sol);
}
template<class FluidSystem>

View File

@ -29,7 +29,10 @@
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
#include <opm/material/fluidsystems/GenericOilGasWaterFluidSystem.hpp>
#include <opm/output/data/Solution.hpp>
#include <algorithm>
#include <utility>
namespace Opm {
@ -58,6 +61,35 @@ allocate(const unsigned bufferSize)
}
}
template<class FluidSystem>
void TracerContainer<FluidSystem>::
outputRestart(data::Solution& sol)
{
if (!this->allocated_) {
return;
}
const auto& tracers = this->eclState_.tracer();
std::for_each(tracers.begin(), tracers.end(),
[idx = 0, &sol, this](const auto& tracer) mutable
{
sol.insert(tracer.fname(),
UnitSystem::measure::identity,
std::move(freeConcentrations_[idx]),
data::TargetType::RESTART_TRACER_SOLUTION);
if (!solConcentrations_[idx].empty()) {
sol.insert(tracer.sname(),
UnitSystem::measure::identity,
std::move(solConcentrations_[idx]),
data::TargetType::RESTART_TRACER_SOLUTION);
}
++idx;
});
this->allocated_ = false;
}
template<class T> using FS = BlackOilFluidSystem<T,BlackOilDefaultIndexTraits>;
#define INSTANTIATE_TYPE(T) \

View File

@ -30,6 +30,7 @@
namespace Opm {
namespace data { class Solution; }
class EclipseState;
template<class FluidSystem>
@ -45,6 +46,8 @@ public:
void allocate(const unsigned bufferSize);
void outputRestart(data::Solution& sol);
const EclipseState& eclState_;
std::vector<ScalarBuffer> freeConcentrations_{};