Commit ed6128e9 authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'fix/return-type-in-function-outsideScvfWithSameIntegrationPoint' into 'master'

[fix] conditional return type in function outsideScvfWithSameIntegrationPoint

Closes #1159

See merge request !3135
parents a3d16878 602e4818
Pipeline #17427 canceled with stages
in 0 seconds
......@@ -204,7 +204,22 @@ public:
//! Returns the the scvf of neighbor element with the same integration point and unit outer normal
const SubControlVolumeFace& outsideScvfWithSameIntegrationPoint(const SubControlVolumeFace& scvf) const
{ return GG::GeometryHelper::outsideScvfWithSameIntegrationPoint(*this, scvf); }
{
const auto& lateralOrthogonalScvf = this->lateralOrthogonalScvf(scvf);
assert(!lateralOrthogonalScvf.boundary());
const auto otherLocalIdx = GG::GeometryHelper::localIndexOutsideScvfWithSameIntegrationPoint(scvf);
auto outsideFVGeometry = localView(gridGeometry());
const auto outsideElementIdx = scv(lateralOrthogonalScvf.outsideScvIdx()).elementIndex();
outsideFVGeometry.bindElement(gridGeometry().element(outsideElementIdx));
for (const auto& otherScvf : scvfs(outsideFVGeometry))
if (otherScvf.localIndex() == otherLocalIdx)
return otherScvf;
DUNE_THROW(Dune::InvalidStateException, "No outside scvf found");
}
private:
......@@ -399,8 +414,24 @@ public:
{ return GG::GeometryHelper::scvfIntegrationPointInConcaveCorner(*this, scvf); }
//! Returns the the scvf of neighbor element with the same integration point and unit outer normal
const SubControlVolumeFace& outsideScvfWithSameIntegrationPoint(const SubControlVolumeFace& scvf) const
{ return GG::GeometryHelper::outsideScvfWithSameIntegrationPoint(*this, scvf); }
//! Todo: this code can likely be improved, we don't need to build all of the outside geometry if we know how to build scvf.
SubControlVolumeFace outsideScvfWithSameIntegrationPoint(const SubControlVolumeFace& scvf) const
{
const SubControlVolumeFace& lateralOrthogonalScvf = this->lateralOrthogonalScvf(scvf);
assert(!lateralOrthogonalScvf.boundary());
const auto otherLocalIdx = GG::GeometryHelper::localIndexOutsideScvfWithSameIntegrationPoint(scvf);
auto outsideFVGeometry = localView(gridGeometry());
const auto outsideElementIdx = scv(lateralOrthogonalScvf.outsideScvIdx()).elementIndex();
outsideFVGeometry.bindElement(gridGeometry().element(outsideElementIdx));
for (const auto& otherScvf : scvfs(outsideFVGeometry))
if (otherScvf.localIndex() == otherLocalIdx)
return otherScvf;
DUNE_THROW(Dune::InvalidStateException, "No outside scvf found");
}
private:
//! Binding of an element preparing the geometries of the whole stencil
......
......@@ -176,7 +176,15 @@ public:
}
}
template<class SubControlVolumeFace>
static SmallLocalIndexType localIndexOutsideScvfWithSameIntegrationPoint(const SubControlVolumeFace& scvf)
{
const SmallLocalIndexType offset = (dim == 2) ? 3 : 5;
return isOdd_(scvf.localIndex()) ? scvf.localIndex() - offset : scvf.localIndex() + offset;
}
template<class FVElementGeometry, class SubControlVolumeFace>
[[deprecated("The interface outsideScvfWithSameIntegrationPoint() is deprecated and the function is moved to the FVElementGeometry. Use the new interface localIndexOutsideScvfWithSameIntegrationPoint() instead. Will be removed after 3.5")]]
static const SubControlVolumeFace& outsideScvfWithSameIntegrationPoint(const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvf)
{
const auto& lateralOrthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment