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

Vector2DI.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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00028 
00029 namespace Foam
00030 {
00031 
00032 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00033 
00034 // Construct null
00035 template <class Cmpt>
00036 inline Vector2D<Cmpt>::Vector2D()
00037 {}
00038 
00039 
00040 // Construct given VectorSpace
00041 template <class Cmpt>
00042 inline Vector2D<Cmpt>::Vector2D(const VectorSpace<Vector2D<Cmpt>, Cmpt, 2>& vs)
00043 :
00044     VectorSpace<Vector2D<Cmpt>, Cmpt, 2>(vs)
00045 {}
00046 
00047 
00048 // Construct given three Cmpts
00049 template <class Cmpt>
00050 inline Vector2D<Cmpt>::Vector2D(const Cmpt& vx, const Cmpt& vy)
00051 {
00052     this->v_[X] = vx;
00053     this->v_[Y] = vy;
00054 }
00055 
00056 
00057 // Construct from Istream
00058 template <class Cmpt>
00059 inline Vector2D<Cmpt>::Vector2D(Istream& is)
00060 :
00061     VectorSpace<Vector2D<Cmpt>, Cmpt, 2>(is)
00062 {}
00063 
00064 
00065 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00066 
00067 template <class Cmpt>
00068 inline const Cmpt&  Vector2D<Cmpt>::x() const
00069 {
00070     return this->v_[X];
00071 }
00072 
00073 template <class Cmpt>
00074 inline const Cmpt&  Vector2D<Cmpt>::y() const
00075 {
00076     return this->v_[Y];
00077 }
00078 
00079 
00080 template <class Cmpt>
00081 inline Cmpt& Vector2D<Cmpt>::x()
00082 {
00083     return this->v_[X];
00084 }
00085 
00086 template <class Cmpt>
00087 inline Cmpt& Vector2D<Cmpt>::y()
00088 {
00089     return this->v_[Y];
00090 }
00091 
00092 
00093 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
00094 
00095 template <class Cmpt>
00096 inline typename innerProduct<Vector2D<Cmpt>, Vector2D<Cmpt> >::type
00097 operator&(const Vector2D<Cmpt>& v1, const Vector2D<Cmpt>& v2)
00098 {
00099     return Cmpt(v1.x()*v2.x() + v1.y()*v2.y());
00100 }
00101 
00102 
00103 template <class Cmpt>
00104 inline scalar Vector2D<Cmpt>::perp(const Vector2D<Cmpt>& b) const
00105 {
00106     return x()*b.y()-y()*b.x();
00107 }
00108 
00109 
00110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00111 
00112 } // End namespace Foam
00113 
00114 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd