From 8de4ad7f506b06be1df7e24b1b7d74226bdb0607 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 16 May 2014 13:18:04 +0100 Subject: [PATCH] DiagTensor: add conversion from SymmTensor --- src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H b/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H index 4fd08289..63497e7a 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& t) } -//- Return the inverse of a symmetric tensor +//- Return the inverse of a diagonal tensor template inline DiagTensor inv(const DiagTensor& dt) { @@ -299,6 +300,14 @@ inline DiagTensor inv(const DiagTensor& dt) } +//- Return the diagonal of a symmetric tensor as a diagonal tensor +template +inline DiagTensor diag(const SymmTensor& t) +{ + return DiagTensor(t.xx(), t.yy(), t.zz()); +} + + //- Return the diagonal of a tensor as a diagonal tensor template inline DiagTensor diag(const Tensor& t)