move output of Extbo restart data into ExtboContainer

This commit is contained in:
Arne Morten Kvarving 2025-02-07 13:39:35 +01:00
parent 14e7289059
commit 3aa252e8b2
3 changed files with 48 additions and 6 deletions

View File

@ -23,6 +23,15 @@
#include <config.h> #include <config.h>
#include <opm/simulators/flow/ExtboContainer.hpp> #include <opm/simulators/flow/ExtboContainer.hpp>
#include <opm/input/eclipse/Units/UnitSystem.hpp>
#include <opm/output/data/Solution.hpp>
#include <algorithm>
#include <array>
#include <string>
#include <tuple>
namespace Opm { namespace Opm {
template<class Scalar> template<class Scalar>
@ -39,6 +48,40 @@ allocate(const unsigned bufferSize)
allocated_ = true; allocated_ = true;
} }
template<class Scalar>
void ExtboContainer<Scalar>::
outputRestart(data::Solution& sol)
{
if (!this->allocated_) {
return;
}
using DataEntry =
std::tuple<std::string, UnitSystem::measure, std::vector<Scalar>&>;
auto solutionArrays = std::array {
DataEntry{"SS_X", UnitSystem::measure::identity, X_volume_},
DataEntry{"SS_Y", UnitSystem::measure::identity, Y_volume_},
DataEntry{"SS_Z", UnitSystem::measure::identity, Z_fraction_},
DataEntry{"STD_CO2", UnitSystem::measure::identity, mFracCo2_},
DataEntry{"STD_GAS", UnitSystem::measure::identity, mFracGas_},
DataEntry{"STD_OIL", UnitSystem::measure::identity, mFracOil_},
};
std::for_each(solutionArrays.begin(), solutionArrays.end(),
[&sol](auto& entry)
{
if (!std::get<2>(entry).empty()) {
sol.insert(std::get<std::string>(entry),
std::get<UnitSystem::measure>(entry),
std::move(std::get<2>(entry)),
data::TargetType::RESTART_OPM_EXTENDED);
}
});
this->allocated_ = false;
}
template class ExtboContainer<double>; template class ExtboContainer<double>;
#if FLOW_INSTANTIATE_FLOAT #if FLOW_INSTANTIATE_FLOAT

View File

@ -30,6 +30,8 @@
namespace Opm { namespace Opm {
namespace data { class Solution; }
template<class Scalar> template<class Scalar>
class ExtboContainer class ExtboContainer
{ {
@ -38,6 +40,8 @@ class ExtboContainer
public: public:
void allocate(const unsigned bufferSize); void allocate(const unsigned bufferSize);
void outputRestart(data::Solution& sol);
bool allocated() const bool allocated() const
{ return allocated_; } { return allocated_; }

View File

@ -524,12 +524,6 @@ assignToSolution(data::Solution& sol)
DataEntry{"RVW", UnitSystem::measure::oil_gas_ratio, rvw_}, DataEntry{"RVW", UnitSystem::measure::oil_gas_ratio, rvw_},
DataEntry{"RVWSAT", UnitSystem::measure::oil_gas_ratio, waterVaporizationFactor_}, DataEntry{"RVWSAT", UnitSystem::measure::oil_gas_ratio, waterVaporizationFactor_},
DataEntry{"SALTP", UnitSystem::measure::identity, pSalt_}, DataEntry{"SALTP", UnitSystem::measure::identity, pSalt_},
DataEntry{"SS_X", UnitSystem::measure::identity, extboC_.X_volume_},
DataEntry{"SS_Y", UnitSystem::measure::identity, extboC_.Y_volume_},
DataEntry{"SS_Z", UnitSystem::measure::identity, extboC_.Z_fraction_},
DataEntry{"STD_CO2", UnitSystem::measure::identity, extboC_.mFracCo2_},
DataEntry{"STD_GAS", UnitSystem::measure::identity, extboC_.mFracGas_},
DataEntry{"STD_OIL", UnitSystem::measure::identity, extboC_.mFracOil_},
DataEntry{"TMULT_RC", UnitSystem::measure::identity, rockCompTransMultiplier_}, DataEntry{"TMULT_RC", UnitSystem::measure::identity, rockCompTransMultiplier_},
}; };
@ -584,6 +578,7 @@ assignToSolution(data::Solution& sol)
} }
this->mech_.outputRestart(sol); this->mech_.outputRestart(sol);
this->extboC_.outputRestart(sol);
if (! this->temperature_.empty()) if (! this->temperature_.empty())
{ {