mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
replace repeated if statements with table and lambdas
This commit is contained in:
parent
61a3908f38
commit
c3cba635a2
@ -944,50 +944,43 @@ setRestart(const data::Solution& sol,
|
|||||||
assert(!saturation_[oilPhaseIdx].empty());
|
assert(!saturation_[oilPhaseIdx].empty());
|
||||||
saturation_[oilPhaseIdx][elemIdx] = so;
|
saturation_[oilPhaseIdx][elemIdx] = so;
|
||||||
|
|
||||||
if (!fluidPressure_.empty() && sol.has("PRESSURE"))
|
auto assign = [elemIdx, globalDofIndex, &sol](const std::string& name,
|
||||||
fluidPressure_[elemIdx] = sol.data("PRESSURE")[globalDofIndex];
|
ScalarBuffer& data)
|
||||||
if (!temperature_.empty() && sol.has("TEMP"))
|
|
||||||
temperature_[elemIdx] = sol.data("TEMP")[globalDofIndex];
|
{
|
||||||
if (!rs_.empty() && sol.has("RS"))
|
if (!data.empty() && sol.has(name)) {
|
||||||
rs_[elemIdx] = sol.data("RS")[globalDofIndex];
|
data[elemIdx] = sol.data(name)[globalDofIndex];
|
||||||
if (!rsw_.empty() && sol.has("RSW"))
|
}
|
||||||
rsw_[elemIdx] = sol.data("RSW")[globalDofIndex];
|
};
|
||||||
if (!rv_.empty() && sol.has("RV"))
|
|
||||||
rv_[elemIdx] = sol.data("RV")[globalDofIndex];
|
const auto fields = std::array{
|
||||||
if (!rvw_.empty() && sol.has("RVW"))
|
std::pair{"BIOFILM", &cBiofilm_},
|
||||||
rvw_[elemIdx] = sol.data("RVW")[globalDofIndex];
|
std::pair{"CALCITE",&cCalcite_},
|
||||||
if (!cPolymer_.empty() && sol.has("POLYMER"))
|
std::pair{"FOAM", &cFoam_},
|
||||||
cPolymer_[elemIdx] = sol.data("POLYMER")[globalDofIndex];
|
std::pair{"KRNSW_GO", &krnSwMdcGo_},
|
||||||
if (!cFoam_.empty() && sol.has("FOAM"))
|
std::pair{"KRNSW_OW", &krnSwMdcOw_},
|
||||||
cFoam_[elemIdx] = sol.data("FOAM")[globalDofIndex];
|
std::pair{"MICROBES", &cMicrobes_},
|
||||||
if (!cSalt_.empty() && sol.has("SALT"))
|
std::pair{"OXYGEN", &cOxygen_},
|
||||||
cSalt_[elemIdx] = sol.data("SALT")[globalDofIndex];
|
std::pair{"PCSWM_GO", &pcSwMdcGo_},
|
||||||
if (!pSalt_.empty() && sol.has("SALTP"))
|
std::pair{"PCSWM_OW", &pcSwMdcOw_},
|
||||||
pSalt_[elemIdx] = sol.data("SALTP")[globalDofIndex];
|
std::pair{"PERMFACT", &permFact_},
|
||||||
if (!permFact_.empty() && sol.has("PERMFACT"))
|
std::pair{"POLYMER", &cPolymer_},
|
||||||
permFact_[elemIdx] = sol.data("PERMFACT")[globalDofIndex];
|
std::pair{"PPCW", &ppcw_},
|
||||||
if (!soMax_.empty() && sol.has("SOMAX"))
|
std::pair{"PRESSURE", &fluidPressure_},
|
||||||
soMax_[elemIdx] = sol.data("SOMAX")[globalDofIndex];
|
std::pair{"RS", &rs_},
|
||||||
if (!pcSwMdcOw_.empty() && sol.has("PCSWM_OW"))
|
std::pair{"RSW", &rsw_},
|
||||||
pcSwMdcOw_[elemIdx] = sol.data("PCSWM_OW")[globalDofIndex];
|
std::pair{"RV", &rv_},
|
||||||
if (!krnSwMdcOw_.empty() && sol.has("KRNSW_OW"))
|
std::pair{"RVW", &rvw_},
|
||||||
krnSwMdcOw_[elemIdx] = sol.data("KRNSW_OW")[globalDofIndex];
|
std::pair{"SALT", &cSalt_},
|
||||||
if (!pcSwMdcGo_.empty() && sol.has("PCSWM_GO"))
|
std::pair{"SALTP", &pSalt_},
|
||||||
pcSwMdcGo_[elemIdx] = sol.data("PCSWM_GO")[globalDofIndex];
|
std::pair{"SOMAX", &soMax_},
|
||||||
if (!krnSwMdcGo_.empty() && sol.has("KRNSW_GO"))
|
std::pair{"TEMP", &temperature_},
|
||||||
krnSwMdcGo_[elemIdx] = sol.data("KRNSW_GO")[globalDofIndex];
|
std::pair{"UREA", &cUrea_},
|
||||||
if (!ppcw_.empty() && sol.has("PPCW"))
|
};
|
||||||
ppcw_[elemIdx] = sol.data("PPCW")[globalDofIndex];
|
|
||||||
if (!cMicrobes_.empty() && sol.has("MICROBES"))
|
std::for_each(fields.begin(), fields.end(),
|
||||||
cMicrobes_[elemIdx] = sol.data("MICROBES")[globalDofIndex];
|
[&assign](const auto& p)
|
||||||
if (!cOxygen_.empty() && sol.has("OXYGEN"))
|
{ assign(p.first, *p.second); });
|
||||||
cOxygen_[elemIdx] = sol.data("OXYGEN")[globalDofIndex];
|
|
||||||
if (!cUrea_.empty() && sol.has("UREA"))
|
|
||||||
cUrea_[elemIdx] = sol.data("UREA")[globalDofIndex];
|
|
||||||
if (!cBiofilm_.empty() && sol.has("BIOFILM"))
|
|
||||||
cBiofilm_[elemIdx] = sol.data("BIOFILM")[globalDofIndex];
|
|
||||||
if (!cCalcite_.empty() && sol.has("CALCITE"))
|
|
||||||
cCalcite_[elemIdx] = sol.data("CALCITE")[globalDofIndex];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class FluidSystem,class Scalar>
|
template<class FluidSystem,class Scalar>
|
||||||
|
Loading…
Reference in New Issue
Block a user