move reading of MICP restart data into MICPContainer

This commit is contained in:
Arne Morten Kvarving 2025-02-07 09:26:10 +01:00
parent 66d5bce0d1
commit d1e2d81d84
3 changed files with 41 additions and 6 deletions

View File

@ -762,11 +762,7 @@ setRestart(const data::Solution& sol,
};
const auto fields = std::array{
std::pair{"BIOFILM", &micpC_.cBiofilm_},
std::pair{"CALCITE", &micpC_.cCalcite_},
std::pair{"FOAM", &cFoam_},
std::pair{"MICROBES", &micpC_.cMicrobes_},
std::pair{"OXYGEN", &micpC_.cOxygen_},
std::pair{"PERMFACT", &permFact_},
std::pair{"POLYMER", &cPolymer_},
std::pair{"PPCW", &ppcw_},
@ -784,12 +780,15 @@ setRestart(const data::Solution& sol,
std::pair{"SWHY1", &swmin_},
std::pair{"SWMAX", &swMax_},
std::pair{"TEMP", &temperature_},
std::pair{"UREA", &micpC_.cUrea_},
};
std::for_each(fields.begin(), fields.end(),
[&assign](const auto& p)
{ assign(p.first, *p.second); });
if (this->micpC_.allocated()) {
this->micpC_.readRestart(globalDofIndex, elemIdx, sol);
}
}
template<class FluidSystem>

View File

@ -27,11 +27,11 @@
#include <opm/output/data/Solution.hpp>
#include <algorithm>
#include <array>
#include <string>
#include <tuple>
namespace Opm {
template<class Scalar>
@ -96,6 +96,38 @@ outputRestart(data::Solution& sol)
allocated_ = false;
}
template<class Scalar>
void MICPContainer<Scalar>::
readRestart(const unsigned globalDofIdx,
const unsigned elemIdx,
const data::Solution& sol)
{
if (this->allocated_) {
return;
}
auto assign = [elemIdx, globalDofIdx, &sol](const std::string& name,
ScalarBuffer& data)
{
if (!data.empty() && sol.has(name)) {
data[elemIdx] = sol.data<double>(name)[globalDofIdx];
}
};
const auto fields = std::array{
std::pair{"BIOFILM", &cBiofilm_},
std::pair{"CALCITE", &cCalcite_},
std::pair{"MICROBES", &cMicrobes_},
std::pair{"OXYGEN", &cOxygen_},
std::pair{"UREA", &cUrea_},
};
std::for_each(fields.begin(), fields.end(),
[&assign](const auto& p)
{ assign(p.first, *p.second); });
}
template class MICPContainer<double>;
#if FLOW_INSTANTIATE_FLOAT

View File

@ -49,6 +49,10 @@ public:
void outputRestart(data::Solution& sol);
void readRestart(const unsigned globalDofIdx,
const unsigned elemIdx,
const data::Solution& sol);
bool allocated() const
{ return allocated_; }