FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

SphericalTensor2DI_.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <OpenFOAM/Vector2D_.H>
00027 
00028 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00029 
00030 namespace Foam
00031 {
00032 
00033 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00034 
00035 // Construct null
00036 template <class Cmpt>
00037 inline SphericalTensor2D<Cmpt>::SphericalTensor2D()
00038 {}
00039 
00040 
00041 // Construct given VectorSpace
00042 template <class Cmpt>
00043 inline SphericalTensor2D<Cmpt>::SphericalTensor2D
00044 (
00045     const VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>& vs
00046 )
00047 :
00048     VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>(vs)
00049 {}
00050 
00051 
00052 // Construct given three Cmpts
00053 template <class Cmpt>
00054 inline SphericalTensor2D<Cmpt>::SphericalTensor2D(const Cmpt& stii)
00055 {
00056     this->v_[II] = stii;
00057 }
00058 
00059 
00060 // Construct from Istream
00061 template <class Cmpt>
00062 inline SphericalTensor2D<Cmpt>::SphericalTensor2D(Istream& is)
00063 :
00064     VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>(is)
00065 {}
00066 
00067 
00068 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00069 
00070 template <class Cmpt>
00071 inline const Cmpt&  SphericalTensor2D<Cmpt>::ii() const
00072 {
00073     return this->v_[II];
00074 }
00075 
00076 
00077 template <class Cmpt>
00078 inline Cmpt& SphericalTensor2D<Cmpt>::ii()
00079 {
00080     return this->v_[II];
00081 }
00082 
00083 
00084 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
00085 
00086 //- Inner-product between two spherical tensors
00087 template <class Cmpt>
00088 inline SphericalTensor2D<Cmpt>
00089 operator&
00090 (
00091     const SphericalTensor2D<Cmpt>& st1,
00092     const SphericalTensor2D<Cmpt>& st2
00093 )
00094 {
00095     return SphericalTensor2D<Cmpt>(st1.ii()*st2.ii());
00096 }
00097 
00098 
00099 //- Inner-product between a spherical tensor and a vector
00100 template <class Cmpt>
00101 inline Vector2D<Cmpt>
00102 operator&(const SphericalTensor2D<Cmpt>& st, const Vector2D<Cmpt>& v)
00103 {
00104     return Vector2D<Cmpt>
00105     (
00106         st.ii()*v.x(),
00107                        st.ii()*v.y()
00108     );
00109 }
00110 
00111 
00112 //- Inner-product between a vector and a spherical tensor
00113 template <class Cmpt>
00114 inline Vector2D<Cmpt>
00115 operator&(const Vector2D<Cmpt>& v, const SphericalTensor2D<Cmpt>& st)
00116 {
00117     return Vector2D<Cmpt>
00118     (
00119         v.x()*st.ii(),
00120                        v.y()*st.ii()
00121     );
00122 }
00123 
00124 
00125 //- Division of a scalar by a sphericalTensor2D
00126 template <class Cmpt>
00127 inline SphericalTensor2D<Cmpt>
00128 operator/(const scalar s, const SphericalTensor2D<Cmpt>& st)
00129 {
00130     return SphericalTensor2D<Cmpt>(s/st.ii());
00131 }
00132 
00133 
00134 //- Return the trace of a spherical tensor
00135 template <class Cmpt>
00136 inline Cmpt tr(const SphericalTensor2D<Cmpt>& st)
00137 {
00138     return 2*st.ii();
00139 }
00140 
00141 
00142 //- Return the spherical part of a spherical tensor, i.e. itself
00143 template <class Cmpt>
00144 inline SphericalTensor2D<Cmpt> sph(const SphericalTensor2D<Cmpt>& st)
00145 {
00146     return st;
00147 }
00148 
00149 
00150 //- Return the determinant of a spherical tensor
00151 template <class Cmpt>
00152 inline Cmpt det(const SphericalTensor2D<Cmpt>& st)
00153 {
00154     return st.ii()*st.ii();
00155 }
00156 
00157 
00158 //- Return the inverse of a symmetric tensor
00159 template <class Cmpt>
00160 inline SphericalTensor2D<Cmpt> inv(const SphericalTensor2D<Cmpt>& st)
00161 {
00162     return SphericalTensor2D<Cmpt>(1.0/st.ii()); 
00163 }
00164 
00165 
00166 template<class Cmpt>
00167 class outerProduct<SphericalTensor2D<Cmpt>, Cmpt>
00168 {
00169 public:
00170 
00171     typedef SphericalTensor2D<Cmpt> type;
00172 };
00173 
00174 template<class Cmpt>
00175 class outerProduct<Cmpt, SphericalTensor2D<Cmpt> >
00176 {
00177 public:
00178 
00179     typedef SphericalTensor2D<Cmpt> type;
00180 };
00181 
00182 
00183 template<class Cmpt>
00184 class innerProduct<SphericalTensor2D<Cmpt>, SphericalTensor2D<Cmpt> >
00185 {
00186 public:
00187 
00188     typedef SphericalTensor2D<Cmpt> type;
00189 };
00190 
00191 
00192 template<class Cmpt>
00193 class innerProduct<SphericalTensor2D<Cmpt>, Vector2D<Cmpt> >
00194 {
00195 public:
00196 
00197     typedef Vector2D<Cmpt> type;
00198 };
00199 
00200 template<class Cmpt>
00201 class innerProduct<Vector2D<Cmpt>, SphericalTensor2D<Cmpt> >
00202 {
00203 public:
00204 
00205     typedef Vector2D<Cmpt> type;
00206 };
00207 
00208 
00209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00210 
00211 } // End namespace Foam
00212 
00213 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines