From 3b21b811c6a45ac6e103db1c1ef34cbb4f167436 Mon Sep 17 00:00:00 2001
From: Martin Schoenherr <m.schoenherr@tu-braunschweig.de>
Date: Tue, 24 May 2022 07:28:58 +0200
Subject: [PATCH] bugfix grid generator

---
 src/gpu/GridGenerator/grid/GridImp.cpp | 11 +++++++++++
 src/gpu/GridGenerator/grid/GridImp.h   | 17 +++++++++--------
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/src/gpu/GridGenerator/grid/GridImp.cpp b/src/gpu/GridGenerator/grid/GridImp.cpp
index 9b64d8260..0d1a6c347 100644
--- a/src/gpu/GridGenerator/grid/GridImp.cpp
+++ b/src/gpu/GridGenerator/grid/GridImp.cpp
@@ -868,6 +868,7 @@ void GridImp::findSparseIndices(SPtr<Grid> finerGrid)
 
     if (fineGrid) {
         fineGrid->updateSparseIndices();
+        this->findForGridInterfaceNewIndices(fineGrid);
     }
 
     const uint newGridSize = this->getSparseSize();
@@ -875,6 +876,16 @@ void GridImp::findSparseIndices(SPtr<Grid> finerGrid)
                   << ", delete nodes:" << this->getSize() - newGridSize << "\n";
 }
 
+void GridImp::findForGridInterfaceNewIndices(SPtr<GridImp> fineGrid)
+{
+#pragma omp parallel for
+    for (int index = 0; index < (int)this->getNumberOfNodesCF(); index++)
+        this->gridInterface->findForGridInterfaceSparseIndexCF(this, fineGrid.get(), index);
+
+#pragma omp parallel for
+    for (int index = 0; index < (int)this->getNumberOfNodesFC(); index++)
+        this->gridInterface->findForGridInterfaceSparseIndexFC(this, fineGrid.get(), index);
+}
 
 void GridImp::updateSparseIndices()
 {
diff --git a/src/gpu/GridGenerator/grid/GridImp.h b/src/gpu/GridGenerator/grid/GridImp.h
index 7d44b0bb5..6d6000b67 100644
--- a/src/gpu/GridGenerator/grid/GridImp.h
+++ b/src/gpu/GridGenerator/grid/GridImp.h
@@ -28,7 +28,7 @@
 //
 //! \file GridImp.h
 //! \ingroup grid
-//! \author Soeren Peters, Stephan Lenz, Martin Schönherr
+//! \author Soeren Peters, Stephan Lenz, Martin Schoenherr
 //=======================================================================================
 #ifndef GRID_IMP_H
 #define GRID_IMP_H
@@ -53,19 +53,19 @@ class BoundingBox;
 class TriangularMeshDiscretizationStrategy;
 
 #ifdef __GNUC__
-#ifndef __clang__
-#pragma push
-#pragma diag_suppress = 3156
-#endif
+    #ifndef __clang__
+        #pragma push
+        #pragma diag_suppress = 3156
+    #endif
 #endif
 
 // GCC:  warning #3156-D: extern declaration of the entity DIRECTIONS is treated as a static definition
 extern int DIRECTIONS[DIR_END_MAX][DIMENSION];
 
 #ifdef __GNUC__
-#ifndef __clang__
-#pragma pop
-#endif
+    #ifndef __clang__
+        #pragma pop
+    #endif
 #endif
 
 class GRIDGENERATOR_EXPORT GridImp : public enableSharedFromThis<GridImp>, public Grid
@@ -266,6 +266,7 @@ public:
 public:
     virtual void findSparseIndices(SPtr<Grid> fineGrid) override;
 
+    void findForGridInterfaceNewIndices(SPtr<GridImp> fineGrid);
     void updateSparseIndices();
     void setNeighborIndices(uint index);
     real getFirstFluidNode(real coords[3], int direction, real startCoord) const override;
-- 
GitLab