From 7471e5e9be6b8f43bd0b523990badb88fc3495bf Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Mon, 25 Jan 2016 09:28:12 +0100
Subject: [PATCH] Added CMake option OGS_EIGEN_DYNAMIC for using dyn. all.
 matrices.

---
 CMakeLists.txt                 | 4 ++++
 NumLib/Fem/ShapeMatrixPolicy.h | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15062d443e3..13e414bd9b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -73,6 +73,7 @@ option(OGS_USE_MPI "Use MPI" OFF)
 
 # Eigen
 option(OGS_USE_EIGEN "Use EIGEN for local matrix and vector" ON)
+option(OGS_EIGEN_DYNAMIC "Use dynamically allocated shape matrices" OFF)
 option(EIGEN_NO_DEBUG "Disables Eigen's assertions" OFF)
 
 # Logging
@@ -130,6 +131,9 @@ if(OGS_USE_EIGEN)
 	if (EIGEN_NO_DEBUG)
 		add_definitions(-DEIGEN_NO_DEBUG)
 	endif()
+	if(OGS_EIGEN_DYNAMIC)
+		add_definitions(-DEIGEN_DYNAMIC_MATRICES)
+	endif()
 endif()
 
 ######################
diff --git a/NumLib/Fem/ShapeMatrixPolicy.h b/NumLib/Fem/ShapeMatrixPolicy.h
index 5309b6d6b07..47a5f06fd8f 100644
--- a/NumLib/Fem/ShapeMatrixPolicy.h
+++ b/NumLib/Fem/ShapeMatrixPolicy.h
@@ -107,8 +107,11 @@ struct EigenDynamicShapeMatrixPolicy
 
 /// Default choice of the ShapeMatrixPolicy.
 template <typename ShapeFunction, unsigned GlobalDim>
+#if EIGEN_DYNAMIC_MATRICES
+using ShapeMatrixPolicyType = EigenDynamicShapeMatrixPolicy<ShapeFunction, GlobalDim>;
+#else
 using ShapeMatrixPolicyType = EigenFixedShapeMatrixPolicy<ShapeFunction, GlobalDim>;
-//using ShapeMatrixPolicyType = EigenDynamicShapeMatrixPolicy<ShapeFunction, GlobalDim>;
+#endif
 
 #endif  // OGS_USE_EIGEN
 
-- 
GitLab