28#ifndef FI_BLACK_OIL_MODEL_HPP
29#define FI_BLACK_OIL_MODEL_HPP
34#include <opm/common/ErrorMacros.hpp>
36#include <opm/grid/CpGrid.hpp>
37#include <opm/grid/utility/ElementChunks.hpp>
48template <
typename TypeTag>
57 using Element =
typename GridView::template Codim<0>::Entity;
58 using ElementIterator =
typename GridView::template Codim<0>::Iterator;
60 numEq = getPropValue<TypeTag, Properties::NumEq>(),
61 historySize = getPropValue<TypeTag, Properties::TimeDiscHistorySize>(),
67 static constexpr bool gridIsUnchanging =
68 std::is_same_v<GetPropType<TypeTag, Properties::Grid>, Dune::CpGrid>;
74 Dune::Partitions::all,
75 ThreadManager::maxThreads())
81 this->invalidateIntensiveQuantitiesCache(timeIdx);
83 if constexpr (gridIsUnchanging) {
85#pragma omp parallel for
88 ElementContext elemCtx(this->simulator_);
89 for (
const auto& elem : chunk) {
90 elemCtx.updatePrimaryStencil(elem);
91 elemCtx.updatePrimaryIntensiveQuantities(timeIdx);
96 ElementContext elemCtx(this->simulator_);
97 for (
const auto& elem : elements(this->gridView_)) {
98 elemCtx.updatePrimaryStencil(elem);
99 elemCtx.updatePrimaryIntensiveQuantities(timeIdx);
103 this->simulator_.vanguard().grid().comm());
115 ElementContext elemCtx(this->simulator_);
118 if (elemIt->partitionType() != Dune::OverlapEntity) {
121 const Element& elem = *elemIt;
122 elemCtx.updatePrimaryStencil(elem);
124 const std::size_t numPrimaryDof = elemCtx.numPrimaryDof(timeIdx);
125 for (
unsigned dofIdx = 0; dofIdx < numPrimaryDof; ++dofIdx) {
126 const unsigned globalIndex = elemCtx.globalSpaceIndex(dofIdx, timeIdx);
127 this->setIntensiveQuantitiesCacheEntryValidity(globalIndex, timeIdx,
false);
130 elemCtx.updatePrimaryIntensiveQuantities(0);
134 this->simulator_.vanguard().grid().comm());
137 template <
class Gr
idSubDomain>
141 using GridViewType =
decltype(gridSubDomain.view);
147 ElementContext elemCtx(this->simulator_);
150 if (elemIt->partitionType() != Dune::InteriorEntity) {
153 const Element& elem = *elemIt;
154 elemCtx.updatePrimaryStencil(elem);
156 const std::size_t numPrimaryDof = elemCtx.numPrimaryDof(timeIdx);
157 for (
unsigned dofIdx = 0; dofIdx < numPrimaryDof; ++dofIdx) {
158 const unsigned globalIndex = elemCtx.globalSpaceIndex(dofIdx, timeIdx);
159 this->setIntensiveQuantitiesCacheEntryValidity(globalIndex, timeIdx,
false);
162 elemCtx.updatePrimaryIntensiveQuantities(0);
178 ParentType::updateFailed();
185 if (!this->enableIntensiveQuantityCache_) {
186 OPM_THROW(std::logic_error,
187 "Run without intensive quantites not enabled: "
188 "Use --enable-intensive-quantity=true");
190 const auto* intquant = this->cachedIntensiveQuantities(globalIdx, timeIdx);
192 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:192
#define OPM_BEGIN_PARALLEL_TRY_CATCH()
Macro to setup the try of a parallel try-catch.
Definition: DeferredLoggingErrorHelpers.hpp:158
A fully-implicit black-oil flow model.
Definition: blackoilmodel.hh:336
Definition: FIBlackoilModel.hpp:50
void invalidateAndUpdateIntensiveQuantities(unsigned timeIdx, const GridSubDomain &gridSubDomain) const
Definition: FIBlackoilModel.hpp:138
void invalidateAndUpdateIntensiveQuantitiesOverlap(unsigned timeIdx) const
Definition: FIBlackoilModel.hpp:106
void updateFailed()
Called by the update() method if it was unsuccessful. This is primary a hook which the actual model c...
Definition: FIBlackoilModel.hpp:172
const IntensiveQuantities & intensiveQuantities(unsigned globalIdx, unsigned timeIdx) const
Definition: FIBlackoilModel.hpp:183
void invalidateAndUpdateIntensiveQuantities(unsigned timeIdx) const
Definition: FIBlackoilModel.hpp:79
FIBlackOilModel(Simulator &simulator)
Definition: FIBlackoilModel.hpp:71
ElementChunks< GridView, Dune::Partitions::All > element_chunks_
Definition: FIBlackoilModel.hpp:198
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:168
Provides an STL-iterator like interface to iterate over the enties of a GridView in OpenMP threaded a...
Definition: threadedentityiterator.hh:42
bool isFinished(const EntityIterator &it) const
Definition: threadedentityiterator.hh:67
EntityIterator increment()
Definition: threadedentityiterator.hh:80
EntityIterator beginParallel()
Definition: threadedentityiterator.hh:54
Definition: fvbaseprimaryvariables.hh:141
Definition: blackoilboundaryratevector.hh:39
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:233
The Opm property system, traits with inheritance.