From 83c29cfa9e8a3dc4cef9a42066effb133235c794 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Mon, 24 Oct 2011 18:25:04 +0000
Subject: [PATCH] Use template specialisation

[[Imported from SVN: r4673]]
---
 dune/fufem/mechanics/cubictensor.hh | 31 +++++++++++++++--------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/dune/fufem/mechanics/cubictensor.hh b/dune/fufem/mechanics/cubictensor.hh
index 3fc8f12a..acb94f2e 100644
--- a/dune/fufem/mechanics/cubictensor.hh
+++ b/dune/fufem/mechanics/cubictensor.hh
@@ -4,14 +4,16 @@
 #include "elasticitytensor.hh"
 
 template <int dim>
-class CubicTensor : public ElasticityTensor<dim>
+class CubicTensor;
+
+template <>
+class CubicTensor<3> : public ElasticityTensor<3>
 {
     public:
         CubicTensor(double C11, double C12, double C44) {
 
-            ElasticityTensor<dim>::operator=(0.0);
+            ElasticityTensor<3>::operator=(0.0);
 
-            if (dim == 3) {
                 (*this)[0][0] = C11;
                 (*this)[1][1] = C11;
                 (*this)[2][2] = C11;
@@ -25,25 +27,24 @@ class CubicTensor : public ElasticityTensor<dim>
                 (*this)[1][2] = C12;
                 (*this)[2][0] = C12;
                 (*this)[2][1] = C12;
-            }
-            else if (dim == 2) {
+        }
+};
+
+template <>
+class CubicTensor<2> : public ElasticityTensor<2>
+{
+    public:
+        CubicTensor(double C11, double C12, double C44) {
+
+            ElasticityTensor<2>::operator=(0.0);
+
                 (*this)[0][0] = C11;
                 (*this)[1][1] = C11;
                 (*this)[2][2] = 2*C44;
 
                 (*this)[0][1] = C12;
                 (*this)[1][0] = C12;
-
-            }
         }
-
-        /*	double getTensorEntry(const int i, const int j, const int k, const int l)
-            {
-
-            }
-            double getVoigtEntry(const int i, const int j)
-            {
-            }*/
 };
 
 
-- 
GitLab