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

Vector2D.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 Class
00026     Foam::Vector2D
00027 
00028 Description
00029     Templated 2D Vector derived from VectorSpace adding construction from
00030     2 components, element access using x() and y() member functions and
00031     the inner-product (dot-product).
00032 
00033 SourceFiles
00034     Vector2DI.H
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef Vector2D_H
00039 #define Vector2D_H
00040 
00041 #include "VectorSpace.H"
00042 
00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00044 
00045 namespace Foam
00046 {
00047 
00048 /*---------------------------------------------------------------------------*\
00049                            Class Vector2D Declaration
00050 \*---------------------------------------------------------------------------*/
00051 
00052 template <class Cmpt>
00053 class Vector2D
00054 :
00055     public VectorSpace<Vector2D<Cmpt>, Cmpt, 2>
00056 {
00057 
00058 public:
00059 
00060     // Member constants
00061 
00062         enum
00063         {
00064             rank = 1 // Rank of Vector2D is 1
00065         };
00066 
00067 
00068     // Static data members
00069 
00070         static const char* const typeName;
00071         static const char* componentNames[];
00072         static const Vector2D zero;
00073         static const Vector2D one;
00074         static const Vector2D max;
00075         static const Vector2D min;
00076 
00077 
00078     //- Component labeling enumeration
00079     enum components { X, Y };
00080 
00081 
00082     // Constructors
00083 
00084         //- Construct null
00085         inline Vector2D();
00086 
00087         //- Construct given VectorSpace
00088         inline Vector2D(const VectorSpace<Vector2D<Cmpt>, Cmpt, 2>&);
00089 
00090         //- Construct given two components
00091         inline Vector2D(const Cmpt& vx, const Cmpt& vy);
00092 
00093         //- Construct from Istream
00094         inline Vector2D(Istream&);
00095 
00096 
00097     // Member Functions
00098 
00099         // Access
00100 
00101             inline const Cmpt& x() const;
00102             inline const Cmpt& y() const;
00103 
00104             inline Cmpt& x();
00105             inline Cmpt& y();
00106 
00107 
00108         // Operators
00109 
00110             //- perp dot product (dot product with perpendicular vector)
00111             inline scalar perp(const Vector2D<Cmpt>& b) const;
00112 };
00113 
00114 
00115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00116 
00117 } // End namespace Foam
00118 
00119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00120 
00121 // Include inline implementations
00122 #include "Vector2DI.H"
00123 
00124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00125 
00126 #endif
00127 
00128 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd