move output of mech restart data to MechContainer

This commit is contained in:
Arne Morten Kvarving 2025-02-04 17:51:03 +01:00
parent 2fe36caa08
commit b692bbd15e
3 changed files with 79 additions and 36 deletions

View File

@ -513,22 +513,11 @@ assignToSolution(data::Solution& sol)
const auto extendedSolutionArrays = std::array { const auto extendedSolutionArrays = std::array {
DataEntry{"BIOFILM", UnitSystem::measure::identity, cBiofilm_}, DataEntry{"BIOFILM", UnitSystem::measure::identity, cBiofilm_},
DataEntry{"CALCITE", UnitSystem::measure::identity, cCalcite_}, DataEntry{"CALCITE", UnitSystem::measure::identity, cCalcite_},
DataEntry{"DELSTRXX", UnitSystem::measure::pressure, mech_.delstressXX_},
DataEntry{"DELSTRYY", UnitSystem::measure::pressure, mech_.delstressYY_},
DataEntry{"DELSTRZZ", UnitSystem::measure::pressure, mech_.delstressZZ_},
DataEntry{"DELSTRXY", UnitSystem::measure::pressure, mech_.delstressXY_},
DataEntry{"DELSTRXZ", UnitSystem::measure::pressure, mech_.delstressXZ_},
DataEntry{"DELSTRYZ", UnitSystem::measure::pressure, mech_.delstressYZ_},
DataEntry{"DISPX", UnitSystem::measure::length, mech_.dispX_},
DataEntry{"DISPY", UnitSystem::measure::length, mech_.dispY_},
DataEntry{"DISPZ", UnitSystem::measure::length, mech_.dispZ_},
DataEntry{"DRSDTCON", UnitSystem::measure::gas_oil_ratio_rate, drsdtcon_}, DataEntry{"DRSDTCON", UnitSystem::measure::gas_oil_ratio_rate, drsdtcon_},
DataEntry{"MECHPOTF", UnitSystem::measure::pressure, mech_.potentialForce_},
DataEntry{"MICROBES", UnitSystem::measure::density, cMicrobes_}, DataEntry{"MICROBES", UnitSystem::measure::density, cMicrobes_},
DataEntry{"OXYGEN", UnitSystem::measure::density, cOxygen_}, DataEntry{"OXYGEN", UnitSystem::measure::density, cOxygen_},
DataEntry{"PERMFACT", UnitSystem::measure::identity, permFact_}, DataEntry{"PERMFACT", UnitSystem::measure::identity, permFact_},
DataEntry{"PORV_RC", UnitSystem::measure::identity, rockCompPorvMultiplier_}, DataEntry{"PORV_RC", UnitSystem::measure::identity, rockCompPorvMultiplier_},
DataEntry{"PRESPOTF", UnitSystem::measure::pressure, mech_.potentialPressForce_},
DataEntry{"PRES_OVB", UnitSystem::measure::pressure, overburdenPressure_}, DataEntry{"PRES_OVB", UnitSystem::measure::pressure, overburdenPressure_},
DataEntry{"RSW", UnitSystem::measure::gas_oil_ratio, rsw_}, DataEntry{"RSW", UnitSystem::measure::gas_oil_ratio, rsw_},
DataEntry{"RSWSAT", UnitSystem::measure::gas_oil_ratio, gasDissolutionFactorInWater_}, DataEntry{"RSWSAT", UnitSystem::measure::gas_oil_ratio, gasDissolutionFactorInWater_},
@ -542,31 +531,6 @@ assignToSolution(data::Solution& sol)
DataEntry{"STD_CO2", UnitSystem::measure::identity, mFracCo2_}, DataEntry{"STD_CO2", UnitSystem::measure::identity, mFracCo2_},
DataEntry{"STD_GAS", UnitSystem::measure::identity, mFracGas_}, DataEntry{"STD_GAS", UnitSystem::measure::identity, mFracGas_},
DataEntry{"STD_OIL", UnitSystem::measure::identity, mFracOil_}, DataEntry{"STD_OIL", UnitSystem::measure::identity, mFracOil_},
DataEntry{"STRAINXX", UnitSystem::measure::identity, mech_.strainXX_},
DataEntry{"STRAINYY", UnitSystem::measure::identity, mech_.strainYY_},
DataEntry{"STRAINZZ", UnitSystem::measure::identity, mech_.strainZZ_},
DataEntry{"STRAINXY", UnitSystem::measure::identity, mech_.strainXY_},
DataEntry{"STRAINXZ", UnitSystem::measure::identity, mech_.strainXZ_},
DataEntry{"STRAINYZ", UnitSystem::measure::identity, mech_.strainYZ_},
DataEntry{"STRESSXX", UnitSystem::measure::pressure, mech_.stressXX_},
DataEntry{"STRESSYY", UnitSystem::measure::pressure, mech_.stressYY_},
DataEntry{"STRESSZZ", UnitSystem::measure::pressure, mech_.stressZZ_},
DataEntry{"STRESSXY", UnitSystem::measure::pressure, mech_.stressXY_},
DataEntry{"STRESSXZ", UnitSystem::measure::pressure, mech_.stressXZ_},
DataEntry{"STRESSYZ", UnitSystem::measure::pressure, mech_.stressYZ_},
DataEntry{"LINSTRXX", UnitSystem::measure::pressure, mech_.linstressXX_},
DataEntry{"LINSTRYY", UnitSystem::measure::pressure, mech_.linstressYY_},
DataEntry{"LINSTRZZ", UnitSystem::measure::pressure, mech_.linstressZZ_},
DataEntry{"LINSTRXY", UnitSystem::measure::pressure, mech_.linstressXY_},
DataEntry{"LINSTRXZ", UnitSystem::measure::pressure, mech_.linstressXZ_},
DataEntry{"LINSTRYZ", UnitSystem::measure::pressure, mech_.linstressYZ_},
DataEntry{"FRCSTRXX", UnitSystem::measure::pressure, mech_.fracstressXX_},
DataEntry{"FRCSTRYY", UnitSystem::measure::pressure, mech_.fracstressYY_},
DataEntry{"FRCSTRZZ", UnitSystem::measure::pressure, mech_.fracstressZZ_},
DataEntry{"FRCSTRXY", UnitSystem::measure::pressure, mech_.fracstressXY_},
DataEntry{"FRCSTRXZ", UnitSystem::measure::pressure, mech_.fracstressXZ_},
DataEntry{"FRCSTRYZ", UnitSystem::measure::pressure, mech_.fracstressYZ_},
DataEntry{"TEMPPOTF", UnitSystem::measure::pressure, mech_.potentialTempForce_},
DataEntry{"TMULT_RC", UnitSystem::measure::identity, rockCompTransMultiplier_}, DataEntry{"TMULT_RC", UnitSystem::measure::identity, rockCompTransMultiplier_},
DataEntry{"UREA", UnitSystem::measure::density, cUrea_}, DataEntry{"UREA", UnitSystem::measure::density, cUrea_},
}; };
@ -617,6 +581,8 @@ assignToSolution(data::Solution& sol)
doInsert(array, data::TargetType::RESTART_OPM_EXTENDED); doInsert(array, data::TargetType::RESTART_OPM_EXTENDED);
} }
this->mech_.outputRestart(sol);
if (! this->temperature_.empty()) if (! this->temperature_.empty())
{ {
sol.insert("TEMP", UnitSystem::measure::temperature, sol.insert("TEMP", UnitSystem::measure::temperature,

View File

@ -23,6 +23,12 @@
#include <config.h> #include <config.h>
#include <opm/simulators/flow/MechContainer.hpp> #include <opm/simulators/flow/MechContainer.hpp>
#include <opm/output/data/Solution.hpp>
#include <algorithm>
#include <array>
#include <tuple>
namespace Opm { namespace Opm {
template<class Scalar> template<class Scalar>
@ -111,6 +117,73 @@ allocate(const std::size_t bufferSize,
allocated_ = true; allocated_ = true;
} }
template<class Scalar>
void MechContainer<Scalar>::
outputRestart(data::Solution& sol) const
{
if (!allocated_) {
return;
}
using DataEntry =
std::tuple<std::string, UnitSystem::measure, const std::vector<Scalar>&>;
auto doInsert = [&sol](const 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);
};
const auto solutionVectors = std::array{
DataEntry{"DELSTRXX", UnitSystem::measure::pressure, delstressXX_},
DataEntry{"DELSTRYY", UnitSystem::measure::pressure, delstressYY_},
DataEntry{"DELSTRZZ", UnitSystem::measure::pressure, delstressZZ_},
DataEntry{"DELSTRXY", UnitSystem::measure::pressure, delstressXY_},
DataEntry{"DELSTRXZ", UnitSystem::measure::pressure, delstressXZ_},
DataEntry{"DELSTRYZ", UnitSystem::measure::pressure, delstressYZ_},
DataEntry{"DISPX", UnitSystem::measure::length, dispX_},
DataEntry{"DISPY", UnitSystem::measure::length, dispY_},
DataEntry{"DISPZ", UnitSystem::measure::length, dispZ_},
DataEntry{"FRCSTRXX", UnitSystem::measure::pressure, fracstressXX_},
DataEntry{"FRCSTRYY", UnitSystem::measure::pressure, fracstressYY_},
DataEntry{"FRCSTRZZ", UnitSystem::measure::pressure, fracstressZZ_},
DataEntry{"FRCSTRXY", UnitSystem::measure::pressure, fracstressXY_},
DataEntry{"FRCSTRXZ", UnitSystem::measure::pressure, fracstressXZ_},
DataEntry{"FRCSTRYZ", UnitSystem::measure::pressure, fracstressYZ_},
DataEntry{"LINSTRXX", UnitSystem::measure::pressure, linstressXX_},
DataEntry{"LINSTRYY", UnitSystem::measure::pressure, linstressYY_},
DataEntry{"LINSTRZZ", UnitSystem::measure::pressure, linstressZZ_},
DataEntry{"LINSTRXY", UnitSystem::measure::pressure, linstressXY_},
DataEntry{"LINSTRXZ", UnitSystem::measure::pressure, linstressXZ_},
DataEntry{"LINSTRYZ", UnitSystem::measure::pressure, linstressYZ_},
DataEntry{"MECHPOTF", UnitSystem::measure::pressure, potentialForce_},
DataEntry{"PRESPOTF", UnitSystem::measure::pressure, potentialPressForce_},
DataEntry{"STRAINXX", UnitSystem::measure::identity, strainXX_},
DataEntry{"STRAINYY", UnitSystem::measure::identity, strainYY_},
DataEntry{"STRAINZZ", UnitSystem::measure::identity, strainZZ_},
DataEntry{"STRAINXY", UnitSystem::measure::identity, strainXY_},
DataEntry{"STRAINXZ", UnitSystem::measure::identity, strainXZ_},
DataEntry{"STRAINYZ", UnitSystem::measure::identity, strainYZ_},
DataEntry{"STRESSXX", UnitSystem::measure::length, stressXX_},
DataEntry{"STRESSYY", UnitSystem::measure::length, stressYY_},
DataEntry{"STRESSZZ", UnitSystem::measure::length, stressZZ_},
DataEntry{"STRESSXY", UnitSystem::measure::length, stressXY_},
DataEntry{"STRESSXZ", UnitSystem::measure::length, stressXZ_},
DataEntry{"STRESSYZ", UnitSystem::measure::length, stressYZ_},
DataEntry{"TEMPPOTF", UnitSystem::measure::pressure, potentialTempForce_},
};
std::for_each(solutionVectors.begin(), solutionVectors.end(),
[doInsert](const auto& array)
{ doInsert(array, data::TargetType::RESTART_OPM_EXTENDED); });
}
template class MechContainer<double>; template class MechContainer<double>;
#if FLOW_INSTANTIATE_FLOAT #if FLOW_INSTANTIATE_FLOAT

View File

@ -33,6 +33,8 @@
namespace Opm { namespace Opm {
namespace data { class Solution; }
template<class Scalar> template<class Scalar>
class MechContainer class MechContainer
{ {
@ -42,6 +44,8 @@ public:
void allocate(const std::size_t bufferSize, void allocate(const std::size_t bufferSize,
std::map<std::string, int>& rstKeywords); std::map<std::string, int>& rstKeywords);
void outputRestart(data::Solution& sol) const;
bool allocated() const bool allocated() const
{ return allocated_; } { return allocated_; }