From fe4a78e459f0f8960f39a08c0352b00ae8c4c2a5 Mon Sep 17 00:00:00 2001
From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be>
Date: Wed, 4 May 2011 15:23:46 +0000
Subject: [PATCH] dg : clean dgFunctionEvaluator, merge
 functionEvaluatorInterface in functionEvaluator dg : rewrite strong boundary
 condition for continuous galerkin

---
 Geo/MElementOctree.cpp | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/Geo/MElementOctree.cpp b/Geo/MElementOctree.cpp
index eb8e63bf6f..1616101707 100644
--- a/Geo/MElementOctree.cpp
+++ b/Geo/MElementOctree.cpp
@@ -115,16 +115,18 @@ MElement *MElementOctree::find(double x, double y, double z, int dim)
 {
   double P[3] = {x, y, z};
   MElement *e = (MElement*)Octree_Search(P, _octree);
-  if (dim == -1 || !e || e->getDim() == dim)
+  if (e && (dim == -1 || e->getDim() == dim))
     return e;
   std::list<void*> l;
-  Octree_SearchAll(P, _octree, &l);
-  for (std::list<void*>::iterator it = l.begin(); it != l.end(); it++) {
-    MElement *el = (MElement*) *it;
-    if (el->getDim() == dim)
-      return el;
+  if (e && e->getDim() != dim) {
+    Octree_SearchAll(P, _octree, &l);
+    for (std::list<void*>::iterator it = l.begin(); it != l.end(); it++) {
+      MElement *el = (MElement*) *it;
+      if (el->getDim() == dim) {
+        return el;
+      }
+    }
   }
-  // JF : can you check if this is still needed, now that we changed Octree_SearchAll
   if (!e || (dim != -1 && e->getDim() != dim)){
     double initialTol = MElement::getTolerance();
     double tol = initialTol;
-- 
GitLab