From b4ba6c5fcb527555e11d2f8e1214b7c89edef789 Mon Sep 17 00:00:00 2001
From: Anna Wellmann <a.wellmann@tu-braunschweig.de>
Date: Thu, 9 Nov 2023 13:48:26 +0000
Subject: [PATCH] Add some more tests for the rotation of moments

---
 ...interpolateRotatingToStaticInlinesTest.cpp |  6 ++--
 ...interpolateStaticToRotatingInlinesTest.cpp | 31 +++++++++++++++++--
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/interpolateRotatingToStaticInlinesTest.cpp b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/interpolateRotatingToStaticInlinesTest.cpp
index 274249393..17b0c5ede 100644
--- a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/interpolateRotatingToStaticInlinesTest.cpp
+++ b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/interpolateRotatingToStaticInlinesTest.cpp
@@ -104,7 +104,7 @@ TEST_F(RotateSecondOrderMomentsFromGlobalToRotatingTest, xAngleIsPiHalf_momentsC
     EXPECT_THAT(mxxMyy, RealNear(mxxMzzBeforeRotation, 1e-6));
     EXPECT_THAT(mxxMzz, RealNear(mxxMyyBeforeRotation, 1e-6));
     EXPECT_THAT(m110, RealNear(m101BeforeRotation, 1e-6));
-    
+
     // switched and reversed
     EXPECT_THAT(m101, RealNear(-m110BeforeRotation, 1e-6));
 }
@@ -116,13 +116,13 @@ TEST_F(RotateSecondOrderMomentsFromGlobalToRotatingTest, xAngleIsMinusPiHalf_mom
     rotateSecondOrderMomentsGlobalToRotating(m011, m101, m110, mxxMyy, mxxMzz, angles[0], angles[1], angles[2]);
 
     // reversed
-    EXPECT_THAT(-m011, RealNear(m011BeforeRotation, 1e-6));
+    EXPECT_THAT(m011, RealNear(-m011BeforeRotation, 1e-6));
 
     // switched
     EXPECT_THAT(mxxMyy, RealNear(mxxMzzBeforeRotation, 1e-6));
     EXPECT_THAT(mxxMzz, RealNear(mxxMyyBeforeRotation, 1e-6));
     EXPECT_THAT(m101, RealNear(m110BeforeRotation, 1e-6));
-    
+
     // switched and reversed
     EXPECT_THAT(m110, RealNear(-m101BeforeRotation, 1e-6));
 }
diff --git a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/interpolateStaticToRotatingInlinesTest.cpp b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/interpolateStaticToRotatingInlinesTest.cpp
index 60c70af75..e55964968 100644
--- a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/interpolateStaticToRotatingInlinesTest.cpp
+++ b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/interpolateStaticToRotatingInlinesTest.cpp
@@ -30,7 +30,7 @@ TEST_F(RotateSecondOrderMomentsFromRotatingToGlobalTest, angleIsZero_momentsDoNo
     EXPECT_THAT(m110, RealEq(m110BeforeRotation));
 }
 
