Lookup via method

This commit is contained in:
Antonella Ritorto 2023-10-17 15:42:24 +02:00
parent 17c7e2c91f
commit dc20e63a8c
3 changed files with 19 additions and 16 deletions

View File

@ -269,8 +269,11 @@ public:
int numPressurePointsEquil() const
{ return numPressurePointsEquil_; }
auto getLookUpData() const
{ return lookUpData_; }
auto getLookUpData(unsigned elemIdx) const
{
using Grid = std::remove_cv_t< typename std::remove_reference<decltype(gridView_.grid())>::type>;
return lookUpData_.template getOriginIndex<Grid>(elemIdx);
}
bool operator==(const EclGenericProblem& rhs) const;

View File

@ -169,14 +169,14 @@ readRockParameters_(const std::vector<Scalar>& cellCenterDepths,
rockTableIdx_.resize(numElem);
const auto& num = eclState_.fieldProps().get_int(rock_config.rocknum_property());
for (std::size_t elemIdx = 0; elemIdx < numElem; ++ elemIdx) {
rockTableIdx_[elemIdx] = num[this->lookUpData_.getOriginIndex(elemIdx)] - 1;
rockTableIdx_[elemIdx] = num[this->getLookUpData(elemIdx)] - 1;
auto fmtError =
[&num,elemIdx,&ijkIndex,&rock_config, this](const char* type, std::size_t size)
{
return fmt::format("{} table index {} for elem {} read from {}"
" is is out of bounds for number of tables {}",
type, num[this->lookUpData_.getOriginIndex(elemIdx)],
ijkIndex(this-> lookUpData_.getOriginIndex(elemIdx)),
type, num[this-> getLookUpData(elemIdx)],
ijkIndex(this-> getLookUpData(elemIdx)),
rock_config.rocknum_property(), size);
};
if (!rockCompPoroMult_.empty() &&
@ -213,7 +213,7 @@ readRockParameters_(const std::vector<Scalar>& cellCenterDepths,
tableIdx = rockTableIdx_[elemIdx];
}
overburdenPressure_[elemIdx] =
overburdenTables[tableIdx].eval(cellCenterDepths[this->lookUpData_.getOriginIndex(elemIdx)], /*extrapolation=*/true);
overburdenTables[tableIdx].eval(cellCenterDepths[this->getLookUpData(elemIdx)], /*extrapolation=*/true);
}
}
}
@ -356,7 +356,7 @@ rockFraction(unsigned elementIdx, unsigned timeIdx) const
// geometric volume of the element. Note that it can
// be larger than 1.0 if porevolume multipliers are used
// to for instance implement larger boundary cells
Scalar porosity = poro[this->lookUpData_.getOriginIndex(elementIdx)];
Scalar porosity = poro[this->getLookUpData(elementIdx)];
return referencePorosity(elementIdx, timeIdx) / porosity * (1 - porosity);
}
@ -373,10 +373,10 @@ updateNum(const std::string& name, std::vector<T>& numbers, std::size_t num_regi
unsigned numElems = gridView_.size(/*codim=*/0);
numbers.resize(numElems);
for (unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
if (numData[this->lookUpData_.getOriginIndex(elemIdx)] > (int)num_regions) {
if (numData[this->getLookUpData(elemIdx)] > (int)num_regions) {
throw std::runtime_error("Values larger than maximum number of regions " + std::to_string(num_regions) + " provided in " + name);
} else if (numData[this->lookUpData_.getOriginIndex(elemIdx)] > 0) {
numbers[elemIdx] = static_cast<T>(numData[this->lookUpData_.getOriginIndex(elemIdx)]) - 1;
} else if (numData[this->getLookUpData(elemIdx)] > 0) {
numbers[elemIdx] = static_cast<T>(numData[this->getLookUpData(elemIdx)]) - 1;
} else {
throw std::runtime_error("zero or negative values provided for region array: " + name);
}

View File

@ -2093,18 +2093,18 @@ protected:
if constexpr (enablePolymer)
this->polymer_.concentration[elemIdx] =
eclWriter_->eclOutputModule().getPolymerConcentration(getLookUpData().getOriginIndex(elemIdx));
eclWriter_->eclOutputModule().getPolymerConcentration(getLookUpData(elemIdx));
if constexpr (enableMICP){
this->micp_.microbialConcentration[elemIdx] =
eclWriter_->eclOutputModule().getMicrobialConcentration(getLookUpData().getOriginIndex(elemIdx));
eclWriter_->eclOutputModule().getMicrobialConcentration(getLookUpData(elemIdx));
this->micp_.oxygenConcentration[elemIdx] =
eclWriter_->eclOutputModule().getOxygenConcentration(getLookUpData().getOriginIndex(elemIdx));
eclWriter_->eclOutputModule().getOxygenConcentration(getLookUpData(elemIdx));
this->micp_.ureaConcentration[elemIdx] =
eclWriter_->eclOutputModule().getUreaConcentration(getLookUpData().getOriginIndex(elemIdx));
eclWriter_->eclOutputModule().getUreaConcentration(getLookUpData(elemIdx));
this->micp_.biofilmConcentration[elemIdx] =
eclWriter_->eclOutputModule().getBiofilmConcentration(getLookUpData().getOriginIndex(elemIdx));
eclWriter_->eclOutputModule().getBiofilmConcentration(getLookUpData(elemIdx));
this->micp_.calciteConcentration[elemIdx]
= eclWriter_->eclOutputModule().getCalciteConcentration(getLookUpData().getOriginIndex(elemIdx));
= eclWriter_->eclOutputModule().getCalciteConcentration(getLookUpData(elemIdx));
}
// if we need to restart for polymer molecular weight simulation, we need to add related here
}