From 05ec2603a1e04acae7528fcfeed1665ed61ff8bb Mon Sep 17 00:00:00 2001
From: Christoph Schwarzmeier <christoph.schwarzmeier@fau.de>
Date: Thu, 20 Apr 2023 12:22:45 +0200
Subject: [PATCH] Fix bug in FSLBM mass advection at free-slip boundary
 condition

---
 .../dynamics/functionality/AdvectMass.h            | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/lbm/free_surface/dynamics/functionality/AdvectMass.h b/src/lbm/free_surface/dynamics/functionality/AdvectMass.h
index 9ec9e655c..971529a1b 100644
--- a/src/lbm/free_surface/dynamics/functionality/AdvectMass.h
+++ b/src/lbm/free_surface/dynamics/functionality/AdvectMass.h
@@ -178,7 +178,19 @@ real_t advectMass(const FlagField_T* flagField, const ConstScalarIt_T& fillSrc,
       }
 
       // PDF pointing from neighbor to current cell
-      const real_t neighborPdf = pdfFieldIt.neighbor(*dir, dir.toInvIdx());
+      real_t neighborPdf = real_c(0);
+      if (!isFreeSlip) { neighborPdf = pdfFieldIt.neighbor(*dir, dir.toInvIdx()); }
+      else
+      {
+         // get PDF reflected at free slip boundary condition
+         stencil::Direction neighborPdfDir = *dir;
+
+         if (freeSlipDir[0] != cell_idx_c(0)) { neighborPdfDir = stencil::mirrorX[neighborPdfDir]; }
+         if (freeSlipDir[1] != cell_idx_c(0)) { neighborPdfDir = stencil::mirrorY[neighborPdfDir]; }
+         if (freeSlipDir[2] != cell_idx_c(0)) { neighborPdfDir = stencil::mirrorZ[neighborPdfDir]; }
+         neighborPdf = pdfFieldIt.neighbor(freeSlipDir[0], freeSlipDir[1], freeSlipDir[2],
+                                           LatticeModel_T::Stencil::idx[neighborPdfDir]);
+      }
 
       // PDF pointing to neighbor
       const real_t localPdf = pdfFieldIt.getF(dir.toIdx());
-- 
GitLab