From 88e03e5e8db62a6b16ac63797796ca05803f50be Mon Sep 17 00:00:00 2001 From: Antonella Ritorto Date: Thu, 19 Oct 2023 10:52:25 +0200 Subject: [PATCH] Exception added (restart not supported for LGRs), improved-cleaned code --- ebos/eclgenericproblem.hh | 16 ++++++++-------- ebos/eclgenericproblem_impl.hh | 17 +++++++++-------- ebos/eclproblem.hh | 24 +++++++++++------------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/ebos/eclgenericproblem.hh b/ebos/eclgenericproblem.hh index a37530f1f..fd8a0c6b9 100644 --- a/ebos/eclgenericproblem.hh +++ b/ebos/eclgenericproblem.hh @@ -268,12 +268,6 @@ public: int numPressurePointsEquil() const { return numPressurePointsEquil_; } - - auto getLookUpData(unsigned elemIdx) const - { - using GridType = std::remove_cv_t< typename std::remove_reference::type>; - return lookUpData_.template getOriginIndex(elemIdx); - } bool operator==(const EclGenericProblem& rhs) const; @@ -377,12 +371,18 @@ protected: // equilibration parameters int numPressurePointsEquil_; - + // To lookup origin cell indices using Grid = std::remove_cv_t< typename std::remove_reference::type>; using LookUpData = Opm::LookUpData; const LookUpData lookUpData_; - + + auto getLookUpData(unsigned elemIdx) const + { + using GridType = std::remove_cv_t< typename std::remove_reference::type>; + return lookUpData_.template getOriginIndex(elemIdx); + } + private: template void updateNum(const std::string& name, std::vector& numbers, std::size_t num_regions); diff --git a/ebos/eclgenericproblem_impl.hh b/ebos/eclgenericproblem_impl.hh index 68d4d46b1..b123e36e2 100644 --- a/ebos/eclgenericproblem_impl.hh +++ b/ebos/eclgenericproblem_impl.hh @@ -169,14 +169,15 @@ readRockParameters_(const std::vector& 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->getLookUpData(elemIdx)] - 1; + auto coarseElemIdx = this->getLookUpData(elemIdx); + rockTableIdx_[elemIdx] = num[coarseElemIdx] - 1; 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 {}" " is is out of bounds for number of tables {}", - type, num[this-> getLookUpData(elemIdx)], - ijkIndex(this-> getLookUpData(elemIdx)), + type, num[coarseElemIdx], + ijkIndex(coarseElemIdx), rock_config.rocknum_property(), size); }; if (!rockCompPoroMult_.empty() && @@ -213,7 +214,7 @@ readRockParameters_(const std::vector& cellCenterDepths, tableIdx = rockTableIdx_[elemIdx]; } overburdenPressure_[elemIdx] = - overburdenTables[tableIdx].eval(cellCenterDepths[this->getLookUpData(elemIdx)], /*extrapolation=*/true); + overburdenTables[tableIdx].eval(cellCenterDepths[elemIdx], /*extrapolation=*/true); } } } @@ -320,7 +321,7 @@ rockCompressibility(unsigned globalSpaceIdx) const unsigned tableIdx = 0; if (!this->rockTableIdx_.empty()) { - tableIdx = this->rockTableIdx_[globalSpaceIdx]; + tableIdx = this->rockTableIdx_[globalSpaceIdx]; } return this->rockParams_[tableIdx].compressibility; } @@ -334,7 +335,7 @@ rockReferencePressure(unsigned globalSpaceIdx) const unsigned tableIdx = 0; if (!this->rockTableIdx_.empty()) { - tableIdx = this->rockTableIdx_[globalSpaceIdx]; + tableIdx = this->rockTableIdx_[globalSpaceIdx]; } return this->rockParams_[tableIdx].referencePressure; } @@ -356,7 +357,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->getLookUpData(elementIdx)]; + Scalar porosity = poro[this->getLookUpData(elementIdx)]; return referencePorosity(elementIdx, timeIdx) / porosity * (1 - porosity); } diff --git a/ebos/eclproblem.hh b/ebos/eclproblem.hh index 9fe86235d..add391164 100644 --- a/ebos/eclproblem.hh +++ b/ebos/eclproblem.hh @@ -202,7 +202,6 @@ public: using EclGenericProblem::rockCompressibility; using EclGenericProblem::rockReferencePressure; using EclGenericProblem::porosity; - using EclGenericProblem::getLookUpData; /*! * \copydoc FvBaseProblem::registerParameters @@ -2027,6 +2026,11 @@ protected: 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 auto& simulator = this->simulator(); const auto& schedule = simulator.vanguard().schedule(); @@ -2092,19 +2096,13 @@ protected: this->mixControls_.updateLastValues(elemIdx, elemFluidState.Rs(), elemFluidState.Rv()); if constexpr (enablePolymer) - this->polymer_.concentration[elemIdx] = - eclWriter_->eclOutputModule().getPolymerConcentration(getLookUpData(elemIdx)); + this->polymer_.concentration[elemIdx] = eclWriter_->eclOutputModule().getPolymerConcentration(elemIdx); if constexpr (enableMICP){ - this->micp_.microbialConcentration[elemIdx] = - eclWriter_->eclOutputModule().getMicrobialConcentration(getLookUpData(elemIdx)); - this->micp_.oxygenConcentration[elemIdx] = - eclWriter_->eclOutputModule().getOxygenConcentration(getLookUpData(elemIdx)); - this->micp_.ureaConcentration[elemIdx] = - eclWriter_->eclOutputModule().getUreaConcentration(getLookUpData(elemIdx)); - this->micp_.biofilmConcentration[elemIdx] = - eclWriter_->eclOutputModule().getBiofilmConcentration(getLookUpData(elemIdx)); - this->micp_.calciteConcentration[elemIdx] - = eclWriter_->eclOutputModule().getCalciteConcentration(getLookUpData(elemIdx)); + this->micp_.microbialConcentration[elemIdx] = eclWriter_->eclOutputModule().getMicrobialConcentration(elemIdx); + this->micp_.oxygenConcentration[elemIdx] = eclWriter_->eclOutputModule().getOxygenConcentration(elemIdx); + this->micp_.ureaConcentration[elemIdx] = eclWriter_->eclOutputModule().getUreaConcentration(elemIdx); + this->micp_.biofilmConcentration[elemIdx] = eclWriter_->eclOutputModule().getBiofilmConcentration(elemIdx); + this->micp_.calciteConcentration[elemIdx] = eclWriter_->eclOutputModule().getCalciteConcentration(elemIdx); } // if we need to restart for polymer molecular weight simulation, we need to add related here }