-TEST_F(RotateSecondOrderMomentsFromRotatingToGlobalTest, angleIs2Pi_momentsDoNotChange)
+TEST_F(RotateSecondOrderMomentsFromRotatingToGlobalTest, anglesAre2Pi_momentsDoNotChange)
 {
     std::array<real, 3> angles = { c2Pi, c2Pi, c2Pi };
 
@@ -97,6 +97,7 @@ TEST_F(RotateSecondOrderMomentsFromRotatingToGlobalTest, xAngleIsPiHalf_momentsC
 
     rotateSecondOrderMomentsRotatingToGlobal(m011, m101, m110, mxxMyy, mxxMzz, angles[0], angles[1], angles[2]);
 
+
     // reversed
     EXPECT_THAT(m011, RealNear(-m011BeforeRotation, 1e-6));
 
@@ -107,6 +108,19 @@ TEST_F(RotateSecondOrderMomentsFromRotatingToGlobalTest, xAngleIsPiHalf_momentsC
     
     // switched and reversed
     EXPECT_THAT(m110, RealNear(-m101BeforeRotation, 1e-6));
+
+    real mxxPyyPzz = 0.0;
+    real useNEQ = 1.0;
+    real m200BeforeRotation = c1o3 * (        mxxMyyBeforeRotation +        mxxMzzBeforeRotation + mxxPyyPzz) * useNEQ;
+    real m020BeforeRotation = c1o3 * (-c2o1 * mxxMyyBeforeRotation +        mxxMzzBeforeRotation + mxxPyyPzz) * useNEQ;
+    real m002BeforeRotation = c1o3 * (        mxxMyyBeforeRotation - c2o1 * mxxMzzBeforeRotation + mxxPyyPzz) * useNEQ;
+    real m200 = c1o3 * (        mxxMyy +        mxxMzz + mxxPyyPzz) * useNEQ;
+    real m020 = c1o3 * (-c2o1 * mxxMyy +        mxxMzz + mxxPyyPzz) * useNEQ;
+    real m002 = c1o3 * (        mxxMyy - c2o1 * mxxMzz + mxxPyyPzz) * useNEQ;
+
+    EXPECT_THAT(m200, RealNear(m200BeforeRotation, 1e-6));
+    EXPECT_THAT(m020, RealNear(m002BeforeRotation, 1e-6));
+    EXPECT_THAT(m002, RealNear(m020BeforeRotation, 1e-6));
 }
 
 TEST_F(RotateSecondOrderMomentsFromRotatingToGlobalTest, xAngleIsMinusPiHalf_momentsChange)
@@ -116,7 +130,7 @@ TEST_F(RotateSecondOrderMomentsFromRotatingToGlobalTest, xAngleIsMinusPiHalf_mom
     rotateSecondOrderMomentsRotatingToGlobal(m011, m101, m110, mxxMyy, mxxMzz, angles[0], angles[1], angles[2]);
 
     // reversed
-    EXPECT_THAT(-m011, RealNear(m011BeforeRotation, 1e-6));
+    EXPECT_THAT(m011, RealNear(-m011BeforeRotation, 1e-6));
 
     // switched
     EXPECT_THAT(mxxMyy, RealNear(mxxMzzBeforeRotation, 1e-6));
@@ -125,6 +139,19 @@ TEST_F(RotateSecondOrderMomentsFromRotatingToGlobalTest, xAngleIsMinusPiHalf_mom
     
     // switched and reversed
     EXPECT_THAT(m101, RealNear(-m110BeforeRotation, 1e-6));
+
+    real mxxPyyPzz = 0.0;
+    real useNEQ = 1.0;
+    real m200BeforeRotation = c1o3 * (        mxxMyyBeforeRotation +        mxxMzzBeforeRotation + mxxPyyPzz) * useNEQ;
+    real m020BeforeRotation = c1o3 * (-c2o1 * mxxMyyBeforeRotation +        mxxMzzBeforeRotation + mxxPyyPzz) * useNEQ;
+    real m002BeforeRotation = c1o3 * (        mxxMyyBeforeRotation - c2o1 * mxxMzzBeforeRotation + mxxPyyPzz) * useNEQ;
+    real m200 = c1o3 * (        mxxMyy +        mxxMzz + mxxPyyPzz) * useNEQ;
+    real m020 = c1o3 * (-c2o1 * mxxMyy +        mxxMzz + mxxPyyPzz) * useNEQ;
+    real m002 = c1o3 * (        mxxMyy - c2o1 * mxxMzz + mxxPyyPzz) * useNEQ;
+
+    EXPECT_THAT(m200, RealNear(m200BeforeRotation, 1e-6));
+    EXPECT_THAT(m020, RealNear(m002BeforeRotation, 1e-6));
+    EXPECT_THAT(m002, RealNear(m020BeforeRotation, 1e-6));
 }
 
 TEST_F(RotateSecondOrderMomentsFromRotatingToGlobalTest, yAngleIsPiHalf_momentsChange)
-- 
GitLab