Skip to content
Snippets Groups Projects
Commit 5ece9477 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[tpfa] use more Dune::ReservedVectors in assembly map

This requires additional info to be supplied by the FluxStencils. For example,
this commit further introduces the property MaxNumBranchesPerScvf with
which the size for these reserved vectors is parameterized for network/surface
grids.
parent c5f6ba07
No related branches found
No related tags found
1 merge request!734Feature/improve fvassembler
......@@ -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:
......
......@@ -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
......
......@@ -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)
......
......@@ -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)
{
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment