44: 
public FacetCouplingManager<MDTraits, CouplingMapper, bulkDomainId, lowDimDomainId, DiscretizationMethods::CCTpfa>
 
   49    using BulkIdType = 
typename MDTraits::template SubDomain<bulkDomainId>::Index;
 
   50    using LowDimIdType = 
typename MDTraits::template SubDomain<lowDimDomainId>::Index;
 
   51    static constexpr auto bulkId = BulkIdType();
 
   52    static constexpr auto lowDimId = LowDimIdType();
 
   55    template<std::
size_t id> 
using SubDomainTypeTag = 
typename MDTraits::template SubDomain<id>::TypeTag;
 
   62    template<std::
size_t id> 
using FVElementGeometry = 
typename GridGeometry<id>::LocalView;
 
   63    template<std::
size_t id> 
using SubControlVolume = 
typename GridGeometry<id>::SubControlVolume;
 
   64    template<std::
size_t id> 
using SubControlVolumeFace = 
typename GridGeometry<id>::SubControlVolumeFace;
 
   65    template<std::
size_t id> 
using GridView = 
typename GridGeometry<id>::GridView;
 
   67    template<std::
size_t id> 
using Element = 
typename GridView<id>::template Codim<0>::Entity;
 
   68    template<std::
size_t id> 
using LocalResidual = 
typename MDTraits::template SubDomain<id>::LocalResidual;
 
   71    template<std::
size_t id> 
using GridVolumeVariables = 
typename GridVariables<id>::GridVolumeVariables;
 
   72    template<std::
size_t id> 
using ElementVolumeVariables = 
typename GridVolumeVariables<id>::LocalView;
 
   75    static constexpr int bulkDim = GridView<bulkDomainId>::dimension;
 
   76    static constexpr int lowDimDim = GridView<lowDimDomainId>::dimension;
 
   77    static constexpr auto bulkGridId = CouplingMapper::template gridId<bulkDim>();
 
   78    static constexpr auto lowDimGridId = CouplingMapper::template gridId<lowDimDim>();
 
   95    void init(std::shared_ptr< Problem<bulkId> > bulkProblem,
 
   96              std::shared_ptr< Problem<lowDimId> > lowDimProblem,
 
   97              std::shared_ptr< CouplingMapper > couplingMapper,
 
  101        ParentType::init(bulkProblem, lowDimProblem, couplingMapper, curSol);
 
  104        bulkScvfIsOnFacetElement_.assign(bulkProblem->gridGeometry().numScvf(), 
false);
 
  105        const auto& bulkMap = couplingMapper->couplingMap(bulkGridId, lowDimGridId);
 
  106        for (
const auto& entry : bulkMap)
 
  107            for (
const auto& couplingEntry : entry.second.elementToScvfMap)
 
  108                for (
const auto& scvfIdx : couplingEntry.second)
 
  109                    bulkScvfIsOnFacetElement_[scvfIdx] = 
true;
 
  112        couplingMapperPtr_ = couplingMapper;
 
 
  119                              const SubControlVolumeFace<bulkId>& scvf)
 const 
  120    { 
return bulkScvfIsOnFacetElement_[scvf.index()]; }
 
 
  122    using ParentType::evalCouplingResidual;
 
  129    template< 
class LowDimLocalAssembler >
 
  130    typename LocalResidual<lowDimId>::ElementResidualVector
 
  132                         const LowDimLocalAssembler& lowDimLocalAssembler,
 
  134                         GridIndexType<bulkId> dofIdxGlobalJ)
 
 
  142    template< 
