move assignment of oil fractions into CompositionalContainer

This commit is contained in:
Arne Morten Kvarving 2025-02-12 07:51:22 +01:00
parent 0496f4bb8a
commit ae23b39d40
3 changed files with 23 additions and 4 deletions

View File

@ -80,6 +80,20 @@ assignMoleFractions(const unsigned globalDofIdx,
{ comp[globalDofIdx] = fractions(c++); });
}
template<class FluidSystem>
void CompositionalContainer<FluidSystem>::
assignOilFractions(const unsigned globalDofIdx,
const AssignFunction& fractions)
{
if (phaseMoleFractions_[oilPhaseIdx][0].empty()) {
return;
}
std::for_each(phaseMoleFractions_[oilPhaseIdx].begin(),
phaseMoleFractions_[oilPhaseIdx].end(),
[globalDofIdx, &fractions, c = 0](auto& comp) mutable
{ comp[globalDofIdx] = fractions(c++); });
}
template<class FluidSystem>
void CompositionalContainer<FluidSystem>::
outputRestart(data::Solution& sol)

View File

@ -58,6 +58,9 @@ public:
void assignMoleFractions(const unsigned globalDofIdx,
const AssignFunction& fractions);
void assignOilFractions(const unsigned globalDofIdx,
const AssignFunction& fractions);
void outputRestart(data::Solution& sol);
bool allocated() const

View File

@ -195,13 +195,15 @@ public:
this->compC_.assignMoleFractions(globalDofIdx,
[&fs](const unsigned compIdx)
{ return getValue(fs.moleFraction(compIdx)); });
if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
this->compC_.assignOilFractions(globalDofIdx,
[&fs](const unsigned compIdx)
{ return getValue(fs.moleFraction(oilPhaseIdx, compIdx)); });
}
}
// XMF and YMF
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
if (this->compC_.phaseMoleFractions_[oilPhaseIdx][compIdx].empty()) continue;
this->compC_.phaseMoleFractions_[oilPhaseIdx][compIdx][globalDofIdx] = getValue(fs.moleFraction(oilPhaseIdx, compIdx));
}
if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
if (this->compC_.phaseMoleFractions_[gasPhaseIdx][compIdx].empty()) continue;
this->compC_.phaseMoleFractions_[gasPhaseIdx][compIdx][globalDofIdx] = getValue(fs.moleFraction(gasPhaseIdx, compIdx));