From e34cbe28e0134e08b46839e116560cfe9a0e4d2d Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <dmitri.naumov@ufz.de>
Date: Wed, 13 Nov 2024 14:15:26 +0100
Subject: [PATCH] Replace std::valarray with Eigen::VectorXd

For consistency mainly, but also save one instantiation
of the shape functions.
Also the valarray is kind of obsolete and Eigen provides
equivalent substitute.
---
 .../HeatTransportBHELocalAssemblerSoil-impl.h      |  1 -
 .../SmallDeformationLocalAssemblerMatrix-impl.h    |  1 -
 Tests/NumLib/TestShapeFunctions.cpp                | 14 +++++++-------
 scripts/test/clang_sanitizer_blacklist.txt         |  4 ----
 4 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/ProcessLib/HeatTransportBHE/LocalAssemblers/HeatTransportBHELocalAssemblerSoil-impl.h b/ProcessLib/HeatTransportBHE/LocalAssemblers/HeatTransportBHELocalAssemblerSoil-impl.h
index 6b9b5b42e58..6f91e8ec7d2 100644
--- a/ProcessLib/HeatTransportBHE/LocalAssemblers/HeatTransportBHELocalAssemblerSoil-impl.h
+++ b/ProcessLib/HeatTransportBHE/LocalAssemblers/HeatTransportBHELocalAssemblerSoil-impl.h
@@ -10,7 +10,6 @@
 
 #pragma once
 
-#include <valarray>
 #include <vector>
 
 #include "HeatTransportBHEProcessAssemblerInterface.h"
diff --git a/ProcessLib/LIE/SmallDeformation/LocalAssembler/SmallDeformationLocalAssemblerMatrix-impl.h b/ProcessLib/LIE/SmallDeformation/LocalAssembler/SmallDeformationLocalAssemblerMatrix-impl.h
index f79e1721477..1ffccc3d791 100644
--- a/ProcessLib/LIE/SmallDeformation/LocalAssembler/SmallDeformationLocalAssemblerMatrix-impl.h
+++ b/ProcessLib/LIE/SmallDeformation/LocalAssembler/SmallDeformationLocalAssemblerMatrix-impl.h
@@ -11,7 +11,6 @@
 #pragma once
 
 #include <Eigen/Core>
-#include <valarray>
 #include <vector>
 
 #include "IntegrationPointDataMatrix.h"
diff --git a/Tests/NumLib/TestShapeFunctions.cpp b/Tests/NumLib/TestShapeFunctions.cpp
index e84f7709c38..1fe286985f8 100644
--- a/Tests/NumLib/TestShapeFunctions.cpp
+++ b/Tests/NumLib/TestShapeFunctions.cpp
@@ -12,11 +12,11 @@
 
 #include <gtest/gtest.h>
 
+#include <Eigen/Core>
 #include <algorithm>
 #include <limits>
 #include <numeric>
 #include <type_traits>
-#include <valarray>
 
 #include "MeshLib/Elements/Elements.h"
 #include "NumLib/Fem/ShapeFunction/ShapeHex20.h"
@@ -156,13 +156,13 @@ TEST(NumLib, FemShapeQuad4)
     static const double eps = std::numeric_limits<double>::epsilon();
     static const unsigned NNodes = 4;
     static const unsigned dim = 2;
-    std::valarray<double> r(dim);
-    std::valarray<double> N(NNodes);
-    std::valarray<double> dN(NNodes * dim);
+    Eigen::VectorXd r(dim);
+    Eigen::VectorXd N(NNodes);
+    Eigen::VectorXd dN(NNodes * dim);
 
     // check N, dN at specific location
     {
-        r = .5;  // r = (0,5, 0.5)
+        r << 0.5, 0.5;
         ShapeQuad4::computeShapeFunction(r, N);
         ShapeQuad4::computeGradShapeFunction(r, dN);
         double exp_N[] = {0.5625, 0.1875, 0.0625, 0.1875};
@@ -172,13 +172,13 @@ TEST(NumLib, FemShapeQuad4)
         ASSERT_ARRAY_NEAR(exp_dN, dN, dN.size(), eps);
     }
 
-    std::valarray<double> exp_N(NNodes);
+    Eigen::VectorXd exp_N(NNodes);
     // check N_i(r_j)= {i==j: 1, i!=j: 0}
     for (unsigned i = 0; i < NNodes; i++)
     {
         r[0] = (i == 0 || i == 3) ? 1 : -1;
         r[1] = i < 2 ? 1 : -1;
-        exp_N = .0;
+        exp_N.setZero(NNodes);
         exp_N[i] = 1.0;
         ShapeQuad4::computeShapeFunction(r, N);
         ASSERT_ARRAY_NEAR(exp_N, N, NNodes, eps);
diff --git a/scripts/test/clang_sanitizer_blacklist.txt b/scripts/test/clang_sanitizer_blacklist.txt
index 4aa88c22164..07a89b30406 100644
--- a/scripts/test/clang_sanitizer_blacklist.txt
+++ b/scripts/test/clang_sanitizer_blacklist.txt
@@ -29,7 +29,3 @@ fun:_ZNKSs12find_last_ofEPKcmm
 fun:_ZNSt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EE11_M_gen_randEv
 fun:_ZNSt24uniform_int_distributionIiEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEiRT_
 fun:_ZNSt24uniform_int_distributionIiEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEiRT_RKNS0_10param_typeE
-
-# valarray fill loop is counting down and reaching integer subtraction overflow
-# STL gcc-5.3: called from operator=(double)
-fun:_ZSt15__valarray_fillIdEvPT_mRKS0_
-- 
GitLab