OpenFOAM logo
Open Source CFD Toolkit

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