28#ifndef FI_BLACK_OIL_MODEL_HPP
29#define FI_BLACK_OIL_MODEL_HPP
31#include <opm/models/blackoil/blackoilmodel.hh>
32#include <opm/models/utils/propertysystem.hh>
34#include <opm/common/ErrorMacros.hpp>
42template <
typename TypeTag>
45 using ParentType = BlackOilModel<TypeTag>;
46 using Simulator = GetPropType<TypeTag, Properties::Simulator>;
47 using IntensiveQuantities = GetPropType<TypeTag, Properties::IntensiveQuantities>;
48 using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
49 using ThreadManager = GetPropType<TypeTag, Properties::ThreadManager>;
50 using GridView = GetPropType<TypeTag, Properties::GridView>;
51 using Element =
typename GridView::template Codim<0>::Entity;
52 using ElementIterator =
typename GridView::template Codim<0>::Iterator;
54 numEq = getPropValue<TypeTag, Properties::NumEq>(),
55 historySize = getPropValue<TypeTag, Properties::TimeDiscHistorySize>(),
60 : BlackOilModel<TypeTag>(simulator)
67 this->invalidateIntensiveQuantitiesCache(timeIdx);
70 ThreadedEntityIterator<GridView, 0> threadedElemIt(this->gridView_);
75 ElementContext elemCtx(this->simulator_);
76 ElementIterator elemIt = threadedElemIt.beginParallel();
77 for (; !threadedElemIt.isFinished(elemIt); elemIt = threadedElemIt.increment()) {
78 const Element& elem = *elemIt;
79 elemCtx.updatePrimaryStencil(elem);
80 elemCtx.updatePrimaryIntensiveQuantities(timeIdx);
89 ThreadedEntityIterator<GridView, 0> threadedElemIt(this->gridView_);
95 ElementContext elemCtx(this->simulator_);
96 auto elemIt = threadedElemIt.beginParallel();
97 for (; !threadedElemIt.isFinished(elemIt); elemIt = threadedElemIt.increment()) {
98 if (elemIt->partitionType() != Dune::OverlapEntity) {
101 const Element& elem = *elemIt;
102 elemCtx.updatePrimaryStencil(elem);
104 const std::size_t numPrimaryDof = elemCtx.numPrimaryDof(timeIdx);
105 for (
unsigned dofIdx = 0; dofIdx < numPrimaryDof; ++dofIdx) {
106 const unsigned globalIndex = elemCtx.globalSpaceIndex(dofIdx, timeIdx);
107 this->setIntensiveQuantitiesCacheEntryValidity(globalIndex, timeIdx,
false);
110 elemCtx.updatePrimaryIntensiveQuantities(0);
113 OPM_END_PARALLEL_TRY_CATCH(
"InvalideAndUpdateIntensiveQuantitiesOverlap: state error", this->simulator_.vanguard().grid().comm());
116 template <
class Gr
idSubDomain>
120 using GridViewType =
decltype(gridSubDomain.view);
121 ThreadedEntityIterator<GridViewType, 0> threadedElemIt(gridSubDomain.view);
126 ElementContext elemCtx(this->simulator_);
127 auto elemIt = threadedElemIt.beginParallel();
128 for (; !threadedElemIt.isFinished(elemIt); elemIt = threadedElemIt.increment()) {
129 if (elemIt->partitionType() != Dune::InteriorEntity) {
132 const Element& elem = *elemIt;
133 elemCtx.updatePrimaryStencil(elem);
135 const std::size_t numPrimaryDof = elemCtx.numPrimaryDof(timeIdx);
136 for (
unsigned dofIdx = 0; dofIdx < numPrimaryDof; ++dofIdx) {
137 const unsigned globalIndex = elemCtx.globalSpaceIndex(dofIdx, timeIdx);
138 this->setIntensiveQuantitiesCacheEntryValidity(globalIndex, timeIdx,
false);
141 elemCtx.updatePrimaryIntensiveQuantities(0);
157 ParentType::updateFailed();
164 if (!this->enableIntensiveQuantityCache_) {
165 OPM_THROW(std::logic_error,
166 "Run without intensive quantites not enabled: Use --enable-intensive-quantity=true");
168 const auto* intquant = this->cachedIntensiveQuantities(globalIdx, timeIdx);
170 OPM_THROW(std::logic_error,
"Intensive quantites need to be updated in code");
#define OPM_END_PARALLEL_TRY_CATCH(prefix, comm)
Catch exception and throw in a parallel try-catch clause.
Definition: DeferredLoggingErrorHelpers.hpp:172
#define OPM_BEGIN_PARALLEL_TRY_CATCH()
Macro to setup the try of a parallel try-catch.
Definition: DeferredLoggingErrorHelpers.hpp:138
Definition: FIBlackoilModel.hpp:44
void invalidateAndUpdateIntensiveQuantities(unsigned timeIdx, const GridSubDomain &gridSubDomain) const
Definition: FIBlackoilModel.hpp:117
void invalidateAndUpdateIntensiveQuantitiesOverlap(unsigned timeIdx) const
Definition: FIBlackoilModel.hpp:86
void updateFailed()
Called by the update() method if it was unsuccessful. This is primary a hook which the actual model c...
Definition: FIBlackoilModel.hpp:151
const IntensiveQuantities & intensiveQuantities(unsigned globalIdx, unsigned timeIdx) const
Definition: FIBlackoilModel.hpp:162
void invalidateAndUpdateIntensiveQuantities(unsigned timeIdx) const
Definition: FIBlackoilModel.hpp:64
FIBlackOilModel(Simulator &simulator)
Definition: FIBlackoilModel.hpp:59
Definition: BlackoilPhases.hpp:27