From a74b2cdb922f8b560660e3ec0533ace62f1184d5 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Thu, 11 Mar 2010 13:02:09 +0000 Subject: [PATCH] Small bugfix in findElInfoAtPoint, thanks to Francisco. --- AMDiS/src/Mesh.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/AMDiS/src/Mesh.cc b/AMDiS/src/Mesh.cc index 9e421e01..80f05347 100644 --- a/AMDiS/src/Mesh.cc +++ b/AMDiS/src/Mesh.cc @@ -674,10 +674,22 @@ namespace AMDiS { mel_info->fillMacroInfo(mel); + // We have the care about not to visite a macro element twice. In this case the + // function would end up in an infinite loop. If a macro element is visited a + // second time, what can happen with periodic boundary conditions, the point is + // not within the mesh! + std::set<int> macrosVisited; + macrosVisited.insert(mel->getIndex()); + int k; while ((k = mel_info->worldToCoord(xy, &lambda)) >= 0) { if (mel->getNeighbour(k)) { mel = mel->getNeighbour(k); + mel = mel->getNeighbour(k); + if (macrosVisited.count(mel->getIndex())) + return false; + + macrosVisited.insert(mel->getIndex()); mel_info->fillMacroInfo(mel); continue; } -- GitLab