class LowDimLocalAssembler >
 
  143    typename LocalResidual<lowDimId>::ElementResidualVector
 
  147        assert(this->lowDimCouplingContext().isSet);
 
  148        assert(this->problem(lowDimId).gridGeometry().elementMapper().index(lowDimLocalAssembler.element()) == this->lowDimCouplingContext().elementIdx);
 
  151        typename LowDimLocalAssembler::LocalResidual::ElementResidualVector res(lowDimLocalAssembler.fvGeometry().numScv());
 
  153        for (
const auto& scv : scvs(lowDimLocalAssembler.fvGeometry()))
 
  155                                                             lowDimLocalAssembler.fvGeometry(),
 
  156                                                             lowDimLocalAssembler.curElemVolVars(),
 
 
  165                                              const FVElementGeometry<lowDimId>& fvGeometry,
 
  166                                              const ElementVolumeVariables<lowDimId>& elemVolVars,
 
  167                                              const SubControlVolume<lowDimId>& scv)
 const 
  170        assert(this->problem(lowDimId).gridGeometry().elementMapper().index(element) == this->lowDimCouplingContext().elementIdx);
 
  172        NumEqVector<lowDimId> sources(0.0);
 
  174        const auto& map = couplingMapperPtr_->couplingMap(lowDimGridId, bulkGridId);
 
  175        auto it = map.find(this->lowDimCouplingContext().elementIdx);
 
  179        assert(this->lowDimCouplingContext().isSet);
 
  180        for (
const auto& embedment : it->second.embedments)
 
  185            const auto& coincidingScvfs = embedment.second;
 
  186            const auto& scvfList = lowDimUsesBox ? std::vector<GridIndexType<lowDimId>>{ coincidingScvfs[scv.localDofIndex()] }
 
  189            sources += this->evalBulkFluxes(this->problem(bulkId).gridGeometry().element(embedment.first),
 
  190                                            *this->lowDimCouplingContext().bulkFvGeometry,
 
  191                                            *this->lowDimCouplingContext().bulkElemVolVars,
 
  192                                            *this->lowDimCouplingContext().bulkElemFluxVarsCache,
 
  193                                            *this->lowDimCouplingContext().bulkLocalResidual,
 
 
  204    template<
class JacobianPattern>
 
  207        const auto& lowDimFVGridGeometry = this->problem(lowDimId).gridGeometry();
 
  208        for (
const auto& element : elements(lowDimFVGridGeometry.gridView()))
 
  211            const auto eIdx = lowDimFVGridGeometry.elementMapper().index(element);
 
  212            const auto& map = couplingMapperPtr_->couplingMap(lowDimGridId, bulkGridId);
 
  213            auto it = map.find(eIdx);
 
  219                const auto bulkElemIdx = it->second.embedments[0].first;
 
  220                const auto& bulkMapEntry = couplingMapperPtr_->couplingMap(bulkGridId, lowDimGridId).at(bulkElemIdx);
 
  221                const auto& couplingStencil = bulkMapEntry.couplingStencil;
 
  223                for (
auto globalJ : couplingStencil)
 
  227                        for (
int i = 0; i < element.subEntities(lowDimDim); ++i)
 
  228                            pattern.add(lowDimFVGridGeometry.vertexMapper().subIndex(element, i, lowDimDim), globalJ);
 
  231                        pattern.add(eIdx, globalJ);
 
 
  238    template<
class JacobianPattern>
 
  248    template<
class LowDimLocalAssembler, 
class JacobianMatrixDiagBlock, 
class Gr
idVariables>
 
  250                                         const LowDimLocalAssembler& lowDimLocalAssembler,
 
  251                                         const typename LowDimLocalAssembler::LocalResidual::ElementResidualVector&,
 
  252                                         JacobianMatrixDiagBlock& A,
 
  253                                         GridVariables& gridVariables)
 
  257        if (!LowDimLocalAssembler::isImplicit())
 
  261        auto updateContext = [&] (
auto elemIdx, 
auto dofIdx, 
auto priVars, 
auto pvIdx)
 
  264            auto& ldSol = this->curSol(lowDimId);
 
  265            ldSol[dofIdx][pvIdx] = priVars[pvIdx];
 
  268            assert(this->bulkCouplingContext().isSet);
 
  269            const auto& bulkMap = couplingMapperPtr_->couplingMap(bulkGridId, lowDimGridId);
 
  270            const auto& couplingElementStencil = bulkMap.find(this->bulkCouplingContext().elementIdx)->second.couplingElementStencil;
 
  272            auto it = std::find(couplingElementStencil.begin(), couplingElementStencil.end(), elemIdx);
 
  273            assert(it != couplingElementStencil.end());
 
  274            const auto idxInContext = std::distance(couplingElementStencil.begin(), it);
 
  276            auto& volVars = this->bulkCouplingContext().lowDimVolVars[idxInContext];
 
  277            const auto& fvGeom = this->bulkCouplingContext().lowDimFvGeometries[idxInContext];
 
  278            const auto& element = this->problem(lowDimId).gridGeometry().element(elemIdx);
 
  283                const auto elemGeom = element.geometry();
 
  288                volVars.update( 
elementSolution(element, ldSol, this->problem(lowDimId).gridGeometry()),
 
  289                                this->problem(lowDimId),
 
  291                                fvGeom.scv(elemIdx) );
 
  294            const auto contextElem = this->problem(bulkId).gridGeometry().element(this->bulkCouplingContext().elementIdx);
 
  295            this->lowDimCouplingContext().bulkElemFluxVarsCache->update(contextElem,
 
  296                                                                        *this->lowDimCouplingContext().bulkFvGeometry,
 
  297                                                                        *this->lowDimCouplingContext().bulkElemVolVars);
 
  300        const auto eIdx = this->problem(lowDimId).gridGeometry().elementMapper().index(lowDimLocalAssembler.element());
 
  303        assert(this->lowDimCouplingContext().isSet);
 
  304        assert(this->lowDimCouplingContext().elementIdx == eIdx);
 
  307        const auto& map = couplingMapperPtr_->couplingMap(lowDimGridId, bulkGridId);
 
  308        auto it = map.find(eIdx);
 
  310            evalLowDimSourceDerivatives_(updateContext, lowDimLocalAssembler, A);
 
 
  314    template<
class LocalAssemblerI, 
class JacobianMatrixDiagBlock, 
class Gr
idVariables>
 
  316                                         const LocalAssemblerI& localAssemblerI,
 
  317                                         const typename LocalAssemblerI::LocalResidual::ElementResidualVector& origResiduals,
 
  318                                         JacobianMatrixDiagBlock& A,
 
  319                                         GridVariables& gridVariables)
 
 
  324    template<
class UpdateContext, 
class LowDimLocalAssembler, 
class JacobianMatrixDiagBlock>
 
  325    void evalLowDimSourceDerivatives_(
const UpdateContext& updateContext,
 
  326                                      const LowDimLocalAssembler& lowDimLocalAssembler,
 
  327                                      JacobianMatrixDiagBlock& A)
 
  329        const auto& lowDimFVGridGeometry = this->problem(lowDimId).gridGeometry();
 
  330        const auto eIdx = lowDimFVGridGeometry.elementMapper().index(lowDimLocalAssembler.element());
 
  333        const auto bulkElemIdx = this->bulkCouplingContext().elementIdx;
 
  334        const auto& bulkMapEntry = couplingMapperPtr_->couplingMap(bulkGridId, lowDimGridId).at(bulkElemIdx);
 
  335        const auto& couplingStencil = bulkMapEntry.couplingStencil;
 
  336        const auto& couplingElementStencil = bulkMapEntry.couplingElementStencil;
 
  339        const auto origResidual = evalCouplingResidual(lowDimId, lowDimLocalAssembler, bulkId);
 
  342        std::vector< std::decay_t<
decltype(couplingStencil[0])> > elemDofs;
 
  343        elemDofs.reserve(lowDimLocalAssembler.fvGeometry().numScv());
 
  344        for (
const auto& scv : scvs(lowDimLocalAssembler.fvGeometry()))
 
  345            elemDofs.push_back(scv.dofIndex());
 
  348        for (
const auto couplingElemIdx : couplingElementStencil)
 
  351            if (couplingElemIdx == eIdx)
 
  355            std::vector< std::decay_t<
decltype(couplingStencil[0])> > elemDofsJ;
 
  358                const auto& elemJ = lowDimFVGridGeometry.element(couplingElemIdx);
 
  359                for (
int i = 0; i < elemJ.subEntities(lowDimDim); ++i)
 
  360                    elemDofsJ.push_back(lowDimFVGridGeometry.vertexMapper().subIndex(elemJ, i, lowDimDim));
 
  363                elemDofsJ.push_back(couplingElemIdx);
 
  365            for (
auto dofIndex : elemDofsJ)
 
  367                auto partialDerivs = origResidual;
 
  368                const auto origPriVars = this->curSol(lowDimId)[dofIndex];
 
  371                static constexpr auto numEq = std::decay_t<
decltype(origPriVars)>::dimension;
 
  372                for (
int pvIdx = 0; pvIdx < numEq; pvIdx++)
 
  377                    auto evalResiduals = [&](Scalar<lowDimId> priVar)
 
  379                        auto priVars = origPriVars;
 
  380                        priVars[pvIdx] = priVar;
 
  383                        updateContext(couplingElemIdx, dofIndex, priVars, pvIdx);
 
  384                        return this->evalCouplingResidual(lowDimId, lowDimLocalAssembler, bulkId);
 
  387                    static const int numDiffMethod = 
