From d7eace111a44a58595a4c57b2147c6ce40d279b2 Mon Sep 17 00:00:00 2001
From: Louis Denis <louis.denis@student.uliege.be>
Date: Sat, 21 May 2022 03:17:37 +0200
Subject: [PATCH] FINAL DEADLINE AND FINAL VERSION OF THE CODE

---
 srcs/BEM/postProcessing.cpp | 53 +++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 29 deletions(-)

diff --git a/srcs/BEM/postProcessing.cpp b/srcs/BEM/postProcessing.cpp
index 45919f2..7977f83 100644
--- a/srcs/BEM/postProcessing.cpp
+++ b/srcs/BEM/postProcessing.cpp
@@ -317,47 +317,42 @@ void boundaryElementTags(std::vector<std::size_t> &domainBoundaryElementTags,
                          const int domainPhysicalGroupTag)
 {
     // #pragma omp parallel
+    std::vector<std::size_t> localElementTags;  // For parallelization.
+
+    // Loops over each boundary element and retrieves the element in contact with its boundary nodes.
+    // #pragma omp for schedule(guided)
+    for(std::size_t i = 0; i < elementVector.size(); i++)
     {
-        std::vector<std::size_t> localElementTags;  // For parallelization.
+        std::vector<size_t> elementTags;
+        gmsh::model::mesh::getElementsByCoordinates(elementVector[i].x1, elementVector[i].y1, 0, elementTags, 2);
+
 
-        // Loops over each boundary element and retrieves the element in contact with its boundary nodes.
-        // #pragma omp for schedule(guided)
-        for(std::size_t i = 0; i < elementVector.size(); i++)
+        // Adds the elements tags to the local vector. 
+        for(std::size_t j = 0; j < elementTags.size(); j++)
         {
+            // Retrieves the physical group to which the element belongs because it is possible that the element belongs to
+            // an adjacent physical surface.
             int elementType;
             std::vector<size_t> nodeTags;
             int entityDim;
             int entityTag;
             std::vector<int> physicalTags;
-
-            // Adds the elements tags to the local vector. 
-            for(std::size_t j = 0; j < elementTags.size(); j++)
+            // #pragma omp critical
             {
-                // Retrieves the physical group to which the element belongs because it is possible that the element belongs to
-                // an adjacent physical surface.
-                int elementType;
-                std::vector<size_t> nodeTags;
-                int entityDim;
-                int entityTag;
-                std::vector<int> physicalTags;
-                // #pragma omp critical
-                {
-                    gmsh::model::mesh::getElement(elementTags[j], elementType, nodeTags, entityDim, entityTag);
-                    gmsh::model::getPhysicalGroupsForEntity(entityDim, entityTag, physicalTags);
-                }
-                
-                // Add the element tag (to a local 'thread safe' vector) if the physical tag is the right one.
-                for(std::size_t k = 0; k < physicalTags.size(); k++)
-                    if(physicalTags[k] == domainPhysicalGroupTag)
-                        localElementTags.push_back(elementTags[j]);
+                gmsh::model::mesh::getElement(elementTags[j], elementType, nodeTags, entityDim, entityTag);
+                gmsh::model::getPhysicalGroupsForEntity(entityDim, entityTag, physicalTags);
             }
+            
+            // Add the element tag (to a local 'thread safe' vector) if the physical tag is the right one.
+            for(std::size_t k = 0; k < physicalTags.size(); k++)
+                if(physicalTags[k] == domainPhysicalGroupTag)
+                    localElementTags.push_back(elementTags[j]);
         }
-
-        // // Fills the "domainBoundaryElementTags" vector.
-        // #pragma omp critical
-        domainBoundaryElementTags.insert(domainBoundaryElementTags.end(), localElementTags.begin(), localElementTags.end());
     }
-    
+
+    // // Fills the "domainBoundaryElementTags" vector.
+    // #pragma omp critical
+    domainBoundaryElementTags.insert(domainBoundaryElementTags.end(), localElementTags.begin(), localElementTags.end());
 
     // Allows duplicate tags to be removed. If an element has several nodes in common with the boundary, it has been counted
     // several times before.
-- 
GitLab