Commit 57e8235b authored by Dave Moxey's avatar Dave Moxey
Browse files

Merge branch 'fix/GetExpIndex' into 'master'

Fix/get exp index

This MR fixes a couple of bugs in the GetExpIndex function for identifying the expansion in an ExpList containing a specific point.

See merge request !417
parents 150cd99b cecf7523
......@@ -1235,36 +1235,44 @@ namespace Nektar
{
SpatialDomains::PointGeomSharedPtr v;
SpatialDomains::PointGeom w;
NekDouble x, y, z;
NekDouble dist;
// Scan all elements and store those which may contain the point
for (int i = 0; i < (*m_exp).size(); ++i)
{
if ((*m_exp)[i]->GetGeom()->ContainsPoint(gloCoords, locCoords,
if ((*m_exp)[i]->GetGeom()->ContainsPoint(gloCoords,
locCoords,
tol, resid))
{
v = m_graph->GetVertex((*m_exp)[i]->GetGeom()->GetVid(0));
w.SetX(gloCoords[0]);
w.SetY(gloCoords[1]);
w.SetZ(gloCoords[2]);
v->GetCoords(x,y,z);
elmtIdDist.push_back(std::pair<int, NekDouble>(i, v->dist(w)));
// Find closest vertex
for (int j = 0; j < (*m_exp)[i]->GetNverts(); ++j) {
v = m_graph->GetVertex(
(*m_exp)[i]->GetGeom()->GetVid(j));
if (j == 0 || dist > v->dist(w))
{
dist = v->dist(w);
}
}
elmtIdDist.push_back(
std::pair<int, NekDouble>(i, dist));
}
}
// Find nearest element
if (!elmtIdDist.empty())
{
NekDouble min_d = elmtIdDist[0].first;
int min_id = elmtIdDist[0].second;
int min_id = elmtIdDist[0].first;
NekDouble min_d = elmtIdDist[0].second;
for (int i = 1; i < elmtIdDist.size(); ++i)
{
if (elmtIdDist[i].second < min_d) {
min_d = elmtIdDist[i].second;
min_id = elmtIdDist[i].first;
min_d = elmtIdDist[i].second;
}
}
......
Markdown is supported
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