getParamFromGroup<int>(this->problem(lowDimId).paramGroup(), 
"Assembly.NumericDifferenceMethod");
 
  388                    static const NumericEpsilon< Scalar<lowDimId>, numEq > eps{this->problem(lowDimId).paramGroup()};
 
  390                                                              origResidual, eps(origPriVars[pvIdx], pvIdx), numDiffMethod);
 
  395                    for (
const auto& scv : scvs(lowDimLocalAssembler.fvGeometry()))
 
  396                        for (
int eqIdx = 0; eqIdx < numEq; eqIdx++)
 
  397                            A[scv.dofIndex()][dofIndex][eqIdx][pvIdx] += partialDerivs[scv.indexInElement()][eqIdx];
 
  400                    updateContext(couplingElemIdx, dofIndex, origPriVars, pvIdx);
 
  407    std::vector<bool> bulkScvfIsOnFacetElement_;
 
  410    std::shared_ptr< CouplingMapper > couplingMapperPtr_;
 
 
NumEqVector< lowDimId > evalSourcesFromBulk(const Element< lowDimId > &element, const FVElementGeometry< lowDimId > &fvGeometry, const ElementVolumeVariables< lowDimId > &elemVolVars, const SubControlVolume< lowDimId > &scv) const
Computes the sources in a lower-dimensional sub-control volume stemming from the bulk domain.
Definition multidomain/facet/cellcentered/mpfa/couplingmanager.hh:164
bool isOnInteriorBoundary(const Element< bulkId > &element, const SubControlVolumeFace< bulkId > &scvf) const
returns true if a bulk scvf coincides with a facet element.
Definition multidomain/facet/cellcentered/mpfa/couplingmanager.hh:118
LocalResidual< lowDimId >::ElementResidualVector evalCouplingResidual(LowDimIdType, const LowDimLocalAssembler &lowDimLocalAssembler, BulkIdType)
Evaluates the coupling element residual of a lower-dimensional domain element with respect to a dof i...
Definition multidomain/facet/cellcentered/mpfa/couplingmanager.hh:144
void extendJacobianPattern(LowDimIdType, JacobianPattern &pattern) const
Extend the jacobian pattern of the diagonal block of the lowdim domain by the elements that are in th...
Definition multidomain/facet/cellcentered/mpfa/couplingmanager.hh:205
typename MDTraits::SolutionVector SolutionVector
the type of the solution vector
Definition multidomain/facet/cellcentered/mpfa/couplingmanager.hh:85
LocalResidual< lowDimId >::ElementResidualVector evalCouplingResidual(LowDimIdType, const LowDimLocalAssembler &lowDimLocalAssembler, BulkIdType, GridIndexType< bulkId > dofIdxGlobalJ)
Evaluates the coupling element residual of a lower-dimensional domain element with respect to a dof i...
Definition multidomain/facet/cellcentered/mpfa/couplingmanager.hh:131
void evalAdditionalDomainDerivatives(BulkIdType, const LocalAssemblerI &localAssemblerI, const typename LocalAssemblerI::LocalResidual::ElementResidualVector &origResiduals, JacobianMatrixDiagBlock &A, GridVariables &gridVariables)
The bulk domain has no additional derivatives.
Definition multidomain/facet/cellcentered/mpfa/couplingmanager.hh:315
void init(std::shared_ptr< Problem< bulkId > > bulkProblem, std::shared_ptr< Problem< lowDimId > > lowDimProblem, std::shared_ptr< CouplingMapper > couplingMapper, const SolutionVector &curSol)
Initialize the coupling manager.
Definition multidomain/facet/cellcentered/mpfa/couplingmanager.hh:95
void evalAdditionalDomainDerivatives(LowDimIdType, const LowDimLocalAssembler &lowDimLocalAssembler, const typename LowDimLocalAssembler::LocalResidual::ElementResidualVector &, JacobianMatrixDiagBlock &A, GridVariables &gridVariables)
evaluate additional derivatives of the element residual of the low-dim domain with respect to dofs in...
Definition multidomain/facet/cellcentered/mpfa/couplingmanager.hh:249
void extendJacobianPattern(BulkIdType, JacobianPattern &pattern) const
The bulk domain has no extended jacobian pattern.
Definition multidomain/facet/cellcentered/mpfa/couplingmanager.hh:239
void makeInterpolatedVolVars(VolumeVariables &volVars, const Problem &problem, const SolutionVector &sol, const FVGeometry &fvGeometry, const typename FVGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const typename FVGeometry::GridGeometry::GridView::template Codim< 0 >::Entity::Geometry &elemGeom, const typename FVGeometry::GridGeometry::GridView::template Codim< 0 >::Entity::Geometry::GlobalCoordinate &pos)
Free function that allows the creation of a volume variables object interpolated to a given position ...
Definition multidomain/facet/couplingmanager.hh:40
The interface of the coupling manager for multi domain problems.
Implementation for the coupling manager between two domains of dimension d and (d-1) for models consi...