From 573acc18f20f7769221dbf13f2380943a21ed45d Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Thu, 14 Mar 2019 13:02:07 +0100
Subject: [PATCH] [MPL] Add Tensor2d as PropertyDataType.

---
 MaterialLib/MPL/CreateProperty.cpp | 7 +++++++
 MaterialLib/MPL/Property.h         | 4 ++--
 MaterialLib/MPL/VariableType.h     | 3 +++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/MaterialLib/MPL/CreateProperty.cpp b/MaterialLib/MPL/CreateProperty.cpp
index 4d456d88049..24d700ddd4c 100644
--- a/MaterialLib/MPL/CreateProperty.cpp
+++ b/MaterialLib/MPL/CreateProperty.cpp
@@ -62,6 +62,13 @@ std::unique_ptr<MaterialPropertyLib::Property> createProperty(
                     Vector{values[0], values[1], values[2]};
                 return std::make_unique<Constant>(property_value);
             }
+            case 4:
+            {
+                // Tensor
+                PropertyDataType property_value =
+                    Tensor2d{values[0], values[1], values[2], values[3]};
+                return std::make_unique<Constant>(property_value);
+            }
             case 6:
             {
                 // Symmetric Tensor - xx, yy, zz, xy, xz, yz
diff --git a/MaterialLib/MPL/Property.h b/MaterialLib/MPL/Property.h
index a086887db94..efb75801a42 100644
--- a/MaterialLib/MPL/Property.h
+++ b/MaterialLib/MPL/Property.h
@@ -33,8 +33,8 @@ enum PropertyDataTypeName
     nTensor
 };
 
-using PropertyDataType =
-    boost::variant<double, Pair, Vector, SymmTensor, Tensor, std::string>;
+using PropertyDataType = boost::
+    variant<double, Pair, Vector, Tensor2d, SymmTensor, Tensor, std::string>;
 
 /// This class is the base class for any material property of any
 /// scale (i.e. components, phases, media, ...). The single value of
diff --git a/MaterialLib/MPL/VariableType.h b/MaterialLib/MPL/VariableType.h
index 7ac721108cc..e634d54a329 100644
--- a/MaterialLib/MPL/VariableType.h
+++ b/MaterialLib/MPL/VariableType.h
@@ -30,6 +30,9 @@ using Vector = std::array<double, 3>;
 /// xx, yy, zz, xy, xz, yz tensor components.
 using SymmTensor = std::array<double, 6>;
 
+/// Very simple 2d tensor data type for holding tensor components.
+using Tensor2d = std::array<double, 4>;
+
 /// Very simple tensor data type for holding
 /// tensor components.
 using Tensor = std::array<double, 9>;
-- 
GitLab