mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #4951 from aritorto/hideFieldPropLookUp
Assign Field Property to all leaf grid view elements
This commit is contained in:
commit
4a61d5cf71
@ -166,31 +166,33 @@ readRockParameters_(const std::vector<Scalar>& cellCenterDepths,
|
|||||||
|
|
||||||
unsigned numElem = gridView_.size(0);
|
unsigned numElem = gridView_.size(0);
|
||||||
if (eclState_.fieldProps().has_int(rock_config.rocknum_property())) {
|
if (eclState_.fieldProps().has_int(rock_config.rocknum_property())) {
|
||||||
rockTableIdx_.resize(numElem);
|
// Auxiliary function to check rockTableIdx_ values belong to the right range. Otherwise, throws.
|
||||||
const auto& num = eclState_.fieldProps().get_int(rock_config.rocknum_property());
|
std::function<void(int, int)> valueCheck = [&ijkIndex,&rock_config,this](int fieldPropValue, int coarseElemIdx)
|
||||||
for (std::size_t elemIdx = 0; elemIdx < numElem; ++ elemIdx) {
|
{
|
||||||
auto coarseElemIdx = this->getLookUpData(elemIdx);
|
auto fmtError = [fieldPropValue, coarseElemIdx,&ijkIndex,&rock_config](const char* type, std::size_t size)
|
||||||
rockTableIdx_[elemIdx] = num[coarseElemIdx] - 1;
|
|
||||||
auto fmtError =
|
|
||||||
[&num,coarseElemIdx,&ijkIndex,&rock_config](const char* type, std::size_t size)
|
|
||||||
{
|
{
|
||||||
return fmt::format("{} table index {} for elem {} read from {}"
|
return fmt::format("{} table index {} for elem {} read from {}"
|
||||||
" is is out of bounds for number of tables {}",
|
" is out of bounds for number of tables {}",
|
||||||
type, num[coarseElemIdx],
|
type, fieldPropValue,
|
||||||
ijkIndex(coarseElemIdx),
|
ijkIndex(coarseElemIdx),
|
||||||
rock_config.rocknum_property(), size);
|
rock_config.rocknum_property(), size);
|
||||||
};
|
};
|
||||||
if (!rockCompPoroMult_.empty() &&
|
if (!rockCompPoroMult_.empty() &&
|
||||||
rockTableIdx_[elemIdx] >= rockCompPoroMult_.size()) {
|
fieldPropValue > static_cast<int>(rockCompPoroMult_.size())) {
|
||||||
throw std::runtime_error(fmtError("Rock compaction",
|
throw std::runtime_error(fmtError("Rock compaction",
|
||||||
rockCompPoroMult_.size()));
|
rockCompPoroMult_.size()));
|
||||||
}
|
}
|
||||||
if (!rockCompPoroMultWc_.empty() &&
|
if (!rockCompPoroMultWc_.empty() &&
|
||||||
rockTableIdx_[elemIdx] >= rockCompPoroMultWc_.size()) {
|
fieldPropValue > static_cast<int>(rockCompPoroMultWc_.size())) {
|
||||||
throw std::runtime_error(fmtError("Rock water compaction",
|
throw std::runtime_error(fmtError("Rock water compaction",
|
||||||
rockCompPoroMultWc_.size()));
|
rockCompPoroMultWc_.size()));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
rockTableIdx_ = this->lookUpData_.template assignFieldPropsIntOnLeaf<short unsigned int>(eclState_.fieldProps(),
|
||||||
|
rock_config.rocknum_property(),
|
||||||
|
numElem, true /*needsTranslation*/,
|
||||||
|
valueCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store overburden pressure pr element
|
// Store overburden pressure pr element
|
||||||
@ -367,19 +369,19 @@ updateNum(const std::string& name, std::vector<T>& numbers, std::size_t num_regi
|
|||||||
if (!eclState_.fieldProps().has_int(name))
|
if (!eclState_.fieldProps().has_int(name))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto& numData = eclState_.fieldProps().get_int(name);
|
|
||||||
|
|
||||||
unsigned numElems = gridView_.size(/*codim=*/0);
|
unsigned numElems = gridView_.size(/*codim=*/0);
|
||||||
numbers.resize(numElems);
|
std::function<void(T, int)> valueCheck = [num_regions,name](T fieldPropValue, [[maybe_unused]] int fieldPropIdx) {
|
||||||
for (unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
|
if ( fieldPropValue > (int)num_regions) {
|
||||||
if (numData[this->getLookUpData(elemIdx)] > (int)num_regions) {
|
throw std::runtime_error("Values larger than maximum number of regions "
|
||||||
throw std::runtime_error("Values larger than maximum number of regions " + std::to_string(num_regions) + " provided in " + name);
|
+ std::to_string(num_regions) + " provided in " + name);
|
||||||
} else if (numData[this->getLookUpData(elemIdx)] > 0) {
|
}
|
||||||
numbers[elemIdx] = static_cast<T>(numData[this->getLookUpData(elemIdx)]) - 1;
|
if ( fieldPropValue <= 0) {
|
||||||
} else {
|
|
||||||
throw std::runtime_error("zero or negative values provided for region array: " + name);
|
throw std::runtime_error("zero or negative values provided for region array: " + name);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
numbers = this->lookUpData_.template assignFieldPropsIntOnLeaf<T>(eclState_.fieldProps(), name, numElems,
|
||||||
|
true /*needsTranslation*/, valueCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class GridView, class FluidSystem, class Scalar>
|
template<class GridView, class FluidSystem, class Scalar>
|
||||||
|
@ -132,12 +132,8 @@ finishInit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// internalize the data specified using the EQLNUM keyword
|
// internalize the data specified using the EQLNUM keyword
|
||||||
const auto& fp = eclState_.fieldProps();
|
elemEquilRegion_ = lookUpData_.template assignFieldPropsIntOnLeaf<short unsigned int>(eclState_.fieldProps(),
|
||||||
const auto& equilRegionData = fp.get_int("EQLNUM");
|
"EQLNUM", numElements, true);
|
||||||
elemEquilRegion_.resize(numElements, 0);
|
|
||||||
for (unsigned elemIdx = 0; elemIdx < numElements; ++elemIdx) {
|
|
||||||
elemEquilRegion_[elemIdx] = equilRegionData[elemIdx] - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If this is a restart run the ThresholdPressure object will be active,
|
If this is a restart run the ThresholdPressure object will be active,
|
||||||
@ -171,8 +167,8 @@ applyExplicitThresholdPressures_()
|
|||||||
const auto& inside = intersection.inside();
|
const auto& inside = intersection.inside();
|
||||||
const auto& outside = intersection.outside();
|
const auto& outside = intersection.outside();
|
||||||
|
|
||||||
auto equilRegionInside = lookUpData_(inside, elemEquilRegion_);
|
auto equilRegionInside = elemEquilRegion_[elementMapper_.index(inside)];
|
||||||
auto equilRegionOutside = lookUpData_(outside, elemEquilRegion_);
|
auto equilRegionOutside = elemEquilRegion_[elementMapper_.index(outside)];
|
||||||
|
|
||||||
if (thpres.hasRegionBarrier(equilRegionInside + 1, equilRegionOutside + 1)) {
|
if (thpres.hasRegionBarrier(equilRegionInside + 1, equilRegionOutside + 1)) {
|
||||||
Scalar pth = 0.0;
|
Scalar pth = 0.0;
|
||||||
|
Loading…
Reference in New Issue
Block a user