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 SphericalTensor2D<Cmpt>::SphericalTensor2D()
42 // Construct given VectorSpace
44 inline SphericalTensor2D<Cmpt>::SphericalTensor2D
46 const VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>& vs
49 VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>(vs)
53 // Construct given three Cmpts
55 inline SphericalTensor2D<Cmpt>::SphericalTensor2D(const Cmpt& stii)
61 // Construct from Istream
63 inline SphericalTensor2D<Cmpt>::SphericalTensor2D(Istream& is)
65 VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>(is)
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72 inline const Cmpt& SphericalTensor2D<Cmpt>::ii() const
79 inline Cmpt& SphericalTensor2D<Cmpt>::ii()
85 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
87 //- Inner-product between two spherical tensors
89 inline SphericalTensor2D<Cmpt>
92 const SphericalTensor2D<Cmpt>& st1,
93 const SphericalTensor2D<Cmpt>& st2
96 return SphericalTensor2D<Cmpt>(st1.ii()*st2.ii());
100 //- Inner-product between a spherical tensor and a vector
101 template <class Cmpt>
102 inline Vector2D<Cmpt>
103 operator&(const SphericalTensor2D<Cmpt>& st, const Vector2D<Cmpt>& v)
105 return Vector2D<Cmpt>
113 //- Inner-product between a vector and a spherical tensor
114 template <class Cmpt>
115 inline Vector2D<Cmpt>
116 operator&(const Vector2D<Cmpt>& v, const SphericalTensor2D<Cmpt>& st)
118 return Vector2D<Cmpt>
126 //- Division of a scalar by a sphericalTensor2D
127 template <class Cmpt>
128 inline SphericalTensor2D<Cmpt>
129 operator/(const scalar s, const SphericalTensor2D<Cmpt>& st)
131 return SphericalTensor2D<Cmpt>(s/st.ii());
135 //- Return the trace of a spherical tensor
136 template <class Cmpt>
137 inline Cmpt tr(const SphericalTensor2D<Cmpt>& st)
143 //- Return the spherical part of a spherical tensor, i.e. itself
144 template <class Cmpt>
145 inline SphericalTensor2D<Cmpt> sph(const SphericalTensor2D<Cmpt>& st)
151 //- Return the determinant of a spherical tensor
152 template <class Cmpt>
153 inline Cmpt det(const SphericalTensor2D<Cmpt>& st)
155 return st.ii()*st.ii();
159 //- Return the inverse of a symmetric tensor
160 template <class Cmpt>
161 inline SphericalTensor2D<Cmpt> inv(const SphericalTensor2D<Cmpt>& st)
163 return SphericalTensor2D<Cmpt>(1.0/st.ii());
168 class outerProduct<SphericalTensor2D<Cmpt>, Cmpt>
172 typedef SphericalTensor2D<Cmpt> type;
176 class outerProduct<Cmpt, SphericalTensor2D<Cmpt> >
180 typedef SphericalTensor2D<Cmpt> type;
185 class innerProduct<SphericalTensor2D<Cmpt>, SphericalTensor2D<Cmpt> >
189 typedef SphericalTensor2D<Cmpt> type;
194 class innerProduct<SphericalTensor2D<Cmpt>, Vector2D<Cmpt> >
198 typedef Vector2D<Cmpt> type;
202 class innerProduct<Vector2D<Cmpt>, SphericalTensor2D<Cmpt> >
206 typedef Vector2D<Cmpt> type;
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 } // End namespace Foam
214 // ************************************************************************* //