diff --git a/dumux/discretization/staggered/freeflow/elementvolumevariables.hh b/dumux/discretization/staggered/freeflow/elementvolumevariables.hh index 0ebac5885093c6a8664a3465df23607e2096ffe0..808853aec69b31c34dc17b85b6e5c22b779185a1 100644 --- a/dumux/discretization/staggered/freeflow/elementvolumevariables.hh +++ b/dumux/discretization/staggered/freeflow/elementvolumevariables.hh @@ -31,6 +31,7 @@ #include <dune/common/exceptions.hh> #include <dumux/discretization/staggered/elementsolution.hh> +#include <dumux/common/typetraits/vector.hh> namespace Dumux { @@ -103,7 +104,7 @@ private: template<class GVV> class StaggeredElementVolumeVariables<GVV, /*cachingEnabled*/false> { - using Indices = typename GVV::Indices; //TODO: get them out of the volvars + using PrimaryVariables = typename GVV::VolumeVariables::PrimaryVariables; public: //! export type of the grid volume variables @@ -116,9 +117,20 @@ public: StaggeredElementVolumeVariables(const GridVolumeVariables& gridVolVars) : gridVolVarsPtr_(&gridVolVars) {} + //! Binding of an element, prepares the volume variables within the element stencil + //! called by the local jacobian to prepare element assembly. Specialization callable with MultiTypeBlockVector. + template<class FVElementGeometry, class ...Args> + void bind(const typename FVElementGeometry::FVGridGeometry::GridView::template Codim<0>::Entity& element, + const FVElementGeometry& fvGeometry, + const Dune::MultiTypeBlockVector<Args...>& sol) + { + // forward to the actual method + bind(element, fvGeometry, sol[FVElementGeometry::FVGridGeometry::cellCenterIdx()]); + } + //! Binding of an element, prepares the volume variables within the element stencil //! called by the local jacobian to prepare element assembly - template<class FVElementGeometry, class SolutionVector> + template<class FVElementGeometry, class SolutionVector, typename std::enable_if_t<!isMultiTypeBlockVector<SolutionVector>(), int> = 0> void bind(const typename FVElementGeometry::FVGridGeometry::GridView::template Codim<0>::Entity& element, const FVElementGeometry& fvGeometry, const SolutionVector& sol) @@ -128,7 +140,7 @@ public: const auto& problem = gridVolVars().problem(); const auto& fvGridGeometry = fvGeometry.fvGridGeometry(); const auto globalI = fvGridGeometry.elementMapper().index(element); - const auto map = fvGridGeometry.connectivityMap(); + const auto& map = fvGridGeometry.connectivityMap(); constexpr auto cellCenterIdx = FVElementGeometry::FVGridGeometry::cellCenterIdx(); const auto& connectivityMapI = map(cellCenterIdx, cellCenterIdx, globalI); const auto numDofs = connectivityMapI.size(); @@ -140,16 +152,13 @@ public: volVarIndices_.resize(numDofs); int localIdx = 0; - using CellCenterPrimaryVariables = typename SolutionVector::value_type; - // Update the volume variables of the element at hand and the neighboring elements for (auto globalJ : connectivityMapI) { const auto& elementJ = fvGridGeometry.element(globalJ); auto&& scvJ = fvGeometry.scv(globalJ); - CellCenterPrimaryVariables priVars(0.0); - priVars = sol[cellCenterIdx][globalJ]; - auto elemSol = elementSolution<FVElementGeometry>(std::move(priVars)); + + const auto elemSol = makeElementSolutionFromCellCenterPrivars<PrimaryVariables>(sol[globalJ]); volumeVariables_[localIdx].update(elemSol, problem, elementJ, @@ -168,7 +177,7 @@ public: volumeVariables_.resize(localIdx+1); volVarIndices_.resize(localIdx+1); - auto boundaryPriVars = GVV::Traits::getBoundaryPriVars(problem, sol, element, scvf); + auto boundaryPriVars = gridVolVars().getBoundaryPriVars(problem, sol, element, scvf); auto elemSol = elementSolution<FVElementGeometry>(std::move(boundaryPriVars)); volumeVariables_[localIdx].update(elemSol, problem, @@ -179,26 +188,34 @@ public: } } + //! Binding of an element, prepares the volume variables within the element stencil + //! called by the local jacobian to prepare element assembly. Specialization callable with MultiTypeBlockVector. + template<class FVElementGeometry, class ...Args> + void bindElement(const typename FVElementGeometry::FVGridGeometry::GridView::template Codim<0>::Entity& element, + const FVElementGeometry& fvGeometry, + const Dune::MultiTypeBlockVector<Args...>& sol) + { + // forward to the actual method + bindElement(element, fvGeometry, sol[FVElementGeometry::FVGridGeometry::cellCenterIdx()]); + } + //! Binding of an element, prepares only the volume variables of the element. //! Specialization for Staggered models - template<class FVElementGeometry, class SolutionVector> + template<class FVElementGeometry, class SolutionVector, typename std::enable_if_t<!isMultiTypeBlockVector<SolutionVector>(), int> = 0> void bindElement(const typename FVElementGeometry::FVGridGeometry::GridView::template Codim<0>::Entity& element, const FVElementGeometry& fvGeometry, const SolutionVector& sol) { clear(); - const auto eIdx = fvGeometry.fvGridGeometry().elementMapper().index(element); + const auto globalI = fvGeometry.fvGridGeometry().elementMapper().index(element); volumeVariables_.resize(1); volVarIndices_.resize(1); // update the volume variables of the element - auto&& scv = fvGeometry.scv(eIdx); - using CellCenterPrimaryVariables = typename SolutionVector::value_type; - CellCenterPrimaryVariables priVars(0.0); - constexpr auto cellCenterIdx = FVElementGeometry::FVGridGeometry::cellCenterIdx(); - priVars = sol[cellCenterIdx][eIdx]; - auto elemSol = elementSolution<FVElementGeometry>(std::move(priVars)); + auto&& scv = fvGeometry.scv(globalI); + + const auto elemSol = makeElementSolutionFromCellCenterPrivars<PrimaryVariables>(sol[globalI]); volumeVariables_[0].update(elemSol, gridVolVars().problem(), element, diff --git a/dumux/discretization/staggered/freeflow/gridvolumevariables.hh b/dumux/discretization/staggered/freeflow/gridvolumevariables.hh index 2d0a37f1b7d55f8ccc7f651eab8408e4fca71222..1c3505c960101e7a6af8df0cfe4889807340f4f5 100644 --- a/dumux/discretization/staggered/freeflow/gridvolumevariables.hh +++ b/dumux/discretization/staggered/freeflow/gridvolumevariables.hh @@ -227,6 +227,7 @@ class StaggeredGridVolumeVariables<Traits, /*cachingEnabled*/false> { using ThisType = StaggeredGridVolumeVariables<Traits, false>; using Problem = typename Traits::Problem; + using PrimaryVariables = typename Traits::VolumeVariables::PrimaryVariables; public: //! export the type of the VolumeVariables @@ -246,6 +247,14 @@ public: const Problem& problem() const { return *problemPtr_;} + //! Returns the primary variales used for the boundary volVars and checks for admissable + //! combinations for boundary conditions. + template<class... Args> + PrimaryVariables getBoundaryPriVars(Args&&... args) const + { + return Traits::getBoundaryPriVars(std::forward<Args>(args)...); + } + private: const Problem* problemPtr_; diff --git a/dumux/multidomain/subdomainstaggeredlocalassembler.hh b/dumux/multidomain/subdomainstaggeredlocalassembler.hh index 15d1033a89ffde58f9b24834f37f48056b5c6bfe..bb0247414157b2037d6f20439d6de74656a130d6 100644 --- a/dumux/multidomain/subdomainstaggeredlocalassembler.hh +++ b/dumux/multidomain/subdomainstaggeredlocalassembler.hh @@ -392,7 +392,7 @@ public: // get some references for convenience auto& couplingManager = this->couplingManager(); const auto& element = this->element(); - const auto& curSol = this->curSol()[domainId]; + const auto& curSol = this->curSol(); auto&& fvGeometry = this->fvGeometry(); auto&& curElemVolVars = this->curElemVolVars(); auto&& curElemFaceVars = this->curElemFaceVars();