Skip to content
Snippets Groups Projects
Commit 784e44b2 authored by Elias Pipping's avatar Elias Pipping Committed by pipping
Browse files

Use template specialisation

[[Imported from SVN: r4672]]
parent 09d009e8
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment