Wrong return type for function outsideScvfWithSameIntegrationPoint
The code here may return otherScvf
as a reference of a local variable if caching is disabled.
template<class FVElementGeometry, class SubControlVolumeFace>
static const SubControlVolumeFace& outsideScvfWithSameIntegrationPoint(const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvf)
{
const auto& lateralOrthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf);
assert(!lateralOrthogonalScvf.boundary());
const int offset = (dim == 2) ? 3 : 5;
const auto otherLocalIdx = isOdd_(scvf.localIndex()) ? scvf.localIndex() - offset : scvf.localIndex() + offset;
auto outsideFVGeometry = localView(fvGeometry.gridGeometry());
const auto outsideElementIdx = fvGeometry.scv(lateralOrthogonalScvf.outsideScvIdx()).elementIndex();
outsideFVGeometry.bindElement(fvGeometry.gridGeometry().element(outsideElementIdx));
for (const auto& otherScvf : scvfs(outsideFVGeometry))
{
if (otherScvf.localIndex() == otherLocalIdx)
return otherScvf;
}
DUNE_THROW(Dune::InvalidStateException, "No outside scvf found");
}