correction to d4edb38234db8268907f04836d49bb93461b8a88
[OpenFOAM-1.5.x.git] / src / OpenFOAM / primitives / SphericalTensor2D / SphericalTensor2DI.H
blob1f3e52beab9b657c23a2657e1be2c978153a7ecd
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 \*---------------------------------------------------------------------------*/
27 #include "Vector2D.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 // Construct null
37 template <class Cmpt>
38 inline SphericalTensor2D<Cmpt>::SphericalTensor2D()
42 // Construct given VectorSpace
43 template <class Cmpt>
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
54 template <class Cmpt>
55 inline SphericalTensor2D<Cmpt>::SphericalTensor2D(const Cmpt& stii)
57     this->v_[II] = stii;
61 // Construct from Istream
62 template <class Cmpt>
63 inline SphericalTensor2D<Cmpt>::SphericalTensor2D(Istream& is)
65     VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>(is)
69 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
71 template <class Cmpt>
72 inline const Cmpt&  SphericalTensor2D<Cmpt>::ii() const
74     return this->v_[II];
78 template <class Cmpt>
79 inline Cmpt& SphericalTensor2D<Cmpt>::ii()
81     return this->v_[II];
85 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
87 //- Inner-product between two spherical tensors
88 template <class Cmpt>
89 inline SphericalTensor2D<Cmpt>
90 operator&
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>
106     (
107         st.ii()*v.x(),
108                        st.ii()*v.y()
109     );
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>
119     (
120         v.x()*st.ii(),
121                        v.y()*st.ii()
122     );
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)
139     return 2*st.ii();
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)
147     return 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()); 
167 template<class Cmpt>
168 class outerProduct<SphericalTensor2D<Cmpt>, Cmpt>
170 public:
172     typedef SphericalTensor2D<Cmpt> type;
175 template<class Cmpt>
176 class outerProduct<Cmpt, SphericalTensor2D<Cmpt> >
178 public:
180     typedef SphericalTensor2D<Cmpt> type;
184 template<class Cmpt>
185 class innerProduct<SphericalTensor2D<Cmpt>, SphericalTensor2D<Cmpt> >
187 public:
189     typedef SphericalTensor2D<Cmpt> type;
193 template<class Cmpt>
194 class innerProduct<SphericalTensor2D<Cmpt>, Vector2D<Cmpt> >
196 public:
198     typedef Vector2D<Cmpt> type;
201 template<class Cmpt>
202 class innerProduct<Vector2D<Cmpt>, SphericalTensor2D<Cmpt> >
204 public:
206     typedef Vector2D<Cmpt> type;
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 } // End namespace Foam
214 // ************************************************************************* //