diff --git a/dumux/common/properties.hh b/dumux/common/properties.hh index 2cbc1b8ed7f371161403edffa0f0962cea284e1b..4899e913ebb381a2709c9706823b7a343c2ba63b 100644 --- a/dumux/common/properties.hh +++ b/dumux/common/properties.hh @@ -98,6 +98,7 @@ NEW_PROP_TAG(ElementFluxVariablesCache); //!< A local vector of flux v NEW_PROP_TAG(GridFluxVariablesCache); //!< The global vector of flux variable containers NEW_PROP_TAG(EnableGridFluxVariablesCache); //!< specifies if data on flux vars should be saved (faster, but more memory consuming) NEW_PROP_TAG(GridVariables); //!< The grid variables object managing variable data on the grid (volvars/fluxvars cache) +NEW_PROP_TAG(MaxNumBranchesPerScvf); //!< The maximum number of branches allowed per scvf (used for static memory allocation) ///////////////////////////////////////////////////////////////// // Additional properties used by the cell-centered mpfa schemes: diff --git a/dumux/discretization/cellcentered/connectivitymap.hh b/dumux/discretization/cellcentered/connectivitymap.hh index ad4d8fe31441d3ff7aa2cbee56275dd973043eea..0f935b288ec93fa1040d5f4121963ba02a01cec2 100644 --- a/dumux/discretization/cellcentered/connectivitymap.hh +++ b/dumux/discretization/cellcentered/connectivitymap.hh @@ -50,6 +50,7 @@ template<class TypeTag> class CCSimpleConnectivityMap { using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); + using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry); using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using IndexType = typename GridView::IndexSet::IndexType; using FluxStencil = Dumux::FluxStencil<TypeTag>; @@ -57,10 +58,10 @@ class CCSimpleConnectivityMap struct DataJ { IndexType globalJ; - typename FluxStencil::Stencil scvfsJ; + Dune::ReservedVector<IndexType, FluxStencil::maxNumScvfJForI> scvfsJ; // A list of additional scvfs is needed for compatibility // reasons with more complex connectivity maps (see mpfa) - std::vector<IndexType> additionalScvfs; + Dune::ReservedVector<IndexType, FluxStencil::maxNumScvfJForI> additionalScvfs; }; using Map = std::vector<std::vector<DataJ>>; @@ -76,7 +77,11 @@ public: { map_.clear(); map_.resize(fvGridGeometry.gridView().size(0)); - Dune::ReservedVector<std::pair<IndexType, DataJ>, FluxStencil::maxSize*2*GridView::dimension> dataJForI; + + // container to store for each element J the elements I that appear in J's flux stencils + static constexpr int maxNumJ = FluxStencil::maxFluxStencilSize*FVElementGeometry::maxNumElementScvfs; + Dune::ReservedVector<std::pair<IndexType, DataJ>, maxNumJ> dataJForI; + for (const auto& element : elements(fvGridGeometry.gridView())) { // We are looking for the elements I, for which this element J is in the flux stencil diff --git a/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh b/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh index aa026fdf82fb47ceec3516224a3c1a7c6fb4dbc3..6595e3576c3b987d4118d7c2384e21b7377e64d3 100644 --- a/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh +++ b/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh @@ -72,6 +72,8 @@ public: using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); //! the maximum number of scvs per element static constexpr std::size_t maxNumElementScvs = 1; + //! the maximum number of scvfs per element (use cubes for maximum) + static constexpr std::size_t maxNumElementScvfs = GridView::dimension == 3 ? 6 : 4; //! Constructor CCTpfaFVElementGeometry(const FVGridGeometry& fvGridGeometry) @@ -187,6 +189,8 @@ public: using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); //! the maximum number of scvs per element static constexpr std::size_t maxNumElementScvs = 1; + //! the maximum number of scvfs per element (use cubes for maximum) + static constexpr std::size_t maxNumElementScvfs = dim == 3 ? 6 : 4; //! Constructor CCTpfaFVElementGeometry(const FVGridGeometry& fvGridGeometry) diff --git a/dumux/discretization/cellcentered/tpfa/properties.hh b/dumux/discretization/cellcentered/tpfa/properties.hh index 8e2bca2a4857885649ade46a74e54528762004b1..4e77be6a2f5e28d9573d0f3d902b364b464acaab 100644 --- a/dumux/discretization/cellcentered/tpfa/properties.hh +++ b/dumux/discretization/cellcentered/tpfa/properties.hh @@ -82,6 +82,19 @@ SET_TYPE_PROP(CCTpfaModel, ElementFluxVariablesCache, CCTpfaElementFluxVariables //! The global current volume variables vector class SET_TYPE_PROP(CCTpfaModel, GridVolumeVariables, CCGridVolumeVariables<TypeTag, GET_PROP_VALUE(TypeTag, EnableGridVolumeVariablesCache)>); +//! Set the maximum admissible number of branches per scvf +SET_PROP(CCTpfaModel, MaxNumBranchesPerScvf) +{ +private: + using GridView = typename GET_PROP_TYPE(TypeTag, GridView); + static constexpr int dim = GridView::dimension; + static constexpr int dimWorld = GridView::dimensionworld; + +public: + //! Per default, we allow for 8 neighbors on network/surface grids + static const std::size_t value = dim < dimWorld ? 9 : 2; +}; + //! The sub control volume SET_PROP(CCTpfaModel, SubControlVolume) { diff --git a/dumux/discretization/fluxstencil.hh b/dumux/discretization/fluxstencil.hh index db2f631b762bdbfd8a6cc9095aeeba13085f4dc5..6ee56e89d2050398bc4905ca2fd30ed37677e16e 100644 --- a/dumux/discretization/fluxstencil.hh +++ b/dumux/discretization/fluxstencil.hh @@ -59,12 +59,16 @@ class FluxStencilImplementation<TypeTag, DiscretizationMethods::CCTpfa> using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); using Element = typename GridView::template Codim<0>::Entity; using IndexType = typename GridView::IndexSet::IndexType; - static constexpr bool isNetwork = int(GridView::dimension) < int(GridView::dimensionworld); public: - // we assume a maxium of 8 neighbors in embedded network grids otherwise max stencil size is 2 - static constexpr std::size_t maxSize = isNetwork ? 9 : 2; - using Stencil = Dune::ReservedVector<IndexType, maxSize>; + //! The maximum number of elements in a flux stencil (equal to max number of branches) + static constexpr int maxFluxStencilSize = GET_PROP_VALUE(TypeTag, MaxNumBranchesPerScvf); + + //! States how many scvfs of an element J might have an element I in the flux stencil + static constexpr int maxNumScvfJForI = 1; + + //! The flux stencil type + using Stencil = Dune::ReservedVector<IndexType, maxFluxStencilSize>; static Stencil stencil(const Element& element, const FVElementGeometry& fvGeometry,