From 7d9458415b54721633a0f7472ccc5aac82fd06e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= <dennis.glaeser@iws.uni-stuttgart.de> Date: Fri, 13 Apr 2018 20:21:17 +0200 Subject: [PATCH] [boxinterfacesolver] require equality comparison operator of material params This speeds up the simulations significantly as reconstruction of sn only has to be done at material interfaces. Having an equality comparison operator in material parameters allow their identification. This commit introduces a comparison operator for the van-genuchten parameters. --- .../2p/efftoabslawparams.hh | 13 +++++++++++++ .../2p/regularizedvangenuchtenparams.hh | 15 +++++++++++++++ .../2p/vangenuchtenparams.hh | 12 ++++++++++++ .../2p/boxmaterialinterfaceparams.hh | 11 +++++++++-- 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/dumux/material/fluidmatrixinteractions/2p/efftoabslawparams.hh b/dumux/material/fluidmatrixinteractions/2p/efftoabslawparams.hh index 4a432d8633..31698c3044 100644 --- a/dumux/material/fluidmatrixinteractions/2p/efftoabslawparams.hh +++ b/dumux/material/fluidmatrixinteractions/2p/efftoabslawparams.hh @@ -26,6 +26,8 @@ #ifndef DUMUX_EFF_TO_ABS_LAW_PARAMS_HH #define DUMUX_EFF_TO_ABS_LAW_PARAMS_HH +#include <dune/common/float_cmp.hh> + namespace Dumux { /*! @@ -45,6 +47,17 @@ public: : EffLawParams() { swr_ = snr_ = 0; } + /*! + * \brief Equality comparison with another set of params + */ + template<class OtherParams> + bool operator== (const OtherParams& otherParams) const + { + return Dune::FloatCmp::eq(swr_, otherParams.swr(), /*eps*/1e-6*swr_) + && Dune::FloatCmp::eq(snr_, otherParams.snr(), /*eps*/1e-6*snr_) + && EffLawParamsT::operator==(otherParams); + } + /*! * \brief Return the residual wetting saturation. */ diff --git a/dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchtenparams.hh b/dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchtenparams.hh index 62d1f79962..d968cb98a4 100644 --- a/dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchtenparams.hh +++ b/dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchtenparams.hh @@ -26,6 +26,8 @@ #ifndef REGULARIZED_VAN_GENUCHTEN_PARAMS_HH #define REGULARIZED_VAN_GENUCHTEN_PARAMS_HH +#include <dune/common/float_cmp.hh> + #include "vangenuchtenparams.hh" namespace Dumux @@ -53,6 +55,19 @@ public: initialize(); } + /*! + * \brief Equality comparison with another set of params + */ + template<class OtherParams> + bool operator== (const OtherParams& otherParams) const + { + return Dune::FloatCmp::eq(pcLowSw_, otherParams.pcLowSw(), /*eps*/1e-6*pcLowSw_) + && Dune::FloatCmp::eq(pcHighSw_, otherParams.pcHighSw(), /*eps*/1e-6*pcHighSw_) + && Dune::FloatCmp::eq(krnLowSw_, otherParams.krnLowSw(), /*eps*/1e-6*krnLowSw_) + && Dune::FloatCmp::eq(krwHighSw_, otherParams.krwHighSw(), /*eps*/1e-6*krwHighSw_) + && Parent::operator==(otherParams); + } + /*! * \brief Sets some default regularization thresholds */ diff --git a/dumux/material/fluidmatrixinteractions/2p/vangenuchtenparams.hh b/dumux/material/fluidmatrixinteractions/2p/vangenuchtenparams.hh index 0513827e00..1d948e4cd6 100644 --- a/dumux/material/fluidmatrixinteractions/2p/vangenuchtenparams.hh +++ b/dumux/material/fluidmatrixinteractions/2p/vangenuchtenparams.hh @@ -25,6 +25,8 @@ #ifndef VAN_GENUCHTEN_PARAMS_HH #define VAN_GENUCHTEN_PARAMS_HH +#include <dune/common/float_cmp.hh> + namespace Dumux { /*! @@ -50,6 +52,16 @@ public: setVgn(vgn); } + /*! + * \brief Equality comparison with another set of params + */ + template<class OtherParams> + bool operator== (const OtherParams& otherParams) const + { + return Dune::FloatCmp::eq(vgAlpha_, otherParams.vgAlpha(), /*eps*/1e-6*vgAlpha_) + && Dune::FloatCmp::eq(vgn_, otherParams.vgn(), /*eps*/1e-6*vgn_); + } + /*! * \brief Return the \f$\mathrm{\alpha}\f$ shape parameter \f$\mathrm{[1/Pa]}\f$ of van Genuchten's * curve. diff --git a/dumux/porousmediumflow/2p/boxmaterialinterfaceparams.hh b/dumux/porousmediumflow/2p/boxmaterialinterfaceparams.hh index 4c50018aed..7a1905049f 100644 --- a/dumux/porousmediumflow/2p/boxmaterialinterfaceparams.hh +++ b/dumux/porousmediumflow/2p/boxmaterialinterfaceparams.hh @@ -73,7 +73,7 @@ public: DUNE_THROW(Dune::InvalidStateException, "Determination of the interface material parameters with " "this class only makes sense when using the box method!"); - isOnMaterialInterface_.resize(fvGridGeometry.numDofs(), true); + isOnMaterialInterface_.resize(fvGridGeometry.numDofs(), false); dofParams_.resize(fvGridGeometry.numDofs(), nullptr); for (const auto& element : elements(fvGridGeometry.gridView())) { @@ -85,13 +85,20 @@ public: { const auto& params = spatialParams.materialLawParams(element, scv, elemSol); - // is no parameters had been set, set them now + // if no parameters had been set, set them now if (dofParams_[scv.dofIndex()] == nullptr) dofParams_[scv.dofIndex()] = ¶ms; // otherwise only use the current ones if endPointPc (e.g. Brooks-Corey entry pressure) is lower else if (MaterialLaw::endPointPc( params ) < MaterialLaw::endPointPc( *(dofParams_[scv.dofIndex()]) )) + { dofParams_[scv.dofIndex()] = ¶ms; + isOnMaterialInterface_[scv.dofIndex()] = true; + } + + // keep track of material interfaces in any case + else if ( !(params == *(dofParams_[scv.dofIndex()])) ) + isOnMaterialInterface_[scv.dofIndex()] = true; } } } -- GitLab