Commit f7b06bca authored by Dennis Gläser's avatar Dennis Gläser Committed by Timo Koch
Browse files

[mpfa] get rid of pairs for local index search

parent f22556d6
......@@ -192,7 +192,7 @@ public:
{
auto&& ivScvf = fvGeometry.scvf(scvfIdx);
if (!ivScvf.boundary() || existsLocalIndex(ivScvf.outsideScvIdx(), finishedBoundaries).second)
if (!ivScvf.boundary() || contains(ivScvf.outsideScvIdx(), finishedBoundaries))
continue;
// that means we are on a not yet handled boundary scvf
......@@ -260,16 +260,9 @@ private:
return std::distance(volVarIndices_.begin(), it);
}
const std::pair<IndexType, bool> existsLocalIndex(const IndexType idx,
const std::vector<IndexType>& indices) const
{
auto it = std::find(indices.begin(), indices.end(), idx);
if (it != indices.end())
return std::make_pair<IndexType, bool>(std::distance(indices.begin(), it), true);
else
return std::make_pair<IndexType, bool>(0, false);
}
const bool contains(const IndexType idx,
const std::vector<IndexType>& indices) const
{ return std::find(indices.begin(), indices.end(), idx) != indices.end(); }
std::vector<IndexType> volVarIndices_;
std::vector<VolumeVariables> volumeVariables_;
......
......@@ -240,7 +240,7 @@ public:
const auto eIdx = globalFvGeometry().problem_().elementMapper().index(element);
for (auto&& scvf : scvfs_)
{
if (existsLocalIndex(scvf.vertexIndex(), finishedVertices).second)
if (contains(scvf.vertexIndex(), finishedVertices))
continue;
const bool boundary = globalFvGeometry().scvfTouchesBoundary(scvf);
......@@ -352,8 +352,7 @@ private:
void makeNeighborGeometries(const Element& element, IndexType eIdxGlobal, const IndexVector& ivScvfs)
{
// create the neighbor scv if it doesn't exist yet
auto pair = existsLocalIndex(eIdxGlobal, neighborScvIndices_);
if (!pair.second)
if (!contains(eIdxGlobal, neighborScvIndices_))
{
neighborScvs_.emplace_back(element.geometry(), eIdxGlobal);
neighborScvIndices_.push_back(eIdxGlobal);
......@@ -389,7 +388,7 @@ private:
continue;
// if the actual global scvf index is in the container, make scvf
if (existsLocalIndex(scvFaceIndices[scvfCounter], ivScvfs).second)
if (contains(scvFaceIndices[scvfCounter], ivScvfs))
{
neighborScvfs_.emplace_back(geomHelper,
geomHelper.getScvfCorners(isGeometry, faceScvfIdx),
......@@ -415,19 +414,12 @@ private:
auto it = std::find(indices.begin(), indices.end(), idx);
assert(it != indices.end() && "Could not find the scv/scvf! Make sure to properly bind this class!");
return std::distance(indices.begin(), it);
}
const std::pair<IndexType, bool> existsLocalIndex(const IndexType idx,
const std::vector<IndexType>& indices) const
{
auto it = std::find(indices.begin(), indices.end(), idx);
if (it != indices.end())
return std::make_pair<IndexType, bool>(std::distance(indices.begin(), it), true);
else
return std::make_pair<IndexType, bool>(0, false);
}
//! Returns whether or not an index is stored in a given vector
const bool contains(const IndexType idx,
const std::vector<IndexType>& indices) const
{ return std::find(indices.begin(), indices.end(), idx) != indices.end(); }
void clear()
{
......
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