From f36aa67804522132c4ce56d4349f6527c60e11b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Fri, 23 Sep 2022 00:05:09 +0200 Subject: [PATCH] Return a nullptr to the EclMaterialLawManager Define a method materialLawManagerPtr() that returns a nullpointer to EclMaterialLawManager, but that can be overridden in derived classes e.g. EclProblem --- .../blackoil/blackoilintensivequantities.hh | 4 ++-- opm/models/common/multiphasebaseproblem.hh | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/opm/models/blackoil/blackoilintensivequantities.hh b/opm/models/blackoil/blackoilintensivequantities.hh index e1bb0d226..c5d8c9442 100644 --- a/opm/models/blackoil/blackoilintensivequantities.hh +++ b/opm/models/blackoil/blackoilintensivequantities.hh @@ -661,8 +661,8 @@ private: // mobility_ class attribute. the division by the phase viscosity happens later. MaterialLaw::relativePermeabilities(mobility, materialParams, fluidState); Valgrind::CheckDefined(mobility); - const auto& materialLawManager = problem.materialLawManager(); - if (materialLawManager->hasDirectionalRelperms()) { + const auto* materialLawManager = problem.materialLawManagerPtr(); + if (materialLawManager && materialLawManager->hasDirectionalRelperms()) { auto satnumIdx = materialLawManager->satnumRegionIdx(globalSpaceIdx); using Dir = FaceDir::DirEnum; constexpr int ndim = 3; diff --git a/opm/models/common/multiphasebaseproblem.hh b/opm/models/common/multiphasebaseproblem.hh index 85964a5c4..f0380b64a 100644 --- a/opm/models/common/multiphasebaseproblem.hh +++ b/opm/models/common/multiphasebaseproblem.hh @@ -40,7 +40,13 @@ #include namespace Opm { - +// TODO: This hack is used to be able compile blackoilintensitivequantities.hh (see the function updateRelperms()) when +// the problem is not an EclProblem. For example if the problem is a ReservoirBlackOilVcfvProblem, the problem will not +// have a materialLawManager pointer (as the EclProblem has). Since this class MuitPhaseBaseProblem (see below) is a parent +// class for both those problem types, we can solve this problem by forward declaring EclMaterialLawManager here +// and defining a method materialLawManagerPtr() here that returns a nullptr, but is overridden in EclProblem to +// return the real EclMaterialManager pointer. +template class EclMaterialLawManager; /*! * \ingroup Discretization * @@ -246,6 +252,13 @@ public: return dummy; } + // TODO: See the comment at the top of this file for the reason why we need this method + template + const ::Opm::EclMaterialLawManager* materialLawManagerPtr() const + { + return nullptr; + } + /*! * \brief Returns the temperature \f$\mathrm{[K]}\f$ within a control volume. *