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

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