25#ifndef DUMUX_STOKES_DARCY_COUPLINGMAPPER_HH
26#define DUMUX_STOKES_DARCY_COUPLINGMAPPER_HH
33#include <unordered_map>
36#include <dune/common/timer.hh>
37#include <dune/common/exceptions.hh>
47template<
class MDTraits>
50 using Scalar =
typename MDTraits::Scalar;
54 static constexpr auto stokesFaceIdx =
typename MDTraits::template SubDomain<1>::Index();
55 static constexpr auto cellCenterIdx =
typename MDTraits::template SubDomain<0>::Index();
56 static constexpr auto faceIdx =
typename MDTraits::template SubDomain<1>::Index();
58 static constexpr auto darcyIdx =
typename MDTraits::template SubDomain<2>::Index();
63 using StokesTypeTag =
typename MDTraits::template SubDomain<0>::TypeTag;
64 using DarcyTypeTag =
typename MDTraits::template SubDomain<2>::TypeTag;
70 std::size_t flipScvfIdx;
74 template<std::
size_t id>
75 using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
79 "The free flow domain must use the staggered discretization");
82 "The Darcy domain must use the CCTpfa discretization");
93 template<
class Stencils>
95 Stencils& darcyToStokesFaceStencils,
96 Stencils& stokesCellCenterToDarcyStencils,
97 Stencils& stokesFaceToDarcyStencils)
99 const auto& stokesProblem = couplingManager_.problem(
stokesIdx);
100 const auto& darcyProblem = couplingManager_.problem(
darcyIdx);
102 const auto& stokesFvGridGeometry = stokesProblem.gridGeometry();
103 const auto& darcyFvGridGeometry = darcyProblem.gridGeometry();
105 isCoupledDarcyScvf_.resize(darcyFvGridGeometry.numScvf(),
false);
107 auto darcyFvGeometry =
localView(darcyFvGridGeometry);
108 auto stokesFvGeometry =
localView(stokesFvGridGeometry);
109 const auto& stokesGridView = stokesFvGridGeometry.gridView();
111 for(
const auto& stokesElement : elements(stokesGridView))
113 stokesFvGeometry.bindElement(stokesElement);
115 for(
const auto& scvf : scvfs(stokesFvGeometry))
123 const auto eps = (scvf.center() - stokesElement.geometry().center()).two_norm()*1e-8;
124 auto globalPos = scvf.center(); globalPos.axpy(
eps, scvf.unitOuterNormal());
125 const auto darcyElementIdx =
intersectingEntities(globalPos, darcyFvGridGeometry.boundingBoxTree());
128 if(darcyElementIdx.empty())
132 if(darcyElementIdx.size() > 1)
133 DUNE_THROW(Dune::InvalidStateException,
"Stokes face dof should only intersect with one Darcy element");
135 const auto stokesElementIdx = stokesFvGridGeometry.elementMapper().index(stokesElement);
137 const auto darcyDofIdx = darcyElementIdx[0];
139 stokesFaceToDarcyStencils[scvf.dofIndex()].push_back(darcyDofIdx);
140 stokesCellCenterToDarcyStencils[stokesElementIdx].push_back(darcyDofIdx);
142 darcyToStokesFaceStencils[darcyElementIdx[0]].push_back(scvf.dofIndex());
143 darcyToStokesCellCenterStencils[darcyElementIdx[0]].push_back(stokesElementIdx);
145 const auto& darcyElement = darcyFvGridGeometry.element(darcyElementIdx[0]);
146 darcyFvGeometry.bindElement(darcyElement);
149 for(
const auto& darcyScvf : scvfs(darcyFvGeometry))
151 const Scalar distance = (darcyScvf.center() - scvf.center()).two_norm();
155 isCoupledDarcyScvf_[darcyScvf.index()] =
true;
156 darcyElementToStokesElementMap_[darcyElementIdx[0]].push_back({stokesElementIdx, scvf.index(), darcyScvf.index()});
157 stokesElementToDarcyElementMap_[stokesElementIdx].push_back({darcyElementIdx[0], darcyScvf.index(), scvf.index()});
169 return isCoupledDarcyScvf_[darcyScvfIdx];
177 return darcyElementToStokesElementMap_;
185 return stokesElementToDarcyElementMap_;
189 std::unordered_map<std::size_t, std::vector<ElementMapInfo>> darcyElementToStokesElementMap_;
190 std::unordered_map<std::size_t, std::vector<ElementMapInfo>> stokesElementToDarcyElementMap_;
192 std::vector<bool> isCoupledDarcyScvf_;
The available discretization methods in Dumux.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
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:45
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
constexpr double eps
epsilon for checking direction of scvf normals
Definition: test_tpfafvgeometry_nonconforming.cc:44
Definition: common/properties.hh:150
Coupling mapper for Stokes and Darcy domains with equal dimension.
Definition: boundary/stokesdarcy/couplingmapper.hh:49
static constexpr auto stokesIdx
Definition: boundary/stokesdarcy/couplingmapper.hh:57
static constexpr auto darcyIdx
Definition: boundary/stokesdarcy/couplingmapper.hh:58
bool isCoupledDarcyScvf(std::size_t darcyScvfIdx) const
Returns whether a Darcy scvf is coupled to the other domain.
Definition: boundary/stokesdarcy/couplingmapper.hh:167
StokesDarcyCouplingMapper(const CouplingManager &couplingManager)
Constructor.
Definition: boundary/stokesdarcy/couplingmapper.hh:88
static constexpr auto faceIdx
Definition: boundary/stokesdarcy/couplingmapper.hh:56
static constexpr auto cellCenterIdx
Definition: boundary/stokesdarcy/couplingmapper.hh:55
const auto & darcyElementToStokesElementMap() const
A map that returns all Stokes elements coupled to a Darcy element.
Definition: boundary/stokesdarcy/couplingmapper.hh:175
const auto & stokesElementToDarcyElementMap() const
A map that returns all Darcy elements coupled to a Stokes element.
Definition: boundary/stokesdarcy/couplingmapper.hh:183
static constexpr auto stokesFaceIdx
Definition: boundary/stokesdarcy/couplingmapper.hh:54
void computeCouplingMapsAndStencils(Stencils &darcyToStokesCellCenterStencils, Stencils &darcyToStokesFaceStencils, Stencils &stokesCellCenterToDarcyStencils, Stencils &stokesFaceToDarcyStencils)
Main update routine.
Definition: boundary/stokesdarcy/couplingmapper.hh:94
static constexpr auto stokesCellCenterIdx
Definition: boundary/stokesdarcy/couplingmapper.hh:53
Definition: multidomain/couplingmanager.hh:46
Declares all properties used in Dumux.