From de01d840f7fdad9ecaa2d2ee9fa3035c56fc68b1 Mon Sep 17 00:00:00 2001
From: Hussein Alihussein <h.alihussein@tu-braunschweig.de>
Date: Wed, 22 Nov 2023 15:58:01 +0100
Subject: [PATCH] clean BC

---
 apps/cpu/TPMSRow/TPMSRow.cpp                  |  6 ++---
 .../VelocityNonReflecting.cpp                 | 26 ++++++++++++++-----
 .../VelocityNonReflecting.h                   |  1 +
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/apps/cpu/TPMSRow/TPMSRow.cpp b/apps/cpu/TPMSRow/TPMSRow.cpp
index e6fcb72e2..0d4dd035d 100644
--- a/apps/cpu/TPMSRow/TPMSRow.cpp
+++ b/apps/cpu/TPMSRow/TPMSRow.cpp
@@ -86,8 +86,8 @@ void run(string configname)
         //SPtr<BC> funnelNoslipAdapter(new NoSlipBC(1));
 
            // SPtr<BC> xMinApr(new DensityBC(0.0000001));
-         SPtr<BC> xMinApr(new DensityBC());
-        //  SPtr<BC> xMinApr(new VelocityBC(vx, 0., BCFunction::INFCONST, 0., 0., BCFunction::INFCONST,
+         //SPtr<BC> xMinApr(new DensityBC());
+          SPtr<BC> xMinApr(new VelocityBC(vx, 0., BCFunction::INFCONST, 0., 0., BCFunction::INFCONST,
          //  0.,0., BCFunction::INFCONST));
 
         SPtr<BC> xMaxApr(new DensityBC(0.));
@@ -107,7 +107,7 @@ void run(string configname)
 
          //xMinApr->setBcAlgorithm(SPtr<BCStrategy>(new NonEqDensityBCStrategy()));
         // xMinApr->setBcAlgorithm(SPtr<BCStrategy>(new VelocityBCStrategy()));
-        xMinApr->setBCStrategy(SPtr<BCStrategy>(new NonReflectingInflowBCStrategy(vx, c1o2))); 
+        xMinApr->setBCStrategy(SPtr<BCStrategy>(new NonReflectingInflowBCStrategy(c1o2))); 
         // xMinApr->setBcAlgorithm(SPtr<BCStrategy>(new VelocityWithDensityBCStrategy()));
          //xMaxApr->setBcAlgorithm(SPtr<BCStrategy>(new NonEqDensityBCStrategy()));
          xMaxApr->setBCStrategy(SPtr<BCStrategy>(new NonReflectingOutflowWithRelaxationBCStrategy()));
diff --git a/src/cpu/core/BoundaryConditions/VelocityNonReflecting.cpp b/src/cpu/core/BoundaryConditions/VelocityNonReflecting.cpp
index f1bb49f52..1e45749e0 100644
--- a/src/cpu/core/BoundaryConditions/VelocityNonReflecting.cpp
+++ b/src/cpu/core/BoundaryConditions/VelocityNonReflecting.cpp
@@ -41,11 +41,17 @@ VelocityNonReflecting::VelocityNonReflecting()
     BCStrategy::preCollision = true;
 }
 //////////////////////////////////////////////////////////////////////////
+VelocityNonReflecting::VelocityNonReflecting(real relaxationRate)
+{
+    BCStrategy::preCollision = true;
+    this->BCVeloWeight = relaxationRate;
+}
+//////////////////////////////////////////////////////////////////////////
 VelocityNonReflecting::~VelocityNonReflecting() = default;
 //////////////////////////////////////////////////////////////////////////
 SPtr<BCStrategy> VelocityNonReflecting::clone()
 {
-    SPtr<BCStrategy> bc(new VelocityNonReflecting());
+    SPtr<BCStrategy> bc(new VelocityNonReflecting(this->BCVeloWeight));
     return bc;
 }
 //////////////////////////////////////////////////////////////////////////
@@ -70,24 +76,30 @@ void VelocityNonReflecting::applyBC()
     int direction = -1;
 
     // flag points in direction of fluid
-    if (bcPtr->hasDensityBoundaryFlag(dP00)) {
+    if (bcPtr->hasVelocityBoundaryFlag(dP00)) {
         nx1 += 1;
         direction = dP00;
-    } else if (bcPtr->hasDensityBoundaryFlag(dM00)) {
+        this->velocity = bcPtr->getBoundaryVelocityX1();
+    } else if (bcPtr->hasVelocityBoundaryFlag(dM00)) {
         nx1 -= 1;
         direction = dM00;
-    } else if (bcPtr->hasDensityBoundaryFlag(d0P0)) {
+        this->velocity = bcPtr->getBoundaryVelocityX1();
+    } else if (bcPtr->hasVelocityBoundaryFlag(d0P0)) {
         nx2 += 1;
         direction = d0P0;
-    } else if (bcPtr->hasDensityBoundaryFlag(d0M0)) {
+        this->velocity = bcPtr->getBoundaryVelocityX2();
+    } else if (bcPtr->hasVelocityBoundaryFlag(d0M0)) {
         nx2 -= 1;
         direction = d0M0;
-    } else if (bcPtr->hasDensityBoundaryFlag(d00P)) {
+        this->velocity = bcPtr->getBoundaryVelocityX2();
+    } else if (bcPtr->hasVelocityBoundaryFlag(d00P)) {
         nx3 += 1;
         direction = d00P;
-    } else if (bcPtr->hasDensityBoundaryFlag(d00M)) {
+        this->velocity = bcPtr->getBoundaryVelocityX3();
+    } else if (bcPtr->hasVelocityBoundaryFlag(d00M)) {
         nx3 -= 1;
         direction = d00M;
+        this->velocity = bcPtr->getBoundaryVelocityX3();
     } else
         UB_THROW(UbException(UB_EXARGS, "Danger...no orthogonal BC-Flag on density boundary..."));
 
diff --git a/src/cpu/core/BoundaryConditions/VelocityNonReflecting.h b/src/cpu/core/BoundaryConditions/VelocityNonReflecting.h
index 46e82f626..6a64198b8 100644
--- a/src/cpu/core/BoundaryConditions/VelocityNonReflecting.h
+++ b/src/cpu/core/BoundaryConditions/VelocityNonReflecting.h
@@ -42,6 +42,7 @@ class VelocityNonReflecting : public BCStrategy
 {
 public:
     VelocityNonReflecting();
+    VelocityNonReflecting(real relaxationRate);
     ~VelocityNonReflecting() override;
     SPtr<BCStrategy> clone() override;
     void addDistributions(SPtr<DistributionArray3D> distributions) override;
-- 
GitLab