From d5c1b2757062a69f53fb906713d609277eae9481 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Fri, 15 Dec 2017 11:18:40 +0100 Subject: [PATCH] [disc] Remove flux stencil from base fluxvars. Use directly. --- .../cellcentered/connectivitymap.hh | 7 +++- .../cellcentered/mpfa/connectivitymap.hh | 1 + .../mpfa/generalconnectivitymap.hh | 12 ++++-- dumux/discretization/fluxstencil.hh | 24 ------------ dumux/discretization/fluxvariablesbase.hh | 16 ++------ .../cellcentered/tpfa/test_tpfafvgeometry.cc | 24 +++--------- .../tpfa/test_tpfafvgeometry_nonconforming.cc | 37 ++++++------------- 7 files changed, 33 insertions(+), 88 deletions(-) diff --git a/dumux/discretization/cellcentered/connectivitymap.hh b/dumux/discretization/cellcentered/connectivitymap.hh index 2c7447599b..5c69551e77 100644 --- a/dumux/discretization/cellcentered/connectivitymap.hh +++ b/dumux/discretization/cellcentered/connectivitymap.hh @@ -26,6 +26,9 @@ #define DUMUX_CC_CONNECTIVITY_MAP_HH #include <vector> +#include <utility> +#include <dumux/common/properties.hh> +#include <dumux/discretization/fluxstencil.hh> namespace Dumux { @@ -44,9 +47,9 @@ template<class TypeTag> class CCSimpleConnectivityMap { using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables); using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using IndexType = typename GridView::IndexSet::IndexType; + using FluxStencil = Dumux::FluxStencil<TypeTag>; struct DataJ { @@ -84,7 +87,7 @@ public: // loop over sub control faces for (auto&& scvf : scvfs(fvGeometry)) { - const auto& stencil = FluxVariables::computeStencil(element, fvGeometry, scvf); + const auto& stencil = FluxStencil::stencil(element, fvGeometry, scvf); // insert our index in the neighbor stencils of the elements in the flux stencil for (auto globalI : stencil) diff --git a/dumux/discretization/cellcentered/mpfa/connectivitymap.hh b/dumux/discretization/cellcentered/mpfa/connectivitymap.hh index 8e08056332..3c7152e75b 100644 --- a/dumux/discretization/cellcentered/mpfa/connectivitymap.hh +++ b/dumux/discretization/cellcentered/mpfa/connectivitymap.hh @@ -24,6 +24,7 @@ #ifndef DUMUX_CC_MPFA_CONNECTIVITY_MAP_HH #define DUMUX_CC_MPFA_CONNECTIVITY_MAP_HH +#include <dumux/common/properties.hh> #include <dumux/discretization/cellcentered/mpfa/methods.hh> #include <dumux/discretization/cellcentered/connectivitymap.hh> #include <dumux/discretization/cellcentered/mpfa/generalconnectivitymap.hh> diff --git a/dumux/discretization/cellcentered/mpfa/generalconnectivitymap.hh b/dumux/discretization/cellcentered/mpfa/generalconnectivitymap.hh index 3c455c5155..fce8cd33d6 100644 --- a/dumux/discretization/cellcentered/mpfa/generalconnectivitymap.hh +++ b/dumux/discretization/cellcentered/mpfa/generalconnectivitymap.hh @@ -24,6 +24,11 @@ #ifndef DUMUX_CC_MPFA_GENERAL_CONNECTIVITY_MAP_HH #define DUMUX_CC_MPFA_GENERAL_CONNECTIVITY_MAP_HH +#include <vector> +#include <utility> +#include <dumux/common/properties.hh> +#include <dumux/discretization/fluxstencil.hh> + namespace Dumux { @@ -40,9 +45,9 @@ class CCMpfaGeneralConnectivityMap { using MpfaHelper = typename GET_PROP_TYPE(TypeTag, MpfaHelper); using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables); using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using IndexType = typename GridView::IndexSet::IndexType; + using FluxStencil = Dumux::FluxStencil<TypeTag>; // To each cell "globalI" there will be a list of "globalJ", in which globalI is part // of the stencil. We save the scvfs over which fluxes depend on globalI and a list of @@ -80,8 +85,7 @@ public: // loop over sub control faces for (auto&& scvf : scvfs(fvGeometry)) { - FluxVariables fluxVars; - const auto& stencil = fluxVars.computeStencil(element, fvGeometry, scvf); + const auto& stencil = FluxStencil::stencil(element, fvGeometry, scvf); // insert our index in the neighbor stencils of the elements in the flux stencil for (auto globalI : stencil) @@ -192,6 +196,6 @@ public: private: Map map_; }; -} +} // end namespace Dumux #endif diff --git a/dumux/discretization/fluxstencil.hh b/dumux/discretization/fluxstencil.hh index d6edbc1be9..23a6090db0 100644 --- a/dumux/discretization/fluxstencil.hh +++ b/dumux/discretization/fluxstencil.hh @@ -45,33 +45,10 @@ class FluxStencilImplementation; template<class TypeTag> using FluxStencil = FluxStencilImplementation<TypeTag, GET_PROP_VALUE(TypeTag, DiscretizationMethod)>; -//! Flux stencil for the box method -template<class TypeTag> -class FluxStencilImplementation<TypeTag, DiscretizationMethods::Box> -{ - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry); - using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); - using Element = typename GridView::template Codim<0>::Entity; - using IndexType = typename GridView::IndexSet::IndexType; - using Stencil = std::vector<IndexType>; - -public: - // This is for compatibility with the cc methods. The flux stencil info is obsolete for the box method. - static Stencil stencil(const Element& element, - const FVElementGeometry& fvGeometry, - const SubControlVolumeFace& scvf) - { - return Stencil(); - } -}; - //! Flux stencil for the cell-centered TPFA scheme template<class TypeTag> class FluxStencilImplementation<TypeTag, DiscretizationMethods::CCTpfa> { - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry); using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); @@ -102,7 +79,6 @@ public: template<class TypeTag> class FluxStencilImplementation<TypeTag, DiscretizationMethods::CCMpfa> { - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry); using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); diff --git a/dumux/discretization/fluxvariablesbase.hh b/dumux/discretization/fluxvariablesbase.hh index d2d74d03b7..f0ecac1fef 100644 --- a/dumux/discretization/fluxvariablesbase.hh +++ b/dumux/discretization/fluxvariablesbase.hh @@ -23,14 +23,12 @@ #ifndef DUMUX_DISCRETIZATION_FLUXVARIABLESBASE_HH #define DUMUX_DISCRETIZATION_FLUXVARIABLESBASE_HH -#include <dumux/discretization/methods.hh> -#include <dumux/discretization/fluxstencil.hh> #include <dumux/discretization/upwindscheme.hh> namespace Dumux { -template<class TypeTag, class UpwindScheme, class FluxStencil> +template<class TypeTag, class UpwindScheme> class FluxVariablesBaseImplementation; /*! @@ -39,7 +37,7 @@ class FluxVariablesBaseImplementation; * The upwind scheme is chosen depending on the discretization method */ template<class TypeTag> -using FluxVariablesBase = FluxVariablesBaseImplementation<TypeTag, UpwindScheme<TypeTag>, FluxStencil<TypeTag>>; +using FluxVariablesBase = FluxVariablesBaseImplementation<TypeTag, UpwindScheme<TypeTag>>; /*! * \ingroup Discretization @@ -48,7 +46,7 @@ using FluxVariablesBase = FluxVariablesBaseImplementation<TypeTag, UpwindScheme< * \param TypeTag The type tag * \param UpwindScheme The type used for the upwinding of the advective fluxes */ -template<class TypeTag, class UpwindScheme, class FluxStencil> +template<class TypeTag, class UpwindScheme> class FluxVariablesBaseImplementation { using Problem = typename GET_PROP_TYPE(TypeTag, Problem); @@ -105,14 +103,6 @@ public: return UpwindScheme::apply(*this, upwindTerm, flux, phaseIdx); } - static Stencil computeStencil(const Element& element, - const FVElementGeometry& fvGeometry, - const SubControlVolumeFace& scvf) - { - //! Forward to the discretization specific implementation - return FluxStencil::stencil(element, fvGeometry, scvf); - } - private: const Problem* problemPtr_; //! Pointer to the problem const Element* elementPtr_; //! Pointer to the element at hand diff --git a/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc b/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc index baa2ecac34..87109b1ced 100644 --- a/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc +++ b/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc @@ -34,26 +34,12 @@ #include <dumux/common/properties.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> -//! Dummy flux variables class so that we can update the connectivity map -class MockFluxVariables -{ -public: - template<class Element, class FvGeometry, class Scvf> - static std::vector<std::size_t> computeStencil(const Element& element, - const FvGeometry& fvGeometry, - const Scvf& scvf) - { - return std::vector<std::size_t>(); - } -}; - namespace Dumux { - namespace Properties { - NEW_TYPE_TAG(TestFVGeometry, INHERITS_FROM(CCTpfaModel)); - SET_TYPE_PROP(TestFVGeometry, Grid, Dune::YaspGrid<2>); - SET_TYPE_PROP(TestFVGeometry, FluxVariables, MockFluxVariables); - } -} +namespace Properties { +NEW_TYPE_TAG(TestFVGeometry, INHERITS_FROM(CCTpfaModel)); +SET_TYPE_PROP(TestFVGeometry, Grid, Dune::YaspGrid<2>); +} // end namespace Properties +} // end namespace Dumux template<class T> class NoopFunctor { diff --git a/test/discretization/cellcentered/tpfa/test_tpfafvgeometry_nonconforming.cc b/test/discretization/cellcentered/tpfa/test_tpfafvgeometry_nonconforming.cc index 34548b1a6a..89ac7daad5 100644 --- a/test/discretization/cellcentered/tpfa/test_tpfafvgeometry_nonconforming.cc +++ b/test/discretization/cellcentered/tpfa/test_tpfafvgeometry_nonconforming.cc @@ -36,33 +36,18 @@ #include <dumux/common/properties.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> -//! Dummy flux variables class so that we can update the connectivity map -class MockFluxVariables -{ -public: - template<class Element, class FvGeometry, class Scvf> - static std::vector<std::size_t> computeStencil(const Element& element, - const FvGeometry& fvGeometry, - const Scvf& scvf) - { - return std::vector<std::size_t>(); - } -}; - namespace Dumux { - namespace Properties{ - //! Test without using global caching of the geometries - NEW_TYPE_TAG(TestFVGeometryNonConforming, INHERITS_FROM(CCTpfaModel)); - SET_TYPE_PROP(TestFVGeometryNonConforming, Grid, Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>); - SET_TYPE_PROP(TestFVGeometryNonConforming, FluxVariables, MockFluxVariables); - - //! Test using global geometry caching - NEW_TYPE_TAG(TestCachedFVGeometryNonConforming, INHERITS_FROM(CCTpfaModel)); - SET_TYPE_PROP(TestCachedFVGeometryNonConforming, Grid, Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>); - SET_BOOL_PROP(TestCachedFVGeometryNonConforming, EnableFVGridGeometryCache, true); - SET_TYPE_PROP(TestCachedFVGeometryNonConforming, FluxVariables, MockFluxVariables); - } -} +namespace Properties{ +//! Test without using global caching of the geometries +NEW_TYPE_TAG(TestFVGeometryNonConforming, INHERITS_FROM(CCTpfaModel)); +SET_TYPE_PROP(TestFVGeometryNonConforming, Grid, Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>); + +//! Test using global geometry caching +NEW_TYPE_TAG(TestCachedFVGeometryNonConforming, INHERITS_FROM(CCTpfaModel)); +SET_TYPE_PROP(TestCachedFVGeometryNonConforming, Grid, Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>); +SET_BOOL_PROP(TestCachedFVGeometryNonConforming, EnableFVGridGeometryCache, true); +} // end namespace Properties +} // end namespace Dumux //! epsilon for checking direction of scvf normals constexpr double eps = 1e-6; -- GitLab