Exception added (restart not supported for LGRs), improved-cleaned code

This commit is contained in:
Antonella Ritorto 2023-10-19 10:52:25 +02:00
parent 93731c419d
commit 88e03e5e8d
3 changed files with 28 additions and 29 deletions

View File

@ -269,12 +269,6 @@ public:
int numPressurePointsEquil() const int numPressurePointsEquil() const
{ return numPressurePointsEquil_; } { return numPressurePointsEquil_; }
auto getLookUpData(unsigned elemIdx) const
{
using GridType = std::remove_cv_t< typename std::remove_reference<decltype(gridView_.grid())>::type>;
return lookUpData_.template getOriginIndex<GridType>(elemIdx);
}
bool operator==(const EclGenericProblem& rhs) const; bool operator==(const EclGenericProblem& rhs) const;
template<class Serializer> template<class Serializer>
@ -383,6 +377,12 @@ protected:
using LookUpData = Opm::LookUpData<Grid,GridView>; using LookUpData = Opm::LookUpData<Grid,GridView>;
const LookUpData lookUpData_; const LookUpData lookUpData_;
auto getLookUpData(unsigned elemIdx) const
{
using GridType = std::remove_cv_t< typename std::remove_reference<decltype(gridView_.grid())>::type>;
return lookUpData_.template getOriginIndex<GridType>(elemIdx);
}
private: private:
template<class T> template<class T>
void updateNum(const std::string& name, std::vector<T>& numbers, std::size_t num_regions); void updateNum(const std::string& name, std::vector<T>& numbers, std::size_t num_regions);

View File

@ -169,14 +169,15 @@ readRockParameters_(const std::vector<Scalar>& cellCenterDepths,
rockTableIdx_.resize(numElem); rockTableIdx_.resize(numElem);
const auto& num = eclState_.fieldProps().get_int(rock_config.rocknum_property()); const auto& num = eclState_.fieldProps().get_int(rock_config.rocknum_property());
for (std::size_t elemIdx = 0; elemIdx < numElem; ++ elemIdx) { for (std::size_t elemIdx = 0; elemIdx < numElem; ++ elemIdx) {
rockTableIdx_[elemIdx] = num[this->getLookUpData(elemIdx)] - 1; auto coarseElemIdx = this->getLookUpData(elemIdx);
rockTableIdx_[elemIdx] = num[coarseElemIdx] - 1;
auto fmtError = auto fmtError =
[&num,elemIdx,&ijkIndex,&rock_config, this](const char* type, std::size_t size) [&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 is out of bounds for number of tables {}",
type, num[this-> getLookUpData(elemIdx)], type, num[coarseElemIdx],
ijkIndex(this-> getLookUpData(elemIdx)), ijkIndex(coarseElemIdx),
rock_config.rocknum_property(), size); rock_config.rocknum_property(), size);
}; };
if (!rockCompPoroMult_.empty() && if (!rockCompPoroMult_.empty() &&
@ -213,7 +214,7 @@ readRockParameters_(const std::vector<Scalar>& cellCenterDepths,
tableIdx = rockTableIdx_[elemIdx]; tableIdx = rockTableIdx_[elemIdx];
} }
overburdenPressure_[elemIdx] = overburdenPressure_[elemIdx] =
overburdenTables[tableIdx].eval(cellCenterDepths[this->getLookUpData(elemIdx)], /*extrapolation=*/true); overburdenTables[tableIdx].eval(cellCenterDepths[elemIdx], /*extrapolation=*/true);
} }
} }
} }

View File

@ -202,7 +202,6 @@ public:
using EclGenericProblem<GridView,FluidSystem,Scalar>::rockCompressibility; using EclGenericProblem<GridView,FluidSystem,Scalar>::rockCompressibility;
using EclGenericProblem<GridView,FluidSystem,Scalar>::rockReferencePressure; using EclGenericProblem<GridView,FluidSystem,Scalar>::rockReferencePressure;
using EclGenericProblem<GridView,FluidSystem,Scalar>::porosity; using EclGenericProblem<GridView,FluidSystem,Scalar>::porosity;
using EclGenericProblem<GridView,FluidSystem,Scalar>::getLookUpData;
/*! /*!
* \copydoc FvBaseProblem::registerParameters * \copydoc FvBaseProblem::registerParameters
@ -2027,6 +2026,11 @@ protected:
void readEclRestartSolution_() void readEclRestartSolution_()
{ {
// Throw an exception if the grid has LGRs. Refined grid are not supported for restart.
if(this->simulator().vanguard().grid().maxLevel() > 0) {
throw std::invalid_argument("Refined grids are not yet supported for restart ");
}
// Set the start time of the simulation // Set the start time of the simulation
auto& simulator = this->simulator(); auto& simulator = this->simulator();
const auto& schedule = simulator.vanguard().schedule(); const auto& schedule = simulator.vanguard().schedule();
@ -2092,19 +2096,13 @@ protected:
this->mixControls_.updateLastValues(elemIdx, elemFluidState.Rs(), elemFluidState.Rv()); this->mixControls_.updateLastValues(elemIdx, elemFluidState.Rs(), elemFluidState.Rv());
if constexpr (enablePolymer) if constexpr (enablePolymer)
this->polymer_.concentration[elemIdx] = this->polymer_.concentration[elemIdx] = eclWriter_->eclOutputModule().getPolymerConcentration(elemIdx);
eclWriter_->eclOutputModule().getPolymerConcentration(getLookUpData(elemIdx));
if constexpr (enableMICP){ if constexpr (enableMICP){
this->micp_.microbialConcentration[elemIdx] = this->micp_.microbialConcentration[elemIdx] = eclWriter_->eclOutputModule().getMicrobialConcentration(elemIdx);
eclWriter_->eclOutputModule().getMicrobialConcentration(getLookUpData(elemIdx)); this->micp_.oxygenConcentration[elemIdx] = eclWriter_->eclOutputModule().getOxygenConcentration(elemIdx);
this->micp_.oxygenConcentration[elemIdx] = this->micp_.ureaConcentration[elemIdx] = eclWriter_->eclOutputModule().getUreaConcentration(elemIdx);
eclWriter_->eclOutputModule().getOxygenConcentration(getLookUpData(elemIdx)); this->micp_.biofilmConcentration[elemIdx] = eclWriter_->eclOutputModule().getBiofilmConcentration(elemIdx);
this->micp_.ureaConcentration[elemIdx] = this->micp_.calciteConcentration[elemIdx] = eclWriter_->eclOutputModule().getCalciteConcentration(elemIdx);
eclWriter_->eclOutputModule().getUreaConcentration(getLookUpData(elemIdx));
this->micp_.biofilmConcentration[elemIdx] =
eclWriter_->eclOutputModule().getBiofilmConcentration(getLookUpData(elemIdx));
this->micp_.calciteConcentration[elemIdx]
= eclWriter_->eclOutputModule().getCalciteConcentration(getLookUpData(elemIdx));
} }
// if we need to restart for polymer molecular weight simulation, we need to add related here // if we need to restart for polymer molecular weight simulation, we need to add related here
} }