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()});