diff --git a/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H b/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H index 4fd082897ae1546d46ea6a7497d3c5e9e8e05b42..63497e7a2463e8e51125504c24eb10f1d8afb58d 100644 --- a/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H +++ b/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "SphericalTensor.H" +#include "SymmTensor.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -291,7 +292,7 @@ inline Cmpt det(const DiagTensor<Cmpt>& t) } -//- Return the inverse of a symmetric tensor +//- Return the inverse of a diagonal tensor template<class Cmpt> inline DiagTensor<Cmpt> inv(const DiagTensor<Cmpt>& dt) { @@ -299,6 +300,14 @@ inline DiagTensor<Cmpt> inv(const DiagTensor<Cmpt>& dt) } +//- Return the diagonal of a symmetric tensor as a diagonal tensor +template<class Cmpt> +inline DiagTensor<Cmpt> diag(const SymmTensor<Cmpt>& t) +{ + return DiagTensor<Cmpt>(t.xx(), t.yy(), t.zz()); +} + + //- Return the diagonal of a tensor as a diagonal tensor template<class Cmpt> inline DiagTensor<Cmpt> diag(const Tensor<Cmpt>& t)