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 auto darcyFvGeometry =
localView(darcyFvGridGeometry);
74 auto stokesFvGeometry =
localView(stokesFvGridGeometry);
75 const auto& stokesGridView = stokesFvGridGeometry.gridView();
77 for (
const auto& stokesElement : elements(stokesGridView))
79 stokesFvGeometry.bindElement(stokesElement);
81 for (
const auto& scvf : scvfs(stokesFvGeometry))
89 const auto eps = (scvf.center() - stokesElement.geometry().center()).two_norm()*1e-8;
90 auto globalPos = scvf.center(); globalPos.axpy(eps, scvf.unitOuterNormal());
91 const auto darcyElementIdx =
intersectingEntities(globalPos, darcyFvGridGeometry.boundingBoxTree());
94 if (darcyElementIdx.empty())
98 if (darcyElementIdx.size() > 1)
99 DUNE_THROW(Dune::InvalidStateException,
"Stokes face dof should only intersect with one Darcy element");
101 const auto stokesElementIdx = stokesFvGridGeometry.elementMapper().index(stokesElement);
103 const auto darcyDofIdx = darcyElementIdx[0];
105 stokesFaceToDarcyStencils[scvf.dofIndex()].push_back(darcyDofIdx);
106 stokesCellCenterToDarcyStencils[stokesElementIdx].push_back(darcyDofIdx);
108 darcyToStokesFaceStencils[darcyElementIdx[0]].push_back(scvf.dofIndex());
109 darcyToStokesCellCenterStencils[darcyElementIdx[0]].push_back(stokesElementIdx);
111 const auto& darcyElement = darcyFvGridGeometry.element(darcyElementIdx[0]);
112 darcyFvGeometry.bindElement(darcyElement);
115 for (
const auto& darcyScvf : scvfs(darcyFvGeometry))
117 const auto distance = (darcyScvf.center() - scvf.center()).two_norm();
121 isCoupledDarcyScvf_[darcyScvf.index()] =
true;
122 darcyElementToStokesElementMap_[darcyElementIdx[0]].push_back({stokesElementIdx, scvf.index(), darcyScvf.index()});
123 stokesElementToDarcyElementMap_[stokesElementIdx].push_back({darcyElementIdx[0], darcyScvf.index(), scvf.index()});