From f4767ab1bc99c3406d6b9e818856136532a59b03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Buchwald?= <joerg.buchwald@ufz.de>
Date: Mon, 19 Apr 2021 16:58:05 +0200
Subject: [PATCH] [MPL] Zero initialization for constant dvalue.

---
 MaterialLib/MPL/Properties/Constant.cpp | 39 +++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/MaterialLib/MPL/Properties/Constant.cpp b/MaterialLib/MPL/Properties/Constant.cpp
index fcff143af39..112de01d1e4 100644
--- a/MaterialLib/MPL/Properties/Constant.cpp
+++ b/MaterialLib/MPL/Properties/Constant.cpp
@@ -12,14 +12,47 @@
 
 #include "Constant.h"
 
+
 namespace MaterialPropertyLib
 {
+struct ZeroInitPropertyDataType
+{
+    PropertyDataType operator()(double) const { return 0.; }
+
+    PropertyDataType operator()(Eigen::Vector2d) const
+    {
+        return Eigen::Vector2d::Zero().eval();
+    }
+
+    PropertyDataType operator()(Eigen::Vector3d) const
+    {
+        return Eigen::Vector3d::Zero().eval();
+    }
+
+    PropertyDataType operator()(Eigen::Matrix<double, 2, 2>) const
+    {
+        return Eigen::Matrix<double, 2, 2>::Zero().eval();
+    }
+    PropertyDataType operator()(Eigen::Matrix<double, 3, 3>) const
+    {
+        return Eigen::Matrix<double, 3, 3>::Zero().eval();
+    }
+
+    PropertyDataType operator()(Eigen::Matrix<double, 4, 1>) const
+    {
+        return Eigen::Matrix<double, 4, 1>::Zero().eval();
+    }
+
+    PropertyDataType operator()(Eigen::Matrix<double, 6, 1>) const
+    {
+        return Eigen::Matrix<double, 6, 1>::Zero().eval();
+    }
+};
+
 Constant::Constant(std::string name, PropertyDataType const& v)
 {
     name_ = std::move(name);
     value_ = v;
-    dvalue_ = std::visit(
-        [](auto const& value) -> PropertyDataType { return decltype(value){}; },
-        v);
+    dvalue_ = std::visit(ZeroInitPropertyDataType{}, v);
 };
 }  // namespace MaterialPropertyLib
-- 
GitLab