From 51e616818b08a8c0c6f99bdf954c3b1abe3cc58b Mon Sep 17 00:00:00 2001
From: Anna Wellmann <a.wellmann@tu-braunschweig.de>
Date: Tue, 14 Nov 2023 13:12:13 +0000
Subject: [PATCH] Add to string function for axis

---
 apps/gpu/RotatingGrid/RotatingGrid.cpp    |  5 ++++-
 src/basics/geometry3d/Axis.cpp            | 14 ++++++++++++++
 src/basics/geometry3d/Axis.h              |  8 +++++++-
 src/gpu/core/Calculation/UpdateGrid27.cpp | 17 +++++++++--------
 4 files changed, 34 insertions(+), 10 deletions(-)
 create mode 100644 src/basics/geometry3d/Axis.cpp

diff --git a/apps/gpu/RotatingGrid/RotatingGrid.cpp b/apps/gpu/RotatingGrid/RotatingGrid.cpp
index 3e70d42ca..8c100d4d7 100644
--- a/apps/gpu/RotatingGrid/RotatingGrid.cpp
+++ b/apps/gpu/RotatingGrid/RotatingGrid.cpp
@@ -97,7 +97,7 @@ int main()
 
         const std::string path("./output/RotatingGrid");
         const std::string simulationName = (rotOrInt == Int ? "RotatingGridInterpolationTest" : "RotatingGrid") +
-                                           rotationStrings.at(initialRot) + "_inflowFrom" + sideTypeNames.at(inflowSide);
+                                           rotationStrings.at(initialRot) + "around" + axis::to_string(rotationAxis) + "_inflowFrom" + sideTypeNames.at(inflowSide);
 
         const real L = 1.0;
         const real Re = 2000.0;
@@ -196,6 +196,9 @@ int main()
                 gridBuilder->setPressureBoundaryCondition(SideType::MZ, 0.0);
                 gridBuilder->setVelocityBoundaryCondition(SideType::PZ, 0.0, 0.0, -velocityLB);
                 break;
+            case SideType::GEOMETRY:
+                throw std::runtime_error("Can't generate inflow at geometry.");
+                break;
         }
 
         gridBuilder->setNoSlipBoundaryCondition(SideType::MX);
diff --git a/src/basics/geometry3d/Axis.cpp b/src/basics/geometry3d/Axis.cpp
new file mode 100644
index 000000000..8d83ca8fb
--- /dev/null
+++ b/src/basics/geometry3d/Axis.cpp
@@ -0,0 +1,14 @@
+#include "Axis.h"
+
+std::string axis::to_string(Axis axis)
+{
+    switch (axis) {
+        case x:
+            return "x";
+        case y:
+            return "y";
+        case z:
+            return "z";
+    }
+    return "Axis not found.";
+}
\ No newline at end of file
diff --git a/src/basics/geometry3d/Axis.h b/src/basics/geometry3d/Axis.h
index 5662483f6..4bd924db1 100644
--- a/src/basics/geometry3d/Axis.h
+++ b/src/basics/geometry3d/Axis.h
@@ -3,6 +3,7 @@
 
 #include <array>
 #include <map>
+#include <string>
 
 enum Axis {
     x = 0,
@@ -14,4 +15,9 @@ const std::map<Axis, std::array<double, 3>> unitVectors{ { x, { 1, 0, 0 } },
                                                          { y, { 0, 1, 0 } },
                                                          { z, { 0, 0, 1 } } };
 
-#endif
\ No newline at end of file
+namespace axis
+{
+std::string to_string(Axis axis);
+}
+
+#endif
diff --git a/src/gpu/core/Calculation/UpdateGrid27.cpp b/src/gpu/core/Calculation/UpdateGrid27.cpp
index 894c945b1..118dd22ed 100644
--- a/src/gpu/core/Calculation/UpdateGrid27.cpp
+++ b/src/gpu/core/Calculation/UpdateGrid27.cpp
@@ -398,15 +398,16 @@ void UpdateGrid27::rotateGridInInitializationProcess(int level)
     SPtr<ParameterRotatingGrid> paraRot = para->getRotatingGridParameter();
 
     real intendedRotation = (real)paraRot->initialGridRotation;
-    auto axis = paraRot->rotationalAxis;
+    auto axisRotation = paraRot->rotationalAxis;
     auto angularVelocityInSimulation = paraRot->parameterRotHost->angularVelocity;
-    paraRot->parameterRotHost->angularVelocity[axis] = intendedRotation / steps;
-    paraRot->parameterRotDevice->angularVelocity[axis] = paraRot->parameterRotHost->angularVelocity[axis];
+    paraRot->parameterRotHost->angularVelocity[axisRotation] = intendedRotation / steps;
+    paraRot->parameterRotDevice->angularVelocity[axisRotation] = paraRot->parameterRotHost->angularVelocity[axisRotation];
 
-
-    VF_LOG_INFO("Intended initial rotation for the rotating grid: {}. Center point for the rotation: ({}, {}, {}), Axis : {}, Angular Velocity: {}.",
+    VF_LOG_INFO("Intended initial rotation for the rotating grid: {}. Center point for the rotation: ({}, {}, {}), Axis : "
+                "{}, Angular Velocity: {}.",
                 intendedRotation, paraRot->parameterRotHost->centerPoint[0], paraRot->parameterRotHost->centerPoint[1],
-                paraRot->parameterRotHost->centerPoint[2], axis, paraRot->parameterRotHost->angularVelocity[axis]);
+                paraRot->parameterRotHost->centerPoint[2], axis::to_string(axisRotation),
+                paraRot->parameterRotHost->angularVelocity[axisRotation]);
 
     for (int i = 0; i < steps; i++) {
         paraRot->parameterRotHost->gridAngle[0] += paraRot->parameterRotHost->angularVelocity[0];
@@ -433,8 +434,8 @@ void UpdateGrid27::rotateGridInInitializationProcess(int level)
             para->getParD(level)->neighborFineToCoarse);
     }
 
-    paraRot->parameterRotHost->angularVelocity[axis] = angularVelocityInSimulation[axis];
-    paraRot->parameterRotDevice->angularVelocity[axis] = angularVelocityInSimulation[axis];
+    paraRot->parameterRotHost->angularVelocity[axisRotation] = angularVelocityInSimulation[axisRotation];
+    paraRot->parameterRotDevice->angularVelocity[axisRotation] = angularVelocityInSimulation[axisRotation];
 
     VF_LOG_INFO("Angle x {}", paraRot->parameterRotHost->gridAngle[0]);
     VF_LOG_INFO("Angle y {}", paraRot->parameterRotHost->gridAngle[1]);
-- 
GitLab