Commit f28e90b6 authored by Dennis Gläser's avatar Dennis Gläser Committed by Timo Koch
Browse files

[cc] make flux stencil independent of type tag

parent ae32d4af
......@@ -122,6 +122,7 @@ class CCLocalAssembler<TypeTag, Assembler, DiffMethod::numeric, /*implicit=*/tru
using LocalResidualValues = typename GET_PROP_TYPE(TypeTag, NumEqVector);
using Element = typename GET_PROP_TYPE(TypeTag, GridView)::template Codim<0>::Entity;
using ElementSolutionVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector);
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
using JacobianMatrix = typename GET_PROP_TYPE(TypeTag, JacobianMatrix);
......@@ -129,8 +130,8 @@ class CCLocalAssembler<TypeTag, Assembler, DiffMethod::numeric, /*implicit=*/tru
enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
enum { dim = GET_PROP_TYPE(TypeTag, GridView)::dimension };
using FluxStencil = Dumux::FluxStencil<TypeTag>;
static constexpr int maxNeighbors = FluxStencil::maxFluxStencilSize*FVElementGeometry::maxNumElementScvfs;
using FluxStencil = Dumux::FluxStencil<FVElementGeometry>;
static constexpr int maxElementStencilSize = FVGridGeometry::maxElementStencilSize;
static constexpr bool enableGridFluxVarsCache = GET_PROP_VALUE(TypeTag, EnableGridFluxVariablesCache);
public:
......@@ -164,11 +165,11 @@ public:
const auto numNeighbors = connectivityMap[globalI].size();
// container to store the neighboring elements
Dune::ReservedVector<Element, maxNeighbors+1> neighborElements;
Dune::ReservedVector<Element, maxElementStencilSize> neighborElements;
neighborElements.resize(numNeighbors);
// assemble the undeflected residual
using Residuals = ReservedBlockVector<LocalResidualValues, maxNeighbors+1>;
using Residuals = ReservedBlockVector<LocalResidualValues, maxElementStencilSize>;
Residuals origResiduals(numNeighbors + 1); origResiduals = 0.0;
origResiduals[0] = this->evalLocalResidual()[0];
......
......@@ -53,7 +53,7 @@ class CCSimpleConnectivityMap
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>;
using FluxStencil = Dumux::FluxStencil<FVElementGeometry>;
struct DataJ
{
......@@ -78,9 +78,8 @@ public:
map_.clear();
map_.resize(fvGridGeometry.gridView().size(0));
// 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;
// container to store for each element J the elements I which have J in their flux stencil
Dune::ReservedVector<std::pair<IndexType, DataJ>, FVGridGeometry::maxElementStencilSize> dataJForI;
for (const auto& element : elements(fvGridGeometry.gridView()))
{
......
......@@ -59,20 +59,19 @@ class CCMpfaFVGridGeometry;
template<class TypeTag>
class CCMpfaFVGridGeometry<TypeTag, true> : public BaseFVGridGeometry<TypeTag>
{
public:
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
private:
using ParentType = BaseFVGridGeometry<TypeTag>;
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using ElementMapper = typename GET_PROP_TYPE(TypeTag, ElementMapper);
using MpfaHelper = typename GET_PROP_TYPE(TypeTag, MpfaHelper);
using ElementMapper = typename GET_PROP_TYPE(TypeTag, ElementMapper);
using PrimaryInteractionVolume = typename GET_PROP_TYPE(TypeTag, PrimaryInteractionVolume);
using DualGridNodalIndexSet = typename GET_PROP_TYPE(TypeTag, DualGridNodalIndexSet);
using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using ScvfOutsideGridIndexStorage = typename SubControlVolumeFace::Traits::OutsideGridIndexStorage;
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
static constexpr int dim = GridView::dimension;
static constexpr int dimWorld = GridView::dimensionworld;
......@@ -82,6 +81,7 @@ class CCMpfaFVGridGeometry<TypeTag, true> : public BaseFVGridGeometry<TypeTag>
using CoordScalar = typename GridView::ctype;
using GridIndexType = typename GridView::IndexSet::IndexType;
using LocalIndexType = typename PrimaryInteractionVolume::Traits::LocalIndexType;
using ScvfOutsideGridIndexStorage = typename SubControlVolumeFace::Traits::OutsideGridIndexStorage;
using GridIVIndexSets = CCMpfaGridInteractionVolumeIndexSets<TypeTag>;
using ConnectivityMap = CCMpfaConnectivityMap<TypeTag>;
......@@ -89,9 +89,14 @@ class CCMpfaFVGridGeometry<TypeTag, true> : public BaseFVGridGeometry<TypeTag>
using ReferenceElements = typename Dune::ReferenceElements<CoordScalar, dim>;
public:
//! export discretization method
//! Export the discretization method this geometry belongs to
static constexpr DiscretizationMethods discretizationMethod = DiscretizationMethods::CCMpfa;
//! The maximum admissible stencil size (used for static memory allocation during assembly)
// TODO: Re-implement and obtain from nodal index set (for now we use a high value)
static constexpr int maxElementStencilSize = (dim < dimWorld || dim == 3) ? 45 : 15;
using DualGridNodalIndexSet = typename GET_PROP_TYPE(TypeTag, DualGridNodalIndexSet);
using SecondaryIvIndicatorType = std::function<bool(const Element&, const Intersection&, bool)>;
//! Constructor without indicator function for secondary interaction volumes
......@@ -397,20 +402,19 @@ private:
template<class TypeTag>
class CCMpfaFVGridGeometry<TypeTag, false> : public BaseFVGridGeometry<TypeTag>
{
public:
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
private:
using ParentType = BaseFVGridGeometry<TypeTag>;
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using ElementMapper = typename GET_PROP_TYPE(TypeTag, ElementMapper);
using MpfaHelper = typename GET_PROP_TYPE(TypeTag, MpfaHelper);
using ElementMapper = typename GET_PROP_TYPE(TypeTag, ElementMapper);
using PrimaryInteractionVolume = typename GET_PROP_TYPE(TypeTag, PrimaryInteractionVolume);
using DualGridNodalIndexSet = typename GET_PROP_TYPE(TypeTag, DualGridNodalIndexSet);
using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using ScvfOutsideGridIndexStorage = typename SubControlVolumeFace::Traits::OutsideGridIndexStorage;
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
static constexpr int dim = GridView::dimension;
static constexpr int dimWorld = GridView::dimensionworld;
......@@ -420,6 +424,7 @@ class CCMpfaFVGridGeometry<TypeTag, false> : public BaseFVGridGeometry<TypeTag>
using CoordScalar = typename GridView::ctype;
using GridIndexType = typename GridView::IndexSet::IndexType;
using LocalIndexType = typename PrimaryInteractionVolume::Traits::LocalIndexType;
using ScvfOutsideGridIndexStorage = typename SubControlVolumeFace::Traits::OutsideGridIndexStorage;
using GridIVIndexSets = CCMpfaGridInteractionVolumeIndexSets<TypeTag>;
using ConnectivityMap = CCMpfaConnectivityMap<TypeTag>;
......@@ -427,9 +432,14 @@ class CCMpfaFVGridGeometry<TypeTag, false> : public BaseFVGridGeometry<TypeTag>
using ReferenceElements = typename Dune::ReferenceElements<CoordScalar, dim>;
public:
//! export discretization method
//! Export the discretization method this geometry belongs to
static constexpr DiscretizationMethods discretizationMethod = DiscretizationMethods::CCMpfa;
//! The maximum admissible stencil size (used for static memory allocation during assembly)
// TODO: Re-implement and obtain from nodal index set (for now we use a high value)
static constexpr int maxElementStencilSize = (dim < dimWorld || dim == 3) ? 45 : 15;
using DualGridNodalIndexSet = typename GET_PROP_TYPE(TypeTag, DualGridNodalIndexSet);
using SecondaryIvIndicator = std::function<bool(const Element&, const Intersection&, bool)>;
//! Constructor without indicator function for secondary interaction volumes
......
......@@ -57,16 +57,19 @@ class CCTpfaFVGridGeometry
template<class TypeTag>
class CCTpfaFVGridGeometry<TypeTag, true> : public BaseFVGridGeometry<TypeTag>
{
using ParentType = BaseFVGridGeometry<TypeTag>;
public:
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using IndexType = typename GridView::IndexSet::IndexType;
using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using ScvfGridIndexStorage = typename SubControlVolumeFace::Traits::GridIndexStorage;
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
private:
using ParentType = BaseFVGridGeometry<TypeTag>;
using ConnectivityMap = CCSimpleConnectivityMap<TypeTag>;
using ElementMapper = typename GET_PROP_TYPE(TypeTag, ElementMapper);
using ScvfGridIndexStorage = typename SubControlVolumeFace::Traits::GridIndexStorage;
using IndexType = typename GridView::IndexSet::IndexType;
using Element = typename GridView::template Codim<0>::Entity;
using ConnectivityMap = CCSimpleConnectivityMap<TypeTag>;
static const int dim = GridView::dimension;
static const int dimWorld = GridView::dimensionworld;
......@@ -78,9 +81,14 @@ class CCTpfaFVGridGeometry<TypeTag, true> : public BaseFVGridGeometry<TypeTag>
friend typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
public:
//! export discretization method
//! Export the discretization method this geometry belongs to
static constexpr DiscretizationMethods discretizationMethod = DiscretizationMethods::CCTpfa;
//! The maximum admissible stencil size (used for static memory allocation during assembly)
//! Per default, we allow for 9 branches per scvf on network/surface grids
static constexpr int maxElementStencilSize = (dim < dimWorld) ? FVElementGeometry::maxNumElementScvfs*8 + 1
: FVElementGeometry::maxNumElementScvfs + 1;
//! Constructor
CCTpfaFVGridGeometry(const GridView& gridView)
: ParentType(gridView)
......@@ -318,16 +326,19 @@ private:
template<class TypeTag>
class CCTpfaFVGridGeometry<TypeTag, false> : public BaseFVGridGeometry<TypeTag>
{
using ParentType = BaseFVGridGeometry<TypeTag>;
public:
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using IndexType = typename GridView::IndexSet::IndexType;
using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using ScvfGridIndexStorage = typename SubControlVolumeFace::Traits::GridIndexStorage;
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
private:
using ParentType = BaseFVGridGeometry<TypeTag>;
using ConnectivityMap = CCSimpleConnectivityMap<TypeTag>;
using ElementMapper = typename GET_PROP_TYPE(TypeTag, ElementMapper);
using ScvfGridIndexStorage = typename SubControlVolumeFace::Traits::GridIndexStorage;
using IndexType = typename GridView::IndexSet::IndexType;
using Element = typename GridView::template Codim<0>::Entity;
using ConnectivityMap = CCSimpleConnectivityMap<TypeTag>;
static const int dim = GridView::dimension;
static const int dimWorld = GridView::dimensionworld;
......@@ -340,9 +351,14 @@ class CCTpfaFVGridGeometry<TypeTag, false> : public BaseFVGridGeometry<TypeTag>
Dune::ReservedVector<IndexType, 1> >;
public:
//! export discretization method
//! Export the discretization method this geometry belongs to
static constexpr DiscretizationMethods discretizationMethod = DiscretizationMethods::CCTpfa;
//! The maximum admissible stencil size (used for static memory allocation during assembly)
//! Per default, we allow for 9 branches per scvf on network/surface grids
static constexpr int maxElementStencilSize = (dim < dimWorld) ? FVElementGeometry::maxNumElementScvfs*8 + 1
: FVElementGeometry::maxNumElementScvfs + 1;
//! Constructor
CCTpfaFVGridGeometry(const GridView& gridView)
: ParentType(gridView)
......
......@@ -25,16 +25,11 @@
#define DUMUX_DISCRETIZATION_FLUXSTENCIL_HH
#include <dune/common/reservedvector.hh>
#include <dumux/common/properties.hh>
#include <dumux/discretization/methods.hh>
namespace Dumux
{
//! Forward declaration of the upwind scheme implementation
template<class TypeTag, DiscretizationMethods Method>
class FluxStencilImplementation;
/*!
* \ingroup Discretization
* \brief The flux stencil specialized for different discretization schemes
......@@ -44,32 +39,31 @@ class FluxStencilImplementation;
* since we use the flux stencil for matrix and assembly. This might lead to some zeros stored
* in the matrix.
*/
template<class TypeTag>
using FluxStencil = FluxStencilImplementation<TypeTag, GET_PROP_VALUE(TypeTag, DiscretizationMethod)>;
template<class FVElementGeometry, DiscretizationMethods Method = FVElementGeometry::FVGridGeometry::discretizationMethod>
class FluxStencil;
/*
* \ingroup Discretization
* \brief Flux stencil specialization for the cell-centered tpfa scheme
* \tparam FVElementGeometry The local view on the finite volume grid geometry
*/
template<class TypeTag>
class FluxStencilImplementation<TypeTag, DiscretizationMethods::CCTpfa>
template<class FVElementGeometry>
class FluxStencil<FVElementGeometry, DiscretizationMethods::CCTpfa>
{
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 FVGridGeometry = typename FVElementGeometry::FVGridGeometry;
using SubControlVolumeFace = typename FVGridGeometry::SubControlVolumeFace;
using GridView = typename FVGridGeometry::GridView;
using Element = typename GridView::template Codim<0>::Entity;
using IndexType = typename GridView::IndexSet::IndexType;
public:
//! The maximum number of elements in a flux stencil
static constexpr int maxFluxStencilSize = GET_PROP_VALUE(TypeTag, MaxNumNeighborsPerScvf);
//! Each cell I couples to a cell J always only via one face
using ScvfStencilIForJ = Dune::ReservedVector<IndexType, 1>;
//! The flux stencil type
using Stencil = Dune::ReservedVector<IndexType, maxFluxStencilSize>;
using Stencil = typename SubControlVolumeFace::Traits::GridIndexStorage;
//! Returns the flux stencil
static Stencil stencil(const Element& element,
const FVElementGeometry& fvGeometry,
const SubControlVolumeFace& scvf)
......@@ -91,41 +85,28 @@ public:
/*
* \ingroup Discretization
* \brief Flux stencil specialization for the cell-centered mpfa scheme
* \tparam FVElementGeometry The local view on the finite volume grid geometry
*/
template<class TypeTag>
class FluxStencilImplementation<TypeTag, DiscretizationMethods::CCMpfa>
template<class FVElementGeometry>
class FluxStencil<FVElementGeometry, DiscretizationMethods::CCMpfa>
{
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 FVGridGeometry = typename FVElementGeometry::FVGridGeometry;
using SubControlVolumeFace = typename FVGridGeometry::SubControlVolumeFace;
using GridView = typename FVGridGeometry::GridView;
using Element = typename GridView::template Codim<0>::Entity;
using IndexType = typename GridView::IndexSet::IndexType;
static constexpr int dim = GridView::dimension;
// Use the stencil type of the primary interaction volume
using NodalIndexSet = typename GET_PROP_TYPE(TypeTag, DualGridNodalIndexSet);
using NodalIndexSet = typename FVGridGeometry::DualGridNodalIndexSet;
public:
//! The maximum number of elements in a flux stencil (equal to number of elements at node)
static constexpr int maxFluxStencilSize = NodalIndexSet::maxNumElementsAtNode;
//! We don't know yet how many faces couple to a neighboring element
using ScvfStencilIForJ = std::vector<IndexType>;
//! The flux stencil type
using Stencil = typename NodalIndexSet::GridStencilType;
/*
* \brief Returns a set of grid element indices that participate in the
* flux calculations on a given scvf.
*
* \note The interaction volume index sets must use the same type for the
* stencils as the nodal index set. If not, the compiler will complain here.
*
* \param element The grid element
* \param fvGeometry The finite volume geometry of this element
* \param scvf The sub-control volume face embedded in this element
*/
//! Returns the indices of the elements required for flux calculation on an scvf.
static const Stencil& stencil(const Element& element,
const FVElementGeometry& fvGeometry,
const SubControlVolumeFace& scvf)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment