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

[[Imported from SVN: r4672]]
---
 dune/fufem/mechanics/tetratensor.hh | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/dune/fufem/mechanics/tetratensor.hh b/dune/fufem/mechanics/tetratensor.hh
index 7d104bb4..947ee7db 100644
--- a/dune/fufem/mechanics/tetratensor.hh
+++ b/dune/fufem/mechanics/tetratensor.hh
@@ -8,19 +8,19 @@
  */
 
 template <int dim>
-class TetraTensor : public ElasticityTensor<dim>
+class TetraTensor;
+
+template <>
+class TetraTensor<3> : public ElasticityTensor<3>
 {
     public:
-        /**  \brief constructor for elasticity tensors with tetragonal symmetry 
+        /**  \brief constructor for elasticity tensors with tetragonal symmetry
           *
           *  Parameters are named according to Voigt notation
           */
         TetraTensor(double C11, double C12, double C13, double C33, double C44, double C66)
         {
-            if (dim!=3)
-                DUNE_THROW(Dune::Exception,"Parameters given for a 3-dim tetragonal elasticity tensor but dim!=3");
-
-            ElasticityTensor<dim>::operator=(0.0);
+            ElasticityTensor<3>::operator=(0.0);
 
             (*this)[0][0] = C11;
             (*this)[1][1] = C11;
@@ -36,14 +36,19 @@ class TetraTensor : public ElasticityTensor<dim>
             (*this)[2][0] = C13;
             (*this)[2][1] = C13;
         }
+};
 
-        /** \brief for computations in 2 dimensions - the tetragonal symmetry can of course not be represented in 2D */
+template <>
+class TetraTensor<2> : public ElasticityTensor<2>
+{
+    public:
+        /**  \brief for computations in 2 dimensions - the tetragonal symmetry can of course not be represented in 2D
+          *
+          *  Parameters are named according to Voigt notation
+          */
         TetraTensor(double C11, double C22, double C33, double C12)
         {
-            if (dim!=2)
-                DUNE_THROW(Dune::Exception,"Parameters given for a 2-dim tetragonal elasticity tensor but dim!=2");
-
-            ElasticityTensor<dim>::operator=(0.0);
+            ElasticityTensor<2>::operator=(0.0);
 
             (*this)[0][0] = C11;
             (*this)[1][1] = C22;
@@ -52,8 +57,6 @@ class TetraTensor : public ElasticityTensor<dim>
             (*this)[0][1] = C12;
             (*this)[1][0] = C12;
         }
-
 };
 
-
 #endif
-- 
GitLab