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

VectorI_.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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00027 
00028 namespace Foam
00029 {
00030 
00031 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00032 
00033 // Construct null
00034 template <class Cmpt>
00035 inline Vector<Cmpt>::Vector()
00036 {}
00037 
00038 
00039 // Construct given VectorSpace
00040 template <class Cmpt>
00041 inline Vector<Cmpt>::Vector(const VectorSpace<Vector<Cmpt>, Cmpt, 3>& vs)
00042 :
00043     VectorSpace<Vector<Cmpt>, Cmpt, 3>(vs)
00044 {}
00045 
00046 
00047 // Construct given three Cmpts
00048 template <class Cmpt>
00049 inline Vector<Cmpt>::Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz)
00050 {
00051     this->v_[X] = vx;
00052     this->v_[Y] = vy;
00053     this->v_[Z] = vz;
00054 }
00055 
00056 
00057 // Construct from Istream
00058 template <class Cmpt>
00059 inline Vector<Cmpt>::Vector(Istream& is)
00060 :
00061     VectorSpace<Vector<Cmpt>, Cmpt, 3>(is)
00062 {}
00063 
00064 
00065 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00066 
00067 template <class Cmpt>
00068 inline const Cmpt&  Vector<Cmpt>::x() const
00069 {
00070     return this->v_[X];
00071 }
00072 
00073 template <class Cmpt>
00074 inline const Cmpt&  Vector<Cmpt>::y() const
00075 {
00076     return this->v_[Y];
00077 }
00078 
00079 template <class Cmpt>
00080 inline const Cmpt&  Vector<Cmpt>::z() const
00081 {
00082     return this->v_[Z];
00083 }
00084 
00085 
00086 template <class Cmpt>
00087 inline Cmpt& Vector<Cmpt>::x()
00088 {
00089     return this->v_[X];
00090 }
00091 
00092 template <class Cmpt>
00093 inline Cmpt& Vector<Cmpt>::y()
00094 {
00095     return this->v_[Y];
00096 }
00097 
00098 template <class Cmpt>
00099 inline Cmpt& Vector<Cmpt>::z()
00100 {
00101     return this->v_[Z];
00102 }
00103 
00104 
00105 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00106 
00107 template <class Cmpt>
00108 inline const Vector<Cmpt>& Vector<Cmpt>::centre
00109 (
00110     const Foam::List<Vector<Cmpt> >&
00111 )const
00112 {
00113     return *this;
00114 }
00115 
00116 
00117 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
00118 
00119 template <class Cmpt>
00120 inline typename innerProduct<Vector<Cmpt>, Vector<Cmpt> >::type
00121 operator&(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
00122 {
00123     return Cmpt(v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z());
00124 }
00125 
00126 
00127 template <class Cmpt>
00128 inline Vector<Cmpt> operator^(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
00129 {
00130     return Vector<Cmpt>
00131     (
00132         (v1.y()*v2.z() - v1.z()*v2.y()),
00133         (v1.z()*v2.x() - v1.x()*v2.z()),
00134         (v1.x()*v2.y() - v1.y()*v2.x())
00135     );
00136 }
00137 
00138 
00139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00140 
00141 } // End namespace Foam
00142 
00143 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines