1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Global functions for expansion and contraction of tensor coefficient
30 Hrvoje Jasak, Wikki Ltd. All rights reserved
32 \*---------------------------------------------------------------------------*/
34 #ifndef expandTensor_H
35 #define expandTensor_H
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 //- Return the diagonal of a tensor as a scalar
46 inline void contractScalar(Cmpt& result, const Tensor<Cmpt>& t)
48 result = 1.0/3.0*(t.xx() + t.yy() + t.zz());
52 //- Return the diagonal of a tensor as a vector
54 inline void contractLinear(Vector<Cmpt>& result, const Tensor<Cmpt>& t)
56 result = Vector<Cmpt>(t.xx(), t.yy(), t.zz());
60 //- Return the vector given a scalar
62 inline void expandScalar(Vector<Cmpt>& result, const Cmpt& v)
64 result = Vector<Cmpt>(v, v, v);
68 //- Return the tensor given a scalar
70 inline void expandScalar(Tensor<Cmpt>& result, const Cmpt& v)
74 v, pTraits<Cmpt>::zero, pTraits<Cmpt>::zero,
75 pTraits<Cmpt>::zero, v, pTraits<Cmpt>::zero,
76 pTraits<Cmpt>::zero, pTraits<Cmpt>::zero, v
81 //- Return the tensor given a diagonal vector
83 inline void expandLinear(Tensor<Cmpt>& result, const Vector<Cmpt>& v)
87 v.x(), pTraits<Cmpt>::zero, pTraits<Cmpt>::zero,
88 pTraits<Cmpt>::zero, v.y(), pTraits<Cmpt>::zero,
89 pTraits<Cmpt>::zero, pTraits<Cmpt>::zero, v.z()
94 } // End namespace Foam
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 // ************************************************************************* //