From db4667777a01933b857e2ebf7ac64325d4cfbafd Mon Sep 17 00:00:00 2001 From: DennisGlaeser <dennis.glaeser@iws.uni-stuttgart.de> Date: Thu, 11 Jan 2018 19:34:14 +0100 Subject: [PATCH] [mpfa][ivtraits] get rid of stencil the stencil types could not be different for the different iv types anyway. We now use the stencil type specified in the unique DualGridNodalIndexSet. --- .../cellcentered/mpfa/darcyslaw.hh | 17 ++++++-------- .../cellcentered/mpfa/fickslaw.hh | 22 ++++++++----------- .../cellcentered/mpfa/fourierslaw.hh | 17 ++++++-------- .../mpfa/interactionvolumebase.hh | 4 +--- .../mpfa/omethod/interactionvolume.hh | 12 +--------- .../mpfa/omethod/staticinteractionvolume.hh | 12 +--------- .../1p/incompressiblelocalresidual.hh | 3 +-- 7 files changed, 27 insertions(+), 60 deletions(-) diff --git a/dumux/discretization/cellcentered/mpfa/darcyslaw.hh b/dumux/discretization/cellcentered/mpfa/darcyslaw.hh index 0d7f2a7be9..9ff8141419 100644 --- a/dumux/discretization/cellcentered/mpfa/darcyslaw.hh +++ b/dumux/discretization/cellcentered/mpfa/darcyslaw.hh @@ -94,6 +94,9 @@ class DarcysLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> static constexpr int dimWorld = GridView::dimensionworld; static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); + using DualGridNodalIndexSet = typename GET_PROP_TYPE(TypeTag, DualGridNodalIndexSet); + using Stencil = typename DualGridNodalIndexSet::GridStencilType; + using MpfaHelper = typename GET_PROP_TYPE(TypeTag, MpfaHelper); static constexpr bool considerSecondaryIVs = MpfaHelper::considerSecondaryIVs(); @@ -109,7 +112,6 @@ class DarcysLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> using PrimaryIvVector = typename PrimaryInteractionVolume::Traits::Vector; using PrimaryIvMatrix = typename PrimaryInteractionVolume::Traits::Matrix; using PrimaryIvTij = typename PrimaryIvMatrix::row_type; - using PrimaryIvStencil = typename PrimaryInteractionVolume::Traits::Stencil; using SecondaryInteractionVolume = typename GET_PROP_TYPE(TypeTag, SecondaryInteractionVolume); using SecondaryIvLocalFaceData = typename SecondaryInteractionVolume::Traits::LocalFaceData; @@ -117,7 +119,6 @@ class DarcysLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> using SecondaryIvVector = typename SecondaryInteractionVolume::Traits::Vector; using SecondaryIvMatrix = typename SecondaryInteractionVolume::Traits::Matrix; using SecondaryIvTij = typename SecondaryIvMatrix::row_type; - using SecondaryIvStencil = typename SecondaryInteractionVolume::Traits::Stencil; public: // export the filler type @@ -138,7 +139,7 @@ class DarcysLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> const SubControlVolumeFace &scvf) { switchFluxSign_ = localFaceData.isOutside(); - primaryStencil_ = &iv.stencil(); + stencil_ = &iv.stencil(); for (unsigned int pIdx = 0; pIdx < numPhases; ++pIdx) primaryPj_[pIdx] = &dataHandle.pressures(pIdx); @@ -191,7 +192,7 @@ class DarcysLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> const SubControlVolumeFace &scvf) { switchFluxSign_ = localFaceData.isOutside(); - secondaryStencil_ = &iv.stencil(); + stencil_ = &iv.stencil(); for (unsigned int pIdx = 0; pIdx < numPhases; ++pIdx) secondaryPj_[pIdx] = &dataHandle.pressures(pIdx); @@ -229,10 +230,7 @@ class DarcysLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> } //! The stencil corresponding to the transmissibilities (primary type) - const PrimaryIvStencil& advectionStencilPrimaryIv() const { return *primaryStencil_; } - - //! The stencil corresponding to the transmissibilities (secondary type) - const SecondaryIvStencil& advectionStencilSecondaryIv() const { return *secondaryStencil_; } + const Stencil& advectionStencil() const { return *stencil_; } //! Coefficients for the cell (& Dirichlet) unknowns in flux expressions (primary type) const PrimaryIvTij& advectionTijPrimaryIv() const { return *primaryTij_; } @@ -259,8 +257,7 @@ class DarcysLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> bool switchFluxSign_; //! The stencil, i.e. the grid indices j - const PrimaryIvStencil* primaryStencil_; - const SecondaryIvStencil* secondaryStencil_; + const Stencil* stencil_; //! The transmissibilities such that f = Tij*pj const PrimaryIvTij* primaryTij_; diff --git a/dumux/discretization/cellcentered/mpfa/fickslaw.hh b/dumux/discretization/cellcentered/mpfa/fickslaw.hh index be10d54f81..1f3ea99206 100644 --- a/dumux/discretization/cellcentered/mpfa/fickslaw.hh +++ b/dumux/discretization/cellcentered/mpfa/fickslaw.hh @@ -90,6 +90,9 @@ class FicksLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> //! The cache used in conjunction with the mpfa Fick's Law class MpfaFicksLawCache { + using DualGridNodalIndexSet = typename GET_PROP_TYPE(TypeTag, DualGridNodalIndexSet); + using Stencil = typename DualGridNodalIndexSet::GridStencilType; + using MpfaHelper = typename GET_PROP_TYPE(TypeTag, MpfaHelper); static constexpr bool considerSecondaryIVs = MpfaHelper::considerSecondaryIVs(); @@ -105,7 +108,6 @@ class FicksLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> using PrimaryIvVector = typename PrimaryInteractionVolume::Traits::Vector; using PrimaryIvMatrix = typename PrimaryInteractionVolume::Traits::Matrix; using PrimaryIvTij = typename PrimaryIvMatrix::row_type; - using PrimaryIvStencil = typename PrimaryInteractionVolume::Traits::Stencil; using SecondaryInteractionVolume = typename GET_PROP_TYPE(TypeTag, SecondaryInteractionVolume); using SecondaryIvLocalFaceData = typename SecondaryInteractionVolume::Traits::LocalFaceData; @@ -113,7 +115,6 @@ class FicksLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> using SecondaryIvVector = typename SecondaryInteractionVolume::Traits::Vector; using SecondaryIvMatrix = typename SecondaryInteractionVolume::Traits::Matrix; using SecondaryIvTij = typename SecondaryIvMatrix::row_type; - using SecondaryIvStencil = typename SecondaryInteractionVolume::Traits::Stencil; static constexpr int dim = GridView::dimension; static constexpr int dimWorld = GridView::dimensionworld; @@ -138,7 +139,7 @@ class FicksLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> const SubControlVolumeFace &scvf, unsigned int phaseIdx, unsigned int compIdx) { - primaryStencil_[phaseIdx][compIdx] = &iv.stencil(); + stencil_[phaseIdx][compIdx] = &iv.stencil(); switchFluxSign_[phaseIdx][compIdx] = localFaceData.isOutside(); // store pointer to the mole fraction vector of this iv @@ -168,7 +169,7 @@ class FicksLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> const SubControlVolumeFace &scvf, unsigned int phaseIdx, unsigned int compIdx) { - secondaryStencil_[phaseIdx][compIdx] = &iv.stencil(); + stencil_[phaseIdx][compIdx] = &iv.stencil(); switchFluxSign_[phaseIdx][compIdx] = localFaceData.isOutside(); // store pointer to the mole fraction vector of this iv @@ -205,20 +206,15 @@ class FicksLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> const SecondaryIvVector& moleFractionsSecondaryIv(unsigned int phaseIdx, unsigned int compIdx) const { return *secondaryXj_[phaseIdx][compIdx]; } - //! The stencils corresponding to the transmissibilities (primary type) - const PrimaryIvStencil& diffusionStencilPrimaryIv(unsigned int phaseIdx, unsigned int compIdx) const - { return *primaryStencil_[phaseIdx][compIdx]; } - - //! The stencils corresponding to the transmissibilities (secondary type) - const SecondaryIvStencil& diffusionStencilSecondaryIv(unsigned int phaseIdx, unsigned int compIdx) const - { return *secondaryStencil_[phaseIdx][compIdx]; } + //! The stencils corresponding to the transmissibilities + const Stencil& diffusionStencil(unsigned int phaseIdx, unsigned int compIdx) const + { return *stencil_[phaseIdx][compIdx]; } private: std::array< std::array<bool, numComponents>, numPhases > switchFluxSign_; //! The stencils, i.e. the grid indices j - std::array< std::array<const PrimaryIvStencil*, numComponents>, numPhases > primaryStencil_; - std::array< std::array<const SecondaryIvStencil*, numComponents>, numPhases > secondaryStencil_; + std::array< std::array<const Stencil*, numComponents>, numPhases > stencil_; //! The transmissibilities such that f = Tij*xj std::array< std::array<const PrimaryIvVector*, numComponents>, numPhases > primaryTij_; diff --git a/dumux/discretization/cellcentered/mpfa/fourierslaw.hh b/dumux/discretization/cellcentered/mpfa/fourierslaw.hh index 11e2a4accd..ebdb9d76aa 100644 --- a/dumux/discretization/cellcentered/mpfa/fourierslaw.hh +++ b/dumux/discretization/cellcentered/mpfa/fourierslaw.hh @@ -88,6 +88,9 @@ class FouriersLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> //! The cache used in conjunction with the mpfa Fourier's Law class MpfaFouriersLawCache { + using DualGridNodalIndexSet = typename GET_PROP_TYPE(TypeTag, DualGridNodalIndexSet); + using Stencil = typename DualGridNodalIndexSet::GridStencilType; + using MpfaHelper = typename GET_PROP_TYPE(TypeTag, MpfaHelper); static constexpr bool considerSecondaryIVs = MpfaHelper::considerSecondaryIVs(); @@ -103,7 +106,6 @@ class FouriersLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> using PrimaryIvVector = typename PrimaryInteractionVolume::Traits::Vector; using PrimaryIvMatrix = typename PrimaryInteractionVolume::Traits::Matrix; using PrimaryIvTij = typename PrimaryIvMatrix::row_type; - using PrimaryIvStencil = typename PrimaryInteractionVolume::Traits::Stencil; using SecondaryInteractionVolume = typename GET_PROP_TYPE(TypeTag, SecondaryInteractionVolume); using SecondaryIvLocalFaceData = typename SecondaryInteractionVolume::Traits::LocalFaceData; @@ -111,7 +113,6 @@ class FouriersLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> using SecondaryIvVector = typename SecondaryInteractionVolume::Traits::Vector; using SecondaryIvMatrix = typename SecondaryInteractionVolume::Traits::Matrix; using SecondaryIvTij = typename SecondaryIvMatrix::row_type; - using SecondaryIvStencil = typename SecondaryInteractionVolume::Traits::Stencil; static constexpr int dim = GridView::dimension; static constexpr int dimWorld = GridView::dimensionworld; @@ -134,7 +135,7 @@ class FouriersLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> const PrimaryIvDataHandle& dataHandle, const SubControlVolumeFace &scvf) { - primaryStencil_ = &iv.stencil(); + stencil_ = &iv.stencil(); switchFluxSign_ = localFaceData.isOutside(); // store pointer to the temperature vector of this iv @@ -163,7 +164,7 @@ class FouriersLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> const SecondaryIvDataHandle& dataHandle, const SubControlVolumeFace &scvf) { - secondaryStencil_ = &iv.stencil(); + stencil_ = &iv.stencil(); switchFluxSign_ = localFaceData.isOutside(); // store pointer to the temperature vector of this iv @@ -184,10 +185,7 @@ class FouriersLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> const SecondaryIvTij& heatConductionTijSecondaryIv() const { return *secondaryTij_; } //! The stencil corresponding to the transmissibilities (primary type) - const PrimaryIvStencil& heatConductionStencilPrimaryIv() const { return *primaryStencil_; } - - //! The stencil corresponding to the transmissibilities (secondary type) - const SecondaryIvStencil& heatConductionStencilSecondaryIv() const { return *secondaryStencil_; } + const Stencil& heatConductionStencil() const { return *stencil_; } //! The cell (& Dirichlet) temperatures within this interaction volume (primary type) const PrimaryIvVector& temperaturesPrimaryIv() const { return *primaryTj_; } @@ -205,8 +203,7 @@ class FouriersLawImplementation<TypeTag, DiscretizationMethods::CCMpfa> bool switchFluxSign_; //! The stencil, i.e. the grid indices j - const PrimaryIvStencil* primaryStencil_; - const SecondaryIvStencil* secondaryStencil_; + const Stencil* stencil_; //! The transmissibilities such that f = Tij*Tj const PrimaryIvTij* primaryTij_; diff --git a/dumux/discretization/cellcentered/mpfa/interactionvolumebase.hh b/dumux/discretization/cellcentered/mpfa/interactionvolumebase.hh index 51ac0be10e..d5e46c9b0f 100644 --- a/dumux/discretization/cellcentered/mpfa/interactionvolumebase.hh +++ b/dumux/discretization/cellcentered/mpfa/interactionvolumebase.hh @@ -65,8 +65,6 @@ namespace Dumux * using Matrix = ...; * //! export the type used for iv-local vectors * using Vector = ...; - * //! export the type used for the iv-stencils - * using Stencil = ...; * //! export the data handle type for this iv * using DataHandle = ...; * \endcode @@ -123,7 +121,7 @@ public: { DUNE_THROW(Dune::NotImplemented, "Interaction volume implementation does not provide a localFaceData() funtion"); } //! returns the cell-stencil of this interaction volume - const typename Traits::Stencil& stencil() const { return asImp().stencil(); } + const typename Traits::IndexSet::GridStencilType& stencil() const { return asImp().stencil(); } //! returns the local scvf entity corresponding to a given iv-local scvf idx const typename Traits::LocalScvfType& localScvf(typename Traits::LocalIndexType ivLocalScvfIdx) const diff --git a/dumux/discretization/cellcentered/mpfa/omethod/interactionvolume.hh b/dumux/discretization/cellcentered/mpfa/omethod/interactionvolume.hh index 0a8f754d6f..06fefbd08a 100644 --- a/dumux/discretization/cellcentered/mpfa/omethod/interactionvolume.hh +++ b/dumux/discretization/cellcentered/mpfa/omethod/interactionvolume.hh @@ -83,8 +83,6 @@ public: using Matrix = Dune::DynamicMatrix< ScalarType >; //! export the type used for iv-local vectors using Vector = Dune::DynamicVector< ScalarType >; - //! export the type used for the iv-stencils - using Stencil = typename NodalIndexSet::GridStencilType; //! export the data handle type for this iv using DataHandle = InteractionVolumeDataHandle< TypeTag, Matrix, Vector, LocalIndexType >; }; @@ -120,15 +118,7 @@ class CCMpfaOInteractionVolume : public CCMpfaInteractionVolumeBase< CCMpfaOInte using IndexSet = typename Traits::IndexSet; using GridIndexType = typename GridView::IndexSet::IndexType; using LocalIndexType = typename Traits::LocalIndexType; - using Stencil = typename Traits::Stencil; - - //! For the o method, the interaction volume stencil can be taken directly - //! from the nodal index set, which always uses Dune::ReservedVector with a maximum - //! admissible number of elements per node. Thus, we have to make sure that - //! the type set for the stencils in the traits is castable. - static_assert( std::is_convertible<Stencil*, typename IndexSet::GridStencilType*>::value, - "The o-method uses the (dynamic) nodal index set's stencil as the interaction volume stencil. " - "Using a different type is not permissive here." ); + using Stencil = typename IndexSet::GridStencilType; //! Data attached to scvf touching Dirichlet boundaries. //! For the default o-scheme, we only store the corresponding vol vars index. diff --git a/dumux/discretization/cellcentered/mpfa/omethod/staticinteractionvolume.hh b/dumux/discretization/cellcentered/mpfa/omethod/staticinteractionvolume.hh index c57a82f3ac..a800e18829 100644 --- a/dumux/discretization/cellcentered/mpfa/omethod/staticinteractionvolume.hh +++ b/dumux/discretization/cellcentered/mpfa/omethod/staticinteractionvolume.hh @@ -84,8 +84,6 @@ public: using Matrix = Dune::FieldMatrix< ScalarType, localSize, localSize >; //! export the type used for iv-local vectors using Vector = Dune::FieldVector< ScalarType, localSize >; - //! export the type used for the iv-stencils - using Stencil = typename NodalIndexSet::GridStencilType; //! export the data handle type for this iv using DataHandle = InteractionVolumeDataHandle< TypeTag, Matrix, Vector, LocalIndexType >; }; @@ -127,15 +125,7 @@ class CCMpfaOStaticInteractionVolume : public CCMpfaInteractionVolumeBase< CCMpf using IndexSet = typename Traits::IndexSet; using GridIndexType = typename GridView::IndexSet::IndexType; using LocalIndexType = typename Traits::LocalIndexType; - using Stencil = typename Traits::Stencil; - - //! For the o method, the interaction volume stencil can be taken directly - //! from the nodal index set, which always uses dynamic types to be compatible - //! on the boundaries and unstructured grids. Thus, we have to make sure that - //! the type set for the stencils in the traits is castable. - static_assert( std::is_convertible<Stencil*, typename IndexSet::GridStencilType*>::value, - "The o-method uses the (dynamic) nodal index set's stencil as the interaction volume stencil. " - "Using a different type is not permissive here." ); + using Stencil = typename IndexSet::GridStencilType; //! Data attached to scvf touching Dirichlet boundaries. //! For the default o-scheme, we only store the corresponding vol vars index. diff --git a/dumux/porousmediumflow/1p/incompressiblelocalresidual.hh b/dumux/porousmediumflow/1p/incompressiblelocalresidual.hh index 9e0a78bb7a..dfdc173f08 100644 --- a/dumux/porousmediumflow/1p/incompressiblelocalresidual.hh +++ b/dumux/porousmediumflow/1p/incompressiblelocalresidual.hh @@ -124,9 +124,9 @@ public: / curElemVolVars[scvf.insideScvIdx()].viscosity(); const auto& fluxVarsCache = elemFluxVarsCache[scvf]; + const auto& stencil = fluxVarsCache.advectionStencil(); if (fluxVarsCache.usesSecondaryIv()) { - const auto& stencil = fluxVarsCache.advectionStencilSecondaryIv(); const auto& tij = fluxVarsCache.advectionTijSecondaryIv(); assert(stencil.size() == tij.size()); @@ -141,7 +141,6 @@ public: } else { - const auto& stencil = fluxVarsCache.advectionStencilPrimaryIv(); const auto& tij = fluxVarsCache.advectionTijPrimaryIv(); assert(stencil.size() == tij.size()); -- GitLab