From d012a26f4dfa25a4264bc5acc2d999fc5a103cff Mon Sep 17 00:00:00 2001
From: HenrikAsmuth <henrik.asmuth@geo.uu.se>
Date: Tue, 24 May 2022 15:47:57 +0200
Subject: [PATCH] added levels to StressBC

---
 .../grid/GridBuilder/LevelGridBuilder.cpp     | 23 +++++++++++--------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp
index 30156a7c6..c6fa80c7a 100644
--- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp
+++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp
@@ -93,21 +93,24 @@ void LevelGridBuilder::setStressBoundaryCondition(  SideType sideType,
                                                     real nomalX, real normalY, real normalZ, 
                                                     uint samplingOffset, real z0)
 {
-    SPtr<StressBoundaryCondition> stressBoundaryCondition = StressBoundaryCondition::make(nomalX, normalY, normalZ, samplingOffset, z0);
+    for (uint level = 0; level < getNumberOfGridLevels(); level++)
+    {
+        SPtr<StressBoundaryCondition> stressBoundaryCondition = StressBoundaryCondition::make(nomalX, normalY, normalZ, samplingOffset, z0);
 
-    auto side = SideFactory::make(sideType);
+        auto side = SideFactory::make(sideType);
 
-    stressBoundaryCondition->side = side;
-    stressBoundaryCondition->side->addIndices(grids, 0, stressBoundaryCondition);
+        stressBoundaryCondition->side = side;
+        stressBoundaryCondition->side->addIndices(grids, level, stressBoundaryCondition);
 
-    stressBoundaryCondition->fillStressNormalLists();
-    stressBoundaryCondition->fillSamplingOffsetLists();
-    stressBoundaryCondition->fillZ0Lists();
-    // stressBoundaryCondition->fillSamplingIndices(grids, 0, samplingOffset); //redundant with Side::setStressSamplingIndices but potentially a better approach for cases with complex geometries
+        stressBoundaryCondition->fillStressNormalLists();
+        stressBoundaryCondition->fillSamplingOffsetLists();
+        stressBoundaryCondition->fillZ0Lists();
+        // stressBoundaryCondition->fillSamplingIndices(grids, 0, samplingOffset); //redundant with Side::setStressSamplingIndices but potentially a better approach for cases with complex geometries
 
-    boundaryConditions[0]->stressBoundaryConditions.push_back(stressBoundaryCondition);
+        boundaryConditions[level]->stressBoundaryConditions.push_back(stressBoundaryCondition);
 
-    *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Stress BC on level " << 0 << " with " << (int)stressBoundaryCondition->indices.size() << "\n";
+        *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Stress BC on level " << level << " with " << (int)stressBoundaryCondition->indices.size() << "\n";
+    }
 }
 
 void LevelGridBuilder::setVelocityBoundaryCondition(SideType sideType, real vx, real vy, real vz)
-- 
GitLab