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