1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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
25 \*---------------------------------------------------------------------------*/
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 inline SphericalTensor<Cmpt>::SphericalTensor()
42 // Construct given VectorSpace
44 inline SphericalTensor<Cmpt>::SphericalTensor
46 const VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>& vs
49 VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>(vs)
53 // Construct given three Cmpts
55 inline SphericalTensor<Cmpt>::SphericalTensor(const Cmpt& stii)
61 // Construct from Istream
63 inline SphericalTensor<Cmpt>::SphericalTensor(Istream& is)
65 VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>(is)
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72 inline const Cmpt& SphericalTensor<Cmpt>::ii() const
79 inline Cmpt& SphericalTensor<Cmpt>::ii()
86 inline const SphericalTensor<Cmpt>& SphericalTensor<Cmpt>::T() const
92 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
94 //- Inner-product between two spherical tensors
96 inline SphericalTensor<Cmpt>
97 operator&(const SphericalTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& st2)
99 return SphericalTensor<Cmpt>(st1.ii()*st2.ii());
103 //- Inner-product between a spherical tensor and a vector
104 template <class Cmpt>
106 operator&(const SphericalTensor<Cmpt>& st, const Vector<Cmpt>& v)
117 //- Inner-product between a vector and a spherical tensor
118 template <class Cmpt>
120 operator&(const Vector<Cmpt>& v, const SphericalTensor<Cmpt>& st)
131 //- Double-dot-product between a spherical tensor and a spherical tensor
132 template <class Cmpt>
134 operator&&(const SphericalTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& st2)
136 return 3*st1.ii()*st2.ii();
140 //- Division of a scalar by a sphericalTensor
141 template <class Cmpt>
142 inline SphericalTensor<Cmpt>
143 operator/(const scalar s, const SphericalTensor<Cmpt>& st)
145 return SphericalTensor<Cmpt>(s/st.ii());
149 template <class Cmpt>
150 inline Cmpt magSqr(const SphericalTensor<Cmpt>& st)
152 return 3*magSqr(st.ii());
156 //- Return the trace of a spherical tensor
157 template <class Cmpt>
158 inline Cmpt tr(const SphericalTensor<Cmpt>& st)
164 //- Return the spherical part of a spherical tensor, i.e. itself
165 template <class Cmpt>
166 inline SphericalTensor<Cmpt> sph(const SphericalTensor<Cmpt>& st)
172 //- Return the determinant of a spherical tensor
173 template <class Cmpt>
174 inline Cmpt det(const SphericalTensor<Cmpt>& st)
176 return st.ii()*st.ii()*st.ii();
180 //- Return the inverse of a symmetric tensor
181 template <class Cmpt>
182 inline SphericalTensor<Cmpt> inv(const SphericalTensor<Cmpt>& st)
184 return SphericalTensor<Cmpt>(1.0/st.ii());
189 class outerProduct<SphericalTensor<Cmpt>, Cmpt>
193 typedef SphericalTensor<Cmpt> type;
197 class outerProduct<Cmpt, SphericalTensor<Cmpt> >
201 typedef SphericalTensor<Cmpt> type;
207 class innerProduct<SphericalTensor<Cmpt>, SphericalTensor<Cmpt> >
211 typedef SphericalTensor<Cmpt> type;
216 class innerProduct<SphericalTensor<Cmpt>, Vector<Cmpt> >
220 typedef Vector<Cmpt> type;
224 class innerProduct<Vector<Cmpt>, SphericalTensor<Cmpt> >
228 typedef Vector<Cmpt> type;
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 } // End namespace Foam
237 // ************************************************************************* //