25#ifndef DUMUX_STOKES_DARCY_COUPLINGMAPPER_HH
26#define DUMUX_STOKES_DARCY_COUPLINGMAPPER_HH
29#include <unordered_map>
32#include <dune/common/exceptions.hh>
47 std::size_t flipScvfIdx;
55 template<
class CouplingManager,
class Stencils>
57 Stencils& darcyToStokesCellCenterStencils,
58 Stencils& darcyToStokesFaceStencils,
59 Stencils& stokesCellCenterToDarcyStencils,
60 Stencils& stokesFaceToDarcyStencils)
62 const auto& stokesFvGridGeometry = couplingManager.
problem(CouplingManager::stokesIdx).gridGeometry();
63 const auto& darcyFvGridGeometry = couplingManager.
problem(CouplingManager::darcyIdx).gridGeometry();
66 "The free flow domain must use the staggered discretization");
69 "The Darcy domain must use the CCTpfa discretization");
71 isCoupledDarcyScvf_.resize(darcyFvGridGeometry.numScvf(),
false);
73 const auto& stokesGridView = stokesFvGridGeometry.gridView();
74 auto stokesFvGeometry =
localView(stokesFvGridGeometry);
75 for (
const auto& stokesElement : elements(stokesGridView))
77 stokesFvGeometry.bindElement(stokesElement);
79 for (
const auto& scvf : scvfs(stokesFvGeometry))
87 const auto eps = (scvf.center() - stokesElement.geometry().center()).two_norm()*1e-8;
88 auto globalPos = scvf.center(); globalPos.axpy(eps, scvf.unitOuterNormal());
89 const auto darcyElementIdx =
intersectingEntities(globalPos, darcyFvGridGeometry.boundingBoxTree());
92 if (darcyElementIdx.empty())
96 if (darcyElementIdx.size() > 1)
97 DUNE_THROW(Dune::InvalidStateException,
"Stokes face dof should only intersect with one Darcy element");
99 const auto stokesElementIdx = stokesFvGridGeometry.elementMapper().index(stokesElement);
101 const auto darcyDofIdx = darcyElementIdx[0];
103 stokesFaceToDarcyStencils[scvf.dofIndex()].push_back(darcyDofIdx);
104 stokesCellCenterToDarcyStencils[stokesElementIdx].push_back(darcyDofIdx);
106 darcyToStokesFaceStencils[darcyElementIdx[0]].push_back(scvf.dofIndex());
107 darcyToStokesCellCenterStencils[darcyElementIdx[0]].push_back(stokesElementIdx);
109 const auto& darcyElement = darcyFvGridGeometry.element(darcyElementIdx[0]);
110 const auto darcyFvGeometry =
localView(darcyFvGridGeometry).bindElement(darcyElement);
113 for (
const auto& darcyScvf : scvfs(darcyFvGeometry))
115 const auto distance = (darcyScvf.center() - scvf.center()).two_norm();
119 isCoupledDarcyScvf_[darcyScvf.index()] =
true;
120 darcyElementToStokesElementMap_[darcyElementIdx[0]].push_back({stokesElementIdx, scvf.index(), darcyScvf.index()});
121 stokesElementToDarcyElementMap_[stokesElementIdx].push_back({darcyElementIdx[0], darcyScvf.index(), scvf.index()});
133 return isCoupledDarcyScvf_[darcyScvfIdx];
141 return darcyElementToStokesElementMap_;
149 return stokesElementToDarcyElementMap_;
153 std::unordered_map<std::size_t, std::vector<ElementMapInfo>> darcyElementToStokesElementMap_;
154 std::unordered_map<std::size_t, std::vector<ElementMapInfo>> stokesElementToDarcyElementMap_;
156 std::vector<bool> isCoupledDarcyScvf_;
The available discretization methods in Dumux.
static ctype distance(const Dune::FieldVector< ctype, dimWorld > &a, const Dune::FieldVector< ctype, dimWorld > &b)
Compute the shortest distance between two points.
Definition: distance.hh:292
std::vector< std::size_t > intersectingEntities(const Dune::FieldVector< ctype, dimworld > &point, const BoundingBoxTree< EntitySet > &tree, bool isCartesianGrid=false)
Compute all intersections between entities and a point.
Definition: intersectingentities.hh:112
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
constexpr CCTpfa cctpfa
Definition: method.hh:137
constexpr Staggered staggered
Definition: method.hh:140
Coupling mapper for Stokes and Darcy domains with equal dimension.
Definition: boundary/stokesdarcy/couplingmapper.hh:42
bool isCoupledDarcyScvf(std::size_t darcyScvfIdx) const
Returns whether a Darcy scvf is coupled to the other domain.
Definition: boundary/stokesdarcy/couplingmapper.hh:131
void computeCouplingMapsAndStencils(const CouplingManager &couplingManager, Stencils &darcyToStokesCellCenterStencils, Stencils &darcyToStokesFaceStencils, Stencils &stokesCellCenterToDarcyStencils, Stencils &stokesFaceToDarcyStencils)
Main update routine.
Definition: boundary/stokesdarcy/couplingmapper.hh:56
const auto & darcyElementToStokesElementMap() const
A map that returns all Stokes elements coupled to a Darcy element.
Definition: boundary/stokesdarcy/couplingmapper.hh:139
const auto & stokesElementToDarcyElementMap() const
A map that returns all Darcy elements coupled to a Stokes element.
Definition: boundary/stokesdarcy/couplingmapper.hh:147
The interface of the coupling manager for multi domain problems.
Definition: multidomain/couplingmanager.hh:60
const Problem< i > & problem(Dune::index_constant< i > domainIdx) const
Return a reference to the sub problem.
Definition: multidomain/couplingmanager.hh:321