OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "Vector2D.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00035 
00036 // Construct null
00037 template <class Cmpt>
00038 inline SphericalTensor2D<Cmpt>::SphericalTensor2D()
00039 {}
00040 
00041 
00042 // Construct given VectorSpace
00043 template <class Cmpt>
00044 inline SphericalTensor2D<Cmpt>::SphericalTensor2D
00045 (
00046     const VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>& vs
00047 )
00048 :
00049     VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>(vs)
00050 {}
00051 
00052 
00053 // Construct given three Cmpts
00054 template <class Cmpt>
00055 inline SphericalTensor2D<Cmpt>::SphericalTensor2D(const Cmpt& stii)
00056 {
00057     this->v_[II] = stii;
00058 }
00059 
00060 
00061 // Construct from Istream
00062 template <class Cmpt>
00063 inline SphericalTensor2D<Cmpt>::SphericalTensor2D(Istream& is)
00064 :
00065     VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>(is)
00066 {}
00067 
00068 
00069 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00070 
00071 template <class Cmpt>
00072 inline const Cmpt&  SphericalTensor2D<Cmpt>::ii() const
00073 {
00074     return this->v_[II];
00075 }
00076 
00077 
00078 template <class Cmpt>
00079 inline Cmpt& SphericalTensor2D<Cmpt>::ii()
00080 {
00081     return this->v_[II];
00082 }
00083 
00084 
00085 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
00086 
00087 //- Inner-product between two spherical tensors
00088 template <class Cmpt>
00089 inline SphericalTensor2D<Cmpt>
00090 operator&
00091 (
00092     const SphericalTensor2D<Cmpt>& st1,
00093     const SphericalTensor2D<Cmpt>& st2
00094 )
00095 {
00096     return SphericalTensor2D<Cmpt>(st1.ii()*st2.ii());
00097 }
00098 
00099 
00100 //- Inner-product between a spherical tensor and a vector
00101 template <class Cmpt>
00102 inline Vector2D<Cmpt>
00103 operator&(const SphericalTensor2D<Cmpt>& st, const Vector2D<Cmpt>& v)
00104 {
00105     return Vector2D<Cmpt>
00106     (
00107         st.ii()*v.x(),
00108                        st.ii()*v.y()
00109     );
00110 }
00111 
00112 
00113 //- Inner-product between a vector and a spherical tensor
00114 template <class Cmpt>
00115 inline Vector2D<Cmpt>
00116 operator&(const Vector2D<Cmpt>& v, const SphericalTensor2D<Cmpt>& st)
00117 {
00118     return Vector2D<Cmpt>
00119     (
00120         v.x()*st.ii(),
00121                        v.y()*st.ii()
00122     );
00123 }
00124 
00125 
00126 //- Division of a scalar by a sphericalTensor2D
00127 template <class Cmpt>
00128 inline SphericalTensor2D<Cmpt>
00129 operator/(const scalar s, const SphericalTensor2D<Cmpt>& st)
00130 {
00131     return SphericalTensor2D<Cmpt>(s/st.ii());
00132 }
00133 
00134 
00135 //- Return the trace of a spherical tensor
00136 template <class Cmpt>
00137 inline Cmpt tr(const SphericalTensor2D<Cmpt>& st)
00138 {
00139     return 2*st.ii();
00140 }
00141 
00142 
00143 //- Return the spherical part of a spherical tensor, i.e. itself
00144 template <class Cmpt>
00145 inline SphericalTensor2D<Cmpt> sph(const SphericalTensor2D<Cmpt>& st)
00146 {
00147     return st;
00148 }
00149 
00150 
00151 //- Return the determinant of a spherical tensor
00152 template <class Cmpt>
00153 inline Cmpt det(const SphericalTensor2D<Cmpt>& st)
00154 {
00155     return st.ii()*st.ii();
00156 }
00157 
00158 
00159 //- Return the inverse of a symmetric tensor
00160 template <class Cmpt>
00161 inline SphericalTensor2D<Cmpt> inv(const SphericalTensor2D<Cmpt>& st)
00162 {
00163     return SphericalTensor2D<Cmpt>(1.0/st.ii()); 
00164 }
00165 
00166 
00167 template<class Cmpt>
00168 class outerProduct<SphericalTensor2D<Cmpt>, Cmpt>
00169 {
00170 public:
00171 
00172     typedef SphericalTensor2D<Cmpt> type;
00173 };
00174 
00175 template<class Cmpt>
00176 class outerProduct<Cmpt, SphericalTensor2D<Cmpt> >
00177 {
00178 public:
00179 
00180     typedef SphericalTensor2D<Cmpt> type;
00181 };
00182 
00183 
00184 template<class Cmpt>
00185 class innerProduct<SphericalTensor2D<Cmpt>, SphericalTensor2D<Cmpt> >
00186 {
00187 public:
00188 
00189     typedef SphericalTensor2D<Cmpt> type;
00190 };
00191 
00192 
00193 template<class Cmpt>
00194 class innerProduct<SphericalTensor2D<Cmpt>, Vector2D<Cmpt> >
00195 {
00196 public:
00197 
00198     typedef Vector2D<Cmpt> type;
00199 };
00200 
00201 template<class Cmpt>
00202 class innerProduct<Vector2D<Cmpt>, SphericalTensor2D<Cmpt> >
00203 {
00204 public:
00205 
00206     typedef Vector2D<Cmpt> type;
00207 };
00208 
00209 
00210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00211 
00212 } // End namespace Foam
00213 
00214 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd